Search in sources :

Example 1 with FeatureToggleService

use of com.thoughtworks.go.server.service.support.toggle.FeatureToggleService 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);
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) URISyntaxException(java.net.URISyntaxException) SiteUrl(com.thoughtworks.go.domain.SiteUrl) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) WebApplicationContext(org.springframework.web.context.WebApplicationContext) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HttpTestUtil(com.thoughtworks.go.server.util.HttpTestUtil) FeatureToggleService(com.thoughtworks.go.server.service.support.toggle.FeatureToggleService) UrlRewriteFilter(org.tuckey.web.filters.urlrewrite.UrlRewriteFilter) SecureSiteUrl(com.thoughtworks.go.domain.SecureSiteUrl) File(java.io.File) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with FeatureToggleService

use of com.thoughtworks.go.server.service.support.toggle.FeatureToggleService in project gocd by gocd.

the class InitialContextProviderTest method setup.

@BeforeEach
void setup() {
    railsAssetsService = mock(RailsAssetsService.class);
    webpackAssetsService = mock(WebpackAssetsService.class);
    securityService = mock(SecurityService.class);
    versionInfoService = mock(VersionInfoService.class);
    pluginInfoFinder = mock(DefaultPluginInfoFinder.class);
    featureToggleService = mock(FeatureToggleService.class);
    maintenanceModeService = mock(MaintenanceModeService.class);
    serverConfigService = mock(ServerConfigService.class);
    Toggles.initializeWith(featureToggleService);
    initialContextProvider = new InitialContextProvider(railsAssetsService, webpackAssetsService, securityService, versionInfoService, pluginInfoFinder, maintenanceModeService, serverConfigService);
    SessionUtils.setCurrentUser(new GoUserPrinciple("bob", "Bob"));
}
Also used : FeatureToggleService(com.thoughtworks.go.server.service.support.toggle.FeatureToggleService) GoUserPrinciple(com.thoughtworks.go.server.security.userdetail.GoUserPrinciple) DefaultPluginInfoFinder(com.thoughtworks.go.server.service.plugins.builder.DefaultPluginInfoFinder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

FeatureToggleService (com.thoughtworks.go.server.service.support.toggle.FeatureToggleService)2 SecureSiteUrl (com.thoughtworks.go.domain.SecureSiteUrl)1 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)1 SiteUrl (com.thoughtworks.go.domain.SiteUrl)1 GoUserPrinciple (com.thoughtworks.go.server.security.userdetail.GoUserPrinciple)1 DefaultPluginInfoFinder (com.thoughtworks.go.server.service.plugins.builder.DefaultPluginInfoFinder)1 HttpTestUtil (com.thoughtworks.go.server.util.HttpTestUtil)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 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1 UrlRewriteFilter (org.tuckey.web.filters.urlrewrite.UrlRewriteFilter)1