use of org.jboss.pnc.spi.SshCredentials in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method shouldStoreSshCredentialsOnSshEnabled.
@Test
public void shouldStoreSshCredentialsOnSshEnabled() throws DatastoreException {
BuildTask buildTask = mockBuildTask();
BuildResult buildResult = mockBuildResult(true);
SshCredentials sshCredentials = new SshCredentials();
sshCredentials.setCommand(RandomStringUtils.randomAlphabetic(30));
sshCredentials.setPassword(RandomStringUtils.randomAlphabetic(30));
when(buildResult.getEnvironmentDriverResult()).thenReturn(Optional.of(new EnvironmentDriverResult(CompletionStatus.FAILED, "", Optional.of(sshCredentials))));
when(buildResult.getRepourResult()).thenReturn(Optional.of(RepourResultMock.mock()));
ArgumentGrabbingAnswer<BuildRecord.Builder> answer = new ArgumentGrabbingAnswer<>(BuildRecord.Builder.class);
when(datastore.storeCompletedBuild(any(BuildRecord.Builder.class), any(), any())).thenAnswer(answer);
coordinator.completeBuild(buildTask, buildResult);
assertThat(answer.arguments).hasSize(1);
BuildRecord.Builder builder = answer.arguments.iterator().next();
BuildRecord record = builder.build();
assertThat(record.getSshCommand()).isEqualTo(sshCredentials.getCommand());
assertThat(record.getSshPassword()).isEqualTo(sshCredentials.getPassword());
}
Aggregations