use of com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient in project gocd by gocd.
the class RemoteRegistrationRequesterTest method shouldPassAllParametersToPostForRegistrationOfNonElasticAgent.
@Test
public void shouldPassAllParametersToPostForRegistrationOfNonElasticAgent() throws IOException, ClassNotFoundException {
String url = "http://cruise.com/go";
GoAgentServerHttpClient httpClient = mock(GoAgentServerHttpClient.class);
when(httpClient.execute(argThat(isA(HttpUriRequest.class)))).thenReturn(mock(CloseableHttpResponse.class));
final DefaultAgentRegistry defaultAgentRegistry = new DefaultAgentRegistry();
Properties properties = new Properties();
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_KEY, "t0ps3cret");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_RESOURCES, "linux, java");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_ENVIRONMENTS, "uat, staging");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_HOSTNAME, "agent01.example.com");
remoteRegistryRequester(url, httpClient, defaultAgentRegistry, 200).requestRegistration("cruise.com", new AgentAutoRegistrationPropertiesImpl(null, properties));
verify(httpClient).execute(argThat(hasAllParams(defaultAgentRegistry.uuid(), "", "")));
}
use of com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient in project gocd by gocd.
the class SslInfrastructureServiceTest method requesterStub.
private SslInfrastructureService.RemoteRegistrationRequester requesterStub(final Registration registration) {
final SslInfrastructureServiceTest me = this;
final SystemEnvironment systemEnvironment = new SystemEnvironment();
return new SslInfrastructureService.RemoteRegistrationRequester(null, agentRegistryStub(), new GoAgentServerHttpClient(new GoAgentServerHttpClientBuilder(systemEnvironment))) {
protected Registration requestRegistration(String agentHostName, AgentAutoRegistrationProperties agentAutoRegisterProperties) throws IOException, ClassNotFoundException {
LOGGER.debug("Requesting remote registration");
me.remoteCalled = true;
return registration;
}
};
}
use of com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient in project gocd by gocd.
the class AgentUpgradeServiceTest method setUp.
@Before
public void setUp() throws Exception {
systemEnvironment = mock(SystemEnvironment.class);
urlService = mock(URLService.class);
GoAgentServerHttpClient httpClient = mock(GoAgentServerHttpClient.class);
jvmExitter = mock(AgentUpgradeService.JvmExitter.class);
agentUpgradeService = spy(new AgentUpgradeService(urlService, httpClient, systemEnvironment, jvmExitter));
httpMethod = mock(HttpGet.class);
doReturn(httpMethod).when(agentUpgradeService).getAgentLatestStatusGetMethod();
closeableHttpResponse = mock(CloseableHttpResponse.class);
when(closeableHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK"));
when(httpClient.execute(httpMethod)).thenReturn(closeableHttpResponse);
}
use of com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient in project gocd by gocd.
the class HttpService method execute.
public CloseableHttpResponse execute(HttpRequestBase httpMethod) throws IOException {
GoAgentServerHttpClient client = httpClientFactory.httpClient();
CloseableHttpResponse response = client.execute(httpMethod);
LOGGER.info("Got back " + response.getStatusLine().getStatusCode() + " from server");
return response;
}
use of com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient in project gocd by gocd.
the class RemoteRegistrationRequesterTest method shouldPassAllParametersToPostForRegistrationOfElasticAgent.
@Test
public void shouldPassAllParametersToPostForRegistrationOfElasticAgent() throws IOException, ClassNotFoundException {
String url = "http://cruise.com/go";
GoAgentServerHttpClient httpClient = mock(GoAgentServerHttpClient.class);
when(httpClient.execute(argThat(isA(HttpUriRequest.class)))).thenReturn(mock(CloseableHttpResponse.class));
final DefaultAgentRegistry defaultAgentRegistry = new DefaultAgentRegistry();
Properties properties = new Properties();
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_KEY, "t0ps3cret");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_RESOURCES, "linux, java");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_ENVIRONMENTS, "uat, staging");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_HOSTNAME, "agent01.example.com");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_ELASTIC_AGENT_ID, "42");
properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_ELASTIC_PLUGIN_ID, "tw.go.elastic-agent.docker");
remoteRegistryRequester(url, httpClient, defaultAgentRegistry, 200).requestRegistration("cruise.com", new AgentAutoRegistrationPropertiesImpl(null, properties));
verify(httpClient).execute(argThat(hasAllParams(defaultAgentRegistry.uuid(), "42", "tw.go.elastic-agent.docker")));
}
Aggregations