@@ -31,6 +31,7 @@ def test_settings_defaults_client(self):
31
31
assert s [h2 .settings .SettingCodes .ENABLE_PUSH ] == 1
32
32
assert s [h2 .settings .SettingCodes .INITIAL_WINDOW_SIZE ] == 65535
33
33
assert s [h2 .settings .SettingCodes .MAX_FRAME_SIZE ] == 16384
34
+ assert s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] == 0
34
35
35
36
def test_settings_defaults_server (self ):
36
37
"""
@@ -42,6 +43,7 @@ def test_settings_defaults_server(self):
42
43
assert s [h2 .settings .SettingCodes .ENABLE_PUSH ] == 0
43
44
assert s [h2 .settings .SettingCodes .INITIAL_WINDOW_SIZE ] == 65535
44
45
assert s [h2 .settings .SettingCodes .MAX_FRAME_SIZE ] == 16384
46
+ assert s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] == 0
45
47
46
48
@pytest .mark .parametrize ('client' , [True , False ])
47
49
def test_can_set_initial_values (self , client ):
@@ -54,6 +56,7 @@ def test_can_set_initial_values(self, client):
54
56
h2 .settings .SettingCodes .MAX_FRAME_SIZE : 16388 ,
55
57
h2 .settings .SettingCodes .MAX_CONCURRENT_STREAMS : 100 ,
56
58
h2 .settings .SettingCodes .MAX_HEADER_LIST_SIZE : 2 ** 16 ,
59
+ h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL : 1 ,
57
60
}
58
61
s = h2 .settings .Settings (client = client , initial_values = overrides )
59
62
@@ -63,6 +66,7 @@ def test_can_set_initial_values(self, client):
63
66
assert s [h2 .settings .SettingCodes .MAX_FRAME_SIZE ] == 16388
64
67
assert s [h2 .settings .SettingCodes .MAX_CONCURRENT_STREAMS ] == 100
65
68
assert s [h2 .settings .SettingCodes .MAX_HEADER_LIST_SIZE ] == 2 ** 16
69
+ assert s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] == 1
66
70
67
71
@pytest .mark .parametrize (
68
72
'setting,value' ,
@@ -74,6 +78,7 @@ def test_can_set_initial_values(self, client):
74
78
(h2 .settings .SettingCodes .MAX_FRAME_SIZE , 1 ),
75
79
(h2 .settings .SettingCodes .MAX_FRAME_SIZE , 2 ** 30 ),
76
80
(h2 .settings .SettingCodes .MAX_HEADER_LIST_SIZE , - 1 ),
81
+ (h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL , - 1 ),
77
82
]
78
83
)
79
84
def test_cannot_set_invalid_initial_values (self , setting , value ):
@@ -108,6 +113,7 @@ def test_acknowledging_values(self):
108
113
h2 .settings .SettingCodes .ENABLE_PUSH : 0 ,
109
114
h2 .settings .SettingCodes .INITIAL_WINDOW_SIZE : 60 ,
110
115
h2 .settings .SettingCodes .MAX_FRAME_SIZE : 16385 ,
116
+ h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL : 1 ,
111
117
}
112
118
s .update (new_settings )
113
119
@@ -171,16 +177,16 @@ def test_length_correctly_reported(self):
171
177
Length is related only to the number of keys.
172
178
"""
173
179
s = h2 .settings .Settings (client = True )
174
- assert len (s ) == 4
180
+ assert len (s ) == 5
175
181
176
182
s [h2 .settings .SettingCodes .HEADER_TABLE_SIZE ] == 8000
177
- assert len (s ) == 4
183
+ assert len (s ) == 5
178
184
179
185
s .acknowledge ()
180
- assert len (s ) == 4
186
+ assert len (s ) == 5
181
187
182
188
del s [h2 .settings .SettingCodes .HEADER_TABLE_SIZE ]
183
- assert len (s ) == 3
189
+ assert len (s ) == 4
184
190
185
191
def test_new_values_work (self ):
186
192
"""
@@ -234,6 +240,9 @@ def test_settings_getters(self):
234
240
assert s .max_frame_size == s [h2 .settings .SettingCodes .MAX_FRAME_SIZE ]
235
241
assert s .max_concurrent_streams == 2 ** 32 + 1 # A sensible default.
236
242
assert s .max_header_list_size is None
243
+ assert s .enable_connect_protocol == s [
244
+ h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL
245
+ ]
237
246
238
247
def test_settings_setters (self ):
239
248
"""
@@ -247,6 +256,7 @@ def test_settings_setters(self):
247
256
s .max_frame_size = 16385
248
257
s .max_concurrent_streams = 4
249
258
s .max_header_list_size = 2 ** 16
259
+ s .enable_connect_protocol = 1
250
260
251
261
s .acknowledge ()
252
262
assert s [h2 .settings .SettingCodes .HEADER_TABLE_SIZE ] == 0
@@ -255,6 +265,7 @@ def test_settings_setters(self):
255
265
assert s [h2 .settings .SettingCodes .MAX_FRAME_SIZE ] == 16385
256
266
assert s [h2 .settings .SettingCodes .MAX_CONCURRENT_STREAMS ] == 4
257
267
assert s [h2 .settings .SettingCodes .MAX_HEADER_LIST_SIZE ] == 2 ** 16
268
+ assert s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] == 1
258
269
259
270
@given (integers ())
260
271
def test_cannot_set_invalid_values_for_enable_push (self , val ):
@@ -363,6 +374,28 @@ def test_cannot_set_invalid_values_for_max_header_list_size(self, val):
363
374
with pytest .raises (KeyError ):
364
375
s [h2 .settings .SettingCodes .MAX_HEADER_LIST_SIZE ]
365
376
377
+ @given (integers ())
378
+ def test_cannot_set_invalid_values_for_enable_connect_protocol (self , val ):
379
+ """
380
+ SETTINGS_ENABLE_CONNECT_PROTOCOL only allows two values: 0, 1.
381
+ """
382
+ assume (val not in (0 , 1 ))
383
+ s = h2 .settings .Settings ()
384
+
385
+ with pytest .raises (h2 .exceptions .InvalidSettingsValueError ) as e :
386
+ s .enable_connect_protocol = val
387
+
388
+ s .acknowledge ()
389
+ assert e .value .error_code == h2 .errors .ErrorCodes .PROTOCOL_ERROR
390
+ assert s .enable_connect_protocol == 0
391
+
392
+ with pytest .raises (h2 .exceptions .InvalidSettingsValueError ) as e :
393
+ s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] = val
394
+
395
+ s .acknowledge ()
396
+ assert e .value .error_code == h2 .errors .ErrorCodes .PROTOCOL_ERROR
397
+ assert s [h2 .settings .SettingCodes .ENABLE_CONNECT_PROTOCOL ] == 0
398
+
366
399
367
400
class TestSettingsEquality (object ):
368
401
"""
0 commit comments