def test_validate_token_info_response_scope_missing(): response = mock.Mock() response_json = { 'user_id': 'bob', } with pytest.raises(IncorrectResponseError) as exc_info: AuthAPI.validate_token_info_response(response, response_json) assert str(exc_info.value) == "'scope' field is missing or wrong type"
def create_auth_api_client( auth_api_base_url: Optional[str] = None, http_request_timeout: Optional[int] = None) -> AuthAPI: auth_api_base_url = auth_api_base_url or config.AUTH_API_BASE_URL http_request_timeout = http_request_timeout or config.HTTP_REQUEST_TIMEOUT auth_api = AuthAPI(auth_api_base_url, http_request_timeout) return auth_api
def create_auth_api_client( auth_api_base_url: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, http_request_timeout: Optional[int] = None) -> AuthAPI: auth_api_base_url = auth_api_base_url or config.AUTH_API_BASE_URL client_id = client_id or config.CLIENT_ID client_secret = client_secret or config.CLIENT_SECRET http_request_timeout = http_request_timeout or config.HTTP_REQUEST_TIMEOUT auth_api = AuthAPI(auth_api_base_url, client_id, client_secret, http_request_timeout) return auth_api
def test_validate_token_info_response_smoke(): response = mock.Mock() response_json = {'user_id': 'bob', 'scope': ['current_time', 'epoch_time']} result = AuthAPI.validate_token_info_response(response, response_json) assert result == ('bob', ['current_time', 'epoch_time'])
def test_validate_token_info_response_user_id_wrong_type(): response = mock.Mock() response_json = {'user_id': 100, 'scope': ['current_time', 'epoch_time']} with pytest.raises(IncorrectResponseError) as exc_info: AuthAPI.validate_token_info_response(response, response_json) assert str(exc_info.value) == "'user_id' field is missing or wrong type"
def test_validate_token_info_response_empty_scope(): response = mock.Mock() response_json = {'user_id': 'bob', 'scope': []} result = AuthAPI.validate_token_info_response(response, response_json) assert result == ('bob', [])