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));
}
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));
}
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));
}
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"));
}
};
}
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);
}
Aggregations