Search in sources :

Example 11 with ServerSiteUrlConfig

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

the class ServerConfigServiceIntegrationTest method shouldSiteUrlForGivenUrl.

@Test
public void shouldSiteUrlForGivenUrl() throws URISyntaxException {
    configHelper.setBaseUrls(new ServerSiteUrlConfig("http://foo.com"), new ServerSiteUrlConfig("https://bar.com"));
    assertThat(serverConfigService.siteUrlFor("http://test.host/foo/bar", true), is("https://bar.com/foo/bar"));
    assertThat(serverConfigService.siteUrlFor("http://test.host/foo/bar", false), is("http://foo.com/foo/bar"));
}
Also used : ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) Test(org.junit.Test)

Example 12 with ServerSiteUrlConfig

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

the class ServerConfigTest method shouldReturnTaskRepositoryLocation.

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

Example 13 with ServerSiteUrlConfig

use of com.thoughtworks.go.domain.ServerSiteUrlConfig 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 14 with ServerSiteUrlConfig

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

the class ServerConfig method getSiteUrlPreferablySecured.

public ServerSiteUrlConfig getSiteUrlPreferablySecured() {
    ServerSiteUrlConfig siteUrl = getSiteUrl();
    ServerSiteUrlConfig secureSiteUrlConfig = getSecureSiteUrl();
    if (secureSiteUrlConfig.hasNonNullUrl()) {
        return secureSiteUrlConfig;
    }
    if (!secureSiteUrlConfig.hasNonNullUrl()) {
        return siteUrl;
    }
    return new ServerSiteUrlConfig();
}
Also used : ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig)

Example 15 with ServerSiteUrlConfig

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

the class BaseUrlChangeListener method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    ServerConfig newServerConfig = newCruiseConfig.server();
    ServerSiteUrlConfig newSecureSiteUrl = newServerConfig.getSecureSiteUrl();
    ServerSiteUrlConfig newSiteUrl = newServerConfig.getSiteUrl();
    if (!(secureSiteUrl.equals(newSecureSiteUrl) && siteUrl.equals(newSiteUrl))) {
        goCache.remove(URLS_CACHE_KEY);
        LOGGER.info("[Configuration Changed] Site URL was changed from [{}] to [{}] and Secure Site URL was changed from [{}] to [{}]", siteUrl, newSiteUrl, secureSiteUrl, newSecureSiteUrl);
    }
    setUrls(newSiteUrl, newSecureSiteUrl);
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig)

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