Search in sources :

Example 21 with MapBackedVariables

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

the class UnitTest method requiredParametersTest.

@Test
public void requiredParametersTest() {
    TaskParams params = TaskParams.of(new MapBackedVariables(getMap()), null, exporter);
    try {
        params.baseUrl();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'baseUrl' is required"));
    }
    try {
        params.apiToken();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'apiToken' is required"));
    }
    try {
        params.path();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'path' is required"));
    }
    // default action
    params.kvPairs();
    // kvPairs required when action is writeKv
    params = TaskParams.of(new MapBackedVariables(getMap("action", "writeKv")), null, exporter);
    try {
        params.kvPairs();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'kvPairs' is required"));
    }
    // cubbyhole is a v1 engine
    params = TaskParams.of(new MapBackedVariables(getMap("path", "cubbyhole/mysecret", "engineVersion", 2)), null, exporter);
    assertEquals(1, params.engineVersion());
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Test(org.junit.Test)

Example 22 with MapBackedVariables

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

the class HashiVaultTask method createParams.

private TaskParams createParams(Context ctx, Map<String, Object> input) {
    final MapBackedVariables vars = new MapBackedVariables(input);
    final SecretExporterV1 exporterV1 = new SecretExporterV1(ctx, secretService);
    return TaskParams.of(vars, defaults, exporterV1);
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)

Aggregations

MapBackedVariables (com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)21 HashMap (java.util.HashMap)14 Test (org.junit.Test)10 Variables (com.walmartlabs.concord.runtime.v2.sdk.Variables)9 Test (org.junit.jupiter.api.Test)6 SimpleResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)5 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)3 Context (com.walmartlabs.concord.runtime.v2.sdk.Context)3 MimeMessage (javax.mail.internet.MimeMessage)3 ForkParams (com.walmartlabs.concord.client.ConcordTaskParams.ForkParams)1 ForkStartParams (com.walmartlabs.concord.client.ConcordTaskParams.ForkStartParams)1 HashiVaultTask (com.walmartlabs.concord.plugins.hashivault.v2.HashiVaultTask)1 TaskCall (com.walmartlabs.concord.runtime.v2.model.TaskCall)1 TaskCallOptions (com.walmartlabs.concord.runtime.v2.model.TaskCallOptions)1 TaskContext (com.walmartlabs.concord.runtime.v2.runner.context.TaskContext)1 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)1 TaskCallInterceptor (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor)1 CallContext (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallInterceptor.CallContext)1 TaskException (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskException)1 TaskProviders (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders)1