use of org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint in project sw360portal by sw360.
the class FossologyHostKeyRepositoryTest method testCheckAValidNewKeyIsSavedAsUntrusted.
@Test
public void testCheckAValidNewKeyIsSavedAsUntrusted() throws Exception {
when(connector.getAll()).thenReturn(Collections.<FossologyHostFingerPrint>emptyList());
String host = "host";
byte[] key = GOOD_KEY.getBytes();
final String expectedFingerPrint = new HostKey(host, key).getFingerPrint(jSch);
assertThat(expectedFingerPrint, not(isEmptyOrNullString()));
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
FossologyHostFingerPrint fingerPrint = (FossologyHostFingerPrint) invocation.getArguments()[0];
assertThat(fingerPrint.getFingerPrint(), is(expectedFingerPrint));
assertFalse(fingerPrint.isTrusted());
return null;
}
}).when(connector).add(any(FossologyHostFingerPrint.class));
assertThat(repo.check(host, key), is(HostKeyRepository.NOT_INCLUDED));
verify(connector).getAll();
verify(connector).add(any(FossologyHostFingerPrint.class));
}
use of org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint in project sw360portal by sw360.
the class FossologyHostKeyRepositoryTest method testCheckAValidKnownUntrustedKeyIsNotTrusted.
@Test
public void testCheckAValidKnownUntrustedKeyIsNotTrusted() throws Exception {
String host = "host";
byte[] key = GOOD_KEY.getBytes();
final String expectedFingerPrint = new HostKey(host, key).getFingerPrint(jSch);
assertThat(expectedFingerPrint, not(isEmptyOrNullString()));
when(connector.getAll()).thenReturn(ImmutableList.of(new FossologyHostFingerPrint().setFingerPrint(expectedFingerPrint).setTrusted(false)));
assertThat(repo.check(host, key), is(HostKeyRepository.NOT_INCLUDED));
verify(connector).getAll();
verify(connector, never()).add(any(FossologyHostFingerPrint.class));
}
Aggregations