Skip to content

Commit c52e9b4

Browse files
authored
adapt auth tests to hub version (#2146)
No-Issue
1 parent a0ec76c commit c52e9b4

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

galaxy_ng/tests/integration/api/test_auth.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
55
"""
66
import pytest
7+
from pkg_resources import parse_version
78

89
from galaxykit.utils import GalaxyClientError
910
from urllib.parse import urlparse
1011
from ..utils import uuid4
11-
from ..utils.iqe_utils import is_keycloak
12+
from ..utils.iqe_utils import is_keycloak, get_hub_version
1213
from ..utils.iqe_utils import remove_from_cache, aap_gateway
1314

1415
pytestmark = pytest.mark.qa # noqa: F821
@@ -18,18 +19,23 @@
1819
@pytest.mark.deployment_standalone
1920
@pytest.mark.galaxyapi_smoke
2021
@pytest.mark.skip_in_gw
21-
def test_token_auth(profile, galaxy_client):
22+
def test_token_auth(profile, galaxy_client, ansible_config):
2223
"""Test whether normal auth is required and works to access APIs.
2324
2425
Also tests the settings for user profiles used for testing.
2526
"""
27+
hub_version = get_hub_version(ansible_config)
28+
expected_status_code = 401
29+
if parse_version(hub_version) < parse_version('4.10.0dev'):
30+
expected_status_code = 403
31+
2632
gc = galaxy_client(profile)
2733
del gc.headers["Authorization"]
2834
remove_from_cache(profile)
2935

3036
with pytest.raises(GalaxyClientError) as ctx:
3137
gc.get("v3/collections/")
32-
assert ctx.value.response.status_code == 401
38+
assert ctx.value.response.status_code == expected_status_code
3339
gc = galaxy_client(profile, ignore_cache=True)
3440
resp = gc.get("")
3541
assert "available_versions" in resp
@@ -38,29 +44,37 @@ def test_token_auth(profile, galaxy_client):
3844
@pytest.mark.deployment_standalone
3945
@pytest.mark.galaxyapi_smoke
4046
@pytest.mark.skip_in_gw
41-
def test_auth_admin(galaxy_client):
47+
def test_auth_admin(galaxy_client, ansible_config):
4248
"""Test whether admin can not access collections page using invalid token."""
49+
hub_version = get_hub_version(ansible_config)
50+
expected_status_code = 401
51+
if parse_version(hub_version) < parse_version('4.10.0dev'):
52+
expected_status_code = 403
4353

4454
gc = galaxy_client("admin")
4555
gc.headers["Authorization"] = f"Bearer {uuid4()}"
4656
remove_from_cache("admin")
4757
with pytest.raises(GalaxyClientError) as ctx:
4858
gc.get("v3/collections/")
49-
assert ctx.value.response.status_code == 401
59+
assert ctx.value.response.status_code == expected_status_code
5060

5161

5262
@pytest.mark.deployment_standalone
5363
@pytest.mark.galaxyapi_smoke
5464
@pytest.mark.skip_in_gw
55-
def test_auth_exception(galaxy_client):
65+
def test_auth_exception(galaxy_client, ansible_config):
5666
"""Test whether an HTTP exception when using an invalid token."""
67+
hub_version = get_hub_version(ansible_config)
68+
expected_status_code = 401
69+
if parse_version(hub_version) < parse_version('4.10.0dev'):
70+
expected_status_code = 403
5771

5872
gc = galaxy_client("basic_user")
5973
gc.headers["Authorization"] = f"Bearer {uuid4()}"
6074
remove_from_cache("basic_user")
6175
with pytest.raises(GalaxyClientError) as ctx:
6276
gc.get("v3/collections/")
63-
assert ctx.value.response.status_code == 401
77+
assert ctx.value.response.status_code == expected_status_code
6478

6579

6680
@pytest.mark.deployment_standalone

0 commit comments

Comments
 (0)