From 9d1b5308f769362ba075be590939332e72d857e9 Mon Sep 17 00:00:00 2001 From: Federico Negri Date: Tue, 25 Mar 2025 16:59:58 +0100 Subject: [PATCH 1/5] Test against HPS latest-dev version --- .github/workflows/ci_cd.yml | 2 +- .github/workflows/nightly.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 198c68fba..4d98797d4 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -56,7 +56,7 @@ jobs: python-version: ${{ matrix.cfg.python-version }} toxenv: ${{ matrix.cfg.toxenv }} runner: ${{ matrix.os }} - hps-version: ${{ inputs.hps-version || 'v1.2.0' }} + hps-version: ${{ inputs.hps-version || 'latest-dev' }} hps-feature: ${{ inputs.hps-feature || 'main' }} docs: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index abea292f0..c7493f8ec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -46,7 +46,7 @@ jobs: python-version: ${{ matrix.cfg.python-version }} toxenv: ${{ matrix.cfg.toxenv }} runner: ${{ matrix.os }} - hps-version: ${{ inputs.hps-version || 'v1.2.0' }} + hps-version: ${{ inputs.hps-version || 'latest-dev' }} smoke-tests: name: Build and Smoke tests From 36e20c6c1f9a1a03f64fd9df9ced38041ff7c9ab Mon Sep 17 00:00:00 2001 From: Federico Negri Date: Wed, 26 Mar 2025 15:25:05 +0100 Subject: [PATCH 2/5] log test error --- tests/auth/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auth/test_api.py b/tests/auth/test_api.py index 55bf8efa9..aa8368349 100644 --- a/tests/auth/test_api.py +++ b/tests/auth/test_api.py @@ -143,6 +143,7 @@ def test_impersonate_user(url, keycloak_client): verify=False, ) except HPSError as e: + log.error(e) if e.response.status_code == 501 and "Feature not enabled" in e.reason: pytest.skip("This test requires to enable the feature 'token-exchange' in keycloak.") From f49e13055319f2b81c3cc4fca224785fa0519a36 Mon Sep 17 00:00:00 2001 From: Jon Novak Date: Wed, 26 Mar 2025 10:49:27 -0500 Subject: [PATCH 3/5] push fix to this branch also --- .vscode/settings.json | 7 +++++++ tests/auth/test_api.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..9b388533a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/tests/auth/test_api.py b/tests/auth/test_api.py index aa8368349..3f09e3bb3 100644 --- a/tests/auth/test_api.py +++ b/tests/auth/test_api.py @@ -132,10 +132,10 @@ def test_impersonate_user(url, keycloak_client): r = None try: r = authenticate( - url=url, + auth_url=client.auth_url, client_id=rep_impersonation_client["clientId"], client_secret=rep_impersonation_client["secret"], - scope="opendid offline_access", + scope="openid offline_access", grant_type="urn:ietf:params:oauth:grant-type:token-exchange", subject_token=client.access_token, requested_token_type="urn:ietf:params:oauth:token-type:refresh_token", From 824f6949bf09b101e1b5db9e11a73ba2dca99844 Mon Sep 17 00:00:00 2001 From: Jon Novak Date: Wed, 26 Mar 2025 10:51:20 -0500 Subject: [PATCH 4/5] remove added file --- .vscode/settings.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9b388533a..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "python.testing.pytestArgs": [ - "tests" - ], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true -} \ No newline at end of file From 60dde8e0a45565654a943ad5119f39f2743c2f70 Mon Sep 17 00:00:00 2001 From: Jon Novak Date: Wed, 26 Mar 2025 11:01:02 -0500 Subject: [PATCH 5/5] fix some other authenticate tests to use proper url's as well. --- tests/auth/test_authenticate.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/auth/test_authenticate.py b/tests/auth/test_authenticate.py index 4342cbabf..727fc297e 100644 --- a/tests/auth/test_authenticate.py +++ b/tests/auth/test_authenticate.py @@ -25,19 +25,25 @@ import pytest import requests -from ansys.hps.client import authenticate +from ansys.hps.client import Client, authenticate log = logging.getLogger(__name__) def test_authenticate(url, username, password): - resp = authenticate(url=url, username=username, password=password, verify=False) + client = Client(url=url, username=username, password=password, verify=False) + resp = authenticate( + auth_url=client.auth_url, username=username, password=password, verify=False + ) assert "access_token" in resp assert "refresh_token" in resp def test_authenticate_with_ssl_verification(url, username, password): + # Doesn't matter that the auth url is wrong.... The first request will fail with pytest.raises(requests.exceptions.SSLError) as ex_info: - _ = authenticate(url=url, username=username, password=password, verify=True) + _ = authenticate( + auth_url=f"{url}/auth/realms/rep", username=username, password=password, verify=True + ) assert "CERTIFICATE_VERIFY_FAILED" in str(ex_info.value)