Search in sources :

Example 1 with RbacCfg

use of com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg in project concord-plugins by walmartlabs.

the class PuppetTaskTest method testTokenPayload.

@Test
public void testTokenPayload() throws Exception {
    MockContext ctx = new MockContext(buildRbacCfg());
    ctx.setVariable("tokenDescription", "token description");
    ctx.setVariable("tokenLabel", "token label");
    ctx.setVariable("tokenLife", "5h");
    RbacCfg cfg = Utils.createCfg(ctx, secretService, ctx.toMap(), RbacCfg.class);
    TokenPayload payload = new TokenPayload(cfg);
    assertEquals("token description", payload.getDescription());
    assertEquals("token label", payload.getLabel());
    assertEquals("5h", payload.getLifetime());
}
Also used : MockContext(com.walmartlabs.concord.sdk.MockContext) RbacCfg(com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg) TokenPayload(com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload) Test(org.junit.Test)

Example 2 with RbacCfg

use of com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg in project concord-plugins by walmartlabs.

the class PuppetTask method createToken.

/**
 * Create an API token
 *
 * @param ctx Concord process {@link Context}
 * @return the new API token
 * @throws Exception When something goes wrong communicating with the API
 */
private String createToken(Context ctx) throws Exception {
    RbacCfg cfg = Utils.createCfg(ctx, secretService, defaults, RbacCfg.class);
    PuppetClient client = new PuppetClient(cfg);
    TokenPayload payload = new TokenPayload(cfg);
    return client.createToken(payload);
}
Also used : RbacCfg(com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg) TokenPayload(com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload)

Example 3 with RbacCfg

use of com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg in project concord-plugins by walmartlabs.

the class PuppetTaskV2 method createToken.

/**
 * Create an API token
 *
 * @param params merged global and task parameters
 * @return the new API token
 * @throws Exception When something goes wrong communicating with the API
 */
private String createToken(Map<String, Object> params) throws Exception {
    RbacCfg cfg = UtilsV2.createCfg(params, secretService, RbacCfg.class);
    PuppetClient client = new PuppetClient(cfg);
    TokenPayload payload = new TokenPayload(cfg);
    return client.createToken(payload);
}
Also used : RbacCfg(com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg) TokenPayload(com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload)

Aggregations

RbacCfg (com.walmartlabs.concord.plugins.puppet.model.cfg.RbacCfg)3 TokenPayload (com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload)3 MockContext (com.walmartlabs.concord.sdk.MockContext)1 Test (org.junit.Test)1