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;
}
};
}
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"));
}
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));
}
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));
}
Aggregations