def test_call_token_endpoint_returns_tokens(mock_post, rf): """ when we call the token endpoint with valid data we expect to receive a bunch of tokens. See assertions to understand which. """ mock_post.return_value = Mock(ok=True) mock_post.return_value.json.return_value = { "access_token": build_access_token(), "id_token": build_id_token(), "refresh_token": "refresh", } endpoint_data = {"grant_type": "authorization_code", "code": "imacode"} c = Config() MockDiscoveryDocument = MagicMock() with patch("okta_oauth2.tokens.DiscoveryDocument", MockDiscoveryDocument): tv = TokenValidator(c, "defaultnonce", rf.get("/")) tokens = tv.call_token_endpoint(endpoint_data) assert "access_token" in tokens assert "id_token" in tokens assert "refresh_token" in tokens
def get_normal_user_with_groups_token(self, code): return { "access_token": build_access_token(), "id_token": build_id_token(groups=["one", "two"]), "refresh_token": "refresh", }
def get_staff_token_result(self, code): return { "access_token": build_access_token(), "id_token": build_id_token(groups=[STAFF_GROUP]), "refresh_token": "refresh", }
def get_superuser_token_result(self, code): return { "access_token": build_access_token(), "id_token": build_id_token(groups=[SUPERUSER_GROUP]), "refresh_token": "refresh", }
def get_token_result(self, code): return { "access_token": build_access_token(), "id_token": build_id_token(), "refresh_token": "refresh", }