Search in sources :

Example 1 with SecureSiteUrl

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

the class WebBasedPluginAuthenticationProviderTest method shouldGetAuthorizationServerUrlWithConfiguredSecureSiteUrl.

@Test
void shouldGetAuthorizationServerUrlWithConfiguredSecureSiteUrl() {
    final ServerConfig serverConfig = mock(ServerConfig.class);
    when(goConfigService.serverConfig()).thenReturn(serverConfig);
    when(serverConfig.hasAnyUrlConfigured()).thenReturn(true);
    when(serverConfig.getSiteUrlPreferablySecured()).thenReturn(new SecureSiteUrl("https://foo.bar.com"));
    authenticationProvider.getAuthorizationServerUrl(PLUGIN_ID, "https://example.com");
    verify(authorizationExtension, never()).getAuthorizationServerUrl(PLUGIN_ID, singletonList(githubSecurityAuthconfig), "https://example.com");
    verify(authorizationExtension).getAuthorizationServerUrl(PLUGIN_ID, singletonList(githubSecurityAuthconfig), "https://foo.bar.com");
}
Also used : SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) Test(org.junit.jupiter.api.Test)

Example 2 with SecureSiteUrl

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

the class ArtifactsDiskSpaceFullCheckerTest method configWithSiteUrl.

private static CruiseConfig configWithSiteUrl() {
    ServerConfig serverConfig = new ServerConfig(null, null, new SiteUrl("http://test.host"), new SecureSiteUrl("https://test.host"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(serverConfig);
    return cruiseConfig;
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) 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)

Example 3 with SecureSiteUrl

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

the class DiskSpaceFullCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.

@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
    String expectedHelpUrl = docsUrl("/installation/configuring_server_details.html");
    ServerConfig serverConfig = new ServerConfig(null, null, new SiteUrl("http://test.host"), new SecureSiteUrl("https://test.host"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(serverConfig);
    GoConfigService goConfigService = mock(GoConfigService.class);
    when(goConfigService.artifactsDir()).thenReturn(null);
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(goConfigService.adminEmail()).thenReturn("admin@email.com");
    ArtifactsDiskSpaceFullChecker diskSpaceFullChecker = new ArtifactsDiskSpaceFullChecker(new SystemEnvironment(), null, goConfigService, null) {

        @Override
        protected String targetFolderCanonicalPath() {
            return "";
        }
    };
    SendEmailMessage actual = diskSpaceFullChecker.createEmail();
    assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) 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 4 with SecureSiteUrl

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

the class ServerConfigTest method shouldIgnoreErrorsFieldOnEquals.

@Test
public void shouldIgnoreErrorsFieldOnEquals() throws Exception {
    ServerConfig one = new ServerConfig(new SecurityConfig(), new MailHost(new GoCipher()), new SiteUrl("siteURL"), new SecureSiteUrl("secureURL"));
    one.addError("siteUrl", "I dont like this url");
    assertThat(one, is(new ServerConfig(new SecurityConfig(), new MailHost(new GoCipher()), new SiteUrl("siteURL"), new SecureSiteUrl("secureURL"))));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) 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 5 with SecureSiteUrl

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

the class ServerConfigTest method shouldReturnAnEmptyForSecureSiteUrlIfOnlySiteUrlIsConfigured.

@Test
public void shouldReturnAnEmptyForSecureSiteUrlIfOnlySiteUrlIsConfigured() throws Exception {
    ServerConfig serverConfig = new ServerConfig(null, null, new SiteUrl("http://foo.bar:813"), new SecureSiteUrl());
    assertThat(serverConfig.getHttpsUrl(), is(new SecureSiteUrl()));
}
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