use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldReturnErrorIfThePipelineBeingScheduledDoesnotExist.
@Test
public void shouldReturnErrorIfThePipelineBeingScheduledDoesnotExist() {
String pipelineName = "does-not-exist";
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(false));
assertThat(result.fullMessage(), is("Pipeline 'does-not-exist' not found."));
assertThat(result.httpCode(), is(404));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldReturnErrorIfTheFirstStageOfThePipelineBeingScheduledIsAlreadyRunning.
@Test
public void shouldReturnErrorIfTheFirstStageOfThePipelineBeingScheduledIsAlreadyRunning() {
pipelineTriggerService.schedule(pipelineName, new PipelineScheduleOptions(), admin, result);
assertThat(result.isSuccess(), is(true));
pipelineTriggerService.schedule(pipelineName, new PipelineScheduleOptions(), admin, result);
assertThat(result.isSuccess(), is(false));
assertThat(result.fullMessage(), is(String.format("Failed to trigger pipeline: %s { Pipeline already triggered }", pipelineName)));
assertThat(result.getServerHealthState().getDescription(), is("Pipeline already triggered"));
assertThat(result.httpCode(), is(409));
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions 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));
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldErrorOutIfSchedulingAPipelineWithBothValueAndEncryptedValueForAGiveVariable.
@Test
public void shouldErrorOutIfSchedulingAPipelineWithBothValueAndEncryptedValueForAGiveVariable() throws InvalidCipherTextException {
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
EnvironmentVariableConfig config = new EnvironmentVariableConfig(new GoCipher(), "SEC_VAR1", "PLAIN", true);
config.deserialize("SEC_VAR1", "PLAIN", true, new GoCipher().encrypt("ENCRYPTED"));
pipelineScheduleOptions.getAllEnvironmentVariables().add(config);
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, new Username("foo"), result);
System.out.println(result.fullMessage());
assertThat(result.isSuccess(), is(false));
assertThat(result.httpCode(), is(422));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline rejected { Variable 'SEC_VAR1' has not been configured for pipeline '%s' }", pipelineName)));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
}
use of com.thoughtworks.go.server.domain.PipelineScheduleOptions in project gocd by gocd.
the class PipelineTriggerServiceIntegrationTest method shouldReturnErrorWhenSchedulingAPipelineWithUnconfiguredEnvironmentVariables.
@Test
public void shouldReturnErrorWhenSchedulingAPipelineWithUnconfiguredEnvironmentVariables() throws IOException {
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
PipelineScheduleOptions pipelineScheduleOptions = new PipelineScheduleOptions();
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "ENV_VAR1", "value", false));
pipelineScheduleOptions.getAllEnvironmentVariables().add(new EnvironmentVariableConfig(new GoCipher(), "SECURE_VAR1", "value", true));
pipelineTriggerService.schedule(pipelineName, pipelineScheduleOptions, admin, result);
assertThat(result.isSuccess(), is(false));
assertThat(result.fullMessage(), is(String.format("Request to schedule pipeline rejected { Variable 'ENV_VAR1' has not been configured for pipeline '%s' }", pipelineName)));
assertThat(result.httpCode(), is(422));
assertThat(triggerMonitor.isAlreadyTriggered(pipelineName), is(false));
}
Aggregations