Search in sources :

Example 1 with SimpleResult

use of com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method testCubbyV2.

@Test
public void testCubbyV2() throws Exception {
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("path", "cubbyhole/hello");
    Variables vars = new MapBackedVariables(varMap);
    SimpleResult result = getTask(true).execute(vars);
    Assert.assertTrue(result.ok());
    final Map<String, Object> data = MapUtils.assertMap(result.values(), "data");
    assertEquals("cubbyVal", data.get("cubbyKey"));
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) HashMap(java.util.HashMap) SimpleResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult) Test(org.junit.Test)

Example 2 with SimpleResult

use of com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method testKvV2.

@Test
public void testKvV2() throws Exception {
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("path", "secret/testing");
    Variables vars = new MapBackedVariables(varMap);
    SimpleResult result = getTask(true).execute(vars);
    Assert.assertTrue(result.ok());
    final Map<String, Object> data = MapUtils.assertMap(result.values(), "data");
    assertEquals("password1", data.get("top_secret"));
    assertEquals("dbpassword1", data.get("db_password"));
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) HashMap(java.util.HashMap) SimpleResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult) Test(org.junit.Test)

Example 3 with SimpleResult

use of com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method writeAndRead.

private void writeAndRead(String path, String prefix) throws Exception {
    HashiVaultTask task = getTask(true);
    Map<String, Object> vars1 = new HashMap<>();
    vars1.put("action", "writeKV");
    vars1.put("path", path);
    Map<String, Object> kvPairs = new HashMap<>(2);
    kvPairs.put("key1", prefix + "Value1");
    kvPairs.put("key2", prefix + "Value2");
    vars1.put("kvPairs", kvPairs);
    Variables input1 = new MapBackedVariables(vars1);
    SimpleResult writeResult = task.execute(input1);
    assertTrue(writeResult.ok());
    // -- now get the values back
    // resets context
    task = getTask(true);
    Map<String, Object> vars2 = new HashMap<>();
    vars2.put("action", "readKV");
    vars2.put("path", path);
    Variables input2 = new MapBackedVariables(vars2);
    SimpleResult readResult = task.execute(input2);
    assertTrue(readResult.ok());
    Map<String, Object> data = MapUtils.getMap(readResult.values(), "data", Collections.emptyMap());
    assertEquals(prefix + "Value1", MapUtils.getString(data, "key1"));
    assertEquals(prefix + "Value2", MapUtils.getString(data, "key2"));
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) HashiVaultTask(com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask) HashMap(java.util.HashMap) SimpleResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)

Example 4 with SimpleResult

use of com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method testReadTokenFromSecretV2.

@Test
public void testReadTokenFromSecretV2() throws Exception {
    Map<String, Object> varMap = new HashMap<>();
    Map<String, Object> secretInfo = new HashMap<>(3);
    secretInfo.put("org", "my-org");
    secretInfo.put("name", "my-secret");
    varMap.put("apiTokenSecret", secretInfo);
    varMap.put("baseUrl", getBaseUrl());
    varMap.put("path", "cubbyhole/hello");
    Variables vars = new MapBackedVariables(varMap);
    SimpleResult result = getTask(false).execute(vars);
    Assert.assertTrue(result.ok());
    final Map<String, Object> data = MapUtils.assertMap(result.values(), "data");
    assertEquals("cubbyVal", data.get("cubbyKey"));
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) HashMap(java.util.HashMap) SimpleResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult) Test(org.junit.Test)

Example 5 with SimpleResult

use of com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult in project concord-plugins by walmartlabs.

the class HashiVaultTaskV2Test method testReadKvSingleV2.

@Test
public void testReadKvSingleV2() throws Exception {
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("path", "secret/testing");
    varMap.put("key", "db_password");
    Variables vars = new MapBackedVariables(varMap);
    SimpleResult result = getTask(true).execute(vars);
    Assert.assertTrue(result.ok());
    final String data = MapUtils.getString(result.values(), "data");
    assertEquals("dbpassword1", data);
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) HashMap(java.util.HashMap) SimpleResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult) Test(org.junit.Test)

Aggregations

MapBackedVariables (com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)5 SimpleResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)5 Variables (com.walmartlabs.concord.runtime.v2.sdk.Variables)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)4 HashiVaultTask (com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask)1