use of com.thoughtworks.go.domain.EnvironmentVariable in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldScheduleAPipelineWithTheProvidedEncryptedEnvironmentVariable.
@Test
public void shouldScheduleAPipelineWithTheProvidedEncryptedEnvironmentVariable() throws InvalidCipherTextException {
pipelineConfig.addEnvironmentVariable(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", "SECURE_VAL", true));
pipelineConfigService.updatePipelineConfig(admin, pipelineConfig, entityHashingService.md5ForEntity(pipelineConfig), new HttpLocalizedOperationResult());
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
String overriddenEncryptedValue = new GoCipher().encrypt("overridden_value");
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", overriddenEncryptedValue));
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(true));
materialUpdateStatusNotifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 1));
BuildCause buildCause = pipelineScheduleQueue.toBeScheduled().get(pipelineName);
assertNotNull(buildCause);
EnvironmentVariable secureVariable = (EnvironmentVariable) CollectionUtils.find(buildCause.getVariables(), new Predicate() {
@Override
public boolean evaluate(Object o) {
EnvironmentVariable variable = (EnvironmentVariable) o;
return variable.getName().equals("SECURE_VAR1");
}
});
assertThat(secureVariable.getValue(), is("overridden_value"));
assertThat(secureVariable.isSecure(), is(true));
}
Aggregations