Skip to content

Commit

Permalink
GH-3: Add IT for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
markhobson committed Oct 6, 2023
1 parent 98440e9 commit 1f29ff2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/integration/test_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Any, Mapping

import pytest
from flask import session
from flask.testing import FlaskClient


@pytest.fixture(name="config")
def config_fixture(config: Mapping[str, Any]) -> Mapping[str, Any]:
return config | {"GOVUK_END_SESSION_ENDPOINT": "https://example.com/logout"}


def test_logout_logs_out_from_oidc(client: FlaskClient) -> None:
with client.session_transaction() as setup_session:
setup_session["user"] = "test"
setup_session["id_token"] = "id_token"

response = client.get("/auth/logout")

assert (
response.status_code == 302
and response.location
== "https://example.com/logout?id_token_hint=id_token&post_logout_redirect_uri=http%3A%2F%2Flocalhost%2F"
)


def test_logout_logs_out_from_schemes(client: FlaskClient) -> None:
with client.session_transaction() as setup_session:
setup_session["user"] = "test"
setup_session["id_token"] = "test"

with client:
client.get("/auth/logout")

assert "user" not in session and "id_token" not in session

0 comments on commit 1f29ff2

Please sign in to comment.