client = <django.test.client.Client object at 0x7f3faafd7dd8>
keycloak_oidc = <swh.auth.pytest_plugin.KeycloackOpenIDConnectMock object at 0x7f3faafd7c18>
@pytest.mark.django_db
def test_oidc_profile_view(client, keycloak_oidc):
"""
Authenticated users should be able to request the profile page
and link to Keycloak account UI should be present.
"""
url = reverse("oidc-profile")
kc_config = get_config()["keycloak"]
user_permissions = ["perm1", "perm2"]
keycloak_oidc.user_permissions = user_permissions
client.login(code="", code_verifier="", redirect_uri="")
resp = check_html_get_response(
client, url, status_code=200, template_used="auth/profile.html"
)
user = resp.wsgi_request.user
kc_account_url = (
f"{kc_config['server_url']}realms/{kc_config['realm_name']}/account/"
)
assert_contains(resp, kc_account_url)
assert_contains(resp, user.username)
assert_contains(resp, user.first_name)
assert_contains(resp, user.last_name)
assert_contains(resp, user.email)
for perm in user_permissions:
> assert_contains(resp, perm)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/auth/test_views.py:306:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/django/test/testcases.py:454: in assertContains
self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.test.testcases.TestCase testMethod=run>, expr = False
msg = "False is not true : Couldn't find 'perm1' in response"
def assertTrue(self, expr, msg=None):
"""Check that the expression is true."""
if not expr:
msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
> raise self.failureException(msg)
E AssertionError: False is not true : Couldn't find 'perm1' in response
/usr/lib/python3.7/unittest/case.py:692: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Apr 23 2021, 11:26 AM