Skip to content

Commit 6275b9c

Browse files
authored
Merge branch 'main' into cp_maria
2 parents 5f3c96a + 0c3c73f commit 6275b9c

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

tests/model_registry/rest_api/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ def patch_invalid_ca(
9393
request: pytest.FixtureRequest,
9494
) -> Generator[str, Any, Any]:
9595
"""
96-
Patches the odh-trusted-ca-bundle ConfigMap with an invalid CA certificate.
96+
Patches the ConfigMap with an invalid CA certificate.
9797
"""
9898
ca_configmap_name = request.param.get("ca_configmap_name", "odh-trusted-ca-bundle")
9999
ca_file_name = request.param.get("ca_file_name", "invalid-ca.crt")
100100
ca_file_path = f"{CA_MOUNT_PATH}/{ca_file_name}"
101+
LOGGER.info(f"Patching the {ca_configmap_name} ConfigMap with an invalid CA certificate: {ca_file_path}")
101102
ca_data = {ca_file_name: "-----BEGIN CERTIFICATE-----\nINVALIDCERTIFICATE\n-----END CERTIFICATE-----"}
102103
ca_configmap = ConfigMap(
103104
client=admin_client,
@@ -113,6 +114,7 @@ def patch_invalid_ca(
113114
"data": ca_data,
114115
}
115116
with ResourceEditor(patches={ca_configmap: patch}):
117+
LOGGER.info(f"Patched the {ca_configmap_name} ConfigMap with an invalid CA certificate: {ca_file_path}")
116118
yield ca_file_path
117119

118120

@@ -159,6 +161,7 @@ def deploy_secure_mysql_and_mr(
159161
model_registry_db_deployment: The deployment for the model registry's MySQL database
160162
model_registry_mysql_config: The MySQL config dictionary
161163
mysql_template_with_ca: The MySQL template with the CA file path and volume mount
164+
patch_mysql_deployment_with_ssl_ca: The MySQL deployment with the CA file path and volume mount
162165
"""
163166
with ModelRegistry(
164167
name=SECURE_MR_NAME,
@@ -240,14 +243,18 @@ def patch_mysql_deployment_with_ssl_ca(
240243
model_registry_namespace: str,
241244
model_registry_db_deployment: Deployment,
242245
mysql_ssl_secrets: dict[str, Any],
243-
ca_configmap_for_test: ConfigMap,
244246
) -> Generator[Deployment, Any, Any]:
245247
"""
246248
Patch the MySQL deployment to use the test CA bundle (mysql-ca-configmap),
247249
and mount the server cert/key for SSL.
248250
"""
251+
252+
if request.param.get("ca_configmap_for_test"):
253+
LOGGER.info("Invoking ca_configmap_for_test fixture")
254+
request.getfixturevalue("ca_configmap_for_test") # noqa: FCN001
249255
CA_CONFIGMAP_NAME = request.param.get("ca_configmap_name", "mysql-ca-configmap")
250256
CA_MOUNT_PATH = request.param.get("ca_mount_path", "/etc/mysql/ssl")
257+
251258
deployment = model_registry_db_deployment.instance.to_dict()
252259
spec = deployment["spec"]["template"]["spec"]
253260
my_sql_container = next(container for container in spec["containers"] if container["name"] == "mysql")

tests/model_registry/rest_api/test_model_registry_secure_db.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Self, Any
44
from pytest_testconfig import config as py_config
55
from tests.model_registry.rest_api.utils import register_model_rest_api, validate_resource_attributes
6-
from tests.model_registry.constants import CA_MOUNT_PATH
76
from tests.model_registry.utils import get_mr_service_by_label, get_endpoint_from_mr_service
87
from kubernetes.dynamic import DynamicClient
98
from utilities.constants import DscComponents, Protocols
@@ -40,12 +39,15 @@ class TestModelRegistryWithSecureDB:
4039

4140
# Implements RHOAIENG-26150
4241
@pytest.mark.parametrize(
43-
"patch_mysql_deployment_with_ssl_ca,patch_invalid_ca,model_registry_mysql_config,local_ca_bundle",
42+
"patch_mysql_deployment_with_ssl_ca,patch_invalid_ca,local_ca_bundle",
4443
[
4544
(
46-
{"ca_configmap_name": "mysql-ca-configmap", "ca_mount_path": "/etc/mysql/ssl"},
45+
{
46+
"ca_configmap_name": "odh-trusted-ca-bundle",
47+
"ca_mount_path": "/etc/mysql/ssl",
48+
"ca_configmap_for_test": False,
49+
},
4750
{"ca_configmap_name": "odh-trusted-ca-bundle", "ca_file_name": "invalid-ca.crt"},
48-
{"ssl_ca": f"{CA_MOUNT_PATH}/invalid-ca.crt"},
4951
{"cert_name": "invalid-ca.crt"},
5052
),
5153
],
@@ -85,7 +87,11 @@ def test_register_model_with_invalid_ca(
8587
"patch_mysql_deployment_with_ssl_ca,model_registry_mysql_config,local_ca_bundle",
8688
[
8789
(
88-
{"ca_configmap_name": "mysql-ca-configmap", "ca_mount_path": "/etc/mysql/ssl"},
90+
{
91+
"ca_configmap_name": "mysql-ca-configmap",
92+
"ca_mount_path": "/etc/mysql/ssl",
93+
"ca_configmap_for_test": True,
94+
},
8995
{"sslRootCertificateConfigMap": {"name": "mysql-ca-configmap", "key": "ca-bundle.crt"}},
9096
{"cert_name": "ca-bundle.crt"},
9197
),

0 commit comments

Comments
 (0)