use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testRemoteConfigurationRegistryClientService.
@Test
public void testRemoteConfigurationRegistryClientService() throws Exception {
outContent.reset();
KnoxCLI cli = new KnoxCLI();
Configuration config = new GatewayConfigImpl();
// Configure a client for the test local filesystem registry implementation
config.set("gateway.remote.config.registry.test_client", "type=LocalFileSystem;address=/test");
cli.setConf(config);
// This is only to get the gateway services initialized
cli.run(new String[] { "version" });
RemoteConfigurationRegistryClientService service = cli.getGatewayServices().getService(GatewayServices.REMOTE_REGISTRY_CLIENT_SERVICE);
assertNotNull(service);
RemoteConfigurationRegistryClient client = service.get("test_client");
assertNotNull(client);
assertNull(service.get("bogus"));
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testRemoteConfigurationRegistryGetACLs.
@Test
public void testRemoteConfigurationRegistryGetACLs() throws Exception {
outContent.reset();
final File testRoot = TestUtils.createTempDir(this.getClass().getName());
try {
final File testRegistry = new File(testRoot, "registryRoot");
final String providerConfigName = "my-provider-config.xml";
final String providerConfigContent = "<gateway/>\n";
final File testProviderConfig = new File(testRoot, providerConfigName);
final String[] uploadArgs = { "upload-provider-config", testProviderConfig.getAbsolutePath(), "--registry-client", "test_client", "--master", "master" };
FileUtils.writeStringToFile(testProviderConfig, providerConfigContent);
final String[] args = { "get-registry-acl", "/knox/config/shared-providers", "--registry-client", "test_client", "--master", "master" };
KnoxCLI cli = new KnoxCLI();
Configuration config = new GatewayConfigImpl();
// Configure a client for the test local filesystem registry implementation
config.set("gateway.remote.config.registry.test_client", "type=LocalFileSystem;address=" + testRegistry);
cli.setConf(config);
int rc = cli.run(uploadArgs);
assertEquals(0, rc);
// Run the test command
rc = cli.run(args);
// Validate the result
assertEquals(0, rc);
String result = outContent.toString();
assertEquals(result, 3, result.split("\n").length);
} finally {
FileUtils.forceDelete(testRoot);
}
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testDeleteOfNonExistAliasFromUserDefinedCluster.
@Test
public void testDeleteOfNonExistAliasFromUserDefinedCluster() throws Exception {
KnoxCLI cli = new KnoxCLI();
cli.setConf(new GatewayConfigImpl());
try {
int rc = 0;
outContent.reset();
String[] args1 = { "create-alias", "alias1", "--cluster", "cluster1", "--value", "testvalue1", "--master", "master" };
cli.run(args1);
// Delete invalid alias from the cluster
outContent.reset();
String[] args2 = { "delete-alias", "alias2", "--cluster", "cluster1", "--master", "master" };
rc = cli.run(args2);
assertEquals(0, rc);
assertTrue(outContent.toString().contains("No such alias exists in the cluster."));
} finally {
outContent.reset();
String[] args1 = { "delete-alias", "alias1", "--cluster", "cluster1", "--master", "master" };
cli.run(args1);
}
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testListAndDeleteOfAliasForValidClusterName.
@Test
public void testListAndDeleteOfAliasForValidClusterName() throws Exception {
outContent.reset();
String[] args1 = { "create-alias", "alias1", "--cluster", "cluster1", "--value", "testvalue1", "--master", "master" };
int rc = 0;
KnoxCLI cli = new KnoxCLI();
cli.setConf(new GatewayConfigImpl());
rc = cli.run(args1);
assertEquals(0, rc);
assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " + "created."));
outContent.reset();
String[] args2 = { "list-alias", "--cluster", "cluster1", "--master", "master" };
rc = cli.run(args2);
assertEquals(0, rc);
System.out.println(outContent.toString());
assertTrue(outContent.toString(), outContent.toString().contains("alias1"));
outContent.reset();
String[] args4 = { "delete-alias", "alias1", "--cluster", "cluster1", "--master", "master" };
rc = cli.run(args4);
assertEquals(0, rc);
assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " + "deleted."));
outContent.reset();
rc = cli.run(args2);
assertEquals(0, rc);
assertFalse(outContent.toString(), outContent.toString().contains("alias1"));
}
use of org.apache.knox.gateway.config.impl.GatewayConfigImpl in project knox by apache.
the class KnoxCLITest method testCreateSelfSignedCert.
@Test
public void testCreateSelfSignedCert() throws Exception {
GatewayConfigImpl config = new GatewayConfigImpl();
FileUtils.deleteQuietly(new File(config.getGatewaySecurityDir()));
createTestMaster();
outContent.reset();
KnoxCLI cli = new KnoxCLI();
cli.setConf(config);
String[] gwCreateArgs = { "create-cert", "--hostname", "hostname1", "--master", "master" };
int rc = 0;
rc = cli.run(gwCreateArgs);
assertEquals(0, rc);
assertTrue(outContent.toString(), outContent.toString().contains("gateway-identity has been successfully " + "created."));
}
Aggregations