Search in sources :

Example 1 with SshCredentials

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());
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) SshCredentials(org.jboss.pnc.spi.SshCredentials) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Aggregations

BuildRecord (org.jboss.pnc.model.BuildRecord)1 BuildResult (org.jboss.pnc.spi.BuildResult)1 SshCredentials (org.jboss.pnc.spi.SshCredentials)1 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)1 EnvironmentDriverResult (org.jboss.pnc.spi.environment.EnvironmentDriverResult)1 Test (org.junit.Test)1