Search in sources :

Example 16 with NotAuthorizedException

use of org.apache.geode.security.NotAuthorizedException in project geode by apache.

the class RegisterInterestList61Test method oldSecurityShouldFailIfNotAuthorized.

@Test
public void oldSecurityShouldFailIfNotAuthorized() throws Exception {
    when(this.securityService.isClientSecurityRequired()).thenReturn(true);
    when(this.securityService.isIntegratedSecurity()).thenReturn(false);
    doThrow(new NotAuthorizedException("")).when(this.authzRequest).registerInterestListAuthorize(eq(REGION_NAME), any(), any());
    this.registerInterestList61.cmdExecute(this.message, this.serverConnection, 0);
    verify(this.authzRequest).registerInterestListAuthorize(eq(REGION_NAME), any(), any());
    ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class);
    verify(this.chunkedResponseMessage).addObjPart(argument.capture());
    assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class);
    verify(this.chunkedResponseMessage).sendChunk(this.serverConnection);
}
Also used : NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 17 with NotAuthorizedException

use of org.apache.geode.security.NotAuthorizedException in project geode by apache.

the class RegisterInterestTest method oldSecurityShouldFailIfNotAuthorized.

@Test
public void oldSecurityShouldFailIfNotAuthorized() throws Exception {
    when(this.securityService.isClientSecurityRequired()).thenReturn(true);
    when(this.securityService.isIntegratedSecurity()).thenReturn(false);
    doThrow(new NotAuthorizedException("")).when(this.authzRequest).registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any());
    this.registerInterest.cmdExecute(this.message, this.serverConnection, 0);
    verify(this.authzRequest).registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any());
    ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class);
    verify(this.chunkedResponseMessage).addObjPart(argument.capture());
    assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class);
    verify(this.chunkedResponseMessage).sendChunk(this.serverConnection);
}
Also used : NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 18 with NotAuthorizedException

use of org.apache.geode.security.NotAuthorizedException in project geode by apache.

the class RemoveAllTest 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.removeAll.cmdExecute(this.message, this.serverConnection, 0);
    for (Object key : KEYS) {
        verify(this.authzRequest).removeAllAuthorize(eq(REGION_NAME), any(), any());
    }
    verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection));
}
Also used : NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 19 with NotAuthorizedException

use of org.apache.geode.security.NotAuthorizedException in project geode by apache.

the class InvalidateTest method oldSecurityShouldFailIfNotAuthorized.

@Test
public void oldSecurityShouldFailIfNotAuthorized() throws Exception {
    when(this.securityService.isClientSecurityRequired()).thenReturn(true);
    when(this.securityService.isIntegratedSecurity()).thenReturn(false);
    doThrow(new NotAuthorizedException("")).when(this.authzRequest).invalidateAuthorize(eq(REGION_NAME), eq(KEY_STRING), eq(CALLBACK_ARG));
    this.invalidate.cmdExecute(this.message, this.serverConnection, 0);
    verify(this.authzRequest).invalidateAuthorize(eq(REGION_NAME), eq(KEY_STRING), eq(CALLBACK_ARG));
    ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class);
    verify(this.errorResponseMessage).addObjPart(argument.capture());
    assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class);
    verify(this.errorResponseMessage).send(this.serverConnection);
}
Also used : NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 20 with NotAuthorizedException

use of org.apache.geode.security.NotAuthorizedException in project geode by apache.

the class KeySetTest method integratedSecurityShouldFailIfNotAuthorized.

@Test
public void integratedSecurityShouldFailIfNotAuthorized() throws Exception {
    when(this.securityService.isClientSecurityRequired()).thenReturn(true);
    when(this.securityService.isIntegratedSecurity()).thenReturn(true);
    doThrow(new NotAuthorizedException("")).when(this.securityService).authorizeRegionRead(eq(REGION_NAME));
    this.keySet.cmdExecute(this.message, this.serverConnection, 0);
    verify(this.securityService).authorizeRegionRead(eq(REGION_NAME));
    verify(this.chunkedResponseMessage).sendChunk(this.serverConnection);
}
Also used : NotAuthorizedException(org.apache.geode.security.NotAuthorizedException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

NotAuthorizedException (org.apache.geode.security.NotAuthorizedException)75 UnitTest (org.apache.geode.test.junit.categories.UnitTest)54 Test (org.junit.Test)54 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)12 IOException (java.io.IOException)9 ObjectPartList (org.apache.geode.internal.cache.tier.sockets.ObjectPartList)9 Part (org.apache.geode.internal.cache.tier.sockets.Part)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 GetOperationContext (org.apache.geode.cache.operations.GetOperationContext)6 AuthorizeRequestPP (org.apache.geode.internal.security.AuthorizeRequestPP)6 LocalRegion (org.apache.geode.internal.cache.LocalRegion)5 GetOperationContextImpl (org.apache.geode.cache.operations.internal.GetOperationContextImpl)4 StringId (org.apache.geode.i18n.StringId)4 CacheServerStats (org.apache.geode.internal.cache.tier.sockets.CacheServerStats)4 Result (org.apache.geode.management.cli.Result)4 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3 Region (org.apache.geode.cache.Region)3 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)3