Search in sources :

Example 36 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class HeaderConstraintTest method shouldBeUnsatisfiedIfRequiredHeadersAreAbsent.

@Test
public void shouldBeUnsatisfiedIfRequiredHeadersAreAbsent() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    MockHttpServletRequest request = new MockHttpServletRequest();
    when(systemEnvironment.isApiSafeModeEnabled()).thenReturn(true);
    assertFalse(new HeaderConstraint(systemEnvironment).isSatisfied(request));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 37 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class HeaderConstraintTest method shouldBeSatisfiedInPresenceOfRequiredHeader.

@Test
public void shouldBeSatisfiedInPresenceOfRequiredHeader() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    MockHttpServletRequest request = new MockHttpServletRequest();
    when(systemEnvironment.isApiSafeModeEnabled()).thenReturn(true);
    request.addHeader("Confirm", "True");
    assertTrue(new HeaderConstraint(systemEnvironment).isSatisfied(request));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 38 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class HeaderConstraintTest method shouldBeSatisfiedIfAPISafeModeIsTurnedOff.

@Test
public void shouldBeSatisfiedIfAPISafeModeIsTurnedOff() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    MockHttpServletRequest request = new MockHttpServletRequest();
    when(systemEnvironment.isApiSafeModeEnabled()).thenReturn(false);
    request.addHeader("Confirm", "false");
    assertTrue(new HeaderConstraint(systemEnvironment).isSatisfied(request));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Test(org.junit.Test)

Example 39 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class PluginsInitializerTest method setUp.

@Before
public void setUp() throws Exception {
    systemEnvironment = mock(SystemEnvironment.class);
    goPluginsDir = FileSystemUtils.createDirectory("go-plugins");
    when(systemEnvironment.get(SystemEnvironment.PLUGIN_GO_PROVIDED_PATH)).thenReturn(goPluginsDir.getAbsolutePath());
    pluginManager = mock(PluginManager.class);
    pluginsInitializer = new PluginsInitializer(pluginManager, systemEnvironment, new ZipUtil()) {

        @Override
        public void startDaemon() {
        }

        @Override
        ZipInputStream getPluginsZipStream() {
            return new ZipInputStream(getClass().getResourceAsStream("/dummy-plugins.zip"));
        }
    };
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) ZipInputStream(java.util.zip.ZipInputStream) ZipUtil(com.thoughtworks.go.util.ZipUtil) Before(org.junit.Before)

Example 40 with SystemEnvironment

use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.

the class SCMMaterialSourceTest method setUp.

@Before
public void setUp() throws Exception {
    goConfigService = mock(GoConfigService.class);
    systemEnvironment = new SystemEnvironment();
    serverHealthService = mock(ServerHealthService.class);
    materialConfigConverter = mock(MaterialConfigConverter.class);
    materialUpdateService = mock(MaterialUpdateService.class);
    source = new SCMMaterialSource(goConfigService, systemEnvironment, materialConfigConverter, materialUpdateService);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Before(org.junit.Before)

Aggregations

SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)174 Test (org.junit.Test)93 Before (org.junit.Before)38 File (java.io.File)37 AgentInstance (com.thoughtworks.go.domain.AgentInstance)27 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)15 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)14 ArrayList (java.util.ArrayList)14 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)11 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)10 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)10 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)7 Date (java.util.Date)7 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)6