Search in sources :

Example 1 with ApiClient

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 + ".*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) ApiClient(com.walmartlabs.concord.ApiClient) Test(org.junit.jupiter.api.Test)

Example 2 with ApiClient

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);
}
Also used : ApiClient(com.walmartlabs.concord.ApiClient)

Example 3 with ApiClient

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);
}
Also used : ProcessApi(com.walmartlabs.concord.client.ProcessApi) HashMap(java.util.HashMap) ProcessEntry(com.walmartlabs.concord.client.ProcessEntry) ApiClient(com.walmartlabs.concord.ApiClient) WebElement(org.openqa.selenium.WebElement) StartProcessResponse(com.walmartlabs.concord.client.StartProcessResponse) Test(org.junit.jupiter.api.Test)

Example 4 with ApiClient

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);
}
Also used : ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) ApiClient(com.walmartlabs.concord.ApiClient)

Example 5 with ApiClient

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.*");
}
Also used : ConcordProcess(ca.ibodrov.concord.testcontainers.ConcordProcess) Payload(ca.ibodrov.concord.testcontainers.Payload) ITUtils.randomString(com.walmartlabs.concord.it.common.ITUtils.randomString) ApiClient(com.walmartlabs.concord.ApiClient) Test(org.junit.jupiter.api.Test)

Aggregations

ApiClient (com.walmartlabs.concord.ApiClient)27 Test (org.junit.jupiter.api.Test)7 ITUtils.randomString (com.walmartlabs.concord.it.common.ITUtils.randomString)4 ConcordProcess (ca.ibodrov.concord.testcontainers.ConcordProcess)3 Payload (ca.ibodrov.concord.testcontainers.Payload)3 TaskResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 OkHttpClient (com.squareup.okhttp.OkHttpClient)2 ApiException (com.walmartlabs.concord.ApiException)2 ConcordApiClient (com.walmartlabs.concord.client.ConcordApiClient)2 ProcessHeartbeat (com.walmartlabs.concord.runtime.common.ProcessHeartbeat)2 Path (java.nio.file.Path)2 UUID (java.util.UUID)2 WebElement (org.openqa.selenium.WebElement)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 WireMockTest (com.github.tomakehurst.wiremock.junit5.WireMockTest)1 Injector (com.google.inject.Injector)1 HttpUrl (com.squareup.okhttp.HttpUrl)1 Request (com.squareup.okhttp.Request)1