fix(import): подтвердить обязательные гарантии второго эпика
CI / Rust Checks (pull_request) Successful in 24m43s
CI / UI Checks (pull_request) Successful in 6s
CI / Community Image Smoke (pull_request) Successful in 9m5s
CI / Frontend E2E (pull_request) Successful in 12m43s
CI / Deploy (pull_request) Skipped

This commit is contained in:
bsodfather committed 2026-10-10 13:25:05 +03:00
1 parent 31f6f00d3b
commit ad23cd9a46
33 files changed
+3328 -18

No files matched your search

@@ -643,6 +643,47 @@ fn corrupted_or_symlinked_final_never_returns_bytes() {
);
}
#[test]
fn truncated_published_blob_is_integrity_failure_with_safe_diagnostics() {
let root = TestRoot::new("truncated-final");
let store = ArtifactStore::open(&root.0).unwrap();
let source = b"published blob truncated tail".as_slice();
let stored = store.put(source).unwrap();
let path = root
.0
.join("sha256")
.join(&stored.artifact_ref.digest_hex()[..2])
.join(stored.artifact_ref.digest_hex());
assert_eq!(
fs::metadata(&path).unwrap().permissions().mode() & 0o777,
0o400
);
// Publishing leaves the blob read-only. Reopen it writable only long enough
// to truncate the tail, then restore the exact private mode the verified
// reader validates before it compares length and digest.
fs::set_permissions(&path, fs::Permissions::from_mode(0o600)).unwrap();
fs::File::options()
.write(true)
.open(&path)
.unwrap()
.set_len(u64::try_from(source.len() - 4).unwrap())
.unwrap();
fs::set_permissions(&path, fs::Permissions::from_mode(0o400)).unwrap();
assert_eq!(
fs::metadata(&path).unwrap().permissions().mode() & 0o777,
0o400
);
let error = store.read(&stored.artifact_ref).unwrap_err();
assert_eq!(error, ArtifactError::Integrity);
assert_eq!(error.to_string(), "artifact integrity verification failed");
let diagnostic = format!("{error} {error:?}");
assert!(!diagnostic.contains(stored.artifact_ref.digest_hex()));
assert!(!diagnostic.contains(root.0.to_string_lossy().as_ref()));
assert!(!diagnostic.contains("published"));
}
#[test]
fn directory_at_final_digest_is_integrity_failure() {
let root = TestRoot::new("directory-final");