MCPcopy
hub / github.com/pallets/werkzeug / test_authorization_header

Method test_authorization_header

tests/test_http.py:161–216  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

159 assert csp.img_src is None
160
161 def test_authorization_header(self):
162 a = Authorization.from_header("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
163 assert a.type == "basic"
164 assert a.username == "Aladdin"
165 assert a.password == "open sesame"
166
167 a = Authorization.from_header("Basic 0YDRg9GB0YHQutC40IE60JHRg9C60LLRiw==")
168 assert a.type == "basic"
169 assert a.username == "русскиЁ"
170 assert a.password == "Буквы"
171
172 a = Authorization.from_header("Basic 5pmu6YCa6K+dOuS4reaWhw==")
173 assert a.type == "basic"
174 assert a.username == "普通话"
175 assert a.password == "中文"
176
177 a = Authorization.from_header(
178 'Digest username="Mufasa",'
179 ' realm="testrealm@host.invalid",'
180 ' nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",'
181 ' uri="/dir/index.html",'
182 " qop=auth, nc=00000001,"
183 ' cnonce="0a4f113b",'
184 ' response="6629fae49393a05397450978507c4ef1",'
185 ' opaque="5ccc069c403ebaf9f0171e9517f40e41"'
186 )
187 assert a.type == "digest"
188 assert a.username == "Mufasa"
189 assert a.realm == "testrealm@host.invalid"
190 assert a.nonce == "dcd98b7102dd2f0e8b11d0f600bfb0c093"
191 assert a.uri == "/dir/index.html"
192 assert a.qop == "auth"
193 assert a.nc == "00000001"
194 assert a.cnonce == "0a4f113b"
195 assert a.response == "6629fae49393a05397450978507c4ef1"
196 assert a.opaque == "5ccc069c403ebaf9f0171e9517f40e41"
197
198 a = Authorization.from_header(
199 'Digest username="Mufasa",'
200 ' realm="testrealm@host.invalid",'
201 ' nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",'
202 ' uri="/dir/index.html",'
203 ' response="e257afa1414a3340d93d30955171dd0e",'
204 ' opaque="5ccc069c403ebaf9f0171e9517f40e41"'
205 )
206 assert a.type == "digest"
207 assert a.username == "Mufasa"
208 assert a.realm == "testrealm@host.invalid"
209 assert a.nonce == "dcd98b7102dd2f0e8b11d0f600bfb0c093"
210 assert a.uri == "/dir/index.html"
211 assert a.response == "e257afa1414a3340d93d30955171dd0e"
212 assert a.opaque == "5ccc069c403ebaf9f0171e9517f40e41"
213
214 assert Authorization.from_header("") is None
215 assert Authorization.from_header(None) is None
216 assert Authorization.from_header("foo").type == "foo"
217
218 def test_authorization_ignore_invalid_parameters(self):

Callers

nothing calls this directly

Calls 1

from_headerMethod · 0.45

Tested by

no test coverage detected