Skip to content

Commit a78cc7f

Browse files
lfranckelabrenbe
andauthored
Fix for custom images in OIDC test (#687)
* Fix for custom images in OIDC test * fix pre-commit check * check if nifi version > 1.x --------- Co-authored-by: Benedikt Labrenz <benedikt@labrenz.org>
1 parent 4990e2c commit a78cc7f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/templates/kuttl/oidc/login.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
else f"http://{keycloak_service}:8080"
2525
)
2626

27-
if nifi_version in ["2.0.0-M4"]:
27+
# startswith instead of an exact check to
28+
# a) hit all 2.x versions and
29+
# b) to allow for custom images because `nifi_version` will contain the whole custom image string
30+
# e.g. 2.0.0-M4,localhost:5000/stackable/nifi:2.0.0-M4-stackable0.0.0-dev
31+
if not nifi_version.startswith("1."):
2832
auth_config_page = session.get(
2933
f"https://{nifi}:8443/nifi-api/authentication/configuration",
3034
verify=False,
31-
headers={"Content-type": "application/json"}
35+
headers={"Content-type": "application/json"},
3236
)
3337
assert auth_config_page.ok, "Could not fetch auth config from NiFi"
3438
auth_config = json.loads(auth_config_page.text)
@@ -44,7 +48,10 @@
4448
)
4549

4650
print("actual: ", login_page.url)
47-
print("expected: ", f"{keycloak_base_url}/realms/test/protocol/openid-connect/auth?response_type=code&client_id=nifi&scope=")
51+
print(
52+
"expected: ",
53+
f"{keycloak_base_url}/realms/test/protocol/openid-connect/auth?response_type=code&client_id=nifi&scope=",
54+
)
4855
assert login_page.ok, "Redirection from NiFi to Keycloak failed"
4956
assert login_page.url.startswith(
5057
f"{keycloak_base_url}/realms/test/protocol/openid-connect/auth?response_type=code&client_id=nifi&scope="
@@ -54,7 +61,9 @@
5461
login_page_html = BeautifulSoup(login_page.text, "html.parser")
5562
authenticate_url = login_page_html.form["action"]
5663
welcome_page = session.post(
57-
authenticate_url, data={"username": "jane.doe", "password": "T8mn72D9"}, verify=False
64+
authenticate_url,
65+
data={"username": "jane.doe", "password": "T8mn72D9"},
66+
verify=False,
5867
)
5968
assert welcome_page.ok, "Login failed"
6069
assert (

0 commit comments

Comments
 (0)