Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/auth/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,18 @@ 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",
requested_subject=new_user.id,
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.")

Expand Down
12 changes: 9 additions & 3 deletions tests/auth/test_authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading