2424import org .opensearch .security .auth .UserSubjectImpl ;
2525import org .opensearch .security .configuration .AdminDNs ;
2626import org .opensearch .security .privileges .PrivilegesEvaluator ;
27- import org .opensearch .security .resources .sharing .Recipient ;
2827import org .opensearch .security .resources .sharing .ResourceSharing ;
2928import org .opensearch .security .resources .sharing .ShareWith ;
3029import 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