File tree 2 files changed +38
-2
lines changed
2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,6 @@ def _verify_struct(self, body):
225
225
self .children [i ].verify (member )
226
226
227
227
def _verify_variant (self , body ):
228
- return
229
228
# a variant signature and value is valid by construction
230
229
if not isinstance (body , Variant ):
231
230
raise SignatureBodyMismatchError ('DBus VARIANT type "v" must be Python type "Variant"' )
Original file line number Diff line number Diff line change 1
- from dbus_next import SignatureTree
1
+ from dbus_next import SignatureTree , SignatureBodyMismatchError
2
+
3
+ import pytest
2
4
3
5
4
6
def assert_simple_type (signature , type_ ):
@@ -145,3 +147,38 @@ def test_dict_of_structs():
145
147
assert len (struct_child .children ) == 2
146
148
for i in range (0 , 2 ):
147
149
assert_simple_type ('s' , struct_child .children [i ])
150
+
151
+
152
+ def test_invalid_variants ():
153
+ tree = SignatureTree ('a{sa{sv}}' )
154
+ s_con = {
155
+ 'type' : '802-11-wireless' ,
156
+ 'uuid' : '1234' ,
157
+ 'id' : 'SSID' ,
158
+ }
159
+
160
+ s_wifi = {
161
+ 'ssid' : 'SSID' ,
162
+ 'mode' : 'infrastructure' ,
163
+ 'hidden' : True ,
164
+ }
165
+
166
+ s_wsec = {
167
+ 'key-mgmt' : 'wpa-psk' ,
168
+ 'auth-alg' : 'open' ,
169
+ 'psk' : 'PASSWORD' ,
170
+ }
171
+
172
+ s_ip4 = {'method' : 'auto' }
173
+ s_ip6 = {'method' : 'auto' }
174
+
175
+ con = {
176
+ 'connection' : s_con ,
177
+ '802-11-wireless' : s_wifi ,
178
+ '802-11-wireless-security' : s_wsec ,
179
+ 'ipv4' : s_ip4 ,
180
+ 'ipv6' : s_ip6
181
+ }
182
+
183
+ with pytest .raises (SignatureBodyMismatchError ):
184
+ tree .verify ([con ])
You can’t perform that action at this time.
0 commit comments