use of com.thoughtworks.go.domain.SiteUrl in project gocd by gocd.
the class SiteUrlsTest method shouldAddErrorsIfSiteUrlsAreInvalid.
@Test
void shouldAddErrorsIfSiteUrlsAreInvalid() {
SiteUrls siteUrls = new SiteUrls(new SiteUrl("htp://foo.bar"), new SecureSiteUrl("http://foo.bar"));
siteUrls.validate(null);
assertThat(siteUrls.getSiteUrl().errors()).hasSize(1).containsEntry("siteUrl", Collections.singletonList("Invalid format for site url. 'htp://foo.bar' must start with http/s"));
assertThat(siteUrls.getSecureSiteUrl().errors()).hasSize(1).containsEntry("secureSiteUrl", Collections.singletonList("Invalid format for secure site url. 'http://foo.bar' must start with https"));
}
use of com.thoughtworks.go.domain.SiteUrl in project gocd by gocd.
the class SiteUrlsTest method shouldAddErrorsIfSiteUrlIsInvalid.
@Test
void shouldAddErrorsIfSiteUrlIsInvalid() {
SiteUrls siteUrls = new SiteUrls(new SiteUrl("htp://foo.bar"), new SecureSiteUrl("https://foo.bar"));
siteUrls.validate(null);
assertThat(siteUrls.getSiteUrl().errors()).hasSize(1).containsEntry("siteUrl", Collections.singletonList("Invalid format for site url. 'htp://foo.bar' must start with http/s"));
}
use of com.thoughtworks.go.domain.SiteUrl in project gocd by gocd.
the class SiteUrlsTest method shouldNotAddErrorsIfSiteUrlsAreValid.
@Test
void shouldNotAddErrorsIfSiteUrlsAreValid() {
SiteUrls siteUrls = new SiteUrls(new SiteUrl("http://foo.bar"), new SecureSiteUrl("https://foo.bar"));
siteUrls.validate(null);
assertThat(siteUrls.errors()).hasSize(0);
}
use of com.thoughtworks.go.domain.SiteUrl in project gocd by gocd.
the class BaseUrlChangeListenerTest method shouldNotFlushCacheWhenBaseUrlConfigIsNotChanged.
@Test
public void shouldNotFlushCacheWhenBaseUrlConfigIsNotChanged() {
GoCache cache = mock(GoCache.class);
BaseUrlChangeListener listener = new BaseUrlChangeListener(new SiteUrl(""), new SecureSiteUrl(""), cache);
CruiseConfig newCruiseConfig = new BasicCruiseConfig();
newCruiseConfig.setServerConfig(serverConfigWith("", ""));
listener.onConfigChange(newCruiseConfig);
verifyNoInteractions(cache);
}
use of com.thoughtworks.go.domain.SiteUrl 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);
}
Aggregations