run tree from tal pass
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
use rpki::data_model::crl::RpkixCrl;
|
||||
@@ -7,9 +6,7 @@ use rpki::data_model::rc::ResourceCertificate;
|
||||
use rpki::policy::{Policy, SignedObjectFailurePolicy};
|
||||
use rpki::storage::{PackFile, RocksStore};
|
||||
use rpki::validation::manifest::process_manifest_publication_point;
|
||||
use rpki::validation::objects::{
|
||||
IssuerCaCertificateResolver, ObjectsProcessError, process_verified_publication_point_pack,
|
||||
};
|
||||
use rpki::validation::objects::process_verified_publication_point_pack_for_issuer;
|
||||
|
||||
fn fixture_to_rsync_uri(path: &Path) -> String {
|
||||
let rel = path
|
||||
@@ -33,20 +30,11 @@ fn fixture_dir_to_rsync_uri(dir: &Path) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
struct MapResolver {
|
||||
by_subject_dn: HashMap<String, Vec<u8>>,
|
||||
}
|
||||
|
||||
impl IssuerCaCertificateResolver for MapResolver {
|
||||
fn resolve_by_subject_dn(&self, subject_dn: &str) -> Option<Vec<u8>> {
|
||||
self.by_subject_dn.get(subject_dn).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
fn build_cernet_pack_and_validation_time() -> (
|
||||
rpki::storage::VerifiedPublicationPointPack,
|
||||
time::OffsetDateTime,
|
||||
MapResolver,
|
||||
Vec<u8>,
|
||||
ResourceCertificate,
|
||||
) {
|
||||
let manifest_path = Path::new(
|
||||
"tests/fixtures/repository/rpki.cernet.net/repo/cernet/0/05FC9C5B88506F7C0D3F862C8895BED67E9F8EBA.mft",
|
||||
@@ -109,19 +97,13 @@ fn build_cernet_pack_and_validation_time() -> (
|
||||
}
|
||||
t += time::Duration::seconds(1);
|
||||
|
||||
let mut resolver = MapResolver {
|
||||
by_subject_dn: HashMap::new(),
|
||||
};
|
||||
resolver
|
||||
.by_subject_dn
|
||||
.insert(issuer_ca.tbs.subject_dn, issuer_ca_der);
|
||||
|
||||
(out.pack, t, resolver)
|
||||
(out.pack, t, issuer_ca_der, issuer_ca)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_object_policy_drops_only_failing_object() {
|
||||
let (mut pack, validation_time, resolver) = build_cernet_pack_and_validation_time();
|
||||
let (mut pack, validation_time, issuer_ca_der, issuer_ca) =
|
||||
build_cernet_pack_and_validation_time();
|
||||
|
||||
let valid_roa_uri = pack
|
||||
.files
|
||||
@@ -145,8 +127,15 @@ fn drop_object_policy_drops_only_failing_object() {
|
||||
let mut policy = Policy::default();
|
||||
policy.signed_object_failure_policy = SignedObjectFailurePolicy::DropObject;
|
||||
|
||||
let out = process_verified_publication_point_pack(&pack, &policy, &resolver, validation_time)
|
||||
.expect("drop_object should succeed");
|
||||
let out = process_verified_publication_point_pack_for_issuer(
|
||||
&pack,
|
||||
&policy,
|
||||
&issuer_ca_der,
|
||||
None,
|
||||
issuer_ca.tbs.extensions.ip_resources.as_ref(),
|
||||
issuer_ca.tbs.extensions.as_resources.as_ref(),
|
||||
validation_time,
|
||||
);
|
||||
|
||||
assert!(
|
||||
out.vrps.iter().any(|v| v.asn == 4538),
|
||||
@@ -161,8 +150,9 @@ fn drop_object_policy_drops_only_failing_object() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_publication_point_policy_fails_the_publication_point() {
|
||||
let (mut pack, validation_time, resolver) = build_cernet_pack_and_validation_time();
|
||||
fn drop_publication_point_policy_drops_the_publication_point() {
|
||||
let (mut pack, validation_time, issuer_ca_der, issuer_ca) =
|
||||
build_cernet_pack_and_validation_time();
|
||||
|
||||
let tamper_idx = pack
|
||||
.files
|
||||
@@ -179,11 +169,19 @@ fn drop_publication_point_policy_fails_the_publication_point() {
|
||||
let mut policy = Policy::default();
|
||||
policy.signed_object_failure_policy = SignedObjectFailurePolicy::DropPublicationPoint;
|
||||
|
||||
let err = process_verified_publication_point_pack(&pack, &policy, &resolver, validation_time)
|
||||
.expect_err("drop_publication_point should fail");
|
||||
match err {
|
||||
ObjectsProcessError::PublicationPointDropped { rsync_uri, .. } => {
|
||||
assert_eq!(rsync_uri, victim_uri);
|
||||
}
|
||||
}
|
||||
let out = process_verified_publication_point_pack_for_issuer(
|
||||
&pack,
|
||||
&policy,
|
||||
&issuer_ca_der,
|
||||
None,
|
||||
issuer_ca.tbs.extensions.ip_resources.as_ref(),
|
||||
issuer_ca.tbs.extensions.as_resources.as_ref(),
|
||||
validation_time,
|
||||
);
|
||||
assert!(out.stats.publication_point_dropped);
|
||||
assert!(out.vrps.is_empty(), "expected publication point dropped");
|
||||
assert!(
|
||||
out.audit.iter().any(|a| a.rsync_uri == victim_uri),
|
||||
"expected audit entry for victim object"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user