use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkTest method shouldMaskSecretInEnvironmentVarialbeReport.
@Test
public void shouldMaskSecretInEnvironmentVarialbeReport() throws Exception {
buildWork = (BuildWork) getWork(WITH_SECRET_ENV_VAR, PIPELINE_NAME);
buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
String consoleOut = artifactManipulator.consoleOut();
assertThat(consoleOut, containsString("[go] setting environment variable 'foo' to value 'foo(******)'"));
assertThat(consoleOut, containsString("[go] setting environment variable 'bar' to value '********'"));
assertThat(consoleOut, not(containsString("i am a secret")));
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class BuildWorkTest method shouldReportConsoleout.
@Test
public void shouldReportConsoleout() throws Exception {
buildWork = (BuildWork) getWork(WILL_FAIL, PIPELINE_NAME);
buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
String consoleOutAsString = artifactManipulator.consoleOut();
String locator = JOB_IDENTIFIER.buildLocator();
assertThat(consoleOutAsString, printedPreparingInfo(locator));
assertThat(consoleOutAsString, printedBuildingInfo(locator));
assertThat(consoleOutAsString, printedUploadingInfo(locator));
assertThat(consoleOutAsString, printedBuildFailed());
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentRemoteHandlerTest method removeRegisteredAgent.
@Test
public void removeRegisteredAgent() throws Exception {
AgentInstance instance = AgentInstanceMother.idle();
AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
handler.remove(agent);
assertEquals(0, handler.connectedAgents().size());
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentRemoteHandlerTest method reportCompleted.
@Test
public void reportCompleted() throws Exception {
AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("HostName", "ipAddress", "uuid"), AgentRuntimeStatus.Idle, null, null, false);
JobIdentifier jobIdentifier = new JobIdentifier();
handler.process(agent, new Message(Action.reportCompleted, MessageEncoding.encodeData(new Report(info, jobIdentifier, JobResult.Passed))));
verify(remote).reportCompleted(info, jobIdentifier, JobResult.Passed);
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentRemoteHandlerTest method shouldNotSetDupCookieForSameAgent.
@Test
public void shouldNotSetDupCookieForSameAgent() throws Exception {
AgentInstance instance = AgentInstanceMother.idle();
AgentRuntimeInfo info = new AgentRuntimeInfo(instance.getAgentIdentifier(), AgentRuntimeStatus.Idle, null, null, false);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("cookie");
when(agentService.findAgent(instance.getUuid())).thenReturn(instance);
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
info.setCookie(null);
reset(remote);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(withCookie(info, "cookie"));
info.setCookie(null);
handler.remove(agent);
reset(remote);
when(remote.ping(any(AgentRuntimeInfo.class))).thenReturn(new AgentInstruction(false));
when(remote.getCookie(instance.getAgentIdentifier(), info.getLocation())).thenReturn("new cookie");
handler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
verify(remote).ping(withCookie(info, "new cookie"));
}
Aggregations