Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
24719a7
test(api): drop api_035, DataSpaceFrontend#567 removed /api/website-t…
saqibmanan Nov 26, 2026
53abd81
test: drop the auth-page known failures fixed by DataSpaceKeycloakThe…
saqibmanan Nov 26, 2026
bec05d8
test(keycloak): the auth footer links only to Privacy, which covers T…
saqibmanan Nov 26, 2026
1cc0c63
test(keycloak): register consent names the Privacy Policy, which cove…
saqibmanan Nov 26, 2026
dd3aaed
test(keycloak): register keeps first and last name; password checks w…
saqibmanan Nov 26, 2026
1557888
test(keycloak): registration types a password when the realm asks for…
saqibmanan Nov 26, 2026
30aeef1
test(keycloak): wait for the reset request to load the next page befo…
saqibmanan Nov 26, 2026
c60cf33
test(keycloak): register password checks pass now the realm asks for …
saqibmanan Nov 26, 2026
b7a40fc
test(utils): Keycloak admin can create a throwaway user and read its …
saqibmanan Nov 26, 2026
9fef4f2
test(locators): password checklist, existing-email sign-in link and u…
saqibmanan Nov 26, 2026
b7756ae
test(pages): Keycloak checklist, field errors, real sign-in and the u…
saqibmanan Nov 26, 2026
6c1645a
test(pages): sign-in can report a submit the theme kept in the browser
saqibmanan Nov 26, 2026
22e60e7
test(utils): Keycloak admin reads a user's sessions and pending requi…
saqibmanan Nov 26, 2026
ce17ddf
test(keycloak): auth flows on the redesigned pages: register, sign-in…
saqibmanan Nov 26, 2026
e11dd3f
Sync CI into main (#389-#392)
saqibmanan Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions known_failures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ tests/api/smoke/test_api_067_org_member_permissions.py::test_api_067_only_an_adm
tests/api/smoke/test_api_072_user_lookup_privacy.py::test_api_072_anonymous_user_lookup_hides_the_email # GHSA-v29h-63vw-gw4f
tests/accessibility/test_a11y_008_public_layout.py::test_public_page_does_not_scroll_sideways[home-tablet] # home scrolls sideways at 768px
tests/provider/smoke/test_prv_026_stored_description_html.py::test_description_html_is_not_run_on_the_public_page # stored description HTML runs on the public page
tests/consumer/smoke/test_con_auth_pages.py::TestErrorPage::test_bad_redirect_uri_is_not_blamed_on_google # DataSpaceKeycloakTheme#32
tests/consumer/smoke/test_con_auth_pages.py::TestErrorPage::test_unknown_client_is_not_blamed_on_google # DataSpaceKeycloakTheme#32
tests/consumer/smoke/test_con_auth_pages.py::TestForgotPasswordPage::test_email_carries_over_from_sign_in # DataSpaceKeycloakTheme#40
tests/consumer/smoke/test_con_auth_pages.py::TestForgotPasswordPage::test_empty_request_message_matches_design # DataSpaceKeycloakTheme#40
tests/consumer/smoke/test_con_auth_pages.py::TestForgotPasswordPage::test_request_shows_check_your_email # DataSpaceKeycloakTheme#33
tests/consumer/smoke/test_con_auth_pages.py::TestLegalLinks::test_footer_has_privacy_terms_legal # DataSpaceKeycloakTheme#43
tests/consumer/smoke/test_con_auth_pages.py::TestLegalLinks::test_mobile_shows_legal_links # DataSpaceKeycloakTheme#43
tests/consumer/smoke/test_con_auth_pages.py::TestRegistrationPage::test_consent_covers_terms_and_privacy # DataSpaceKeycloakTheme#42
tests/consumer/smoke/test_con_auth_pages.py::TestRegistrationPage::test_password_requirements_are_shown # DataSpaceKeycloakTheme#41
tests/consumer/smoke/test_con_auth_pages.py::TestRegistrationPage::test_registration_form_renders_design_fields # DataSpaceKeycloakTheme#44
tests/consumer/smoke/test_con_auth_pages.py::TestSignInPage::test_empty_sign_in_is_validated_inline # DataSpaceKeycloakTheme#39
tests/consumer/smoke/test_con_auth_pages.py::TestSignInPage::test_wrong_credentials_message_matches_design # DataSpaceKeycloakTheme#39
tests/api/smoke/test_api_073_anonymous_mutations.py::test_api_073_anonymous_caller_is_refused[update-sector] # GHSA-jcj9-qw6c-98h3
tests/api/smoke/test_api_073_anonymous_mutations.py::test_api_073_anonymous_caller_is_refused[delete-sector] # GHSA-jcj9-qw6c-98h3
tests/api/smoke/test_api_073_anonymous_mutations.py::test_api_073_anonymous_caller_is_refused[update-sdg] # GHSA-jcj9-qw6c-98h3
Expand Down
9 changes: 9 additions & 0 deletions locators/consumer/keycloak_auth_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class KeycloakShellLocators:
LEGAL_LINKS = (By.CSS_SELECTOR, ".civic-legal-links a")
ALERT = (By.CSS_SELECTOR, ".pf-c-alert")
FIELD_ERROR = (By.CSS_SELECTOR, ".civic-field-error")
PASSWORD_RULES = (By.CSS_SELECTOR, "#password-requirements li")
ANY_LINK = (By.TAG_NAME, "a")


Expand Down Expand Up @@ -55,10 +56,12 @@ class KeycloakRegisterLocators:
FIRST_NAME = (By.ID, "firstName")
LAST_NAME = (By.ID, "lastName")
PASSWORD = (By.ID, "password")
PASSWORD_CONFIRM = (By.ID, "password-confirm")
SIGN_IN_PROMPT = (By.ID, "kc-registration")
GOOGLE_BROKER_LINK = (By.CSS_SELECTOR, "a[href*='/broker/google/login']")
TERMS_ROW = (By.CSS_SELECTOR, ".civic-terms")
TERMS_ERROR = (By.ID, "input-error-termsAccepted")
EMAIL_ERROR_SIGN_IN_LINK = (By.CSS_SELECTOR, "#input-error-email a")

# The privacy consent checkbox. Note it carries required=false in the DOM,
# so nothing about the markup guarantees consent is enforced - the tests
Expand All @@ -68,3 +71,9 @@ class KeycloakRegisterLocators:
SUBMIT = (By.CSS_SELECTOR, "input[type=submit], button[type=submit]")
PRIVACY_LINK = (By.CSS_SELECTOR, "a[href*='/privacy']")
BACK_TO_LOGIN = (By.CSS_SELECTOR, "a[href*='login-actions'], a[href*='protocol/openid-connect/auth']")


class KeycloakUpdatePasswordLocators:
NEW_PASSWORD = (By.ID, "password-new")
CONFIRM = (By.ID, "password-confirm")
SUBMIT = (By.CSS_SELECTOR, "#kc-passwd-update-form [type=submit]:not([name=cancel-aia])")
105 changes: 104 additions & 1 deletion pages/consumer/keycloak_auth_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

Expand All @@ -11,6 +12,7 @@
KeycloakRegisterLocators,
KeycloakResetLocators,
KeycloakShellLocators,
KeycloakUpdatePasswordLocators,
)
from pages.base_page import BasePage

Expand All @@ -21,6 +23,8 @@

VERIFY_EMAIL_MARKER = "VERIFY_EMAIL"
REGISTRATION_PATH = "registrations"
# Meets the realm policy planned for #41: 8+ characters, an uppercase letter and a digit.
REGISTER_PASSWORD = "QaAuto-Register-2026"


def _kc_settings():
Expand Down Expand Up @@ -77,6 +81,39 @@ def field_errors(self):
if _squash(e.text)
]

def field_error(self, field):
"""The inline error under one field, or "" when it has none."""
return self._text((By.ID, f"input-error-{field}"))

def password_rules(self):
"""The "Password must contain" checklist as (label, state); state is met, invalid or ""."""
rules = []
for li in self.driver.find_elements(*KeycloakShellLocators.PASSWORD_RULES):
label = _squash(li.text).replace("Not met: ", "").replace("Met: ", "")
classes = (li.get_attribute("class") or "").split()
state = "met" if "is-met" in classes else "invalid" if "is-invalid" in classes else ""
rules.append((label, state))
return rules

def _retype(self, locator, text):
el = self._find(locator)
el.clear()
el.send_keys(text)

def submit_in_browser(self, submit_locator):
"""Click submit; True when the theme kept the form in the browser (nothing was posted)."""
self.mark_document()
self._find(submit_locator).click()
self._wait_ready()
return not self.document_was_replaced()

def wait_until_url_contains(self, fragment, timeout=20):
try:
WebDriverWait(self.driver, timeout).until(lambda d: fragment in d.current_url)
return True
except TimeoutException:
return False

def alert_text(self):
return self._text(KeycloakShellLocators.ALERT)

Expand Down Expand Up @@ -203,6 +240,19 @@ def submit(self):
self._await(KeycloakLoginLocators.USERNAME)
return self

def submit_stays_in_browser(self):
return self.submit_in_browser(KeycloakLoginLocators.SUBMIT)

def sign_in_as(self, email, password):
"""Sign in as a real (throwaway) account. Waits for Keycloak to move on from the form."""
self.type_email(email)
self._find(KeycloakLoginLocators.PASSWORD).send_keys(password)
url_before = self.driver.current_url
self._find(KeycloakLoginLocators.SUBMIT).click()
WebDriverWait(self.driver, 20).until(lambda d: d.current_url != url_before)
self._wait_ready()
return self

def go_to_forgot_password(self):
self._find(KeycloakLoginLocators.FORGOT_LINK).click()
WebDriverWait(self.driver, 20).until(lambda d: "reset-credentials" in d.current_url)
Expand Down Expand Up @@ -245,6 +295,9 @@ def request_reset(self, email):
el.send_keys(email)
self.mark_document()
self._find(KeycloakResetLocators.SUBMIT).click()
if email:
# A filled form goes to the server; without this wait the old page's heading is read.
WebDriverWait(self.driver, 20).until(lambda d: self.document_was_replaced())
self._wait_ready()
self._await(KeycloakShellLocators.HEADING)
return self
Expand Down Expand Up @@ -285,10 +338,15 @@ def has_terms_checkbox(self):
def privacy_hrefs(self):
return [e.get_attribute("href") for e in self.driver.find_elements(*KeycloakRegisterLocators.PRIVACY_LINK)]

def fill(self, email, first_name="QA", last_name="Automation"):
def fill(self, email, first_name="QA", last_name="Automation", password=REGISTER_PASSWORD):
self._find(KeycloakRegisterLocators.EMAIL).send_keys(email)
self._find(KeycloakRegisterLocators.FIRST_NAME).send_keys(first_name)
self._find(KeycloakRegisterLocators.LAST_NAME).send_keys(last_name)
# The realm decides whether register asks for a password; fill it only when shown.
for locator in (KeycloakRegisterLocators.PASSWORD, KeycloakRegisterLocators.PASSWORD_CONFIRM):
el = self._find(locator)
if el is not None:
el.send_keys(password)
return self

def accept_terms(self):
Expand Down Expand Up @@ -380,9 +438,54 @@ def type_password(self, text):
el.send_keys(text)
return True

def type_register_email(self, text):
self._retype(KeycloakRegisterLocators.EMAIL, text)
return self

def retype_password(self, text):
self._retype(KeycloakRegisterLocators.PASSWORD, text)
return self

def type_confirm(self, text):
self._retype(KeycloakRegisterLocators.PASSWORD_CONFIRM, text)
return self

def submit_stays_in_browser(self):
return self.submit_in_browser(KeycloakRegisterLocators.SUBMIT)

def email_error_sign_in_href(self):
el = self._find(KeycloakRegisterLocators.EMAIL_ERROR_SIGN_IN_LINK)
return el.get_attribute("href") if el else None

def submit_without_consent(self):
"""Click Create Account with consent unticked; the theme should block it."""
self.mark_document()
self._find(KeycloakRegisterLocators.SUBMIT).click()
self._wait_ready()
return self


class KeycloakUpdatePasswordPage(_KeycloakPage):
"""login-update-password.ftl, shown when an account has the UPDATE_PASSWORD action."""

def wait_loaded(self):
self._await(KeycloakUpdatePasswordLocators.NEW_PASSWORD)
return self

def type_new(self, text):
self._retype(KeycloakUpdatePasswordLocators.NEW_PASSWORD, text)
return self

def type_confirm(self, text):
self._retype(KeycloakUpdatePasswordLocators.CONFIRM, text)
return self

def submit_stays_in_browser(self):
return self.submit_in_browser(KeycloakUpdatePasswordLocators.SUBMIT)

def submit(self):
url_before = self.driver.current_url
self._find(KeycloakUpdatePasswordLocators.SUBMIT).click()
WebDriverWait(self.driver, 20).until(lambda d: d.current_url != url_before)
self._wait_ready()
return self
55 changes: 0 additions & 55 deletions tests/api/smoke/test_api_035_website_title.py

This file was deleted.

Loading