From e20dc0bb44eb9d2c74ad4f531f7161006c869328 Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Mon, 10 Jul 2023 21:29:42 -0700 Subject: [PATCH] fix failed ut Signed-off-by: Yaliang Wu --- .../ml/helper/ModelAccessControlHelperTests.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugin/src/test/java/org/opensearch/ml/helper/ModelAccessControlHelperTests.java b/plugin/src/test/java/org/opensearch/ml/helper/ModelAccessControlHelperTests.java index 17b8725620..bf73addf04 100644 --- a/plugin/src/test/java/org/opensearch/ml/helper/ModelAccessControlHelperTests.java +++ b/plugin/src/test/java/org/opensearch/ml/helper/ModelAccessControlHelperTests.java @@ -199,8 +199,12 @@ public void test_IsOwner() { public void test_IsUserHasBackendRole() { User user = User.parse("owner|IT,HR|all_access"); MLModelGroupBuilder builder = MLModelGroup.builder(); - assertTrue(modelAccessControlHelper.isUserHasBackendRole(null, builder.access(AccessMode.PUBLIC.getValue()).build())); - assertFalse(modelAccessControlHelper.isUserHasBackendRole(null, builder.access(AccessMode.PRIVATE.getValue()).build())); + assertTrue( + modelAccessControlHelper.isUserHasBackendRole(null, builder.name("test_group").access(AccessMode.PUBLIC.getValue()).build()) + ); + assertFalse( + modelAccessControlHelper.isUserHasBackendRole(null, builder.name("test_group").access(AccessMode.PRIVATE.getValue()).build()) + ); assertTrue( modelAccessControlHelper .isUserHasBackendRole( @@ -218,9 +222,13 @@ public void test_IsOwnerStillHasPermission() { User userLostAccess = User.parse("owner|Finance|myTenant"); assertTrue(modelAccessControlHelper.isOwnerStillHasPermission(null, null)); MLModelGroupBuilder builder = MLModelGroup.builder(); - assertTrue(modelAccessControlHelper.isOwnerStillHasPermission(user, builder.access(AccessMode.PUBLIC.getValue()).build())); assertTrue( - modelAccessControlHelper.isOwnerStillHasPermission(user, builder.access(AccessMode.PRIVATE.getValue()).owner(owner).build()) + modelAccessControlHelper + .isOwnerStillHasPermission(user, builder.name("test_group").access(AccessMode.PUBLIC.getValue()).build()) + ); + assertTrue( + modelAccessControlHelper + .isOwnerStillHasPermission(user, builder.name("test_group").access(AccessMode.PRIVATE.getValue()).owner(owner).build()) ); assertFalse( modelAccessControlHelper