use of com.thoughtworks.go.domain.SecureSiteUrl in project gocd by gocd.
the class UrlRewriterIntegrationTest method beforeClass.
@BeforeAll
public static void beforeClass() throws Exception {
ServletHelper.init();
httpUtil = new HttpTestUtil(new HttpTestUtil.ContextCustomizer() {
@Override
public void customize(WebAppContext ctx) throws Exception {
wac = mock(WebApplicationContext.class);
ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
ctx.setBaseResource(Resource.newResource(new File("src/main/webapp/WEB-INF/urlrewrite.xml").getParentFile()));
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() {
@Override
public boolean hasAnyUrlConfigured() {
return useConfiguredUrls;
}
@Override
public String siteUrlFor(String url, boolean forceSsl) throws URISyntaxException {
ServerSiteUrlConfig siteUrl = forceSsl ? new SecureSiteUrl(HTTPS_SITE_URL) : new SiteUrl(HTTP_SITE_URL);
return siteUrl.siteUrlFor(url);
}
});
httpUtil.start();
FeatureToggleService featureToggleService = mock(FeatureToggleService.class);
when(featureToggleService.isToggleOn(anyString())).thenReturn(true);
Toggles.initializeWith(featureToggleService);
}
use of com.thoughtworks.go.domain.SecureSiteUrl 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"));
}
use of com.thoughtworks.go.domain.SecureSiteUrl 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"));
}
use of com.thoughtworks.go.domain.SecureSiteUrl 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"));
}
use of com.thoughtworks.go.domain.SecureSiteUrl 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));
}
Aggregations