Search in sources :

Example 1 with ObjectPartList

use of org.apache.geode.internal.cache.tier.sockets.ObjectPartList in project geode by apache.

the class GetAll651Test method integratedSecurityShouldFailIfNotAuthorized.

@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).authorizeRegionRead(eq(REGION_NAME), eq(key.toString()));
    }
    this.getAll651.cmdExecute(this.message, this.serverConnection, 0);
    for (Object key : KEYS) {
        verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(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));
}
Also used : ObjectPartList(org.apache.geode.internal.cache.tier.sockets.ObjectPartList) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 2 with ObjectPartList

use of org.apache.geode.internal.cache.tier.sockets.ObjectPartList in project geode by apache.

the class GetAll651Test method oldSecurityShouldFailIfNotAuthorized.

@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, 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));
}
Also used : ObjectPartList(org.apache.geode.internal.cache.tier.sockets.ObjectPartList) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 3 with ObjectPartList

use of org.apache.geode.internal.cache.tier.sockets.ObjectPartList in project geode by apache.

the class GetAll70Test method integratedSecurityShouldFailIfNotAuthorized.

@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).authorizeRegionRead(eq(REGION_NAME), eq(key.toString()));
    }
    this.getAll70.cmdExecute(this.message, this.serverConnection, 0);
    for (Object key : KEYS) {
        verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(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));
}
Also used : ObjectPartList(org.apache.geode.internal.cache.tier.sockets.ObjectPartList) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 4 with ObjectPartList

use of org.apache.geode.internal.cache.tier.sockets.ObjectPartList in project geode by apache.

the class GetAllTest method integratedSecurityShouldFailIfNotAuthorized.

@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).authorizeRegionRead(eq(REGION_NAME), eq(key.toString()));
    }
    this.getAll.cmdExecute(this.message, this.serverConnection, 0);
    for (Object key : KEYS) {
        verify(this.securityService).authorizeRegionRead(eq(REGION_NAME), eq(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));
}
Also used : ObjectPartList(org.apache.geode.internal.cache.tier.sockets.ObjectPartList) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 5 with ObjectPartList

use of org.apache.geode.internal.cache.tier.sockets.ObjectPartList in project geode by apache.

the class GetAllTest method oldSecurityShouldFailIfNotAuthorized.

@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, 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));
}
Also used : ObjectPartList(org.apache.geode.internal.cache.tier.sockets.ObjectPartList) NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

ObjectPartList (org.apache.geode.internal.cache.tier.sockets.ObjectPartList)9 NotAuthorizedException (org.apache.geode.security.NotAuthorizedException)9 UnitTest (org.apache.geode.test.junit.categories.UnitTest)8 Test (org.junit.Test)8 Iterator (java.util.Iterator)1 Set (java.util.Set)1 GetOperationContext (org.apache.geode.cache.operations.GetOperationContext)1 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)1 AuthorizeRequestPP (org.apache.geode.internal.security.AuthorizeRequestPP)1