20260617 发布点级验证缓存复用
This commit is contained in:
@@ -339,6 +339,63 @@ fn roa_cache_projection_groups_multiple_outputs_by_roa_uri() {
|
||||
assert_eq!(projection.entries[0].outputs.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publication_point_cache_projection_roundtrips_with_vcir() {
|
||||
let td = tempfile::tempdir().expect("tempdir");
|
||||
let store = RocksStore::open(td.path()).expect("open rocksdb");
|
||||
let vcir = sample_vcir("rsync://example.test/repo/current.mft");
|
||||
let projection = PublicationPointCacheProjection::from_vcir_with_context(
|
||||
&vcir,
|
||||
"rsync://example.test/repo/".to_string(),
|
||||
Some("rsync://example.test/repo/ca.cer".to_string()),
|
||||
sha256_32(b"ca-cert"),
|
||||
sha256_32(b"manifest"),
|
||||
sha256_32(b"ta-context"),
|
||||
sha256_32(b"parent-context"),
|
||||
sha256_32(b"policy"),
|
||||
)
|
||||
.expect("build publication point projection");
|
||||
|
||||
store
|
||||
.put_vcir_with_publication_point_cache_projection(&vcir, Some(&projection))
|
||||
.expect("put vcir with publication point projection");
|
||||
|
||||
let got_vcir = store
|
||||
.get_vcir(&vcir.manifest_rsync_uri)
|
||||
.expect("get vcir")
|
||||
.expect("vcir exists");
|
||||
assert_eq!(got_vcir, vcir);
|
||||
let got_projection = store
|
||||
.get_publication_point_cache_projection(&vcir.manifest_rsync_uri)
|
||||
.expect("get publication point projection")
|
||||
.expect("projection exists");
|
||||
assert_eq!(got_projection, projection);
|
||||
assert_eq!(got_projection.outputs.len(), 2);
|
||||
assert_eq!(got_projection.children.len(), 1);
|
||||
assert_eq!(got_projection.related_objects.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publication_point_cache_projection_rejects_version_mismatch() {
|
||||
let vcir = sample_vcir("rsync://example.test/repo/current.mft");
|
||||
let mut projection = PublicationPointCacheProjection::from_vcir_with_context(
|
||||
&vcir,
|
||||
"rsync://example.test/repo/".to_string(),
|
||||
Some("rsync://example.test/repo/ca.cer".to_string()),
|
||||
sha256_32(b"ca-cert"),
|
||||
sha256_32(b"manifest"),
|
||||
sha256_32(b"ta-context"),
|
||||
sha256_32(b"parent-context"),
|
||||
sha256_32(b"policy"),
|
||||
)
|
||||
.expect("build publication point projection");
|
||||
projection.schema_version = PUBLICATION_POINT_CACHE_SCHEMA_VERSION + 1;
|
||||
assert!(matches!(
|
||||
projection.validate_internal(),
|
||||
Err(StorageError::InvalidData { .. })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn roa_cache_projection_rejects_duplicate_uri_with_different_hash() {
|
||||
let mut vcir = sample_vcir("rsync://example.test/repo/current.mft");
|
||||
|
||||
Reference in New Issue
Block a user