@Test public void should_parse_notification_use_delta_mismatching_delta_hash_fallback_to_snapshot() { final byte[] certificate = Objects.aParseableCertificate(); final String sessionId = UUID.randomUUID().toString(); final Objects.Publish crl = new Objects.Publish("rsync: rrdpClient.add(crl.uri, crl.content); final byte[] snapshotXml = Objects.snapshotXml(3, sessionId, crl); final Objects.SnapshotInfo emptySnapshot = new Objects.SnapshotInfo(SNAPSHOT_URL, Sha256.hash(snapshotXml)); rrdpClient.add(emptySnapshot.uri, snapshotXml); final Objects.DeltaPublish publishCert = new Objects.DeltaPublish("rsync: final byte[] deltaXml1 = Objects.deltaXml(3, sessionId, publishCert); final Objects.DeltaInfo deltaInfo1 = new Objects.DeltaInfo("https: rrdpClient.add(deltaInfo1.uri, deltaXml1); final String notificationUri = RRDP_RIPE_NET_NOTIFICATION_XML; rrdpClient.add(notificationUri, Objects.notificationXml(3, sessionId, emptySnapshot, deltaInfo1)); final TrustAnchor trustAnchor = TestObjects.newTrustAnchor(); wtx0(tx -> this.getTrustAnchors().add(tx, trustAnchor)); final RpkiRepository rpkiRepository = makeRpkiRepository(sessionId, notificationUri, trustAnchor); Ref<RpkiRepository> rpkiRepositoryRef = rtx(tx -> this.getRpkiRepositories().makeRef(tx, rpkiRepository.key())); final RrdpRepositoryValidationRun validationRun = wtx(tx -> this.getValidationRuns().add(tx, new RrdpRepositoryValidationRun(rpkiRepositoryRef))); subject.storeRepository(rpkiRepository, validationRun); assertEquals(1, validationRun.getValidationChecks().size()); final ValidationCheck validationCheck = validationRun.getValidationChecks().get(0); assertEquals(ErrorCodes.RRDP_WRONG_DELTA_HASH, validationCheck.getKey()); assertEquals(ValidationCheck.Status.WARNING, validationCheck.getStatus()); assertEquals(rpkiRepository.getRrdpNotifyUri(), validationCheck.getLocation()); assertTrue(validationCheck.getParameters().get(0).startsWith("Hash of the delta file")); assertTrue(validationCheck.getParameters().get(0).contains("is " + Hex.format(Sha256.hash(deltaXml1)) + ", but notification file says FFFFFFFF")); final List<RpkiObject> objects = rtx(tx -> this.getRpkiObjects().values(tx)); assertEquals(1, objects.size()); final RpkiObject rpkiObject = objects.get(0); assertEquals(RpkiObject.Type.CRL, rpkiObject.getType()); rtx0(tx -> assertEquals(Sets.newHashSet("rsync: }
@Override public boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun) { Pair<Boolean, Long> timed = Time.timed(() -> { try { return doStoreRepository(rpkiRepository, validationRun); } catch (RrdpException e) { log.warn("Error retrieving RRDP repository at {}: " + e.getMessage(), rpkiRepository.getRrdpNotifyUri()); ValidationCheck validationCheck = new ValidationCheck(rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.ERROR, ErrorCodes.RRDP_FETCH, e.getMessage()); validationRun.addCheck(validationCheck); validationRun.setFailed(); } return false; }); log.info("RRDP repository job for {} took {}ms", rpkiRepository.getRrdpNotifyUri(), timed.getRight()); return timed.getLeft(); }
RrdpServiceImpl implements RrdpService { @Override public boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun) { Pair<Boolean, Long> timed = Time.timed(() -> { try { return doStoreRepository(rpkiRepository, validationRun); } catch (RrdpException e) { log.warn("Error retrieving RRDP repository at {}: " + e.getMessage(), rpkiRepository.getRrdpNotifyUri()); ValidationCheck validationCheck = new ValidationCheck(rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.ERROR, ErrorCodes.RRDP_FETCH, e.getMessage()); validationRun.addCheck(validationCheck); validationRun.setFailed(); } return false; }); log.info("RRDP repository job for {} took {}ms", rpkiRepository.getRrdpNotifyUri(), timed.getRight()); return timed.getLeft(); } }
RrdpServiceImpl implements RrdpService { @Override public boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun) { Pair<Boolean, Long> timed = Time.timed(() -> { try { return doStoreRepository(rpkiRepository, validationRun); } catch (RrdpException e) { log.warn("Error retrieving RRDP repository at {}: " + e.getMessage(), rpkiRepository.getRrdpNotifyUri()); ValidationCheck validationCheck = new ValidationCheck(rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.ERROR, ErrorCodes.RRDP_FETCH, e.getMessage()); validationRun.addCheck(validationCheck); validationRun.setFailed(); } return false; }); log.info("RRDP repository job for {} took {}ms", rpkiRepository.getRrdpNotifyUri(), timed.getRight()); return timed.getLeft(); } @Autowired  RrdpServiceImpl(
            final RrdpClient rrdpClient,
            final RpkiObjects rpkiObjects,
            final RpkiRepositories rpkiRepositories,
            final Storage storage,
            final RrdpMetricsService rrdpMetrics
    ); }
RrdpServiceImpl implements RrdpService { @Override public boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun) { Pair<Boolean, Long> timed = Time.timed(() -> { try { return doStoreRepository(rpkiRepository, validationRun); } catch (RrdpException e) { log.warn("Error retrieving RRDP repository at {}: " + e.getMessage(), rpkiRepository.getRrdpNotifyUri()); ValidationCheck validationCheck = new ValidationCheck(rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.ERROR, ErrorCodes.RRDP_FETCH, e.getMessage()); validationRun.addCheck(validationCheck); validationRun.setFailed(); } return false; }); log.info("RRDP repository job for {} took {}ms", rpkiRepository.getRrdpNotifyUri(), timed.getRight()); return timed.getLeft(); } @Autowired  RrdpServiceImpl(
            final RrdpClient rrdpClient,
            final RpkiObjects rpkiObjects,
            final RpkiRepositories rpkiRepositories,
            final Storage storage,
            final RrdpMetricsService rrdpMetrics
    ); @Override boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun); }
RrdpServiceImpl implements RrdpService { @Override public boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun) { Pair<Boolean, Long> timed = Time.timed(() -> { try { return doStoreRepository(rpkiRepository, validationRun); } catch (RrdpException e) { log.warn("Error retrieving RRDP repository at {}: " + e.getMessage(), rpkiRepository.getRrdpNotifyUri()); ValidationCheck validationCheck = new ValidationCheck(rpkiRepository.getRrdpNotifyUri(), ValidationCheck.Status.ERROR, ErrorCodes.RRDP_FETCH, e.getMessage()); validationRun.addCheck(validationCheck); validationRun.setFailed(); } return false; }); log.info("RRDP repository job for {} took {}ms", rpkiRepository.getRrdpNotifyUri(), timed.getRight()); return timed.getLeft(); } @Autowired  RrdpServiceImpl(
            final RrdpClient rrdpClient,
            final RpkiObjects rpkiObjects,
            final RpkiRepositories rpkiRepositories,
            final Storage storage,
            final RrdpMetricsService rrdpMetrics
    ); @Override boolean storeRepository(final RpkiRepository rpkiRepository, final RpkiRepositoryValidationRun validationRun);  }