Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +0,0 @@ | ||
from clients.teams import TeamsClient | ||
|
||
__all__ = [ | ||
"TeamsClient", | ||
] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
import pytest | ||
|
||
import responses | ||
from fastapi.testclient import TestClient | ||
from keycloak import KeycloakOpenID | ||
|
||
from app import app | ||
|
||
|
||
team_id = "abc-123-def-456" | ||
valid_access_token = "valid-access-token" | ||
valid_access_token_not_member = "valid-access-token-not-member" | ||
team_member_user = "janedoe" | ||
not_team_member_user = "homersimpson" | ||
origo_team_role = "origo-team" | ||
|
||
|
||
@pytest.fixture | ||
def mock_client(): | ||
app.debug = True | ||
return TestClient(app) | ||
|
||
|
||
@pytest.fixture | ||
def mocked_responses(): | ||
with responses.RequestsMock() as rsps: | ||
yield rsps | ||
|
||
|
||
@pytest.fixture | ||
def mock_keycloak(monkeypatch): | ||
def introspect(self, token): | ||
if token == valid_access_token: | ||
return {"active": True, "username": team_member_user} | ||
elif token == valid_access_token_not_member: | ||
return {"active": True, "username": not_team_member_user} | ||
else: | ||
return {"active": False} | ||
|
||
monkeypatch.setattr(KeycloakOpenID, "introspect", introspect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters