Skip to content

Commit

Permalink
making pre-commit happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Maleware committed Oct 29, 2024
1 parent b67e026 commit 963518e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/modules/airflow/pages/usage-guide/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Users need to authenticate themselves before using Airflow, and there are severa
[IMPORTANT]
.Multiple authentication methods
====
Only one authentication method is supported at a time, and in case of LDAP, only one authentication class is allowed.
Only one authentication method is supported at a time, and in case of LDAP, only one authentication class is allowed.
This means, it is not possible to configure both LDAP and OIDC authentication methods at the same time, but *it is* possible to configure multiple OIDC classes *or* one LDAP authentication class.
====

Expand Down
36 changes: 20 additions & 16 deletions tests/templates/kuttl/oidc/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,49 @@
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()

# Click on "Sign In with keycloak" in Airflow
login_page = session.get("http://airflow-webserver:8080/login/keycloak?next=")

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"
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"

# 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" })
welcome_page = session.post(
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"
assert (
welcome_page.url == "http://airflow-webserver:8080/home"
), "Redirection to the Airflow home page expected"

# Open the user information page in Airflow
userinfo_page = session.get("http://airflow-webserver:8080/users/userinfo/")

assert userinfo_page.ok, "Retrieving user information failed"
assert userinfo_page.url == "http://airflow-webserver:8080/users/userinfo/", \
"Redirection to the Airflow user info page expected"
assert (
userinfo_page.url == "http://airflow-webserver:8080/users/userinfo/"
), "Redirection to the Airflow user info page expected"

# Expect the user data provided by Keycloak in Airflow
userinfo_page_html = BeautifulSoup(userinfo_page.text, 'html.parser')
table_rows = userinfo_page_html.find_all('tr')
user_data = {tr.find('th').text:tr.find('td').text for tr in table_rows}
userinfo_page_html = BeautifulSoup(userinfo_page.text, "html.parser")
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", \
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", \
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", \
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
Expand Down

0 comments on commit 963518e

Please sign in to comment.