Skip to content

Commit c35e61c

Browse files
committed
feat: test failure when using http protocol
Signed-off-by: lugi0 <lgiorgi@redhat.com>
1 parent 55baa49 commit c35e61c

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

tests/model_registry/python_client/test_model_registry_creation_oauth.py

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
from utilities.constants import DscComponents
88
from tests.model_registry.constants import MODEL_NAME, MODEL_DICT
99
from model_registry import ModelRegistry as ModelRegistryClient
10+
from kubernetes.dynamic import DynamicClient
11+
from ocp_resources.service import Service
12+
from utilities.constants import Protocols
13+
from tests.model_registry.utils import get_endpoint_from_mr_service
14+
from aiohttp.client_exceptions import ServerDisconnectedError
1015

1116
LOGGER = get_logger(name=__name__)
1217
MINVER = Version.parse(version="2.21.0")
1318

1419

1520
@pytest.mark.parametrize(
16-
"updated_dsc_component_state_scope_class, model_registry_client",
21+
"updated_dsc_component_state_scope_class",
1722
[
1823
pytest.param(
1924
{
@@ -24,7 +29,6 @@
2429
},
2530
},
2631
},
27-
{"service_fixture": "model_registry_instance_oauth_service"},
2832
id="oauth_proxy",
2933
),
3034
],
@@ -33,14 +37,24 @@
3337
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class")
3438
class TestModelRegistryCreationOAuth:
3539
"""
36-
Tests the creation of a model registry with OAuth proxy configuration.
37-
Jira ID: RHOAIENG-26194
40+
Validate model registry with OAuth proxy configuration.
41+
Jira IDs: RHOAIENG-26194, RHOAIENG-26195
3842
"""
3943

44+
# Tests RHOAIENG-26194
45+
@pytest.mark.parametrize(
46+
"model_registry_client",
47+
[
48+
pytest.param(
49+
{"service_fixture": "model_registry_instance_oauth_service"},
50+
)
51+
],
52+
indirect=True,
53+
)
4054
@pytest.mark.smoke
4155
def test_registering_model_with_oauth(
4256
self: Self,
43-
admin_client,
57+
admin_client: DynamicClient,
4458
model_registry_client: ModelRegistryClient,
4559
):
4660
if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER:
@@ -75,3 +89,29 @@ def test_registering_model_with_oauth(
7589
]
7690
if errors:
7791
pytest.fail("errors found in model registry response validation:\n{}".format("\n".join(errors)))
92+
93+
# Tests RHOAIENG-26195
94+
def test_encripted_oauth_proxy(
95+
self: Self,
96+
admin_client: DynamicClient,
97+
model_registry_instance_oauth_service: Service,
98+
current_client_token: str,
99+
):
100+
if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER:
101+
pytest.skip("Skipping test for RHOAI < 2.21")
102+
103+
# Get the REST endpoint
104+
rest_endpoint = get_endpoint_from_mr_service(svc=model_registry_instance_oauth_service, protocol=Protocols.REST)
105+
106+
# Create the client
107+
server, port = rest_endpoint.split(":")
108+
with pytest.raises(ServerDisconnectedError) as exc_info:
109+
_ = ModelRegistryClient(
110+
server_address=f"{Protocols.HTTP}://{server}",
111+
port=port,
112+
author="opendatahub-test",
113+
user_token=current_client_token,
114+
is_secure=False,
115+
)
116+
assert str(exc_info.value) == "Server disconnected", f"Expected Server disconnected, but got {exc_info.value}"
117+
LOGGER.info("Successfully received expected Server Disconnected exception")

0 commit comments

Comments
 (0)