Search in sources :

Example 1 with AgentAutoRegistrationPropertiesImpl

use of com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl 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(), "", "")));
}
Also used : AgentAutoRegistrationPropertiesImpl(com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) GoAgentServerHttpClient(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient) DefaultAgentRegistry(com.thoughtworks.go.config.DefaultAgentRegistry) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with AgentAutoRegistrationPropertiesImpl

use of com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl in project gocd by gocd.

the class SslInfrastructureServiceTest method shouldInvalidateKeystore.

@Test
public void shouldInvalidateKeystore() throws Exception {
    folder.create();
    File configFile = folder.newFile();
    shouldCreateSslInfrastucture();
    sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
    assertThat(GoAgentServerClientBuilder.AGENT_CERTIFICATE_FILE, exists());
    assertRemoteCalled();
    sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
    assertRemoteNotCalled();
    sslInfrastructureService.invalidateAgentCertificate();
    sslInfrastructureService.registerIfNecessary(new AgentAutoRegistrationPropertiesImpl(configFile));
    assertRemoteCalled();
}
Also used : AgentAutoRegistrationPropertiesImpl(com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl) File(java.io.File) Test(org.junit.Test)

Example 3 with AgentAutoRegistrationPropertiesImpl

use of com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl 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")));
}
Also used : AgentAutoRegistrationPropertiesImpl(com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) GoAgentServerHttpClient(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient) DefaultAgentRegistry(com.thoughtworks.go.config.DefaultAgentRegistry) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

AgentAutoRegistrationPropertiesImpl (com.thoughtworks.go.agent.AgentAutoRegistrationPropertiesImpl)3 Test (org.junit.Test)3 GoAgentServerHttpClient (com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient)2 DefaultAgentRegistry (com.thoughtworks.go.config.DefaultAgentRegistry)2 Properties (java.util.Properties)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 File (java.io.File)1