

@patch('jumpgate.common.hooks.auth_token.identity')
def test_valid_auth(self, identity):
    req = MagicMock()
    req.headers = {
        'X-AUTH-TOKEN': 'AUTHTOK',
    }
    req.method = 'GET'
    req.path = '/v2/servers'
    req.env = {
        'tenant_id': 'public',
    }
    resp = MagicMock()

    def mock_validate(tok, tenant_id=None):
        self.assertEqual('AUTHTOK', tok)
        self.assertEqual('public', tenant_id)

    class MockIdDriver(object):

        def token_from_id(self, tok):
            return 'MYTOKEN'
    identity.validate_token_id = mock_validate
    identity.token_id_driver.return_value = MockIdDriver()
    validate_token(req, resp, {
        
    })
    self.assertEqual(resp.env.get('auth'), 'MYTOKEN')

dataset/ETHPy150Open softlayer/jumpgate/tests/jumpgate-tests/common/hooks/test_hooks.py TestHookAuthToken.test_valid_auth/VarMisuse@157/230 `req`->`resp`