@@ -82,44 +82,49 @@ def test_post_req(self):
82
82
class TestPostQueryExtract (object ):
83
83
@classmethod
84
84
def setup_class (cls ):
85
- cls .post_data = b'foo=bar&dir=%2Fbaz'
85
+ cls .post_data = b'foo=bar&dir=%2Fbaz&do=true&re=false&re=null '
86
86
cls .binary_post_data = b'\x81 6l`L\xa0 4P\x0e \xe0 r\x02 \xb5 \x89 \x19 \x00 fP\xdb \x0e \xb0 \x02 ,'
87
87
88
88
def test_post_extract_1 (self ):
89
89
mq = MethodQueryCanonicalizer ('POST' , 'application/x-www-form-urlencoded' ,
90
90
len (self .post_data ), BytesIO (self .post_data ))
91
91
92
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=/baz'
92
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=/baz&do=true&re=false&re=null '
93
93
94
- assert mq .append_query ('http://example.com/?123=ABC' ) == 'http://example.com/?123=ABC&__wb_method=POST&foo=bar&dir=/baz'
94
+ assert mq .append_query ('http://example.com/?123=ABC' ) == 'http://example.com/?123=ABC&__wb_method=POST&foo=bar&dir=/baz&do=true&re=false&re=null '
95
95
96
96
def test_post_extract_json (self ):
97
- post_data = b'{"a": "b", "c": {"a": 2}, "d": "e"}'
97
+ post_data = b'{"a": "b", "c": {"a": 2}, "d": "e", "f": true, "g": [false, null] }'
98
98
mq = MethodQueryCanonicalizer ('POST' , 'application/json' ,
99
99
len (post_data ), BytesIO (post_data ))
100
100
101
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&a=b&a.2_=2&d=e'
101
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&a=b&a.2_=2&d=e&f=true&g=false&g.2_=null '
102
102
103
+ post_data = b'{"type": "event", "id": 44.0, "float": 35.7, "values": [true, false, null], "source": {"type": "component", "id": "a+b&c= d", "values": [3, 4]}}'
104
+ mq = MethodQueryCanonicalizer ('POST' , 'application/json' ,
105
+ len (post_data ), BytesIO (post_data ))
106
+
107
+ assert mq .append_query ('http://example.com/events' ) == 'http://example.com/events?__wb_method=POST&type=event&id=44&float=35.7&values=true&values.2_=false&values.3_=null&type.2_=component&id.2_=a%2Bb%26c%3D+d&values.4_=3&values.5_=4'
103
108
104
109
def test_put_extract_method (self ):
105
110
mq = MethodQueryCanonicalizer ('PUT' , 'application/x-www-form-urlencoded' ,
106
111
len (self .post_data ), BytesIO (self .post_data ))
107
112
108
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=PUT&foo=bar&dir=/baz'
113
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=PUT&foo=bar&dir=/baz&do=true&re=false&re=null '
109
114
110
115
def test_post_extract_non_form_data_1 (self ):
111
116
mq = MethodQueryCanonicalizer ('POST' , 'application/octet-stream' ,
112
117
len (self .post_data ), BytesIO (self .post_data ))
113
118
114
119
#base64 encoded data
115
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6 '
120
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6JmRvPXRydWUmcmU9ZmFsc2UmcmU9bnVsbA== '
116
121
117
122
def test_post_extract_non_form_data_2 (self ):
118
123
mq = MethodQueryCanonicalizer ('POST' , 'text/plain' ,
119
124
len (self .post_data ), BytesIO (self .post_data ))
120
125
121
126
#base64 encoded data
122
- assert mq .append_query ('http://example.com/pathbar?id=123' ) == 'http://example.com/pathbar?id=123&__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6 '
127
+ assert mq .append_query ('http://example.com/pathbar?id=123' ) == 'http://example.com/pathbar?id=123&__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6JmRvPXRydWUmcmU9ZmFsc2UmcmU9bnVsbA== '
123
128
124
129
def test_post_extract_length_invalid_ignore (self ):
125
130
mq = MethodQueryCanonicalizer ('POST' , 'application/x-www-form-urlencoded' ,
@@ -136,13 +141,13 @@ def test_post_extract_length_too_short(self):
136
141
mq = MethodQueryCanonicalizer ('POST' , 'application/x-www-form-urlencoded' ,
137
142
len (self .post_data ) - 4 , BytesIO (self .post_data ))
138
143
139
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=%2 '
144
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=/baz&do=true&re=false&re= '
140
145
141
146
def test_post_extract_length_too_long (self ):
142
147
mq = MethodQueryCanonicalizer ('POST' , 'application/x-www-form-urlencoded' ,
143
148
len (self .post_data ) + 4 , BytesIO (self .post_data ))
144
149
145
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=/baz'
150
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&foo=bar&dir=/baz&do=true&re=false&re=null '
146
151
147
152
def test_post_extract_malformed_form_data (self ):
148
153
mq = MethodQueryCanonicalizer ('POST' , 'application/x-www-form-urlencoded' ,
@@ -155,7 +160,7 @@ def test_post_extract_no_boundary_in_multipart_form_mimetype(self):
155
160
mq = MethodQueryCanonicalizer ('POST' , 'multipart/form-data' ,
156
161
len (self .post_data ), BytesIO (self .post_data ))
157
162
158
- assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6 '
163
+ assert mq .append_query ('http://example.com/' ) == 'http://example.com/?__wb_method=POST&__wb_post_data=Zm9vPWJhciZkaXI9JTJGYmF6JmRvPXRydWUmcmU9ZmFsc2UmcmU9bnVsbA== '
159
164
160
165
161
166
def test_options (self ):
0 commit comments