Search in sources :

Example 21 with BasicCruiseConfig

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

the class DiskSpaceFullCheckerTest method shouldReturnTrueIfTheArtifactFolderHasSizeLimit.

@Test
public void shouldReturnTrueIfTheArtifactFolderHasSizeLimit() {
    new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1M");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
    ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    fullChecker.check(result);
    assertThat(result.canContinue(), is(true));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 22 with BasicCruiseConfig

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

the class GoConfigInvalidExceptionTest method shouldReturnAllErrorMessagesOnCruiseConfig.

@Test
public void shouldReturnAllErrorMessagesOnCruiseConfig() {
    BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
    cruiseConfig.addError("BasicCruiseConfig_key", "BasicCruiseConfig_error");
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("");
    pipelineConfig.addError("PipelineConfig_key", "PipelineConfig_error");
    cruiseConfig.addPipeline("default", pipelineConfig);
    GoConfigInvalidException exception = new GoConfigInvalidException(cruiseConfig, "");
    assertThat(exception.getAllErrorMessages(), is("BasicCruiseConfig_error, PipelineConfig_error"));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 23 with BasicCruiseConfig

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

the class BaseUrlChangeListenerTest method shouldFlushCacheWhenBaseUrlConfigChangesAndUpdateTheSiteURLAndSecureSiteURLToTheNewValues.

@Test
public void shouldFlushCacheWhenBaseUrlConfigChangesAndUpdateTheSiteURLAndSecureSiteURLToTheNewValues() throws IOException {
    GoCache cache = mock(GoCache.class);
    BaseUrlChangeListener listener = new BaseUrlChangeListener(new ServerSiteUrlConfig(""), new ServerSiteUrlConfig(""), cache);
    CruiseConfig newCruiseConfig = new BasicCruiseConfig();
    newCruiseConfig.setServerConfig(serverConfigWith("http://blah.com", "https://blah.com"));
    listener.onConfigChange(newCruiseConfig);
    listener.onConfigChange(newCruiseConfig);
    verify(cache, times(1)).remove("urls_cache");
}
Also used : GoCache(com.thoughtworks.go.server.cache.GoCache) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) Test(org.junit.Test)

Example 24 with BasicCruiseConfig

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

the class SecurityAuthConfigCreateCommandTest method shouldInvokePluginValidationsBeforeSave.

@Test
public void shouldInvokePluginValidationsBeforeSave() throws Exception {
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("key", "error"));
    when(extension.validatePluginConfiguration(eq("aws"), Matchers.<Map<String, String>>any())).thenReturn(validationResult);
    SecurityAuthConfig newProfile = new SecurityAuthConfig("foo", "aws", new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("val")));
    PluginProfileCommand command = new SecurityAuthConfigCreateCommand(mock(GoConfigService.class), newProfile, extension, null, new HttpLocalizedOperationResult());
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    thrown.expect(PluginProfileNotFoundException.class);
    thrown.expectMessage("Security auth config `foo` does not exist.");
    command.isValid(cruiseConfig);
    command.update(cruiseConfig);
    assertThat(newProfile.first().errors().size(), is(1));
    assertThat(newProfile.first().errors().asString(), is("error"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Test(org.junit.Test)

Example 25 with BasicCruiseConfig

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

the class RoleConfigCreateCommandTest method shouldAddPluginRoleConfig.

@Test
public void shouldAddPluginRoleConfig() throws Exception {
    BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
    PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
    RoleConfigCreateCommand command = new RoleConfigCreateCommand(null, role, extension, null, null);
    command.update(cruiseConfig);
    assertThat(cruiseConfig.server().security().getRoles().findByName(new CaseInsensitiveString("blackbird")), equalTo(role));
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)31 Test (org.junit.Test)28 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)18 ServerConfig (com.thoughtworks.go.config.ServerConfig)10 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)4 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)2 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)2 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2