Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
from utilities.constants import DscComponents
from tests.model_registry.constants import MODEL_NAME, MODEL_DICT
from model_registry import ModelRegistry as ModelRegistryClient
from kubernetes.dynamic import DynamicClient
from ocp_resources.service import Service
from utilities.constants import Protocols
from tests.model_registry.utils import get_endpoint_from_mr_service
from aiohttp.client_exceptions import ServerDisconnectedError

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


@pytest.mark.parametrize(
"updated_dsc_component_state_scope_class, model_registry_client",
"updated_dsc_component_state_scope_class",
[
pytest.param(
{
Expand All @@ -24,7 +29,6 @@
},
},
},
{"service_fixture": "model_registry_instance_oauth_service"},
id="oauth_proxy",
),
],
Expand All @@ -33,14 +37,24 @@
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class")
class TestModelRegistryCreationOAuth:
"""
Tests the creation of a model registry with OAuth proxy configuration.
Jira ID: RHOAIENG-26194
Validate model registry with OAuth proxy configuration.
Jira IDs: RHOAIENG-26194, RHOAIENG-26195
"""

# Tests RHOAIENG-26194
@pytest.mark.parametrize(
"model_registry_client",
[
pytest.param(
{"service_fixture": "model_registry_instance_oauth_service"},
)
],
indirect=True,
)
@pytest.mark.smoke
def test_registering_model_with_oauth(
self: Self,
admin_client,
admin_client: DynamicClient,
model_registry_client: ModelRegistryClient,
):
if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER:
Expand Down Expand Up @@ -75,3 +89,29 @@ def test_registering_model_with_oauth(
]
if errors:
pytest.fail("errors found in model registry response validation:\n{}".format("\n".join(errors)))

# Tests RHOAIENG-26195
def test_encripted_oauth_proxy(
self: Self,
admin_client: DynamicClient,
model_registry_instance_oauth_service: Service,
current_client_token: str,
):
if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER:
pytest.skip("Skipping test for RHOAI < 2.21")
Comment thread
lugi0 marked this conversation as resolved.
Outdated

# Get the REST endpoint
rest_endpoint = get_endpoint_from_mr_service(svc=model_registry_instance_oauth_service, protocol=Protocols.REST)

# Create the client
server, port = rest_endpoint.split(":")
with pytest.raises(ServerDisconnectedError) as exc_info:
_ = ModelRegistryClient(
server_address=f"{Protocols.HTTP}://{server}",
port=port,
author="opendatahub-test",
user_token=current_client_token,
is_secure=False,
)
assert str(exc_info.value) == "Server disconnected", f"Expected Server disconnected, but got {exc_info.value}"
LOGGER.info("Successfully received expected Server Disconnected exception")
Comment thread
lugi0 marked this conversation as resolved.
Outdated