Skip to content

Commit

Permalink
again pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Maleware committed Oct 29, 2024
1 parent f5e55f7 commit fcda6ea
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/templates/kuttl/oidc/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from bs4 import BeautifulSoup

logging.basicConfig(
level='DEBUG', format="%(asctime)s %(levelname)s: %(message)s", stream=sys.stdout
level="DEBUG", format="%(asctime)s %(levelname)s: %(message)s", stream=sys.stdout
)

session = requests.Session()
Expand All @@ -17,19 +17,19 @@
assert login_page.ok, "Redirection from Airflow to Keycloak failed"
assert login_page.url.startswith(
"https://keycloak1.$NAMESPACE.svc.cluster.local:8443/realms/test1/protocol/openid-connect/auth?response_type=code&client_id=airflow1"
), "Redirection to the Keycloak login page expected"
), "Redirection to the Keycloak login page expected"

# Enter username and password into the Keycloak login page and click on "Sign In"
login_page_html = BeautifulSoup(login_page.text, 'html.parser')
authenticate_url = login_page_html.form['action']
welcome_page = session.post(
authenticate_url, data={ 'username': "jane.doe", 'password': "T8mn72D9" }
authenticate_url, data={ "username": "jane.doe", 'password': "T8mn72D9" }
)

assert welcome_page.ok, "Login failed"
assert (
welcome_page.url == "http://airflow-webserver:8080/home"
), "Redirection to the Airflow home page expected"
), "Redirection to the Airflow home page expected"

# Open the user information page in Airflow
userinfo_page = session.get("http://airflow-webserver:8080/users/userinfo/")
Expand All @@ -44,12 +44,15 @@
table_rows = userinfo_page_html.find_all("tr")
user_data = {tr.find("th").text:tr.find("td").text for tr in table_rows}

assert user_data["First Name"] == "Jane", \
"The first name of the user in Airflow should match the one provided by Keycloak"
assert user_data["Last Name"] == "Doe", \
"The last name of the user in Airflow should match the one provided by Keycloak"
assert user_data["Email"] == "jane.doe@stackable.tech", \
"The email of the user in Airflow should match the one provided by Keycloak"
assert (
user_data["First Name"] == "Jane"
), "The first name of the user in Airflow should match the one provided by Keycloak"
assert (
user_data["Last Name"] == "Doe"
), "The last name of the user in Airflow should match the one provided by Keycloak"
assert (
user_data["Email"] == "jane.doe@stackable.tech"
), "The email of the user in Airflow should match the one provided by Keycloak"

# TODO Use different OIDC providers (currently only Keycloak is
# supported)
Expand Down

0 comments on commit fcda6ea

Please sign in to comment.