use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.
the class TestFullApplicationContext method testRestApiConfig.
@Test
public void testRestApiConfig() {
RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
assertNotNull(restApiConfig);
assertFalse(restApiConfig.isEnabled());
for (RestEndpointGroup group : RestEndpointGroup.values()) {
assertTrue("Unexpected status of REST Endpoint group" + group, restApiConfig.isGroupEnabled(group));
}
}
use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.
the class RestApiFilter method filterConnection.
@Override
public void filterConnection(String commandLine, ServerConnection connection) {
RestEndpointGroup restEndpointGroup = getEndpointGroup(commandLine);
if (restEndpointGroup != null) {
if (!restApiConfig.isGroupEnabled(restEndpointGroup)) {
String name = restEndpointGroup.name();
connection.close("REST endpoint group is not enabled - " + restEndpointGroup + ". To enable it, please do one of the following:\n" + " - Change member config using JAVA API: " + " config.getNetworkConfig().getRestApiConfig().enableGroups(RestEndpointGroup." + name + ");\n" + " - Change XML/YAML configuration property: " + "hazelcast.network.rest-api.endpoint-group " + name + " with `enabled` set to true\n" + " - Add system property: " + " -Dhz.network.rest-api.endpoint-groups." + name.toLowerCase() + ".enabled=true\n" + " - Add environment variable property: HZ_NETWORK_RESTAPI_ENDPOINTGROUPS." + name + ".ENABLED=true" + " (recommended when running container/docker image)", null);
}
} else if (!commandLine.isEmpty()) {
connection.close("Unsupported command received on REST API handler.", null);
}
}
use of com.hazelcast.config.RestEndpointGroup 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));
}
}
}
use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleRestEndpointGroup.
private void handleRestEndpointGroup(RestServerEndpointConfig config, Node node) {
boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
String name = extractName(node);
RestEndpointGroup endpointGroup;
try {
endpointGroup = RestEndpointGroup.valueOf(name);
} catch (IllegalArgumentException e) {
throw new InvalidConfigurationException("Wrong name attribute value was provided in endpoint-group element: " + name + "\nAllowed values: " + Arrays.toString(RestEndpointGroup.values()));
}
if (enabled) {
config.enableGroups(endpointGroup);
} else {
config.disableGroups(endpointGroup);
}
}
use of com.hazelcast.config.RestEndpointGroup in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleEndpointGroup.
void handleEndpointGroup(Node node, String name) {
boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
RestEndpointGroup endpointGroup = lookupEndpointGroup(name);
RestApiConfig restApiConfig = config.getNetworkConfig().getRestApiConfig();
if (enabled) {
restApiConfig.enableGroups(endpointGroup);
} else {
restApiConfig.disableGroups(endpointGroup);
}
}
Aggregations