Search in sources :

Example 1 with SecretConfigUsage

use of com.thoughtworks.go.domain.SecretConfigUsage 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."));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SecretConfig(com.thoughtworks.go.config.SecretConfig) SecretConfigUsage(com.thoughtworks.go.domain.SecretConfigUsage) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

SecretConfig (com.thoughtworks.go.config.SecretConfig)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 SecretConfigUsage (com.thoughtworks.go.domain.SecretConfigUsage)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1