fix(import): подтвердить обязательные гарантии второго эпика
This commit is contained in:
1 parent
31f6f00d3b
commit
ad23cd9a46
33 files changed
+3328
-18
No files matched your search
@@ -30,6 +30,18 @@ pub enum FaultAction {
|
||||
Hold,
|
||||
}
|
||||
|
||||
/// Terminates a debug test process at an explicitly armed transaction boundary.
|
||||
/// Release builds contain neither this hook nor its callers. The checkpoint
|
||||
/// is in-memory only; a request or environment variable cannot arm it.
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn crash_if_checkpointed(stage: &str) {
|
||||
if action(stage) == Some(FaultAction::Exit) {
|
||||
// Deliberately skip destructors/atexit, as a lost process would. Test
|
||||
// containers belong to the parent process, not this child.
|
||||
unsafe { libc::_exit(86) }
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
checkpoint: Option<(String, FaultAction, usize)>,
|
||||
hits: BTreeMap<String, usize>,
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -355,16 +355,19 @@ fn real_process_write_limit_leaves_no_partial_final_blob() {
|
||||
}
|
||||
|
||||
let root = TestRoot::new("real-write-limit");
|
||||
let status = Command::new(std::env::current_exe().unwrap())
|
||||
// Capture the child's stdout/stderr with pipes: the child lowers
|
||||
// RLIMIT_FSIZE to 1 byte, which would otherwise make libtest's own
|
||||
// result write fail with EFBIG against an inherited regular log file.
|
||||
let output = Command::new(std::env::current_exe().unwrap())
|
||||
.args([
|
||||
"--exact",
|
||||
"real_process_write_limit_leaves_no_partial_final_blob",
|
||||
"--nocapture",
|
||||
])
|
||||
.env("CRANK_ARTIFACTS_CHILD_ROOT", &root.0)
|
||||
.status()
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
assert!(output.status.success(), "child status: {}", output.status);
|
||||
|
||||
let store = ArtifactStore::open(&root.0).unwrap();
|
||||
let expected =
|
||||
|
||||
Reference in new issue
Block a user