|
7 | 7 | from utilities.constants import DscComponents |
8 | 8 | from tests.model_registry.constants import MODEL_NAME, MODEL_DICT |
9 | 9 | 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 |
10 | 15 |
|
11 | 16 | LOGGER = get_logger(name=__name__) |
12 | 17 | MINVER = Version.parse(version="2.21.0") |
13 | 18 |
|
14 | 19 |
|
15 | 20 | @pytest.mark.parametrize( |
16 | | - "updated_dsc_component_state_scope_class, model_registry_client", |
| 21 | + "updated_dsc_component_state_scope_class", |
17 | 22 | [ |
18 | 23 | pytest.param( |
19 | 24 | { |
|
24 | 29 | }, |
25 | 30 | }, |
26 | 31 | }, |
27 | | - {"service_fixture": "model_registry_instance_oauth_service"}, |
28 | 32 | id="oauth_proxy", |
29 | 33 | ), |
30 | 34 | ], |
|
33 | 37 | @pytest.mark.usefixtures("updated_dsc_component_state_scope_class") |
34 | 38 | class TestModelRegistryCreationOAuth: |
35 | 39 | """ |
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 |
38 | 42 | """ |
39 | 43 |
|
| 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 | + ) |
40 | 54 | @pytest.mark.smoke |
41 | 55 | def test_registering_model_with_oauth( |
42 | 56 | self: Self, |
43 | | - admin_client, |
| 57 | + admin_client: DynamicClient, |
44 | 58 | model_registry_client: ModelRegistryClient, |
45 | 59 | ): |
46 | 60 | if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER: |
@@ -75,3 +89,29 @@ def test_registering_model_with_oauth( |
75 | 89 | ] |
76 | 90 | if errors: |
77 | 91 | 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