@Test public void getSshCredentials () throws Exception { CloudFoundryContainer container; Integer index = new Random().nextInt(100) + 1; String applicationId = UUID.randomUUID().toString(); String fakePassword = UUID.randomUUID().toString(); container = CloudFoundryContainer.builder().applicationId(applicationId).instance(index).build(); SSHCredentials credentials = cloudFoundryContainerPlatform.getSshCredentials(container); assertEquals("cf:" + applicationId + "/" + index.toString(), credentials.getUsername()); doReturn(fakePassword).when(cloudFoundryContainerPlatform).getSSHOneTimePassword(); assertEquals(fakePassword, credentials.getPasswordGenerator().call()); assertThat(credentials.getSSHKeys().size(), is(0)); }
@Override public SSHCredentials getSshCredentials (CloudFoundryContainer container) { log.debug("Retrieving SSH Credentials for {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); String username = "cf:" + container.getApplicationId() + '/' + container.getInstance(); Callable<String> passwordGenerator = this::getSSHOneTimePassword; return new ChaosSSHCredentials().withUsername(username).withPasswordGenerator(passwordGenerator).withSupportSudo(false); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public SSHCredentials getSshCredentials (CloudFoundryContainer container) { log.debug("Retrieving SSH Credentials for {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); String username = "cf:" + container.getApplicationId() + '/' + container.getInstance(); Callable<String> passwordGenerator = this::getSSHOneTimePassword; return new ChaosSSHCredentials().withUsername(username).withPasswordGenerator(passwordGenerator).withSupportSudo(false); } }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public SSHCredentials getSshCredentials (CloudFoundryContainer container) { log.debug("Retrieving SSH Credentials for {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); String username = "cf:" + container.getApplicationId() + '/' + container.getInstance(); Callable<String> passwordGenerator = this::getSSHOneTimePassword; return new ChaosSSHCredentials().withUsername(username).withPasswordGenerator(passwordGenerator).withSupportSudo(false); } @Autowired  CloudFoundryContainerPlatform(); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public SSHCredentials getSshCredentials (CloudFoundryContainer container) { log.debug("Retrieving SSH Credentials for {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); String username = "cf:" + container.getApplicationId() + '/' + container.getInstance(); Callable<String> passwordGenerator = this::getSSHOneTimePassword; return new ChaosSSHCredentials().withUsername(username).withPasswordGenerator(passwordGenerator).withSupportSudo(false); } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { @Override public SSHCredentials getSshCredentials (CloudFoundryContainer container) { log.debug("Retrieving SSH Credentials for {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); String username = "cf:" + container.getApplicationId() + '/' + container.getInstance(); Callable<String> passwordGenerator = this::getSSHOneTimePassword; return new ChaosSSHCredentials().withUsername(username).withPasswordGenerator(passwordGenerator).withSupportSudo(false); } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container);  }