diff options
| author | Pranay Suresh <psuresh@teslamotors.com> | 2016-04-10 12:49:06 -0700 |
|---|---|---|
| committer | Pranay Suresh <psuresh@teslamotors.com> | 2016-04-10 12:49:06 -0700 |
| commit | dcdaf161267755233318d1882444f083491d3ed6 (patch) | |
| tree | 72241adf197b64bc81c8ee019c36aa45f7c20838 /tests | |
| parent | 4a6a73b2a571a93a70b63923635d01240467d2e1 (diff) | |
| download | webtest-dcdaf161267755233318d1882444f083491d3ed6.tar.gz | |
add test case for bearer auth and append to invalid auth test case
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_authorisation.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_authorisation.py b/tests/test_authorisation.py index f1f03d9..5cdc1e7 100644 --- a/tests/test_authorisation.py +++ b/tests/test_authorisation.py @@ -33,9 +33,27 @@ class TestAuthorization(unittest.TestCase): app.authorization = None self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ) + def test_bearer_authorization(self): + app = self.callFUT() + authorization = ('Bearer', '2588409761fcfa3e378bff4fb766e2e2') + app.authorization = authorization + + self.assertIn('HTTP_AUTHORIZATION', app.extra_environ) + self.assertEquals(app.authorization, authorization) + + resp = app.get('/') + resp.mustcontain('HTTP_AUTHORIZATION: Bearer 2588409761fcfa3e378bff4fb766e2e2') + header = resp.request.environ['HTTP_AUTHORIZATION'] + self.assertTrue(header.startswith('Bearer ')) + + app.authorization = None + self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ) + def test_invalid(self): app = self.callFUT() self.assertRaises(ValueError, app.set_authorization, ()) self.assertRaises(ValueError, app.set_authorization, '') self.assertRaises(ValueError, app.set_authorization, ('Basic', '')) self.assertRaises(ValueError, app.set_authorization, ('Basic', ())) + self.assertRaises(ValueError, app.set_authorization, ('Bearer', ())) + self.assertRaises(ValueError, app.set_authorization, ('Bearer', [])) |
