use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testAdminAndDeployerCanManageSchema.
@Test
public void testAdminAndDeployerCanManageSchema() {
String schema = Exceptions.unchecked(() -> Util.getResourceAsString("/sample_bank_account/bank.proto", this.getClass().getClassLoader()));
for (TestUser user : EnumSet.of(TestUser.ADMIN, TestUser.DEPLOYER)) {
RemoteCacheManager remoteCacheManager = getServerTest().hotrod().withClientConfiguration(hotRodBuilders.get(user)).createRemoteCacheManager();
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put(BANK_PROTO, schema);
metadataCache.remove(BANK_PROTO);
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testRestNonAdminsMustNotModifyCacheIgnores.
@Test
public void testRestNonAdminsMustNotModifyCacheIgnores() {
for (TestUser user : TestUser.NON_ADMINS) {
RestClient client = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get();
assertStatus(FORBIDDEN, client.server().ignoreCache("default", "predefined"));
assertStatus(FORBIDDEN, client.server().unIgnoreCache("default", "predefined"));
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testNonBulkReadUsersCannotQuery.
@Test
public void testNonBulkReadUsersCannotQuery() {
org.infinispan.configuration.cache.ConfigurationBuilder builder = prepareIndexedCache();
// Hot Rod
for (TestUser user : EnumSet.of(TestUser.READER, TestUser.WRITER)) {
RemoteCache<Integer, User> userCache = getServerTest().hotrod().withClientConfiguration(clientConfigurationWithProtostreamMarshaller(user)).withServerConfiguration(builder).get();
QueryFactory qf = Search.getQueryFactory(userCache);
Query<User> query = qf.create("FROM sample_bank_account.User WHERE name = 'Tom'");
Exceptions.expectException(HotRodClientException.class, "(?s).*ISPN000287.*", () -> query.execute().list());
}
// REST
for (TestUser user : EnumSet.of(TestUser.READER, TestUser.WRITER, TestUser.MONITOR)) {
RestCacheClient userCache = getServerTest().rest().withClientConfiguration(restBuilders.get(user)).get().cache(getServerTest().getMethodName());
assertStatus(FORBIDDEN, userCache.query("FROM sample_bank_account.User WHERE name = 'Tom'"));
assertStatus(OK, userCache.searchStats());
assertStatus(OK, userCache.indexStats());
assertStatus(OK, userCache.queryStats());
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testScriptUpload.
@Test
public void testScriptUpload() {
SkipJunit.skipSinceJDK(16);
InfinispanServerTestMethodRule serverTest = getServerTest();
for (TestUser user : EnumSet.of(TestUser.ADMIN, TestUser.DEPLOYER)) {
RemoteCacheManager remoteCacheManager = serverTest.hotrod().withClientConfiguration(hotRodBuilders.get(user)).createRemoteCacheManager();
serverTest.addScript(remoteCacheManager, "scripts/test.js");
}
for (TestUser user : EnumSet.of(TestUser.MONITOR, TestUser.APPLICATION, TestUser.OBSERVER, TestUser.WRITER)) {
RemoteCacheManager remoteCacheManager = serverTest.hotrod().withClientConfiguration(hotRodBuilders.get(user)).createRemoteCacheManager();
Exceptions.expectException(HotRodClientException.class, "(?s).*ISPN000287.*", () -> serverTest.addScript(remoteCacheManager, "scripts/test.js"));
}
}
use of org.infinispan.server.test.api.TestUser in project infinispan by infinispan.
the class AbstractAuthorization method testNonCreatorsSchema.
@Test
public void testNonCreatorsSchema() {
String schema = Exceptions.unchecked(() -> Util.getResourceAsString("/sample_bank_account/bank.proto", this.getClass().getClassLoader()));
for (TestUser user : EnumSet.of(TestUser.APPLICATION, TestUser.OBSERVER, TestUser.WRITER)) {
RemoteCacheManager remoteCacheManager = getServerTest().hotrod().withClientConfiguration(hotRodBuilders.get(user)).createRemoteCacheManager();
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
Exceptions.expectException(HotRodClientException.class, "(?s).*ISPN000287.*", () -> metadataCache.put(BANK_PROTO, schema));
}
}
Aggregations