From cb9c2884f39377ac8133fbe541cd1b734d29a90d Mon Sep 17 00:00:00 2001 From: lugi0 Date: Fri, 15 Nov 2024 18:09:58 +0100 Subject: [PATCH] Add negative test for dashboard RBAC on Model Registry Signed-off-by: lugi0 --- .../Page/ModelRegistry/ModelRegistry.resource | 27 ++++++++++--------- .../1301_model_registry_model_serving.robot | 16 +++++++---- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/ods_ci/tests/Resources/Page/ModelRegistry/ModelRegistry.resource b/ods_ci/tests/Resources/Page/ModelRegistry/ModelRegistry.resource index 47f2592ee..6152a6490 100644 --- a/ods_ci/tests/Resources/Page/ModelRegistry/ModelRegistry.resource +++ b/ods_ci/tests/Resources/Page/ModelRegistry/ModelRegistry.resource @@ -282,6 +282,7 @@ Upload Python Client Files In The Workbench Open Model Registry Dashboard Page [Documentation] Opens the Model Registry page from the dashboard nav bar + [Arguments] ${allowed_user}=${TRUE} ${mr_present}= Run Keyword And Return Status SeleniumLibrary.Page Should Contain Model Registry WHILE ${mr_present}!=${TRUE} limit=120s SeleniumLibrary.Reload Page @@ -294,15 +295,22 @@ Open Model Registry Dashboard Page Wait For RHODS Dashboard To Load wait_for_cards=${FALSE} expected_page=Model Registry SeleniumLibrary.Wait Until Page Contains Select a model registry to view and manage your registered models. Maybe Wait For Dashboard Loading Spinner Page - ${loaded}= Run Keyword And Return Status - ... SeleniumLibrary.Page Should Not Contain Request access to model registries - WHILE ${loaded}!=${TRUE} limit=12 # Retries for 2 minutes - wait for user group to reconcile - SeleniumLibrary.Reload Page - SeleniumLibrary.Wait Until Page Contains Model Registry - SeleniumLibrary.Wait Until Page Contains Select a model registry to view and manage your registered models. + # This works assuming there's a single MR instance and the user is either allowed or not allowed to see it + # TODO: Improve logic to handle multiple registries + IF ${allowed_user} ${loaded}= Run Keyword And Return Status ... SeleniumLibrary.Page Should Not Contain Request access to model registries - Sleep 10s + WHILE ${loaded}!=${TRUE} limit=12 # Retries for 2 minutes - wait for user group to reconcile + SeleniumLibrary.Reload Page + SeleniumLibrary.Wait Until Page Contains Model Registry + SeleniumLibrary.Wait Until Page Contains + ... Select a model registry to view and manage your registered models. + ${loaded}= Run Keyword And Return Status + ... SeleniumLibrary.Page Should Not Contain Request access to model registries + Sleep 10s + END + ELSE + SeleniumLibrary.Page Should Contain Request access to model registries END Maybe Wait For Dashboard Loading Spinner Page @@ -344,11 +352,6 @@ Model Registry Pre Upgrade Scenario Workbench Should Be Listed workbench_title=${WORKBENCH_TITLE} Open Data Science Project Details Page project_title=${PRJ_TITLE} ${workbenches}= Create List ${WORKBENCH_TITLE} - Create S3 Data Connection project_title=${PRJ_TITLE} dc_name=${DC_S3_NAME} - ... aws_access_key=${S3.AWS_ACCESS_KEY_ID} aws_secret_access=${S3.AWS_SECRET_ACCESS_KEY} - ... aws_bucket_name=${AWS_BUCKET} connected_workbench=${workbenches} - Data Connection Should Be Listed name=${DC_S3_NAME} type=${DC_S3_TYPE} connected_workbench=${workbenches} - Open Data Science Project Details Page project_title=${prj_title} tab_id=workbenches Wait Until Workbench Is Started workbench_title=${WORKBENCH_TITLE} timeout=120s Sleep 15s reason=Workbench might not be ready right away, wait for a few seconds before opening it ${handle}= Launch And Access Workbench workbench_title=${WORKBENCH_TITLE} diff --git a/ods_ci/tests/Tests/1300__model_registry/1301_model_registry_model_serving.robot b/ods_ci/tests/Tests/1300__model_registry/1301_model_registry_model_serving.robot index 937847e30..828955a49 100644 --- a/ods_ci/tests/Tests/1300__model_registry/1301_model_registry_model_serving.robot +++ b/ods_ci/tests/Tests/1300__model_registry/1301_model_registry_model_serving.robot @@ -47,11 +47,6 @@ Verify Model Registry Integration With Secured-DB Workbench Should Be Listed workbench_title=${WORKBENCH_TITLE} Open Data Science Project Details Page project_title=${PRJ_TITLE} ${workbenches}= Create List ${WORKBENCH_TITLE} - Create S3 Data Connection project_title=${PRJ_TITLE} dc_name=${DC_S3_NAME} - ... aws_access_key=${S3.AWS_ACCESS_KEY_ID} aws_secret_access=${S3.AWS_SECRET_ACCESS_KEY} - ... aws_bucket_name=${AWS_BUCKET} connected_workbench=${workbenches} - Data Connection Should Be Listed name=${DC_S3_NAME} type=${DC_S3_TYPE} connected_workbench=${workbenches} - Open Data Science Project Details Page project_title=${prj_title} tab_id=workbenches Wait Until Workbench Is Started workbench_title=${WORKBENCH_TITLE} timeout=120s ${handle}= Launch And Access Workbench workbench_title=${WORKBENCH_TITLE} ... username=${TEST_USER.USERNAME} password=${TEST_USER.PASSWORD} @@ -76,3 +71,14 @@ Verify Model Registry Integration With Secured-DB Maybe Wait For Dashboard Loading Spinner Page SeleniumLibrary.Page Should Contain Element xpath:${MR_VERSION_TABLE_XPATH}/tbody/tr/td[@data-label="Version name"]//a[.="${MR_REGISTERED_MODEL_VERSION}"] SeleniumLibrary.Page Should Contain Element xpath:${MR_VERSION_TABLE_XPATH}/tbody/tr/td[@data-label="Author" and .="${MR_REGISTERED_MODEL_AUTHOR}"] + SeleniumLibrary.Close All Browsers + +Verify Unallowed User Cannot See Model Registry From The Dashboard + [Documentation] Negative path test for dashboard RBAC on the Model Registry. User not part of the group that is + ... allowed to use a Model Registry instace should not be able to see it from the dashboard. + [Tags] Smoke MRMS1301 ModelRegistry + Depends On Test Verify Model Registry Integration With Secured-DB + Launch Dashboard ${TEST_USER_3.USERNAME} ${TEST_USER_3.PASSWORD} ${TEST_USER_3.AUTH_TYPE} + ... ${ODH_DASHBOARD_URL} ${BROWSER.NAME} ${BROWSER.OPTIONS} + Open Model Registry Dashboard Page allowed_user=${FALSE} + SeleniumLibrary.Page Should Contain Request access to model registries