use of com.walmartlabs.concord.runtime.v2.sdk.Task in project concord-plugins by walmartlabs.
the class PuppetTaskV2Test method testSelfSignedCertWithSecret.
@Test
public void testSelfSignedCertWithSecret() throws Exception {
// -- Task in-vars
variables.put("action", "pql");
variables.put("queryString", "inventory[certname]{ limit 10 }");
variables.put("databaseUrl", httpsRule.baseUrl());
// Self-signed cert will fail unless we provide a cert to trust
try {
task.execute(input);
fail("Task should fail when self-signed cert is used without a provided certificate to trust.");
} catch (SSLHandshakeException expected) {
// that's fine
log.info("hit expected ssl exception. Not a problem");
} catch (Exception e) {
log.error(e.getMessage());
throw e;
}
// -- Task in-vars - add certificate info (secret)
Map<String, Object> certificate = new HashMap<>();
Map<String, Object> secret = new HashMap<>();
secret.put("org", "org");
secret.put("name", "name");
secret.put("password", null);
certificate.put("secret", secret);
variables.put("certificate", certificate);
// -- Execute - now it should work
TaskResult.SimpleResult result = task.execute(input);
assertNotNull(result);
assertTrue(result.ok());
List data = (List) result.values().get("data");
assertEquals(10, data.size());
}
use of com.walmartlabs.concord.runtime.v2.sdk.Task in project concord-plugins by walmartlabs.
the class PuppetTaskV2Test method testSelfSignedCertWithPath.
@Test
public void testSelfSignedCertWithPath() throws Exception {
// -- Task in-vars
variables.put("action", "pql");
variables.put("queryString", "inventory[certname]{ limit 10 }");
variables.put("databaseUrl", httpsRule.baseUrl());
// Self-signed cert will fail unless we provide a cert to trust
try {
task.execute(input);
throw new Exception("Task should fail when self-signed cert is used without a provided certificate to trust.");
} catch (SSLHandshakeException expected) {
// that's fine
log.info("hit expected ssl exception. Not a problem");
} catch (Exception e) {
log.error(e.getMessage());
throw e;
}
// -- Task in-vars - add certificate info (file path)
Map<String, Object> certificate = new HashMap<>();
certificate.put("path", getWiremockCertFile().toString());
variables.put("certificate", certificate);
// -- Execute - now it should work
TaskResult.SimpleResult result = task.execute(input);
assertNotNull(result);
assertTrue(result.ok());
List data = (List) result.values().get("data");
assertEquals(10, data.size());
}
Aggregations