Search in sources :

Example 1 with ServerConfig

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

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesEmtpty.

@Test
public void shouldThrowExceptionWhenUserProvidesEmtpty() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig("", null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 2 with ServerConfig

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

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesPathPointToServerSandBox.

@Test
public void shouldThrowExceptionWhenUserProvidesPathPointToServerSandBox() {
    File file = new File("");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(file.getAbsolutePath(), null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception, see dot will make server check out the repository in the wrong place.");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) File(java.io.File) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 3 with ServerConfig

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

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesNull.

@Test
public void shouldThrowExceptionWhenUserProvidesNull() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(null, SecurityConfigMother.securityConfigWithRole("role", "user")));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 4 with ServerConfig

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

the class ArtifactDirValidatorTest method shouldNotThrowExceptionWhenUserProvidesValidPath.

@Test
public void shouldNotThrowExceptionWhenUserProvidesValidPath() throws Exception {
    File file = new File("");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(file.getAbsolutePath() + "/logs", null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    dirValidator.validate(cruiseConfig);
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) File(java.io.File) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 5 with ServerConfig

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

the class DiskSpaceFullCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.

@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
    String expectedHelpUrl = "https://docs.gocd.io/current/installation/configuring_server_details.html";
    ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://test.host"), new ServerSiteUrlConfig("https://test.host"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(serverConfig);
    GoConfigService goConfigService = mock(GoConfigService.class);
    when(goConfigService.artifactsDir()).thenReturn(null);
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(goConfigService.adminEmail()).thenReturn("admin@email.com");
    ArtifactsDiskSpaceFullChecker diskSpaceFullChecker = new ArtifactsDiskSpaceFullChecker(new SystemEnvironment(), null, goConfigService, null) {

        @Override
        protected String targetFolderCanonicalPath() {
            return "";
        }
    };
    SendEmailMessage actual = diskSpaceFullChecker.createEmail();
    assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) 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)

Aggregations

ServerConfig (com.thoughtworks.go.config.ServerConfig)21 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)12 Test (org.junit.Test)12 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)11 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 Username (com.thoughtworks.go.server.domain.Username)4 File (java.io.File)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)3 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 Before (org.junit.Before)2 Stage (com.thoughtworks.go.domain.Stage)1 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1