Search in sources :

Example 1 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig in project gocd by gocd.

the class ArtifactsDiskSpaceFullCheckerTest method configWithSiteUrl.

private static CruiseConfig configWithSiteUrl() {
    ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://test.host"), new ServerSiteUrlConfig("https://test.host"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(serverConfig);
    return cruiseConfig;
}
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) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig)

Example 2 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig in project gocd by gocd.

the class DiskSpaceFullCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.

@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
    String expectedHelpUrl = "https://docs.gocd.org/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)

Example 3 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig in project gocd by gocd.

the class UrlRewriterIntegrationTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    ServletHelper.init();
    httpUtil = new HttpTestUtil(new HttpTestUtil.ContextCustomizer() {

        public void customize(WebAppContext ctx) throws Exception {
            wac = mock(WebApplicationContext.class);
            ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
            URL resource = getClass().getClassLoader().getResource("WEB-INF/urlrewrite.xml");
            if (resource == null) {
                throw new RuntimeException("Cannot load WEB-INF/urlrewrite.xml");
            }
            ctx.setBaseResource(Resource.newResource(new File(resource.getFile()).getParent()));
            ctx.addFilter(UrlRewriteFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)).setInitParameter("confPath", "/urlrewrite.xml");
            ctx.addServlet(HttpTestUtil.EchoServlet.class, "/*");
        }
    });
    httpUtil.httpConnector(HTTP);
    httpUtil.httpsConnector(HTTPS);
    when(wac.getBean("serverConfigService")).thenReturn(new BaseUrlProvider() {

        public boolean hasAnyUrlConfigured() {
            return useConfiguredUrls;
        }

        public String siteUrlFor(String url, boolean forceSsl) throws URISyntaxException {
            ServerSiteUrlConfig siteUrl = forceSsl ? new ServerSiteUrlConfig("https://127.2.2.2:" + 9071) : new ServerSiteUrlConfig("http://127.2.2.2:" + 5197);
            return siteUrl.siteUrlFor(url);
        }
    });
    httpUtil.start();
    originalSslPort = System.getProperty(SystemEnvironment.CRUISE_SERVER_SSL_PORT);
    System.setProperty(SystemEnvironment.CRUISE_SERVER_SSL_PORT, String.valueOf(9071));
}
Also used : URISyntaxException(java.net.URISyntaxException) URL(java.net.URL) WebApplicationContext(org.springframework.web.context.WebApplicationContext) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HttpTestUtil(com.thoughtworks.go.server.util.HttpTestUtil) UrlRewriteFilter(org.tuckey.web.filters.urlrewrite.UrlRewriteFilter) File(java.io.File) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) BeforeClass(org.junit.BeforeClass)

Example 4 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig in project gocd by gocd.

the class ServerConfigTest method shouldReturnDefaultTaskRepositoryLocation.

@Test
public void shouldReturnDefaultTaskRepositoryLocation() {
    ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://foo.bar:813"), new ServerSiteUrlConfig());
    assertThat(serverConfig.getCommandRepositoryLocation(), Is.is("default"));
}
Also used : ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) Test(org.junit.Test)

Example 5 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig in project gocd by gocd.

the class ServerConfigTest method shouldReturnAnEmptyForSecureSiteUrlIfOnlySiteUrlIsConfigured.

@Test
public void shouldReturnAnEmptyForSecureSiteUrlIfOnlySiteUrlIsConfigured() throws Exception {
    ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://foo.bar:813"), new ServerSiteUrlConfig());
    assertThat(serverConfig.getHttpsUrl(), is(new ServerSiteUrlConfig()));
}
Also used : ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) Test(org.junit.Test)

Aggregations

ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)18 Test (org.junit.Test)13 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)3 GoCipher (com.thoughtworks.go.security.GoCipher)2 GoCache (com.thoughtworks.go.server.cache.GoCache)2 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 HttpTestUtil (com.thoughtworks.go.server.util.HttpTestUtil)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1 BeforeClass (org.junit.BeforeClass)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1 UrlRewriteFilter (org.tuckey.web.filters.urlrewrite.UrlRewriteFilter)1