@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } 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.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } 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.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } 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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } 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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } 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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } 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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getObjects()) { assertThat(key).isExactlyInstanceOf(NotAuthorizedException.class); } 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.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } 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.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } 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.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getObjects()) { assertThat(key).isExactlyInstanceOf(NotAuthorizedException.class); } 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.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getObjects()) { assertThat(key).isExactlyInstanceOf(NotAuthorizedException.class); } 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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } verify(this.chunkedResponseMessage).sendChunk(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.getAll70.cmdExecute(this.message, this.serverConnection, this.securityService, 0); for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPartNoCopying(argument.capture()); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getObjects()) { assertThat(key).isExactlyInstanceOf(NotAuthorizedException.class); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
private void checkObjectValues(ObjectPartList newList) { assertEquals(5, newList.size()); assertNull(newList.getKeysForTest()); List values = newList.getObjects(); assertEquals("value1", new String((byte[]) values.get(0))); assertEquals("value2", values.get(1)); assertEquals("value3", values.get(2)); assertEquals(new AssertionError("hello"), values.get(3)); assertNull(values.get(4)); }
private void checkSerializedValues(ObjectPartList newList) throws IOException, ClassNotFoundException { assertEquals(5, newList.size()); assertNull(newList.getKeysForTest()); List values = newList.getObjects(); assertEquals("value1", new String((byte[]) values.get(0))); assertEquals("value2", BlobHelper.deserializeBlob((byte[]) values.get(1))); assertEquals("value3", BlobHelper.deserializeBlob((byte[]) values.get(2))); assertEquals(new AssertionError("hello"), values.get(3)); assertNull(values.get(4)); }
if (queryResult instanceof ObjectPartList) { isObjectPartList = true; resultArray = ((ObjectPartList) queryResult).getObjects().toArray(); } else { if (isObjectPartList) { selectResults.add(new StructImpl((StructTypeImpl) objectType, ((ObjectPartList) resultArray[i]).getObjects().toArray())); } else { selectResults