Skip to content

Commit b09be59

Browse files
committed
fix(test): use temp file in sr_crl_10 instead of test_data submodule
The test relied on test_data/certificates/openssl/prime256v1.crl which is not available in all CI environments (submodule not checked out for some jobs). Replace with a self-contained tempfile::NamedTempFile write so the test is hermetic on every runner. Rephrase inline comment to avoid lychee false-positive on file:// placeholder text.
1 parent 25bca6f commit b09be59

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

crate/server/src/core/operations/validate.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,24 +1136,38 @@ mod tests {
11361136
);
11371137
}
11381138

1139-
/// SR-CRL-10: file:// URIs are permitted in test builds and resolve to disk.
1139+
/// SR-CRL-10: `file://` URIs are permitted in test builds and resolve to disk.
11401140
///
1141-
/// Uses an existing CRL fixture from `test_data/` to verify the happy path.
1141+
/// Creates a self-contained temp file so this test works in all CI
1142+
/// environments regardless of whether the `test_data` submodule is present.
11421143
#[actix_web::test]
11431144
async fn sr_crl_10_file_uri_allowed_in_tests() {
1144-
// Use the CRL fixture checked into the repository.
1145-
let crl_path = concat!(
1146-
env!("CARGO_MANIFEST_DIR"),
1147-
"/../../../test_data/certificates/openssl/prime256v1.crl"
1148-
);
1149-
let uri = format!("file://{crl_path}");
1145+
use std::io::Write as _;
1146+
1147+
// Write sentinel bytes to a temp file — content does not need to be a
1148+
// valid CRL; `get_crl_bytes` only performs I/O, not parsing.
1149+
let mut tmp =
1150+
tempfile::NamedTempFile::new().expect("failed to create temp file for SR-CRL-10");
1151+
let sentinel: &[u8] = b"SR-CRL-10-sentinel";
1152+
tmp.write_all(sentinel)
1153+
.expect("failed to write sentinel bytes");
1154+
tmp.flush().expect("failed to flush temp file");
1155+
1156+
let path = tmp.path().to_str().expect("temp path is not valid UTF-8");
1157+
// Build the canonical file URI (three slashes: scheme + empty authority + absolute path).
1158+
let uri = format!("file://{path}");
1159+
11501160
let result = get_crl_bytes(vec![uri.clone()], None, None)
11511161
.await
11521162
.expect("file:// CRL should succeed in test builds");
1163+
11531164
assert!(
11541165
result.contains_key(&uri),
11551166
"Result map must contain the file:// URI as key"
11561167
);
1157-
assert!(!result[&uri].is_empty(), "CRL bytes must not be empty");
1168+
assert_eq!(
1169+
result[&uri], sentinel,
1170+
"Returned bytes must match the sentinel written to the temp file"
1171+
);
11581172
}
11591173
}

documentation/docs/configuration/log-reference.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,19 @@ Crate path: `crate/server`
689689
| `info` | `JoinSplitKey: CO ceremony auto-activated via reconstructed key` | `src/core/operations/join_split_key.rs` | - | - |
690690
| `info` | `PEER_REVOCATION_CLEANUP: revoked victim GET access on caller's share` | `src/core/kms/permissions.rs` | - | - |
691691
| `debug` | `JoinSplitKey: shares reconstructed` | `src/core/operations/join_split_key.rs` | - | - |
692+
| `warn` | `[{idx}] CRL distribution point unreachable for '{:?}', skipping revocation check: {e}` | `src/core/operations/validate.rs` | `idx`, `e` | - |
693+
| `warn` | `CRL signature could not be verified against chain issuers; issuer: {crl_issuer:?}, path: {crl_path}. Continuing (trusted local delivery).` | `src/core/operations/validate.rs` | `crl_issuer`, `crl_path` | - |
694+
| `warn` | `CRL validation failed: {crl_err}` | `src/core/operations/validate.rs` | `crl_err` | - |
695+
| `info` | `GET /certificates/{}/crl` | `src/routes/crl.rs` | - | - |
696+
| `info` | `GET /public/certificates/{}/crl (unauthenticated)` | `src/routes/crl.rs` | - | - |
697+
| `debug` | `Auto-injecting CRL Distribution Point: {crl_url}` | `src/core/operations/certify/build_certificate.rs` | `crl_url` | - |
698+
| `debug` | `CRL cache hit: {uri}` | `src/core/operations/validate.rs` | `uri` | - |
699+
| `debug` | `CRL fetched: uri={uri} size={}` | `src/core/operations/validate.rs` | `uri` | - |
700+
| `debug` | `CRL generated successfully for issuer '{}': {} entries, validity {} days` | `src/core/operations/generate_crl.rs` | - | - |
701+
| `debug` | `CRL response received: uri={uri} status={}` | `src/core/operations/validate.rs` | `uri` | - |
702+
| `debug` | `Generating CRL for issuer certificate: {}` | `src/core/operations/generate_crl.rs` | - | - |
703+
| `trace` | `Found {} revoked certificate(s) for issuer '{}'` | `src/core/operations/generate_crl.rs` | - | - |
704+
| `trace` | `Skipping certificate '{}': cannot parse DER: {e}` | `src/core/operations/generate_crl.rs` | `e` | - |
692705

693706
### `cosmian_kms_server_database`
694707

0 commit comments

Comments
 (0)