DATAGEODE-55 - Adapt to Apache Geode Integrated Security Framework changes.

This commit is contained in:
John Blum
2017-11-11 16:13:37 -08:00
parent ca5585293c
commit 6fc39d0095
7 changed files with 41 additions and 70 deletions

View File

@@ -141,6 +141,7 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ClientServer
@Test
@DirtiesContext
public void authorizedUser() {
assertThat(echo.get("one")).isEqualTo("one");
assertThat(echo.put("two", "four")).isNull();
assertThat(echo.get("two")).isEqualTo("four");
@@ -148,11 +149,13 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ClientServer
@Test(expected = NotAuthorizedException.class)
public void unauthorizedUser() {
try {
assertThat(echo.get("one")).isEqualTo("one");
echo.put("two", "four");
}
catch (ServerOperationException expected) {
assertThat(expected).hasMessageContaining("analyst not authorized for DATA:WRITE:Echo:two");
assertThat(expected).hasCauseInstanceOf(NotAuthorizedException.class);
@@ -233,9 +236,9 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ClientServer
@CacheServerApplication(name = "GeodeSecurityIntegrationTestsServer", logLevel = TEST_GEMFIRE_LOG_LEVEL,
port = CACHE_SERVER_PORT)
@Import({
ApacheShiroIniGeodeSecurityIntegrationTests.ApacheShiroIniConfiguration.class,
ApacheShiroRealmGeodeSecurityIntegrationTests.ApacheShiroRealmConfiguration.class,
ApacheGeodeSecurityManagerGeodeSecurityIntegrationTests.ApacheGeodeSecurityManagerConfiguration.class
ApacheShiroIniSecurityIntegrationTests.ApacheShiroIniConfiguration.class,
ApacheShiroRealmSecurityIntegrationTests.ApacheShiroRealmConfiguration.class,
ApacheGeodeSecurityManagerSecurityIntegrationTests.ApacheGeodeSecurityManagerConfiguration.class
})
@Profile("apache-geode-server")
public static class GeodeServerConfiguration {

View File

@@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
@ActiveProfiles("apache-geode-client")
public class ApacheGeodeSecurityManagerGeodeSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
public class ApacheGeodeSecurityManagerSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
protected static final String GEODE_SECURITY_MANAGER_PROPERTY_CONFIGURATION_PROFILE =
"geode-security-manager-property-configuration";
@@ -59,7 +59,7 @@ public class ApacheGeodeSecurityManagerGeodeSecurityIntegrationTests extends Abs
@Configuration
@EnableSecurity(securityManagerClassName =
"org.springframework.data.gemfire.config.annotation.ApacheGeodeSecurityManagerGeodeSecurityIntegrationTests$TestGeodeSecurityManager")
"org.springframework.data.gemfire.config.annotation.ApacheGeodeSecurityManagerSecurityIntegrationTests$TestGeodeSecurityManager")
@Profile(GEODE_SECURITY_MANAGER_PROPERTY_CONFIGURATION_PROFILE)
public static class ApacheGeodeSecurityManagerConfiguration {
}

View File

@@ -37,7 +37,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
@ActiveProfiles("apache-geode-client")
public class ApacheShiroIniGeodeSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
public class ApacheShiroIniSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
protected static final String SHIRO_INI_CONFIGURATION_PROFILE = "shiro-ini-configuration";

View File

@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class)
@ActiveProfiles("apache-geode-client")
public class ApacheShiroRealmGeodeSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
public class ApacheShiroRealmSecurityIntegrationTests extends AbstractGeodeSecurityIntegrationTests {
protected static final String SHIRO_REALM_CONFIGURATION_PROFILE = "shiro-realm-configuration";
@@ -58,9 +58,12 @@ public class ApacheShiroRealmGeodeSecurityIntegrationTests extends AbstractGeode
@Bean
public PropertiesRealm shiroRealm() {
PropertiesRealm propertiesRealm = new PropertiesRealm();
propertiesRealm.setResourcePath("classpath:shiro.properties");
propertiesRealm.setPermissionResolver(new GeodePermissionResolver());
return propertiesRealm;
}
}