Skip to content

Commit

Permalink
Order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Feb 29, 2024
1 parent e231db2 commit c3e98c2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def test_login_redirect(
else:
assert not redirect_uri.params

def test_logout_redirect(self, client: TestClient):
response = client.get("/auth/logout", follow_redirects=False)
assert response.status_code == status.HTTP_307_TEMPORARY_REDIRECT
assert response.headers["location"] == "/"

def test_auth_flow(self, client: TestClient, keycloak: KeycloakAdmin):
# try accessing protected endpoint
response = client.get("/", follow_redirects=False)
Expand All @@ -149,7 +154,7 @@ def test_auth_flow(self, client: TestClient, keycloak: KeycloakAdmin):

# first check the redirect
response = client.get(exc.value.request.url, follow_redirects=False)
assert response.status_code == status.HTTP_307_TEMPORARY_REDIRECT
assert response.is_redirect
assert response.headers["location"] == "/"

# now follow the redirect
Expand All @@ -158,15 +163,9 @@ def test_auth_flow(self, client: TestClient, keycloak: KeycloakAdmin):
assert response.read() == b'"Hello test"'

# logout user
response = client.get("/auth/logout", follow_redirects=False)
assert response.status_code == status.HTTP_307_TEMPORARY_REDIRECT
assert response.headers["location"] == "/"
response = client.get("/auth/logout")
assert response.is_redirect

# check that endpoint is inaccessible again
response = client.get("/", follow_redirects=False)
assert response.status_code == status.HTTP_401_UNAUTHORIZED

def test_logout_redirect(self, client: TestClient):
response = client.get("/auth/logout", follow_redirects=False)
assert response.status_code == status.HTTP_307_TEMPORARY_REDIRECT
assert response.headers["location"] == "/"

0 comments on commit c3e98c2

Please sign in to comment.