use of com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload 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());
}
use of com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload 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);
}
use of com.walmartlabs.concord.plugins.puppet.model.token.TokenPayload 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);
}
Aggregations