Skip to content

Commit

Permalink
IT Security Tests for model access control (#1095) (#1097)
Browse files Browse the repository at this point in the history
* IT Security Tests for model access control

Signed-off-by: Bhavana Ramaram <[email protected]>

* Fix assertion error

Signed-off-by: Bhavana Ramaram <[email protected]>

* Fix format violations

Signed-off-by: Bhavana Ramaram <[email protected]>

---------

Signed-off-by: Bhavana Ramaram <[email protected]>
(cherry picked from commit e752968)

Co-authored-by: Bhavana Ramaram <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and rbhavna authored Jul 12, 2023
1 parent 11a3571 commit c6e881d
Show file tree
Hide file tree
Showing 5 changed files with 1,067 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void validateRequestForAccessControl(MLUpdateModelGroupInput input, User
&& !modelAccessControlHelper.isAdmin(user)
&& !modelAccessControlHelper.isOwnerStillHasPermission(user, mlModelGroup)) {
throw new IllegalArgumentException(
"You don’t have the specified backend role to update access control data. For more information, contact your administrator."
"You don’t have the specified backend role to update this model group. For more information, contact your administrator."
);
}
AccessMode accessMode = input.getModelAccessMode();
Expand Down Expand Up @@ -258,7 +258,9 @@ private boolean hasAccessControlChange(MLUpdateModelGroupInput input) {
}

private void validateSecurityDisabledOrModelAccessControlDisabled(MLUpdateModelGroupInput input) {
if (input.getModelAccessMode() != null || input.getIsAddAllBackendRoles() != null || input.getBackendRoles() != null) {
if (input.getModelAccessMode() != null
|| input.getIsAddAllBackendRoles() != null
|| !CollectionUtils.isEmpty(input.getBackendRoles())) {
throw new IllegalArgumentException(
"You cannot specify model access control parameters because the Security plugin or model access control is disabled on your cluster."
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void test_OwnerNoMoreHasPermissionException() {
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
verify(actionListener).onFailure(argumentCaptor.capture());
assertEquals(
"You don’t have the specified backend role to update access control data. For more information, contact your administrator.",
"You don’t have the specified backend role to update this model group. For more information, contact your administrator.",
argumentCaptor.getValue().getMessage()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,14 @@ public MLRegisterModelInput createRegisterModelInput(String modelGroupID) {
}

public MLRegisterModelGroupInput createRegisterModelGroupInput(
String name,
List<String> backendRoles,
AccessMode modelAccessMode,
Boolean isAddAllBackendRoles
) {
return MLRegisterModelGroupInput
.builder()
.name("modelGroupName")
.name(name)
.description("This is a test model group")
.backendRoles(backendRoles)
.modelAccessMode(modelAccessMode)
Expand Down
Loading

0 comments on commit c6e881d

Please sign in to comment.