@Test public void should_parse_notification_verify_snapshot_hash() { final Objects.Publish cert = new Objects.Publish("rsync: final Objects.Publish crl = new Objects.Publish("rsync: rrdpClient.add(cert.uri, cert.content); rrdpClient.add(crl.uri, crl.content); final int serial = 1; final String sessionId = UUID.randomUUID().toString(); final byte[] snapshotXml = Objects.snapshotXml(serial, sessionId, cert, crl); final Objects.SnapshotInfo snapshot = new Objects.SnapshotInfo(SNAPSHOT_URL, Hex.parse("FFFFFF")); rrdpClient.add(snapshot.uri, snapshotXml); final byte[] notificationXml = Objects.notificationXml(serial, sessionId, snapshot); rrdpClient.add(RRDP_RIPE_NET_NOTIFICATION_XML, notificationXml); final TrustAnchor trustAnchor = TestObjects.newTrustAnchor(); wtx0(tx -> this.getTrustAnchors().add(tx, trustAnchor)); final Ref<TrustAnchor> trustAnchorRef = rtx(tx -> this.getTrustAnchors().makeRef(tx, trustAnchor.key())); RpkiRepository rpkiRepository = wtx(tx -> this.getRpkiRepositories().register(tx, trustAnchorRef, RRDP_RIPE_NET_NOTIFICATION_XML, RpkiRepository.Type.RRDP)); rpkiRepository.setRrdpSerial(BigInteger.valueOf(serial)); Ref<RpkiRepository> rpkiRepositoryRef = rtx(tx -> this.getRpkiRepositories().makeRef(tx, rpkiRepository.key())); final RrdpRepositoryValidationRun validationRun = new RrdpRepositoryValidationRun(rpkiRepositoryRef); subject.storeRepository(rpkiRepository, validationRun); final List<RpkiObject> objects = rtx(tx -> this.getRpkiObjects().values(tx)); assertEquals(0, objects.size()); assertEquals(1, validationRun.getValidationChecks().size()); final ValidationCheck validationCheck = validationRun.getValidationChecks().get(0); assertEquals(ErrorCodes.RRDP_FETCH, validationCheck.getKey()); assertEquals(ValidationCheck.Status.ERROR, validationCheck.getStatus()); assertEquals("Hash of the snapshot file " + SNAPSHOT_URL + " is " + Hex.format(Sha256.hash(snapshotXml)) + ", but notification file says FFFFFF", validationCheck.getParameters().get(0)); assertEquals(rpkiRepository.getRrdpNotifyUri(), validationCheck.getLocation()); }
@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);  }