Search in sources :

Example 11 with SecretConfig

use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.

the class SecretConfigUpdateCommandTest method shouldRaiseErrorWhenUpdatingNonExistentSecretConfig.

@Test
public void shouldRaiseErrorWhenUpdatingNonExistentSecretConfig() throws Exception {
    cruiseConfig.getSecretConfigs().clear();
    SecretConfig secretConfig = new SecretConfig("foo", "docker");
    SecretConfigUpdateCommand command = new SecretConfigUpdateCommand(null, secretConfig, null, null, new HttpLocalizedOperationResult(), null, null);
    Assertions.assertThrows(RecordNotFoundException.class, () -> command.update(cruiseConfig));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SecretConfig(com.thoughtworks.go.config.SecretConfig) Test(org.junit.jupiter.api.Test)

Example 12 with SecretConfig

use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.

the class SecretConfigsControllerV3 method show.

public String show(Request request, Response response) throws IOException {
    SecretConfig secretConfig = fetchEntityFromConfig(request.params(CONFIG_ID_PARAM));
    if (isGetOrHeadRequestFresh(request, secretConfig)) {
        return notModified(response);
    }
    setEtagHeader(response, etagFor(secretConfig));
    return writerForTopLevelObject(request, response, writer -> SecretConfigRepresenter.toJSON(writer, secretConfig));
}
Also used : SecretConfig(com.thoughtworks.go.config.SecretConfig)

Example 13 with SecretConfig

use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.

the class SecretConfigsControllerV3 method destroy.

public String destroy(Request request, Response response) throws IOException {
    SecretConfig secretConfigToBeDeleted = fetchEntityFromConfig(request.params(CONFIG_ID_PARAM));
    final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    configService.delete(currentUsername(), secretConfigToBeDeleted, operationResult);
    return renderHTTPOperationResult(operationResult, request, response);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SecretConfig(com.thoughtworks.go.config.SecretConfig)

Example 14 with SecretConfig

use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.

the class SecretConfigRepresenter method fromJSON.

public static SecretConfig fromJSON(JsonReader jsonReader) {
    SecretConfig secretConfig = new SecretConfig(jsonReader.getString("id"), jsonReader.getString("plugin_id"));
    jsonReader.optString("description").ifPresent(description -> secretConfig.setDescription(description));
    secretConfig.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "properties"));
    jsonReader.readArrayIfPresent("rules", array -> {
        secretConfig.setRules(RulesRepresenter.fromJSON(array));
    });
    return secretConfig;
}
Also used : SecretConfig(com.thoughtworks.go.config.SecretConfig)

Example 15 with SecretConfig

use of com.thoughtworks.go.config.SecretConfig in project gocd by gocd.

the class SecretConfigUpdateCommand method update.

@Override
public void update(CruiseConfig preprocessedConfig) {
    SecretConfig existingSecretConfig = findExistingProfile(preprocessedConfig);
    SecretConfigs secretConfigs = getPluginProfiles(preprocessedConfig);
    secretConfigs.set(secretConfigs.indexOf(existingSecretConfig), profile);
}
Also used : SecretConfig(com.thoughtworks.go.config.SecretConfig) SecretConfigs(com.thoughtworks.go.config.SecretConfigs)

Aggregations

SecretConfig (com.thoughtworks.go.config.SecretConfig)21 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)13 Test (org.junit.jupiter.api.Test)13 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)2 SecretConfigs (com.thoughtworks.go.config.SecretConfigs)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 SecretConfigUsage (com.thoughtworks.go.domain.SecretConfigUsage)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)1 EntityHashingService (com.thoughtworks.go.server.service.EntityHashingService)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 HashSet (java.util.HashSet)1