use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class CryptoIT method test.
/**
* Tests various methods of the 'crypto' plugin.
*/
@Test
public void test() throws Exception {
ApiClient apiClient = concord.apiClient();
String orgName = "org_" + randomString();
String projectName = "project_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
ProjectsApi projectsApi = new ProjectsApi(apiClient);
projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
// ---
String mySecretPwd = "pwd_" + randomPwd();
String myStringSecretName = "secret_" + randomString();
String myStringSecretValue = "value_" + randomString();
concord.secrets().createSecret(NewSecretQuery.builder().org(orgName).name(myStringSecretName).storePassword(mySecretPwd).build(), myStringSecretValue.getBytes());
String myKeypairName = "secret_" + randomString();
concord.secrets().generateKeyPair(NewSecretQuery.builder().org(orgName).name(myKeypairName).storePassword(mySecretPwd).build());
String myCredentialsName = "secret_" + randomString();
String myUsername = "username_" + randomString();
String myPassword = "password_" + randomPwd();
concord.secrets().createSecret(NewSecretQuery.builder().org(orgName).name(myCredentialsName).storePassword(mySecretPwd).build(), myUsername, myPassword);
String mySecretFileName = "secret_" + randomString();
String mySecretFileValue = "value_" + randomString();
concord.secrets().createSecret(NewSecretQuery.builder().org(orgName).name(mySecretFileName).storePassword(mySecretPwd).build(), mySecretFileValue.getBytes());
String myRawString = "raw_" + randomString();
// ---
Payload payload = new Payload().org(orgName).project(projectName).archive(resource("crypto")).arg("myOrg", orgName).arg("mySecretPwd", mySecretPwd).arg("myStringSecret", myStringSecretName).arg("myKeypair", myKeypairName).arg("myCredentials", myCredentialsName).arg("mySecretFile", mySecretFileName).arg("myRawString", myRawString);
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
proc.assertLog(".*String: " + myStringSecretValue + ".*");
proc.assertLog(".*Keypair: \\{.*private.*}.*");
proc.assertLog(".*Credentials: .*" + myPassword + ".*");
proc.assertLog(".*File: .*");
proc.assertLog(".*Encrypted string: " + myRawString + ".*");
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class AbstractGitHubTriggersIT method sendEvent.
protected void sendEvent(String resource, String event, String... params) throws Exception {
String payload = resourceToString(resource);
if (params != null) {
for (int i = 0; i < params.length; i += 2) {
String k = params[i];
String v = params[i + 1];
payload = payload.replaceAll(k, v);
}
}
ApiClient client = getApiClient();
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload));
GitHubEventsApi eventsApi = new GitHubEventsApi(client);
eventsApi.onEvent(payload, "abc", event);
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class FormsIT method testDateTimeField.
@Test
public void testDateTimeField() throws Exception {
ApiClient apiClient = serverRule.getClient();
// ---
byte[] payload = archive(FormsIT.class.getResource("dateTimeField").toURI());
Map<String, Object> input = new HashMap<>();
input.put("archive", payload);
ProcessApi processApi = new ProcessApi(apiClient);
StartProcessResponse spr = serverRule.start(input);
assertNotNull(spr.getInstanceId());
ProcessEntry pir = waitForStatus(processApi, spr.getInstanceId(), ProcessEntry.StatusEnum.SUSPENDED);
// ---
consoleRule.login(Concord.ADMIN_API_KEY);
String url = "/#/process/" + pir.getInstanceId();
consoleRule.navigateToRelative(url);
WebElement wizardButton = consoleRule.waitFor(By.id("formWizardButton"));
wizardButton.click();
WebElement dateField = consoleRule.waitFor(By.name("dateField"));
dateField.sendKeys("2019-09-04");
WebElement dateTimeField = consoleRule.waitFor(By.name("dateTimeField"));
dateTimeField.sendKeys("2019-09-04T01:05:00.000-04:00");
// close the popup
consoleRule.waitFor(By.id("root")).click();
Thread.sleep(1000);
WebElement submitButton = consoleRule.waitFor(By.id("formSubmitButton"));
submitButton.click();
// ---
pir = waitForCompletion(processApi, pir.getInstanceId());
byte[] ab = serverRule.getLog(pir.getLogFileName());
assertLog(".*dateField=2019-09-04.*", ab);
assertLog(".*dateTimeField=2019-09-04T05:05:00.000Z.*", ab);
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class GitHubTriggersV2IT method sendEvent.
private static void sendEvent(String resource, String event, String... params) throws Exception {
String payload = resourceToString(resource);
if (params != null) {
for (int i = 0; i < params.length; i += 2) {
String k = params[i];
String v = params[i + 1];
payload = payload.replaceAll(k, v);
}
}
ApiClient client = apiClient();
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(payload));
GitHubEventsApi eventsApi = new GitHubEventsApi(client);
eventsApi.onEvent(payload, "abc", event);
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class KvTaskIT method test.
/**
* Tests various methods of the 'kv' plugin.
*/
@Test
public void test() throws Exception {
ApiClient apiClient = concord.apiClient();
String orgName = "org_" + randomString();
String projectName = "project_" + randomString();
OrganizationsApi orgApi = new OrganizationsApi(apiClient);
orgApi.createOrUpdate(new OrganizationEntry().setName(orgName));
ProjectsApi projectsApi = new ProjectsApi(apiClient);
projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName).setRawPayloadMode(ProjectEntry.RawPayloadModeEnum.OWNERS));
// ---
Payload payload = new Payload().org(orgName).project(projectName).archive(resource("kv"));
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
proc.assertLog(".*msg: Hello!.*");
proc.assertLog(".*msg \\(removed\\): \\[].*");
proc.assertLog(".*x: 123.*");
proc.assertLog(".*x \\(updated\\): 124.*");
}
Aggregations