Search in sources :

Example 6 with HashiVaultTask

use of com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask in project concord-plugins by walmartlabs.

the class HashiVaultTaskV1Test method getTask.

private HashiVaultTask getTask(boolean setDefaults) {
    ctx = new MockContext(new HashMap<>());
    HashiVaultTask t = new HashiVaultTask(secretService);
    injectVariable(t, "execution", ctx);
    ctx.setVariable("txId", "643cd26e-6d64-11eb-81f9-0800273425d4");
    if (setDefaults) {
        Map<String, Object> defaults = new HashMap<>(2);
        defaults.put("apiToken", getApiToken());
        defaults.put("baseUrl", getBaseUrl());
        ctx.setVariable("hashivaultParams", defaults);
        injectVariable(t, "hashivaultParams", defaults);
    }
    return t;
}
Also used : HashMap(java.util.HashMap) HashiVaultTask(com.walmartlabs.concord.plugins.hashivault.v1.HashiVaultTask)

Example 7 with HashiVaultTask

use of com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method testWriteKvPublicMethodV2.

@Test
public void testWriteKvPublicMethodV2() {
    String path = "secret/newSecretTaskPublicMethodV2";
    Map<String, Object> kvPairs = new HashMap<>();
    kvPairs.put("key1", "value1");
    kvPairs.put("key2", "value2");
    HashiVaultTask task = getTask(true);
    task.writeKV(path, kvPairs);
    // -- now get the values back
    // resets context
    task = getTask(true);
    Map<String, Object> data = task.readKV(path);
    assertEquals("value1", MapUtils.getString(data, "key1"));
    assertEquals("value2", MapUtils.getString(data, "key2"));
}
Also used : HashMap(java.util.HashMap) HashiVaultTask(com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)7 HashiVaultTask (com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask)4 Test (org.junit.Test)4 HashiVaultTask (com.walmartlabs.concord.plugins.hashivault.v1.HashiVaultTask)3 MockContextV2 (com.walmartlabs.concord.plugins.hashivault.model.MockContextV2)1 MockSecretServiceDelegate (com.walmartlabs.concord.plugins.hashivault.model.MockSecretServiceDelegate)1 MockSecretServiceV2 (com.walmartlabs.concord.plugins.hashivault.model.MockSecretServiceV2)1 Context (com.walmartlabs.concord.runtime.v2.sdk.Context)1 MapBackedVariables (com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)1 SecretService (com.walmartlabs.concord.runtime.v2.sdk.SecretService)1 SimpleResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)1 Variables (com.walmartlabs.concord.runtime.v2.sdk.Variables)1