Skip to content

Commit

Permalink
ISPN-141766 Move OverviewReportIT to RESTAuthorizationTest
Browse files Browse the repository at this point in the history
We lost the check for the Memcached client... I wasn't able to use it from RESTAuthorizationTest.
  • Loading branch information
fax4ever committed Sep 11, 2023
1 parent 9f427e5 commit 5803f7a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 68 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.server.security.authorization;

import static org.assertj.core.api.Assertions.assertThat;
import static org.infinispan.client.rest.RestResponse.ACCEPTED;
import static org.infinispan.client.rest.RestResponse.CREATED;
import static org.infinispan.client.rest.RestResponse.FORBIDDEN;
Expand All @@ -12,6 +13,8 @@
import static org.infinispan.server.test.core.Common.assertStatusAndBodyEquals;
import static org.infinispan.server.test.core.Common.awaitStatus;
import static org.infinispan.server.test.core.Common.sync;
import static org.infinispan.server.test.core.TestSystemPropertyNames.HOTROD_CLIENT_SASL_MECHANISM;
import static org.infinispan.util.concurrent.CompletionStages.join;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -35,6 +38,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.rest.RestCacheClient;
import org.infinispan.client.rest.RestCacheManagerClient;
import org.infinispan.client.rest.RestClient;
Expand All @@ -54,7 +59,9 @@
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.XSiteStateTransferMode;
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants;
import org.infinispan.rest.assertion.ResponseAssertion;
import org.infinispan.rest.resources.WeakSSEListener;
import org.infinispan.server.test.api.RestTestClientDriver;
import org.infinispan.server.test.api.TestUser;
import org.infinispan.server.test.junit5.InfinispanServerExtension;
import org.infinispan.util.concurrent.CompletionStages;
Expand Down Expand Up @@ -587,6 +594,40 @@ public void testRoleManipulation() {
}
}

@Test
public void overviewReport() {
// use REST
String cacheName = ext.getMethodName();
RestTestClientDriver driver = ext.rest().withClientConfiguration(restBuilders.get(TestUser.ADMIN));
RestCacheClient adminCache = driver
.withCacheMode(CacheMode.DIST_SYNC).create().cache(cacheName);
join(adminCache.put("ok", "ok"));

ConfigurationBuilder hotRodBuilder = new ConfigurationBuilder();
hotRodBuilder.security().authentication()
.saslMechanism(System.getProperty(HOTROD_CLIENT_SASL_MECHANISM, "SCRAM-SHA-1"))
.serverName("infinispan")
.realm("default")
.username(TestUser.DEPLOYER.getUser())
.password(TestUser.DEPLOYER.getPassword());

// use HotRod
RemoteCacheManager cacheManager = ext.hotrod().withClientConfiguration(hotRodBuilder).createRemoteCacheManager();
cacheManager.getCache(cacheName).put("ciao", "ciao");

CompletionStage<RestResponse> response = driver.get().server().overviewReport();
ResponseAssertion.assertThat(response).isOk();
Json report = Json.read(join(response).getBody());
assertThat(report).isNotNull();

Map<String, Json> clients = report.at("clients").asJsonMap();
assertThat(clients).containsKeys("SinglePort");

Map<String, Json> singlePort = clients.get("SinglePort").asJsonMap();
assertThat(singlePort.get("protocol-versions").asList()).isNotEmpty();
assertThat(singlePort.get("client-library-names").asList()).isNotEmpty();
}

private void createIndexedCache() {
String schema = Exceptions.unchecked(() -> Util.getResourceAsString("/sample_bank_account/bank.proto", this.getClass().getClassLoader()));
RestClient adminClient = ext.rest().withClientConfiguration(restBuilders.get(TestUser.ADMIN)).get();
Expand Down

0 comments on commit 5803f7a

Please sign in to comment.