Skip to content

Commit

Permalink
Make user_info test use two users
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Oct 26, 2022
1 parent be8568b commit 275fd4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion testsuite/oidc/rhsso/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create_user(self, username, password, **kwargs):
"""Creates new user"""
kwargs["username"] = username
kwargs["enabled"] = True
kwargs["email"] = f"{username}@anything.invalid"
kwargs.setdefault("email", f"{username}@anything.invalid")
self.admin.create_user(kwargs)
user_id = self.admin.get_user_id(username)
self.admin.set_user_password(user_id, password, temporary=False)
Expand Down
11 changes: 9 additions & 2 deletions testsuite/tests/kuadrant/authorino/metadata/test_user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
"""
import pytest

from testsuite.httpx.auth import HttpxOidcClientAuth
from testsuite.openshift.objects.auth_config import Rule


@pytest.fixture(scope="module")
def user2(rhsso):
"""Second User which has incorrect email"""
return rhsso.realm.create_user("user2", "password", email="[email protected]")


@pytest.fixture(scope="module")
def authorization(authorization, rhsso):
"""
Expand All @@ -25,8 +32,8 @@ def test_correct_auth(client, auth):
assert response.status_code == 200


def test_incorrect_auth(client, auth, rhsso):
def test_incorrect_auth(client, rhsso, user2):
"""Updates RHSSO user email address and tests incorrect auth"""
rhsso.user.update_user(email="[email protected]")
auth = HttpxOidcClientAuth(rhsso.get_token(user2.username, user2.password), "authorization")
response = client.get("get", auth=auth)
assert response.status_code == 403

0 comments on commit 275fd4f

Please sign in to comment.