Search in sources :

Example 16 with SecureSiteUrl

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

the class ServerConfig method getSiteUrlPreferablySecured.

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

Example 17 with SecureSiteUrl

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

the class CreateOrUpdateConfigServerSiteUrlsCommandTest method shouldAddBackupConfig.

@Test
void shouldAddBackupConfig() throws Exception {
    SiteUrls siteUrls = new SiteUrls(new SiteUrl("http://foo"), new SecureSiteUrl("https://bar"));
    CreateOrUpdateConfigServerSiteUrlsCommand command = new CreateOrUpdateConfigServerSiteUrlsCommand(siteUrls);
    command.update(cruiseConfig);
    assertThat(cruiseConfig.server().getSiteUrls()).isEqualTo(siteUrls);
}
Also used : SiteUrls(com.thoughtworks.go.config.SiteUrls) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) SiteUrl(com.thoughtworks.go.domain.SiteUrl) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) Test(org.junit.jupiter.api.Test)

Example 18 with SecureSiteUrl

use of com.thoughtworks.go.domain.SecureSiteUrl 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 SiteUrl(""), new SecureSiteUrl(""), 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 : SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) GoCache(com.thoughtworks.go.server.cache.GoCache) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) SiteUrl(com.thoughtworks.go.domain.SiteUrl) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.jupiter.api.Test)

Example 19 with SecureSiteUrl

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

the class SecurityServiceIntegrationTest method shouldReturnSecureSiteUrlAsCasServiceBaseUrlIfBothSiteUrlAndSecureSiteUrlAreDefined.

@Test
public void shouldReturnSecureSiteUrlAsCasServiceBaseUrlIfBothSiteUrlAndSecureSiteUrlAreDefined() throws Exception {
    configHelper.setBaseUrls(new SiteUrl("http://example.com"), new SecureSiteUrl("https://example.com"));
    assertThat(securityService.casServiceBaseUrl(), is("https://example.com"));
}
Also used : SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) SiteUrl(com.thoughtworks.go.domain.SiteUrl) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) Test(org.junit.jupiter.api.Test)

Example 20 with SecureSiteUrl

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

the class ServerConfigServiceIntegrationTest method shouldUseTheSecureSiteUrlInspiteOfCallerNotForcingSsl_whenAlreadyUsingHTTPS.

@Test
public void shouldUseTheSecureSiteUrlInspiteOfCallerNotForcingSsl_whenAlreadyUsingHTTPS() throws URISyntaxException {
    configHelper.setBaseUrls(new SiteUrl("http://foo.com:80"), new SecureSiteUrl("https://bar.com:443"));
    assertThat(serverConfigService.siteUrlFor("https://test.host:1000/foo/bar", false), is("https://bar.com:443/foo/bar"));
    assertThat(serverConfigService.siteUrlFor("http://test.host/foo/bar", false), is("http://foo.com:80/foo/bar"));
}
Also used : SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) SiteUrl(com.thoughtworks.go.domain.SiteUrl) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) Test(org.junit.jupiter.api.Test)

Aggregations

SecureSiteUrl (com.thoughtworks.go.domain.SecureSiteUrl)20 SiteUrl (com.thoughtworks.go.domain.SiteUrl)19 Test (org.junit.jupiter.api.Test)16 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)2 SiteUrls (com.thoughtworks.go.config.SiteUrls)2 GoCache (com.thoughtworks.go.server.cache.GoCache)2 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)1 GoCipher (com.thoughtworks.go.security.GoCipher)1 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)1 FeatureToggleService (com.thoughtworks.go.server.service.support.toggle.FeatureToggleService)1 HttpTestUtil (com.thoughtworks.go.server.util.HttpTestUtil)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1