Search in sources :

Example 1 with AgentAutoRegistrationProperties

use of com.thoughtworks.go.config.AgentAutoRegistrationProperties 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;
        }
    };
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) GoAgentServerHttpClientBuilder(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClientBuilder) GoAgentServerHttpClient(com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient) AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties)

Example 2 with AgentAutoRegistrationProperties

use of com.thoughtworks.go.config.AgentAutoRegistrationProperties in project gocd by gocd.

the class AgentAutoRegistrationPropertiesImplTest method shouldReturnAgentAutoRegisterPropertiesIfPresent.

@Test
public void shouldReturnAgentAutoRegisterPropertiesIfPresent() throws Exception {
    Properties properties = new Properties();
    properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_KEY, "foo");
    properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_RESOURCES, "foo, zoo");
    properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_ENVIRONMENTS, "foo, bar");
    properties.put(AgentAutoRegistrationPropertiesImpl.AGENT_AUTO_REGISTER_HOSTNAME, "agent01.example.com");
    properties.store(new FileOutputStream(configFile), "");
    AgentAutoRegistrationProperties reader = new AgentAutoRegistrationPropertiesImpl(configFile);
    assertThat(reader.agentAutoRegisterKey(), is("foo"));
    assertThat(reader.agentAutoRegisterResources(), is("foo, zoo"));
    assertThat(reader.agentAutoRegisterEnvironments(), is("foo, bar"));
    assertThat(reader.agentAutoRegisterHostname(), is("agent01.example.com"));
}
Also used : FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties) AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties) Test(org.junit.Test)

Example 3 with AgentAutoRegistrationProperties

use of com.thoughtworks.go.config.AgentAutoRegistrationProperties in project gocd by gocd.

the class AgentAutoRegistrationPropertiesImplTest method shouldScrubTheAutoRegistrationProperties.

@Test
public void shouldScrubTheAutoRegistrationProperties() throws Exception {
    String originalContents = "" + "#\n" + "# file autogenerated by chef, any changes will be lost\n" + "#\n" + "# the registration key\n" + "agent.auto.register.key = some secret key\n" + "\n" + "# the resources on this agent\n" + "agent.auto.register.resources = some,resources\n" + "\n" + "# The hostname of this agent\n" + "agent.auto.register.hostname = agent42.example.com\n" + "\n" + "# The environments this agent belongs to\n" + "agent.auto.register.environments = production,blue\n" + "\n";
    FileUtils.write(configFile, originalContents);
    AgentAutoRegistrationProperties properties = new AgentAutoRegistrationPropertiesImpl(configFile);
    properties.scrubRegistrationProperties();
    String newContents = "" + "#\n" + "# file autogenerated by chef, any changes will be lost\n" + "#\n" + "# the registration key\n" + "# The autoregister key has been intentionally removed by Go as a security measure.\n" + "# agent.auto.register.key = some secret key\n" + "\n" + "# the resources on this agent\n" + "# This property has been removed by Go after attempting to auto-register with the Go server.\n" + "# agent.auto.register.resources = some,resources\n" + "\n" + "# The hostname of this agent\n" + "# This property has been removed by Go after attempting to auto-register with the Go server.\n" + "# agent.auto.register.hostname = agent42.example.com\n" + "\n" + "# The environments this agent belongs to\n" + "# This property has been removed by Go after attempting to auto-register with the Go server.\n" + "# agent.auto.register.environments = production,blue\n" + "\n";
    assertThat(FileUtils.readFileToString(configFile), is(newContents));
}
Also used : AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties) Test(org.junit.Test)

Example 4 with AgentAutoRegistrationProperties

use of com.thoughtworks.go.config.AgentAutoRegistrationProperties in project gocd by gocd.

the class AgentAutoRegistrationPropertiesImplTest method shouldReturnEmptyStringIfPropertiesNotPresent.

@Test
public void shouldReturnEmptyStringIfPropertiesNotPresent() {
    AgentAutoRegistrationProperties reader = new AgentAutoRegistrationPropertiesImpl(configFile);
    assertThat(reader.agentAutoRegisterKey().isEmpty(), is(true));
    assertThat(reader.agentAutoRegisterResources().isEmpty(), is(true));
    assertThat(reader.agentAutoRegisterEnvironments().isEmpty(), is(true));
    assertThat(reader.agentAutoRegisterHostname().isEmpty(), is(true));
}
Also used : AgentAutoRegistrationProperties(com.thoughtworks.go.config.AgentAutoRegistrationProperties) Test(org.junit.Test)

Aggregations

AgentAutoRegistrationProperties (com.thoughtworks.go.config.AgentAutoRegistrationProperties)4 Test (org.junit.Test)3 GoAgentServerHttpClient (com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClient)1 GoAgentServerHttpClientBuilder (com.thoughtworks.go.agent.common.ssl.GoAgentServerHttpClientBuilder)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 FileOutputStream (java.io.FileOutputStream)1 Properties (java.util.Properties)1