@Test public void noSecurityShouldSucceed() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(false); this.removeAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
new Object[] {serverConnection.getName(), txt}); errMessage.append(txt); writeChunkedErrorResponse(clientMessage, MessageType.PUT_DATA_ERROR, errMessage.toString(), serverConnection); serverConnection.setAsTrue(RESPONDED); if (region == null) { String reason = " was not found during removeAll request"; writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection); serverConnection.setAsTrue(RESPONDED); return; new Object[] {serverConnection.getName(), txt}); errMessage.append(txt); writeChunkedErrorResponse(clientMessage, MessageType.PUT_DATA_ERROR, errMessage.toString(), serverConnection); serverConnection.setAsTrue(RESPONDED); VersionTag tag = findVersionTagsForRetriedBulkOp(region, entryEventId); retryVersions.add(tag); PartitionedRegion pr = (PartitionedRegion) region; if (pr.getNetworkHopType() != PartitionedRegion.NETWORK_HOP_NONE) { writeReplyWithRefreshMetadata(clientMessage, response, serverConnection, pr, pr.getNetworkHopType()); pr.clearNetworkHopData(); writeChunkedException(clientMessage, rde, serverConnection); serverConnection.setAsTrue(RESPONDED);
gfe81Commands.put(MessageType.GET_ALL_WITH_CALLBACK, GetAllWithCallback.getCommand()); gfe81Commands.put(MessageType.PUT_ALL_WITH_CALLBACK, PutAllWithCallback.getCommand()); gfe81Commands.put(MessageType.REMOVE_ALL, RemoveAll.getCommand());
@Before public void setUp() throws Exception { this.removeAll = new RemoveAll(); MockitoAnnotations.initMocks(this); when(this.authzRequest.removeAllAuthorize(any(), any(), any())) .thenReturn(mock(RemoveAllOperationContext.class)); when(this.cache.getRegion(isA(String.class))).thenReturn(mock(PartitionedRegion.class)); when(this.cache.getCancelCriterion()).thenReturn(mock(CancelCriterion.class)); when(this.callbackArgPart.getObject()).thenReturn(CALLBACK_ARG); when(this.eventPart.getSerializedForm()).thenReturn(EVENT); when(this.flagsPart.getInt()).thenReturn(0); when(this.keyPart.getStringOrObject()).thenReturn(KEYS); when(this.message.getPart(eq(0))).thenReturn(this.regionNamePart); when(this.message.getPart(eq(1))).thenReturn(this.eventPart); when(this.message.getPart(eq(2))).thenReturn(this.flagsPart); when(this.message.getPart(eq(3))).thenReturn(this.callbackArgPart); when(this.message.getPart(eq(4))).thenReturn(this.numberofKeysPart); when(this.message.getPart(eq(5))).thenReturn(this.keyPart); when(this.message.getPart(eq(6))).thenReturn(this.timeoutPart); when(this.numberofKeysPart.getInt()).thenReturn(1); when(this.regionNamePart.getString()).thenReturn(REGION_NAME); when(this.serverConnection.getCache()).thenReturn(this.cache); when(this.serverConnection.getCacheServerStats()).thenReturn(mock(CacheServerStats.class)); when(this.serverConnection.getAuthzRequest()).thenReturn(this.authzRequest); when(this.serverConnection.getCachedRegionHelper()).thenReturn(mock(CachedRegionHelper.class)); when(this.serverConnection.getChunkedResponseMessage()).thenReturn(this.chunkedResponseMessage); when(this.timeoutPart.getInt()).thenReturn(5); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.removeAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.authzRequest).removeAllAuthorize(eq(REGION_NAME), any(), any()); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); for (Object key : KEYS) { doThrow(new NotAuthorizedException("")).when(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } this.removeAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.authzRequest).removeAllAuthorize(eq(REGION_NAME), any(), any()); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void integratedSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); this.removeAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.WRITE, REGION_NAME); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void integratedSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); for (Object key : KEYS) { doThrow(new NotAuthorizedException("")).when(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } this.removeAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.WRITE, REGION_NAME); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }