generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Oauth2/Keycloak configs, decorators
- Loading branch information
Showing
6 changed files
with
86 additions
and
3 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
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 |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
|
||
from entities.models import FilingPeriodDAO, FilingType | ||
|
||
from regtech_api_commons.models.auth import AuthenticatedUser | ||
from starlette.authentication import AuthCredentials, UnauthenticatedUser | ||
|
||
|
||
@pytest.fixture | ||
def app_fixture(mocker: MockerFixture) -> FastAPI: | ||
|
@@ -15,6 +18,32 @@ def app_fixture(mocker: MockerFixture) -> FastAPI: | |
return app | ||
|
||
|
||
@pytest.fixture | ||
def auth_mock(mocker: MockerFixture) -> Mock: | ||
return mocker.patch("regtech_api_commons.oauth2.oauth2_backend.BearerTokenAuthBackend.authenticate") | ||
|
||
|
||
@pytest.fixture | ||
def authed_user_mock(auth_mock: Mock) -> Mock: | ||
claims = { | ||
"name": "test", | ||
"preferred_username": "test_user", | ||
"email": "[email protected]", | ||
"institutions": "123456ABCDEF, 654321FEDCBA", | ||
} | ||
auth_mock.return_value = ( | ||
AuthCredentials(["authenticated"]), | ||
AuthenticatedUser.from_claim(claims), | ||
) | ||
return auth_mock | ||
|
||
|
||
@pytest.fixture | ||
def unauthed_user_mock(auth_mock: Mock) -> Mock: | ||
auth_mock.return_value = (AuthCredentials("unauthenticated"), UnauthenticatedUser()) | ||
return auth_mock | ||
|
||
|
||
@pytest.fixture | ||
def get_filing_period_mock(mocker: MockerFixture) -> Mock: | ||
mock = mocker.patch("entities.repos.submission_repo.get_filing_periods") | ||
|
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