use of io.cdap.cdap.common.conf.SConfiguration in project cdap by caskdata.
the class TaskWorkerServiceTest method testRestartAfterMultipleExecutions.
@Test
public void testRestartAfterMultipleExecutions() throws IOException {
CConfiguration cConf = createCConf();
SConfiguration sConf = createSConf();
cConf.setInt(Constants.TaskWorker.CONTAINER_KILL_AFTER_REQUEST_COUNT, 2);
cConf.setInt(Constants.TaskWorker.CONTAINER_KILL_AFTER_DURATION_SECOND, 0);
TaskWorkerService taskWorkerService = new TaskWorkerService(cConf, sConf, new InMemoryDiscoveryService(), (namespaceId, retryStrategy) -> null, metricsCollectionService, new CommonNettyHttpServiceFactory(cConf, metricsCollectionService));
serviceCompletionFuture = TaskWorkerTestUtil.getServiceCompletionFuture(taskWorkerService);
// start the service
taskWorkerService.startAndWait();
InetSocketAddress addr = taskWorkerService.getBindAddress();
URI uri = URI.create(String.format("http://%s:%s", addr.getHostName(), addr.getPort()));
// Post valid request
String want = "100";
RunnableTaskRequest req = RunnableTaskRequest.getBuilder(TestRunnableClass.class.getName()).withParam(want).build();
String reqBody = GSON.toJson(req);
HttpResponse response = HttpRequests.execute(HttpRequest.post(uri.resolve("/v3Internal/worker/run").toURL()).withBody(reqBody).build(), new DefaultHttpRequestConfig(false));
response = HttpRequests.execute(HttpRequest.post(uri.resolve("/v3Internal/worker/run").toURL()).withBody(reqBody).build(), new DefaultHttpRequestConfig(false));
TaskWorkerTestUtil.waitForServiceCompletion(serviceCompletionFuture);
Assert.assertEquals(Service.State.TERMINATED, taskWorkerService.state());
}
use of io.cdap.cdap.common.conf.SConfiguration in project cdap by caskdata.
the class SystemWorkerServiceTest method beforeTest.
@Before
public void beforeTest() throws IOException {
File keyDir = TEMP_FOLDER.newFolder();
File keyFile = new File(keyDir, "key");
CConfiguration cConf = createCConf();
cConf.set(Constants.Security.CFG_FILE_BASED_KEYFILE_PATH, keyFile.getAbsolutePath());
Injector injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), new FileBasedCoreSecurityModule(), new InMemoryDiscoveryModule());
SConfiguration sConf = createSConf();
SystemWorkerService service = new SystemWorkerService(cConf, sConf, new InMemoryDiscoveryService(), metricsCollectionService, new CommonNettyHttpServiceFactory(cConf, metricsCollectionService), injector.getInstance(FileBasedKeyManager.class), new NoopTwillRunnerService(), getInjector().getInstance(ProvisioningService.class), Guice.createInjector(new RunnableTaskModule(cConf)));
service.startAndWait();
this.systemWorkerService = service;
}
use of io.cdap.cdap.common.conf.SConfiguration in project cdap by caskdata.
the class ExternalLDAPAuthenticationServerSSLTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
URL certUrl = ExternalLDAPAuthenticationServerSSLTest.class.getClassLoader().getResource("cert.jks");
Assert.assertNotNull(certUrl);
String authHandlerConfigBase = Constants.Security.AUTH_HANDLER_CONFIG_BASE;
CConfiguration cConf = CConfiguration.create();
SConfiguration sConf = SConfiguration.create();
cConf.set(Constants.Security.AUTH_SERVER_BIND_ADDRESS, InetAddress.getLoopbackAddress().getHostName());
cConf.set(Constants.Security.SSL.EXTERNAL_ENABLED, "true");
cConf.setInt(Constants.Security.AuthenticationServer.SSL_PORT, 0);
cConf.set(authHandlerConfigBase.concat("useLdaps"), "true");
cConf.set(authHandlerConfigBase.concat("ldapsVerifyCertificate"), "false");
sConf.set(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PATH, certUrl.getPath());
configuration = cConf;
sConfiguration = sConf;
String keystorePassword = sConf.get(Constants.Security.AuthenticationServer.SSL_KEYSTORE_PASSWORD);
KeyStoreKeyManager keyManager = new KeyStoreKeyManager(certUrl.getFile(), keystorePassword.toCharArray());
SSLUtil sslUtil = new SSLUtil(keyManager, new TrustAllTrustManager());
ldapListenerConfig = InMemoryListenerConfig.createLDAPSConfig("LDAP", InetAddress.getLoopbackAddress(), ldapPort, sslUtil.createSSLServerSocketFactory(), sslUtil.createSSLSocketFactory());
testServer = new ExternalLDAPAuthenticationServerSSLTest();
testServer.setup();
}
use of io.cdap.cdap.common.conf.SConfiguration in project cdap by caskdata.
the class TinkCipherTest method testDecryptExceptionTagMismatch.
@Test(expected = CipherException.class)
public void testDecryptExceptionTagMismatch() throws CipherException, IOException, GeneralSecurityException {
SConfiguration sConf = SConfiguration.create();
sConf.set(Constants.Security.Authentication.USER_CREDENTIAL_ENCRYPTION_KEYSET, generateKeySet());
TinkCipher cipher = new TinkCipher(sConf);
byte[] plainData = generateRandomBytes(128);
byte[] associatedData = generateRandomBytes(64);
byte[] cipherData = cipher.encrypt(plainData, associatedData);
byte[] invalidAssociatedData = generateRandomBytes(64);
byte[] decryptedData = cipher.decrypt(cipherData, invalidAssociatedData);
}
use of io.cdap.cdap.common.conf.SConfiguration in project cdap by caskdata.
the class TinkCipherTest method testInitException.
@Test(expected = CipherException.class)
public void testInitException() throws CipherException {
SConfiguration sConf = SConfiguration.create();
sConf.set(Constants.Security.Authentication.USER_CREDENTIAL_ENCRYPTION_KEYSET, "invalid keyset");
TinkCipher cipher = new TinkCipher(sConf);
}
Aggregations