use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testEnabledRestApiCallWithGroupDefaults.
/**
* <pre>
* Given: RestApiConfig is explicitly enabled
* When: REST endpoint is accessed
* Then: it is permitted/denied based on its default groups values
* </pre>
*/
@Test
public void testEnabledRestApiCallWithGroupDefaults() throws Exception {
Config config = new Config();
config.getNetworkConfig().setRestApiConfig(new RestApiConfig().setEnabled(true));
HazelcastInstance hz = factory.newHazelcastInstance(config);
for (TestUrl testUrl : TEST_URLS) {
if (isExpectedDefaultEnabled(testUrl.restEndpointGroup)) {
assertTextProtocolResponse(hz, testUrl);
} else {
assertNoTextProtocolResponse(hz, testUrl);
}
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testAllRestPropertiesEnabled.
@Test
public void testAllRestPropertiesEnabled() throws Exception {
Config config = new Config();
config.getNetworkConfig().getMemcacheProtocolConfig().setEnabled(true);
RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
restApiConfig.setEnabled(true);
restApiConfig.enableGroups(DATA);
HazelcastInstance hz = factory.newHazelcastInstance(config);
hz.getMap("test").put("testKey", "testValue");
assertTextProtocolResponse(hz, TEST_URL_DATA);
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class RestApiFilterTest method testMemcacheWhenRestApiEnabled.
/**
* <pre>
* Given: RestApiConfig is explicitly enabled
* When: a memcache command prefix is used by client
* Then: connection is terminated after reading the first 3 bytes (protocol header)
* </pre>
*/
@Test
public void testMemcacheWhenRestApiEnabled() throws Exception {
Config config = new Config();
config.getNetworkConfig().setRestApiConfig(new RestApiConfig().setEnabled(true));
HazelcastInstance hz = factory.newHazelcastInstance(config);
TextProtocolClient client = new TextProtocolClient(getAddress(hz).getInetSocketAddress());
try {
client.connect();
client.sendData("ver");
client.waitUntilClosed();
assertEquals(3, client.getSentBytesCount());
assertEquals(0, client.getReceivedBytes().length);
assertTrue(client.isConnectionClosed());
} finally {
client.close();
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class RestApiFilterTest method testRestApiDisabled.
/**
* <pre>
* Given: RestApiConfig is explicitly disabled
* When: a HTTP GET method is used by client
* Then: connection is terminated after reading the first 3 bytes (protocol header)
* </pre>
*/
@Test
public void testRestApiDisabled() throws Exception {
Config config = new Config();
config.getNetworkConfig().setRestApiConfig(new RestApiConfig().setEnabled(false));
HazelcastInstance hz = factory.newHazelcastInstance(config);
TextProtocolClient client = new TextProtocolClient(getAddress(hz).getInetSocketAddress());
try {
client.connect();
client.sendData(GET);
client.waitUntilClosed();
assertEquals(3, client.getSentBytesCount());
assertEquals(0, client.getReceivedBytes().length);
assertTrue(client.isConnectionClosed());
} finally {
client.close();
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class RestLogLevelTest method createReadWriteConfig.
protected Config createReadWriteConfig() {
Config config = createConfig();
RestApiConfig restApiConfig = new RestApiConfig().setEnabled(true).enableGroups(RestEndpointGroup.CLUSTER_READ).enableGroups(RestEndpointGroup.CLUSTER_WRITE);
config.getNetworkConfig().setRestApiConfig(restApiConfig);
return config;
}
Aggregations