Skip to content

Commit 8824a72

Browse files
authored
enable oauth for all mr regression tests (#362)
1 parent 5df41ed commit 8824a72

File tree

6 files changed

+118
-63
lines changed

6 files changed

+118
-63
lines changed

tests/model_registry/image_validation/test_verify_rhoai_images.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,34 @@
1515

1616

1717
@pytest.mark.parametrize(
18-
"updated_dsc_component_state_scope_class",
18+
"updated_dsc_component_state_scope_class, is_model_registry_oauth",
1919
[
20-
{
21-
"component_patch": {
22-
DscComponents.MODELREGISTRY: {
23-
"managementState": DscComponents.ManagementState.MANAGED,
24-
"registriesNamespace": py_config["model_registry_namespace"],
20+
pytest.param(
21+
{
22+
"component_patch": {
23+
DscComponents.MODELREGISTRY: {
24+
"managementState": DscComponents.ManagementState.MANAGED,
25+
"registriesNamespace": py_config["model_registry_namespace"],
26+
}
2527
}
26-
}
27-
}
28+
},
29+
{"use_oauth_proxy": True},
30+
),
31+
pytest.param(
32+
{
33+
"component_patch": {
34+
DscComponents.MODELREGISTRY: {
35+
"managementState": DscComponents.ManagementState.MANAGED,
36+
"registriesNamespace": py_config["model_registry_namespace"],
37+
}
38+
}
39+
},
40+
{"use_oauth_proxy": False},
41+
),
2842
],
2943
indirect=True,
3044
)
31-
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class")
45+
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "is_model_registry_oauth")
3246
@pytest.mark.downstream_only
3347
class TestModelRegistryImages:
3448
"""

tests/model_registry/negative_tests/test_model_registry_creation_negative.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323

2424
@pytest.mark.parametrize(
25-
"model_registry_namespace_for_negative_tests, updated_dsc_component_state_scope_class, expected_namespace",
25+
"model_registry_namespace_for_negative_tests, updated_dsc_component_state_scope_class, "
26+
"is_model_registry_oauth, expected_namespace",
2627
[
2728
pytest.param(
2829
{"namespace_name": CUSTOM_NEGATIVE_NS},
@@ -34,6 +35,20 @@
3435
},
3536
}
3637
},
38+
{"use_oauth_proxy": False},
39+
py_config["model_registry_namespace"],
40+
),
41+
pytest.param(
42+
{"namespace_name": CUSTOM_NEGATIVE_NS},
43+
{
44+
"component_patch": {
45+
DscComponents.MODELREGISTRY: {
46+
"managementState": DscComponents.ManagementState.MANAGED,
47+
"registriesNamespace": py_config["model_registry_namespace"],
48+
},
49+
}
50+
},
51+
{"use_oauth_proxy": True},
3752
py_config["model_registry_namespace"],
3853
),
3954
pytest.param(
@@ -46,10 +61,28 @@
4661
},
4762
},
4863
},
64+
{"use_oauth_proxy": True},
4965
CUSTOM_NEGATIVE_NS,
5066
),
67+
pytest.param(
68+
{"namespace_name": py_config["model_registry_namespace"]},
69+
{
70+
"component_patch": {
71+
DscComponents.MODELREGISTRY: {
72+
"managementState": DscComponents.ManagementState.MANAGED,
73+
"registriesNamespace": CUSTOM_NEGATIVE_NS,
74+
},
75+
},
76+
},
77+
{"use_oauth_proxy": False},
78+
CUSTOM_NEGATIVE_NS,
79+
),
80+
],
81+
indirect=[
82+
"model_registry_namespace_for_negative_tests",
83+
"updated_dsc_component_state_scope_class",
84+
"is_model_registry_oauth",
5185
],
52-
indirect=["model_registry_namespace_for_negative_tests", "updated_dsc_component_state_scope_class"],
5386
)
5487
class TestModelRegistryCreationNegative:
5588
def test_registering_model_negative(

tests/model_registry/python_client/test_model_registry_creation.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
@pytest.mark.parametrize(
19-
"updated_dsc_component_state_scope_class, registered_model",
19+
"updated_dsc_component_state_scope_class, is_model_registry_oauth, registered_model",
2020
[
2121
pytest.param(
2222
{
@@ -27,6 +27,31 @@
2727
},
2828
}
2929
},
30+
{"use_oauth_proxy": False},
31+
MODEL_DICT,
32+
),
33+
pytest.param(
34+
{
35+
"component_patch": {
36+
DscComponents.MODELREGISTRY: {
37+
"managementState": DscComponents.ManagementState.MANAGED,
38+
"registriesNamespace": CUSTOM_NAMESPACE,
39+
},
40+
}
41+
},
42+
{"use_oauth_proxy": True},
43+
MODEL_DICT,
44+
),
45+
pytest.param(
46+
{
47+
"component_patch": {
48+
DscComponents.MODELREGISTRY: {
49+
"managementState": DscComponents.ManagementState.MANAGED,
50+
"registriesNamespace": py_config["model_registry_namespace"],
51+
},
52+
},
53+
},
54+
{"use_oauth_proxy": False},
3055
MODEL_DICT,
3156
),
3257
pytest.param(
@@ -38,12 +63,13 @@
3863
},
3964
},
4065
},
66+
{"use_oauth_proxy": True},
4167
MODEL_DICT,
4268
),
4369
],
4470
indirect=True,
4571
)
46-
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "registered_model")
72+
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "is_model_registry_oauth", "registered_model")
4773
class TestModelRegistryCreation:
4874
"""
4975
Tests the creation of a model registry. If the component is set to 'Removed' it will be switched to 'Managed'

tests/model_registry/python_client/test_model_registry_creation_oauth.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from semver import Version
66
from utilities.infra import get_product_version
77
from utilities.constants import DscComponents
8-
from tests.model_registry.constants import MODEL_NAME, MODEL_DICT
98
from model_registry import ModelRegistry as ModelRegistryClient
109
from kubernetes.dynamic import DynamicClient
1110
from utilities.constants import Protocols
@@ -35,51 +34,6 @@
3534
)
3635
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "is_model_registry_oauth")
3736
class TestModelRegistryCreationOAuth:
38-
"""
39-
Validate model registry with OAuth proxy configuration.
40-
Jira IDs: RHOAIENG-26194, RHOAIENG-26195
41-
"""
42-
43-
# Tests RHOAIENG-26194
44-
@pytest.mark.smoke
45-
def test_registering_model_with_oauth(
46-
self: Self,
47-
admin_client: DynamicClient,
48-
model_registry_client: ModelRegistryClient,
49-
):
50-
if py_config["distribution"] == "downstream" and get_product_version(admin_client=admin_client) < MINVER:
51-
pytest.skip(f"Skipping test for RHOAI < {MINVER}")
52-
53-
# Register a new model
54-
registered_model = model_registry_client.register_model(
55-
name=MODEL_DICT["model_name"],
56-
uri=MODEL_DICT["model_uri"],
57-
version=MODEL_DICT["model_version"],
58-
description=MODEL_DICT["model_description"],
59-
model_format_name=MODEL_DICT["model_format"],
60-
model_format_version=MODEL_DICT["model_format_version"],
61-
storage_key=MODEL_DICT["model_storage_key"],
62-
storage_path=MODEL_DICT["model_storage_path"],
63-
metadata=MODEL_DICT["model_metadata"],
64-
)
65-
66-
# Get and verify the model
67-
model = model_registry_client.get_registered_model(name=MODEL_NAME)
68-
expected_attrs = {
69-
"id": registered_model.id,
70-
"name": registered_model.name,
71-
"description": registered_model.description,
72-
"owner": registered_model.owner,
73-
"state": registered_model.state,
74-
}
75-
errors = [
76-
f"Unexpected {attr} expected: {expected}, received {getattr(model, attr)}"
77-
for attr, expected in expected_attrs.items()
78-
if getattr(model, attr) != expected
79-
]
80-
if errors:
81-
pytest.fail("errors found in model registry response validation:\n{}".format("\n".join(errors)))
82-
8337
# Tests RHOAIENG-26195
8438
def test_encrypted_oauth_proxy(
8539
self: Self,

tests/model_registry/rest_api/test_model_registry_rest_api.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
@pytest.mark.parametrize(
28-
"updated_dsc_component_state_scope_class, registered_model_rest_api",
28+
"updated_dsc_component_state_scope_class, is_model_registry_oauth, registered_model_rest_api",
2929
[
3030
pytest.param(
3131
{
@@ -36,12 +36,27 @@
3636
},
3737
},
3838
},
39+
{"use_oauth_proxy": False},
40+
MODEL_REGISTER_DATA,
41+
),
42+
pytest.param(
43+
{
44+
"component_patch": {
45+
DscComponents.MODELREGISTRY: {
46+
"managementState": DscComponents.ManagementState.MANAGED,
47+
"registriesNamespace": py_config["model_registry_namespace"],
48+
},
49+
},
50+
},
51+
{"use_oauth_proxy": True},
3952
MODEL_REGISTER_DATA,
4053
),
4154
],
4255
indirect=True,
4356
)
44-
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "registered_model_rest_api")
57+
@pytest.mark.usefixtures(
58+
"updated_dsc_component_state_scope_class", "is_model_registry_oauth", "registered_model_rest_api"
59+
)
4560
class TestModelRegistryCreationRest:
4661
"""
4762
Tests the creation of a model registry. If the component is set to 'Removed' it will be switched to 'Managed'

tests/model_registry/scc/test_model_registry_scc.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def model_registry_resource(
5151

5252

5353
@pytest.mark.parametrize(
54-
"updated_dsc_component_state_scope_class, registered_model",
54+
"updated_dsc_component_state_scope_class, is_model_registry_oauth, registered_model",
5555
[
5656
pytest.param(
5757
{
@@ -62,12 +62,25 @@ def model_registry_resource(
6262
},
6363
},
6464
},
65+
{"use_oauth_proxy": True},
66+
MODEL_DICT,
67+
),
68+
pytest.param(
69+
{
70+
"component_patch": {
71+
DscComponents.MODELREGISTRY: {
72+
"managementState": DscComponents.ManagementState.MANAGED,
73+
"registriesNamespace": py_config["model_registry_namespace"],
74+
},
75+
},
76+
},
77+
{"use_oauth_proxy": False},
6578
MODEL_DICT,
6679
),
6780
],
6881
indirect=True,
6982
)
70-
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "registered_model")
83+
@pytest.mark.usefixtures("updated_dsc_component_state_scope_class", "is_model_registry_oauth", "registered_model")
7184
class TestModelRegistrySecurityContextValidation:
7285
@pytest.mark.parametrize(
7386
"model_registry_resource",

0 commit comments

Comments
 (0)