Ejemplo n.º 1
0
 def test_oauth_bearer_token(self):
     token = 'Azly3WBiYWeGKfImK25ftpJR1nvn6JABC123'
     with settings.runtime_values(oauth_token=token):
         auth = BasicTowerAuth(None, None, client)
         auth(self.req)
         assert self.req.headers == {
             'Authorization': 'Bearer {}'.format(token)
         }
Ejemplo n.º 2
0
    def setUp(self):
        class Req(object):
            def __init__(self):
                self.headers = {}

        with settings.runtime_values(use_token=True):
            self.auth = BasicTowerAuth('alice', 'pass', client)
        self.req = Req()
        self.expires = dt.utcnow()
Ejemplo n.º 3
0
 def test_auth_token_unsupported(self):
     # If the user specifies `use_token=True`, but `/authtoken/` doesn't
     # exist (in Tower 3.3 and beyond), just fall back to basic auth
     with client.test_mode as t:
         with settings.runtime_values(use_token=True):
             t.register('/authtoken/', json.dumps({}), status_code=404, method='OPTIONS')
             auth = BasicTowerAuth('alice', 'pass', client)
             auth(self.req)
             assert self.req.headers == {'Authorization': 'Basic YWxpY2U6cGFzcw=='}