use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class RuleAwarePluginProfileCommandTest method shouldContinueWithConfigSaveIfUserIsAuthorized.
@Test
public void shouldContinueWithConfigSaveIfUserIsAuthorized() throws Exception {
SecretConfig securityAuthConfig = new SecretConfig("ldap", "cd.go.ldap");
when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
RuleAwarePluginProfileCommand command = new StubSecretConfigCommand(goConfigService, securityAuthConfig, currentUser, result);
assertThat(cruiseConfig.server().security().securityAuthConfigs().find("ldap"), nullValue());
assertThat(command.canContinue(cruiseConfig), is(true));
assertThat(result.httpCode(), is(200));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigDeleteCommandTest method shouldNotValidateIfSecretConfigIsInUseByPipeline.
@Test
public void shouldNotValidateIfSecretConfigIsInUseByPipeline() {
SecretConfig secretConfig = new SecretConfig("foo", "file-based");
Set<SecretConfigUsage> usageInfo = new HashSet<>(Arrays.asList(new SecretConfigUsage("gocd", "P1", "S1", "J1", "template1")));
SecretConfigDeleteCommand command = new SecretConfigDeleteCommand(null, secretConfig, usageInfo, null, null, new HttpLocalizedOperationResult());
GoConfigInvalidException goConfigInvalidException = assertThrows(GoConfigInvalidException.class, () -> {
command.isValid(cruiseConfig);
});
assertThat(goConfigInvalidException.getMessage(), is("The secret config 'foo' is being referenced by pipeline(s): P1."));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigDeleteCommandTest method shouldDeleteASecretConfig.
@Test
public void shouldDeleteASecretConfig() {
SecretConfig secretConfig = new SecretConfig("foo", "file-based");
cruiseConfig.getSecretConfigs().add(secretConfig);
SecretConfigDeleteCommand command = new SecretConfigDeleteCommand(null, secretConfig, Collections.emptySet(), null, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.getSecretConfigs(), is(empty()));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigDeleteCommandTest method shouldValidateIfSecretConfigIsNotInUseByPipeline.
@Test
public void shouldValidateIfSecretConfigIsNotInUseByPipeline() {
SecretConfig secretConfig = new SecretConfig("foo", "file-based");
SecretConfigDeleteCommand command = new SecretConfigDeleteCommand(null, secretConfig, Collections.emptySet(), null, null, new HttpLocalizedOperationResult());
assertThat(command.isValid(cruiseConfig), is(true));
}
use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.
the class SecretConfigCreateCommandTest method shouldAddSecretConfig.
@Test
public void shouldAddSecretConfig() throws Exception {
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
SecretConfig secretConfig = new SecretConfig("CreateTest", "File");
SecretConfigCreateCommand command = new SecretConfigCreateCommand(null, secretConfig, extension, null, null);
command.update(cruiseConfig);
assertThat(cruiseConfig.getSecretConfigs().find("CreateTest"), equalTo(secretConfig));
}
Aggregations