From ff15cfa3789ccc8433c1be99cf96daae36027b11 Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Tue, 23 Jan 2024 17:29:16 +0100 Subject: [PATCH] test: modify login test to approve dex confirmation page --- diracx-testing/src/diracx/testing/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/diracx-testing/src/diracx/testing/__init__.py b/diracx-testing/src/diracx/testing/__init__.py index 02c5a0a05..99a044682 100644 --- a/diracx-testing/src/diracx/testing/__init__.py +++ b/diracx-testing/src/diracx/testing/__init__.py @@ -9,7 +9,7 @@ from html.parser import HTMLParser from pathlib import Path from typing import TYPE_CHECKING -from urllib.parse import urljoin +from urllib.parse import parse_qs, urljoin, urlparse from uuid import uuid4 import pytest @@ -551,5 +551,13 @@ def handle_starttag(self, tag, attrs): verify=ca_path, ) r.raise_for_status() + approval_url = r.url # This is not the same as URL as we redirect to dex + # Do the actual approval + r = requests.post( + approval_url, + {"approval": "approve", "req": parse_qs(urlparse(r.url).query)["req"][0]}, + verify=ca_path, + ) + # This should have redirected to the DiracX page that shows the login is complete assert "Please close the window" in r.text