use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractInfinispanServerDriver method createUserFile.
protected void createUserFile(String realm) {
// Create users and groups for individual permissions
UserTool userTool = new UserTool(rootDir.getAbsolutePath());
for (AuthorizationPermission permission : AuthorizationPermission.values()) {
String name = permission.name().toLowerCase();
userTool.createUser(name + "_user", name, realm, UserTool.Encryption.DEFAULT, Collections.singletonList(name), null);
}
// Create users with composite roles
for (TestUser user : TestUser.values()) {
if (user != TestUser.ANONYMOUS) {
userTool.createUser(user.getUser(), user.getPassword(), realm, UserTool.Encryption.DEFAULT, user.getRoles(), null);
}
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testHotRodWriterCannotRead.
private void testHotRodWriterCannotRead(String... explicitRoles) {
hotRodCreateAuthzCache(explicitRoles);
RemoteCache<String, String> writerCache = getServerTest().hotrod().withClientConfiguration(hotRodBuilders.get(TestUser.WRITER)).get();
writerCache.put("k1", "v1");
Exceptions.expectException(HotRodClientException.class, "(?s).*ISPN000287.*", () -> writerCache.get("k1"));
for (TestUser user : EnumSet.complementOf(EnumSet.of(TestUser.WRITER, TestUser.MONITOR, TestUser.ANONYMOUS))) {
RemoteCache<String, String> userCache = getServerTest().hotrod().withClientConfiguration(hotRodBuilders.get(user)).get();
assertEquals("v1", userCache.get("k1"));
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testRestWriterCannotRead.
private void testRestWriterCannotRead(String... explicitRoles) {
restCreateAuthzCache(explicitRoles);
RestCacheClient writerCache = getServerTest().rest().withClientConfiguration(restBuilders.get(TestUser.WRITER)).get().cache(getServerTest().getMethodName());
sync(writerCache.put("k1", "v1"));
assertStatus(FORBIDDEN, writerCache.get("k1"));
for (TestUser user : EnumSet.of(TestUser.OBSERVER, TestUser.DEPLOYER)) {
RestCacheClient userCache = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().cache(getServerTest().getMethodName());
assertEquals("v1", sync(userCache.get("k1")).getBody());
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotModifyLoggers.
@Test
public void testRestNonAdminsMustNotModifyLoggers() {
for (TestUser user : TestUser.NON_ADMINS) {
assertStatus(FORBIDDEN, getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().server().logging().setLogger("org.infinispan.TEST_LOGGER", "ERROR", "STDOUT"));
assertStatus(FORBIDDEN, getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().server().logging().removeLogger("org.infinispan.TEST_LOGGER"));
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotAdminServer.
@Test
public void testRestNonAdminsMustNotAdminServer() {
for (TestUser user : TestUser.NON_ADMINS) {
RestClientConfigurationBuilder userConfig = restBuilders.get(user);
RestClient client = getServerTest().rest().withClientConfiguration(userConfig).get();
assertStatus(FORBIDDEN, client.server().report());
assertStatus(FORBIDDEN, client.server().connectorStop("endpoint-default"));
assertStatus(FORBIDDEN, client.server().connectorStart("endpoint-default"));
assertStatus(FORBIDDEN, client.server().connectorIpFilterSet("endpoint-default", Collections.emptyList()));
assertStatus(FORBIDDEN, client.server().connectorIpFiltersClear("endpoint-default"));
assertStatus(FORBIDDEN, client.server().memory());
assertStatus(FORBIDDEN, client.server().env());
assertStatus(FORBIDDEN, client.server().configuration());
}
}
Aggregations