fix(m190): presenter 更新链路用例补上清单签名(6 条既有测试回绿)+ 测试公钥守门
背景:M190 把「验签」做成了强制且唯一收口(`source::verified_manifest`,先验签再解析),而 `crates/presenter` 的更新链路用例只写 `manifest.json`、不写 `.sig` —— 它们写在验签之前,所以在 dev 上红成 6 条 `signature_missing`。真发布本来就必须带 `.sig`,所以修的是**夹具**,不是判据: 没有放宽任何断言、没有在测试里关掉验签、没有把 `available=true` 改成「接受 Failed」。 夹具(`crates/presenter/src/host/update_tests.rs`): * `write_manifest()` 把清单**连签名**成对落盘(`dist/stable.json` + `dist/stable.json.sig`), `dir_source()` 改走它;三处直接写清单的用例(坏清单 / 空清单 / 缺本平台产物)也改走它。 * 签名用 `TEST_SIGNING_SEED` + `key_id = test-only-key`,信封形状与 core 的 `tests/support_sign.rs` **同源**(文件头写明「改一处要改两处」;presenter 不依赖 core 的 `#[cfg(test)]` 资产,也没把测试资产导出成生产 API)。 为了让这把**公开**测试公钥在 presenter 的测试构建里被认得: * core 新增 feature `update-test-key`(**只**把 `trust::TEST_ONLY` 并进信任表,不开任何数据源开关); * 只有 `crates/presenter` 的 `[dev-dependencies]` 打开它(库/发布构建拿不到);锁里只多 `ed25519-dalek` 这一行(presenter 的 dev-dep,包已在锁里,无新包、无版本变动); * 新守门 `packaging/check_test_key_off.py`(238 行,带 6 条变异自检)接进 `release-guard.yml`: core 的 `Cargo.toml` 只许自己的声明、presenter 只许 `[dev-dependencies]` 段内,其余(workflow / packaging 脚本 / 根 Cargo.toml / cargo 配置)出现即红 —— 这把钥进发布构建就等于「谁都能签出官方更新」。 * 没有用 `debug_assertions`/`cfg(test)` 旁路:那会让「测试构建的信任表和发布构建不同」变成一句注释, 而不是一条门禁。
This commit is contained in:
1 parent
1f2d89c23e
commit
19cc5c7950
7 files changed
+326
-10
No files matched your search
@@ -81,3 +81,10 @@ workspace = true
|
||||
# 验收用法见 `crates/cli/tests/update_e2e_test.rs` 的文件头;`packaging/check_test_source_off.py`
|
||||
# 守门「发布流水线与打包脚本都不许打开它」。
|
||||
update-test-source = []
|
||||
|
||||
# M190:把**测试公钥**并进信任表(`trust::TEST_ONLY`)。它只加一把**公开**的钥,**不**开任何数据源
|
||||
# 开关(没有环境变量、没有 `DirSource`)。唯一使用者是 `crates/presenter` 的 `[dev-dependencies]`:
|
||||
# presenter 的更新链路用例要构造「本构建认得」的签名清单,而它们编译 core 时既没有 `cfg(test)`,
|
||||
# 也不该去打开 `update-test-source`(那条同时给出「本地目录当更新源」这条路)。
|
||||
# 守门:`packaging/check_test_key_off.py`(只许出现在这里与 presenter 的 dev-dependencies)。
|
||||
update-test-key = []
|
||||
@@ -70,11 +70,26 @@ pub(crate) const TEST_ONLY: &[PinnedKey] = &[PinnedKey {
|
||||
}];
|
||||
|
||||
/// 本构建实际的信任锚(正式表 + 仅测试构建才有的那把测试钥)。
|
||||
///
|
||||
/// 三档「仅测试」的口径,逐档说明为什么需要它:
|
||||
///
|
||||
/// | 档 | 谁在用 | 为什么不能只靠 `cfg(test)` |
|
||||
/// |---|---|---|
|
||||
/// | `cfg(test)` | core 自己的单测 | 够用 |
|
||||
/// | `update-test-source` | CLI 的端到端验收(`--features update-test-source`) | 那是**另一个 target**,`cfg(test)` 不生效 |
|
||||
/// | `update-test-key` | `crates/presenter` 的 `[dev-dependencies]` | presenter 的更新链路用例编译 core 时既无 `cfg(test)`,也不该打开 `update-test-source`(那条会同时给出「本地目录当更新源」这条路)。这一档**只**加一把公开的测试公钥,不开任何数据源开关 |
|
||||
///
|
||||
/// 三者都进不了发布产物:`PRODUCTION` 之外没有任何路径能把 `TEST_ONLY` 带进 `--release` 构建
|
||||
/// (官方构建三个 feature 都不开,且 `check_test_source_off.py` / `check_test_key_off.py` 守着)。
|
||||
pub(crate) fn keyring() -> &'static [PinnedKey] {
|
||||
static ALL: OnceLock<Vec<PinnedKey>> = OnceLock::new();
|
||||
ALL.get_or_init(|| {
|
||||
let mut keys = PRODUCTION.to_vec();
|
||||
if cfg!(any(test, feature = "update-test-source")) {
|
||||
if cfg!(any(
|
||||
test,
|
||||
feature = "update-test-source",
|
||||
feature = "update-test-key"
|
||||
)) {
|
||||
keys.extend_from_slice(TEST_ONLY);
|
||||
}
|
||||
keys
|
||||
|
||||
Reference in new issue
Block a user