Skip to content

Commit

Permalink
refactor(oauth): update tests to handle integer claims
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed May 24, 2024
1 parent 81fb0a1 commit c4d36fc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/pytest/oauth/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ def test_authorize_success(mocked_oauth_create_client, mocked_analytics_module,

@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_analytics_module")
@pytest.mark.parametrize("flag", ["true", "True", "tRuE"])
def test_authorize_success_with_claim_true(
mocked_session_verifier_auth_required, mocked_oauth_create_client, app_request, flag
):
def test_authorize_success_with_claim_true(mocked_session_verifier_auth_required, mocked_oauth_create_client, app_request):
verifier = mocked_session_verifier_auth_required.return_value
verifier.auth_provider.claim = "claim"
mocked_oauth_client = mocked_oauth_create_client.return_value
mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": flag}}
mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "1"}}

result = authorize(app_request)

Expand All @@ -118,14 +115,15 @@ def test_authorize_success_with_claim_true(

@pytest.mark.django_db
@pytest.mark.usefixtures("mocked_analytics_module")
@pytest.mark.parametrize("flag", ["false", "False", "fAlSe"])
def test_authorize_success_with_claim_false(
mocked_session_verifier_auth_required, mocked_oauth_create_client, app_request, flag
mocked_session_verifier_auth_required,
mocked_oauth_create_client,
app_request,
):
verifier = mocked_session_verifier_auth_required.return_value
verifier.auth_provider.claim = "claim"
mocked_oauth_client = mocked_oauth_create_client.return_value
mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": flag}}
mocked_oauth_client.authorize_access_token.return_value = {"id_token": "token", "userinfo": {"claim": "0"}}

result = authorize(app_request)

Expand Down

0 comments on commit c4d36fc

Please sign in to comment.