From a9d9dcd4b00aa8b1a19a38ae59b6c09b9ba5a946 Mon Sep 17 00:00:00 2001 From: alfredeen Date: Mon, 7 Oct 2024 11:31:00 +0200 Subject: [PATCH] Fixed logout task --- source/tests-dev/authenticated.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/tests-dev/authenticated.py b/source/tests-dev/authenticated.py index 395c926..8e4de1b 100644 --- a/source/tests-dev/authenticated.py +++ b/source/tests-dev/authenticated.py @@ -56,9 +56,17 @@ def login(self): response.failure(f"Login as user {username} failed. Response URL does not contain /projects") def logout(self): - logger.debug("Log out user %s", username) - # logout_data = dict(username=username, csrfmiddlewaretoken=self.csrftoken) - self.client.get("/accounts/logout/", name="---ON STOP---LOGOUT") + if self.is_authenticated: + logger.debug("Logout user %s", self.username) + logout_data = dict(username=self.username, csrfmiddlewaretoken=self.csrftoken) + with self.client.post( + "/accounts/logout/", + data=logout_data, + headers={"Referer": "foo"}, + name="---ON STOP---LOGOUT", + catch_response=True, + ): + pass @task def browse_homepage(self):