use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentRegistrationControllerTest method shouldRegisterWithProvidedAgentInformation.
@Test
public void shouldRegisterWithProvidedAgentInformation() {
when(agentService.isRegistered("blahAgent-uuid")).thenReturn(false);
ServerConfig serverConfig = mockedServerConfig("token-generation-key", "someKey");
when(goConfigService.serverConfig()).thenReturn(serverConfig);
when(agentService.createAgentUsername("blahAgent-uuid", request.getRemoteAddr(), "blahAgent-host")).thenReturn(new Username("some-agent-login-name"));
controller.agentRequest("blahAgent-host", "blahAgent-uuid", "blah-location", "34567", "osx", "", "", "", "", "", "", token("blahAgent-uuid", serverConfig.getTokenGenerationKey()), request);
verify(agentService).requestRegistration(AgentRuntimeInfo.fromServer(new Agent("blahAgent-uuid", "blahAgent-host", request.getRemoteAddr()), false, "blah-location", 34567L, "osx"));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentRegistrationControllerTest method shouldAutoRegisterAgentWithHostnameFromAutoRegisterProperties.
@Test
public void shouldAutoRegisterAgentWithHostnameFromAutoRegisterProperties() {
String uuid = "uuid";
when(agentService.isRegistered(uuid)).thenReturn(false);
ServerConfig serverConfig = mockedServerConfig("token-generation-key", "someKey");
when(goConfigService.serverConfig()).thenReturn(serverConfig);
when(agentService.createAgentUsername(uuid, request.getRemoteAddr(), "autoregister-hostname")).thenReturn(new Username("some-agent-login-name"));
controller.agentRequest("host", uuid, "location", "233232", "osx", "someKey", "", "", "autoregister-hostname", "", "", token(uuid, serverConfig.getTokenGenerationKey()), request);
verify(agentService).requestRegistration(AgentRuntimeInfo.fromServer(new Agent(uuid, "autoregister-hostname", request.getRemoteAddr()), false, "location", 233232L, "osx"));
verify(agentService).register(any(Agent.class));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentRegistrationControllerTest method shouldAutoRegisterAgent.
@Test
public void shouldAutoRegisterAgent() {
String uuid = "uuid";
final ServerConfig serverConfig = mockedServerConfig("token-generation-key", "someKey");
final String token = token(uuid, serverConfig.getTokenGenerationKey());
when(agentService.isRegistered(uuid)).thenReturn(false);
when(goConfigService.serverConfig()).thenReturn(serverConfig);
when(agentService.createAgentUsername(uuid, request.getRemoteAddr(), "host")).thenReturn(new Username("some-agent-login-name"));
controller.agentRequest("host", uuid, "location", "233232", "osx", "someKey", "", "", "", "", "", token, request);
verify(agentService).requestRegistration(AgentRuntimeInfo.fromServer(new Agent(uuid, "host", request.getRemoteAddr()), false, "location", 233232L, "osx"));
verify(agentService).register(any(Agent.class));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class JobPresentationServiceTest method shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig.
@Test
public void shouldReturnJobModelForAnAgentThatIsNoMoreAvailableInTheConfig() {
String deletedAgentUuid = "deleted_agent";
JobInstance jobWithDeletedAgent = assignedWithAgentId("dev", deletedAgentUuid);
when(agentService.findAgentAndRefreshStatus(deletedAgentUuid)).thenReturn(null);
Agent agentFromDb = new Agent(deletedAgentUuid, "hostname", "1.2.3.4", "cookie");
when(agentService.findAgentByUUID(deletedAgentUuid)).thenReturn(agentFromDb);
List<JobInstanceModel> models = new JobPresentationService(jobDurationStrategy, agentService).jobInstanceModelFor(new JobInstances(jobWithDeletedAgent));
assertThat(models.size(), is(1));
assertThat(models.get(0), is(new JobInstanceModel(jobWithDeletedAgent, jobDurationStrategy, agentFromDb)));
verify(agentService, times(1)).findAgentAndRefreshStatus(deletedAgentUuid);
verify(agentService, times(1)).findAgentByUUID(deletedAgentUuid);
verifyNoMoreInteractions(agentService);
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentMother method elasticAgent.
public static Agent elasticAgent() {
Agent agent = new Agent(UUID.randomUUID().toString(), UUID.randomUUID().toString(), "127.0.0.1", UUID.randomUUID().toString());
agent.setElasticAgentId(UUID.randomUUID().toString());
agent.setElasticPluginId(UUID.randomUUID().toString());
return agent;
}
Aggregations