Skip to content

Commit c79e7ba

Browse files
committed
Fix test
Signed-off-by: Craig Perkins <[email protected]>
1 parent 1088524 commit c79e7ba

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/test/java/org/opensearch/security/resources/ResourceAccessHandlerTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.opensearch.security.auth.UserSubjectImpl;
2525
import org.opensearch.security.configuration.AdminDNs;
2626
import org.opensearch.security.privileges.PrivilegesEvaluator;
27-
import org.opensearch.security.resources.sharing.Recipient;
2827
import org.opensearch.security.resources.sharing.ResourceSharing;
2928
import org.opensearch.security.resources.sharing.ShareWith;
3029
import org.opensearch.security.securityconf.FlattenedActionGroups;
@@ -124,10 +123,7 @@ public void testHasPermission_sharedWithUserAllowed() {
124123

125124
// Document setup: shared with the user at access-level "read"
126125
ResourceSharing doc = mock(ResourceSharing.class);
127-
when(doc.isCreatedBy("bob")).thenReturn(false);
128-
when(doc.fetchAccessLevels(eq(Recipient.USERS), any())).thenReturn(Set.of("read"));
129-
when(doc.fetchAccessLevels(eq(Recipient.ROLES), any())).thenReturn(Set.of());
130-
when(doc.fetchAccessLevels(eq(Recipient.BACKEND_ROLES), any())).thenReturn(Set.of());
126+
when(doc.getAccessLevelsForUser(user)).thenReturn(Set.of("read"));
131127

132128
FlattenedActionGroups ag = mock(FlattenedActionGroups.class);
133129
when(resourcePluginInfo.flattenedForType(TYPE)).thenReturn(ag);
@@ -154,8 +150,7 @@ public void testHasPermission_noAccessLevelsDenied() {
154150
when(adminDNs.isAdmin(user)).thenReturn(false);
155151

156152
ResourceSharing doc = mock(ResourceSharing.class);
157-
when(doc.isCreatedBy("charlie")).thenReturn(false);
158-
when(doc.fetchAccessLevels(any(), any())).thenReturn(Collections.emptySet());
153+
when(doc.getAccessLevelsForUser(user)).thenReturn(Collections.emptySet());
159154

160155
doAnswer(inv -> {
161156
ActionListener<ResourceSharing> l = inv.getArgument(2);

0 commit comments

Comments
 (0)