use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class RestApiFilterTest method testHttpGetForUnknownResource.
/**
* <pre>
* Given: RestApiConfig is explicitly enabled
* When: HTTP GET command is used to retrieve a non-Hazelcast resource
* Then: connection is terminated after reading the command line
* </pre>
*/
@Test
public void testHttpGetForUnknownResource() 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(GET);
client.waitUntilClosed(2000);
assertFalse(client.isConnectionClosed());
client.sendData(" /test/abc HTTP/1.0" + CRLF);
client.waitUntilClosed();
assertEquals(0, client.getReceivedBytes().length);
assertTrue(client.isConnectionClosed());
} finally {
client.close();
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testRestApiCallEnabledGroupsEnabled.
/**
* <pre>
* Given: RestApiConfig is explicitly enabled and all groups are explicitly enabled
* When: REST endpoint is accessed
* Then: access is permitted
* </pre>
*/
@Test
public void testRestApiCallEnabledGroupsEnabled() throws Exception {
Config config = new Config();
config.getNetworkConfig().setRestApiConfig(new RestApiConfig().setEnabled(true).enableAllGroups());
HazelcastInstance hz = factory.newHazelcastInstance(config);
for (TestUrl testUrl : TEST_URLS) {
assertTextProtocolResponse(hz, testUrl);
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testRestApiCallWithDefaults.
/**
* <pre>
* Given: -
* When: empty RestApiConfig object is created
* Then: access to all REST endpoints is denied
* </pre>
*/
@Test
public void testRestApiCallWithDefaults() throws Exception {
Config config = new Config();
HazelcastInstance hz = factory.newHazelcastInstance(config);
for (TestUrl testUrl : TEST_URLS) {
assertNoTextProtocolResponse(hz, testUrl);
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testRestApiCallDisabledGroupsEnabled.
/**
* <pre>
* Given: RestApiConfig is explicitly disabled and all groups are explicitly enabled
* When: REST endpoint is accessed
* Then: access is denied
* </pre>
*/
@Test
public void testRestApiCallDisabledGroupsEnabled() throws Exception {
Config config = new Config();
config.getNetworkConfig().setRestApiConfig(new RestApiConfig().setEnabled(false).enableAllGroups());
HazelcastInstance hz = factory.newHazelcastInstance(config);
for (TestUrl testUrl : TEST_URLS) {
assertNoTextProtocolResponse(hz, testUrl);
}
}
use of com.hazelcast.config.RestApiConfig in project hazelcast by hazelcast.
the class TextProtocolsConfigTest method testRestApiDefaults.
/**
* <pre>
* Given: -
* When: empty RestApiConfig object is created
* Then: it's disabled and the only enabled REST endpoint group is the CLUSTER_READ
* </pre>
*/
@Test
public void testRestApiDefaults() throws Exception {
RestApiConfig restApiConfig = new RestApiConfig();
assertFalse("REST should be disabled by default", restApiConfig.isEnabled());
for (RestEndpointGroup endpointGroup : RestEndpointGroup.values()) {
if (isExpectedDefaultEnabled(endpointGroup)) {
assertTrue("REST endpoint group should be enabled by default: " + endpointGroup, restApiConfig.isGroupEnabled(endpointGroup));
} else {
assertFalse("REST endpoint group should be disabled by default: " + endpointGroup, restApiConfig.isGroupEnabled(endpointGroup));
}
}
}
Aggregations