MCPcopy Create free account
hub / github.com/Pylons/webtest / test_basic_authorization

Method test_basic_authorization

tests/test_authorisation.py:14–32  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

12 return webtest.TestApp(DebugApp())
13
14 def test_basic_authorization(self):
15 app = self.callFUT()
16 authorization = ('Basic', ['gawel', 'passwd'])
17 app.authorization = authorization
18
19 self.assertIn('HTTP_AUTHORIZATION', app.extra_environ)
20 self.assertEqual(app.authorization, authorization)
21
22 resp = app.get('/')
23 resp.mustcontain('HTTP_AUTHORIZATION: Basic Z2F3ZWw6cGFzc3dk')
24 header = resp.request.environ['HTTP_AUTHORIZATION']
25 self.assertTrue(header.startswith('Basic '))
26 authtype, value = header.split(' ')
27 auth = (authtype,
28 b64decode(to_bytes(value)).decode('latin1').split(':'))
29 self.assertEqual(authorization, auth)
30
31 app.authorization = None
32 self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ)
33
34 def test_bearer_authorization(self):
35 app = self.callFUT()

Callers

nothing calls this directly

Calls 4

callFUTMethod · 0.95
to_bytesFunction · 0.90
mustcontainMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected