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"));
}
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"));
}
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");
}
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();
}
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);
}
Aggregations