Search in sources :

Example 11 with SiteUrl

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

the class SecurityServiceIntegrationTest method shouldReturnSiteUrlAsCasServiceBaseUrlIfOnlySiteUrlIsDefined.

@Test
public void shouldReturnSiteUrlAsCasServiceBaseUrlIfOnlySiteUrlIsDefined() throws Exception {
    configHelper.setBaseUrls(new SiteUrl("http://example.com"), new SecureSiteUrl());
    assertThat(securityService.casServiceBaseUrl(), is("http://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 12 with SiteUrl

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

the class ServerConfigServiceIntegrationTest method shouldUseTheSiteUrlWhenSecureSiteUrlIsNotPresentAndOnlyIfSiteUrlIsHttps.

@Test
public void shouldUseTheSiteUrlWhenSecureSiteUrlIsNotPresentAndOnlyIfSiteUrlIsHttps() throws URISyntaxException {
    configHelper.setBaseUrls(new SiteUrl("https://foo.com"), new SecureSiteUrl());
    assertThat(serverConfigService.siteUrlFor("http://test.host/foo/bar", true), is("https://foo.com/foo/bar"));
    assertThat(serverConfigService.siteUrlFor("http://test.host/foo/bar", false), is("https://foo.com/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)

Example 13 with SiteUrl

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

the class ServerConfigServiceIntegrationTest method shouldSiteUrlForGivenUrl.

@Test
public void shouldSiteUrlForGivenUrl() throws URISyntaxException {
    configHelper.setBaseUrls(new SiteUrl("http://foo.com"), new SecureSiteUrl("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 : 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 14 with SiteUrl

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

the class ServerSiteUrlsConfigRepresenter method fromJson.

public static SiteUrls fromJson(JsonReader jsonReader) {
    String siteUrl = jsonReader.getStringOrDefault("site_url", null);
    String secureSiteUrl = jsonReader.getStringOrDefault("secure_site_url", null);
    return new SiteUrls(new SiteUrl(siteUrl), new SecureSiteUrl(secureSiteUrl));
}
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)

Example 15 with SiteUrl

use of com.thoughtworks.go.domain.SiteUrl 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)

Aggregations

SecureSiteUrl (com.thoughtworks.go.domain.SecureSiteUrl)19 SiteUrl (com.thoughtworks.go.domain.SiteUrl)19 Test (org.junit.jupiter.api.Test)15 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