use of net.ripe.rpki.validator3.domain.ValidationCheck in project rpki-validator-3 by RIPE-NCC.
the class RrdpServiceTest method should_parse_notification_use_delta_the_last_delta_serial_is_not_matching_fallback_to_snapshot.
@Test
public void should_parse_notification_use_delta_the_last_delta_serial_is_not_matching_fallback_to_snapshot() {
final byte[] certificate = Objects.aParseableCertificate();
final String sessionId = UUID.randomUUID().toString();
final Objects.Publish crl = new Objects.Publish("rsync://host/path/crl1.crl", Objects.aParseableCrl());
rrdpClient.add(crl.uri, crl.content);
final byte[] snapshotXml = Objects.snapshotXml(4, sessionId, crl);
final Objects.SnapshotInfo emptySnapshot = new Objects.SnapshotInfo("https://host/path/snapshot.xml", Sha256.hash(snapshotXml));
rrdpClient.add(emptySnapshot.uri, snapshotXml);
final Objects.DeltaPublish publishCert = new Objects.DeltaPublish("rsync://host/path/cert.cer", certificate);
final byte[] deltaXml1 = Objects.deltaXml(2, sessionId, publishCert);
final Objects.DeltaPublish republishCert = new Objects.DeltaPublish("rsync://host/path/cert.cer", Sha256.hash(publishCert.content), certificate);
final byte[] deltaXml2 = Objects.deltaXml(3, sessionId, republishCert);
final Objects.DeltaInfo deltaInfo1 = new Objects.DeltaInfo("https://host/path/delta1.xml", Sha256.hash(deltaXml1), 2);
final Objects.DeltaInfo deltaInfo2 = new Objects.DeltaInfo("https://host/path/delta2.xml", Sha256.hash(deltaXml2), 3);
rrdpClient.add(deltaInfo1.uri, deltaXml1);
rrdpClient.add(deltaInfo2.uri, deltaXml2);
final String notificationUri = "https://rrdp.ripe.net/notification.xml";
rrdpClient.add(notificationUri, Objects.notificationXml(4, sessionId, emptySnapshot, deltaInfo1, deltaInfo2));
final TrustAnchor trustAnchor = TestObjects.newTrustAnchor();
entityManager.persist(trustAnchor);
// make current serial lower to trigger delta download
final RpkiRepository rpkiRepository = makeRpkiRepository(sessionId, notificationUri, trustAnchor);
// do the first run to get the snapshot
final RrdpRepositoryValidationRun validationRun = new RrdpRepositoryValidationRun(rpkiRepository);
subject.storeRepository(rpkiRepository, validationRun);
assertEquals(1, validationRun.getValidationChecks().size());
final ValidationCheck validationCheck = validationRun.getValidationChecks().get(0);
assertEquals(ErrorCodes.RRDP_FETCH_DELTAS, validationCheck.getKey());
assertEquals(ValidationCheck.Status.WARNING, validationCheck.getStatus());
assertEquals(rpkiRepository.getRrdpNotifyUri(), validationCheck.getLocation());
assertEquals("The last delta serial is 3, notification file serial is 4", validationCheck.getParameters().get(0));
final List<RpkiObject> objects = rpkiObjects.all().collect(Collectors.toList());
assertEquals(1, objects.size());
final RpkiObject rpkiObject = objects.get(0);
assertEquals(RpkiObject.Type.CRL, rpkiObject.getType());
assertEquals(Sets.newHashSet("rsync://host/path/crl1.crl"), rpkiObject.getLocations());
}
use of net.ripe.rpki.validator3.domain.ValidationCheck in project rpki-validator-3 by RIPE-NCC.
the class RrdpService method applyDeltaWithdraw.
private void applyDeltaWithdraw(RpkiRepositoryValidationRun validationRun, String uri, DeltaWithdraw deltaWithdraw) {
final Optional<RpkiObject> maybeObject = rpkiObjectRepository.findBySha256(deltaWithdraw.getHash());
if (maybeObject.isPresent()) {
maybeObject.get().removeLocation(uri);
} else {
ValidationCheck validationCheck = new ValidationCheck(validationRun, uri, ValidationCheck.Status.ERROR, ErrorCodes.RRDP_WITHDRAW_NONEXISTENT_OBJECT, Hex.format(deltaWithdraw.getHash()));
validationRun.addCheck(validationCheck);
}
}
use of net.ripe.rpki.validator3.domain.ValidationCheck in project rpki-validator-3 by RIPE-NCC.
the class RrdpService method applyDeltaPublish.
private void applyDeltaPublish(RpkiRepositoryValidationRun validationRun, String uri, DeltaPublish deltaPublish) {
if (deltaPublish.getHash().isPresent()) {
final byte[] sha256 = deltaPublish.getHash().get();
final Optional<RpkiObject> existing = rpkiObjectRepository.findBySha256(sha256);
if (existing.isPresent()) {
addRpkiObject(validationRun, uri, deltaPublish, sha256);
} else {
ValidationCheck validationCheck = new ValidationCheck(validationRun, uri, ValidationCheck.Status.ERROR, ErrorCodes.RRDP_REPLACE_NONEXISTENT_OBJECT, Hex.format(sha256));
validationRun.addCheck(validationCheck);
}
} else {
addRpkiObject(validationRun, uri, deltaPublish, null);
}
}
use of net.ripe.rpki.validator3.domain.ValidationCheck in project rpki-validator-3 by RIPE-NCC.
the class TrustAnchorValidationServiceTest method test_empty_file.
@Test
public void test_empty_file() {
TrustAnchor ta = createRipeNccTrustAnchor();
trustAnchors.add(ta);
ta.setLocations(Arrays.asList("src/test/resources/empty-file.cer"));
subject.validate(ta.getId());
ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
assertThat(ta.getCertificate()).isNull();
Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
assertThat(validationRun).isPresent();
List<ValidationCheck> validationChecks = validationRun.get().getValidationChecks();
assertThat(validationChecks).hasSize(1);
assertThat(validationChecks.get(0).getKey()).isEqualTo(ErrorCodes.REPOSITORY_OBJECT_MINIMUM_SIZE);
}
use of net.ripe.rpki.validator3.domain.ValidationCheck in project rpki-validator-3 by RIPE-NCC.
the class TrustAnchorValidationServiceTest method test_rsync_failure.
@Test
public void test_rsync_failure() {
TrustAnchor ta = createRipeNccTrustAnchor();
ta.setLocations(Arrays.asList(DUMMY_RSYNC_URI));
trustAnchors.add(ta);
subject.validate(ta.getId());
assertThat(ta.getCertificate()).isNull();
Optional<TrustAnchorValidationRun> validationRun = validationRuns.findLatestCompletedForTrustAnchor(ta);
assertThat(validationRun).isPresent();
List<ValidationCheck> validationChecks = validationRun.get().getValidationChecks();
assertThat(validationChecks).hasSize(1);
assertThat(validationChecks.get(0).getKey()).isEqualTo(ErrorCodes.RSYNC_FETCH);
}
Aggregations