20260326 完成数据库model迁移;20260327 增加一键replay脚本
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
use std::path::Path;
|
||||
|
||||
use sha2::Digest;
|
||||
|
||||
use rpki::data_model::manifest::ManifestObject;
|
||||
use rpki::policy::{CaFailedFetchPolicy, Policy};
|
||||
use rpki::storage::RocksStore;
|
||||
use rpki::storage::{RawByHashEntry, RepositoryViewEntry, RepositoryViewState, RocksStore};
|
||||
use rpki::validation::manifest::process_manifest_publication_point;
|
||||
|
||||
fn issuer_ca_fixture() -> Vec<u8> {
|
||||
@@ -16,6 +18,26 @@ fn issuer_ca_rsync_uri() -> &'static str {
|
||||
"rsync://rpki.apnic.net/repository/B527EF581D6611E2BB468F7C72FD1FF2/BfycW4hQb3wNP4YsiJW-1n6fjro.cer"
|
||||
}
|
||||
|
||||
fn put_current_object(store: &RocksStore, rsync_uri: &str, bytes: Vec<u8>, object_type: &str) {
|
||||
let sha256_hex = hex::encode(sha2::Sha256::digest(&bytes));
|
||||
let mut raw_entry = RawByHashEntry::from_bytes(sha256_hex.clone(), bytes);
|
||||
raw_entry.origin_uris.push(rsync_uri.to_string());
|
||||
raw_entry.object_type = Some(object_type.to_string());
|
||||
raw_entry.encoding = Some("der".to_string());
|
||||
store
|
||||
.put_raw_by_hash_entry(&raw_entry)
|
||||
.expect("store raw_by_hash");
|
||||
store
|
||||
.put_repository_view_entry(&RepositoryViewEntry {
|
||||
rsync_uri: rsync_uri.to_string(),
|
||||
current_hash: Some(sha256_hex),
|
||||
repository_source: Some("https://example.test/notification.xml".to_string()),
|
||||
object_type: Some(object_type.to_string()),
|
||||
state: RepositoryViewState::Present,
|
||||
})
|
||||
.expect("store repository view");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn manifest_outside_publication_point_is_failed_fetch_rfc9286_section6_1() {
|
||||
let fixture_manifest_path = Path::new(
|
||||
@@ -35,9 +57,7 @@ fn manifest_outside_publication_point_is_failed_fetch_rfc9286_section6_1() {
|
||||
let store = RocksStore::open(temp.path()).expect("open rocksdb");
|
||||
|
||||
// Store the manifest at its rsync URI.
|
||||
store
|
||||
.put_raw(manifest_rsync_uri, &manifest_bytes)
|
||||
.expect("store manifest raw");
|
||||
put_current_object(&store, manifest_rsync_uri, manifest_bytes.clone(), "mft");
|
||||
|
||||
// Store all referenced files under the (different) publication point so that §6.4/§6.5
|
||||
// would otherwise succeed if §6.1 was not enforced.
|
||||
@@ -50,7 +70,8 @@ fn manifest_outside_publication_point_is_failed_fetch_rfc9286_section6_1() {
|
||||
let bytes = std::fs::read(&file_path)
|
||||
.unwrap_or_else(|_| panic!("read fixture file referenced by manifest: {file_path:?}"));
|
||||
let rsync_uri = format!("{publication_point_rsync_uri}{}", entry.file_name);
|
||||
store.put_raw(&rsync_uri, &bytes).expect("store file raw");
|
||||
let object_type = rsync_uri.rsplit('.').next().unwrap_or("bin");
|
||||
put_current_object(&store, &rsync_uri, bytes, object_type);
|
||||
}
|
||||
|
||||
let mut policy = Policy::default();
|
||||
|
||||
Reference in New Issue
Block a user