Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use postgresql for tests #450

Merged
merged 12 commits into from
Jun 20, 2024
Prev Previous commit
Use client for new tests
  • Loading branch information
armanddidierjean committed Jun 20, 2024
commit 6861a164edd08e4f9d8fbcd1e8a052495382723c
30 changes: 16 additions & 14 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def init_objects() -> None:
)


def test_simple_token():
def test_simple_token(client: TestClient):
response = client.post(
"/auth/simple_token",
data={
Expand Down Expand Up @@ -329,7 +329,7 @@ def test_get_user_info_in_id_token(client: TestClient) -> None:


# Invalid service configuration
def test_authorization_code_flow_with_invalid_client_id() -> None:
def test_authorization_code_flow_with_invalid_client_id(client: TestClient) -> None:
data_with_invalid_client_id = {
"client_id": "InvalidClientId",
"client_secret": "secret",
Expand All @@ -351,7 +351,7 @@ def test_authorization_code_flow_with_invalid_client_id() -> None:


# Invalid service configuration
def test_authorization_code_flow_with_invalid_redirect_uri() -> None:
def test_authorization_code_flow_with_invalid_redirect_uri(client: TestClient) -> None:
data_with_invalid_client_id = {
"client_id": "AppAuthClientWithClientSecret",
"client_secret": "secret",
Expand All @@ -373,7 +373,7 @@ def test_authorization_code_flow_with_invalid_redirect_uri() -> None:


# Invalid service configuration
def test_authorization_code_flow_with_invalid_response_type() -> None:
def test_authorization_code_flow_with_invalid_response_type(client: TestClient) -> None:
data_with_invalid_client_id = {
"client_id": "AppAuthClientWithClientSecret",
"client_secret": "secret",
Expand All @@ -397,7 +397,9 @@ def test_authorization_code_flow_with_invalid_response_type() -> None:


# Invalid user response
def test_authorization_code_flow_with_invalid_user_credentials() -> None:
def test_authorization_code_flow_with_invalid_user_credentials(
client: TestClient,
) -> None:
data_with_invalid_client_id = {
"client_id": "AppAuthClientWithClientSecret",
"client_secret": "secret",
Expand All @@ -417,9 +419,9 @@ def test_authorization_code_flow_with_invalid_user_credentials() -> None:


# Valid user response
def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and_user_member_of_an_allowed_group() -> (
None
):
def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and_user_member_of_an_allowed_group(
client: TestClient,
) -> None:
# For an user that is a member of a required group #
data_with_invalid_client_id = {
"client_id": "AcceptingOnlyECLUsersAuthClient",
Expand All @@ -444,9 +446,9 @@ def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and
assert query["code"][0] != ""


def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and_user_not_member_of_an_allowed_group() -> (
None
):
def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and_user_not_member_of_an_allowed_group(
client: TestClient,
) -> None:
# For an user that is not a member of a required group #
data_with_invalid_client_id = {
"client_id": "AcceptingOnlyECLUsersAuthClient",
Expand All @@ -470,9 +472,9 @@ def test_authorization_code_flow_with_auth_client_restricting_allowed_groups_and
assert query["error"][0] == "consent_required"


def test_authorization_code_flow_with_auth_client_restricting_external_users_and_user_external() -> (
None
):
def test_authorization_code_flow_with_auth_client_restricting_external_users_and_user_external(
client: TestClient,
) -> None:
# For an user that is not a member of a required group #
data_with_invalid_client_id = {
"client_id": "RalllyAuthClient",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_flappybird.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_create_flappybird_score(client: TestClient) -> None:
assert response.status_code == 201


def test_update_flappybird_score():
def test_update_flappybird_score(client: TestClient):
response = client.post(
"/flappybird/scores",
json={
Expand Down