Meilu/tbor tests get unwrapping key - #695
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes are isolated to test code and improve coverage/validation with only minor consistency/formatting nits noted.
Pull request overview
This PR expands the TBOR GetUnwrappingKey integration tests to more thoroughly validate the returned RSA-2048 public key and to cover additional role/access and error-path behaviors within the TBOR test harness.
Changes:
- Strengthens “happy path” validation by checking RSA-2048 modulus bit properties and the standard exponent (65537).
- Adds coverage for Crypto-User access (including default-PSK gate behavior) and verifies the key is consistent across CO/CU sessions and across PSK rotations.
- Adds negative-path tests for closed/unknown session IDs.
File summaries
| File | Description |
|---|---|
| ddi/tbor/types/tests/commands/get_unwrapping_key.rs | Expands GetUnwrappingKey emulator-gated integration tests to validate RSA key structure, role access behavior, stability across sessions, and key error cases. |
Review details
Suppressed comments (1)
ddi/tbor/types/tests/commands/get_unwrapping_key.rs:141
- There is an extraneous trailing comma in this
assert!invocation; removing it avoids unnecessary diffs and keeps formatting consistent with other tests.
assert!(modulus[0] & 1 != 0, "RSA modulus must be odd",);
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are test-only and add meaningful coverage without introducing functional risk.
Review details
Suppressed comments (3)
Previously missed (1) — in code that hasn't changed since the last review.
ddi/tbor/types/tests/commands/get_unwrapping_key.rs:114
- This test duplicates the harness’s
bootstrap_rotated_cuflow (open CU under default PSK →PskChange→ reopen under rotated PSK). Reusing the helper reduces repetition and keeps rotated-PSK setup consistent across the suite.
This issue also appears in the following locations of the same file:
- line 224
- line 291
ddi/tbor/types/tests/commands/get_unwrapping_key.rs:243
- This block re-implements the CU PSK rotation + session bootstrap sequence that already exists as
crate::harness::bootstrap_rotated_cu. Using the shared helper avoids copy/paste and centralizes any future handshake/rotation changes.
// Rotate the CU PSK so GetUnwrappingKey reaches its handler instead
// of being rejected by the dispatcher's default-PSK gate.
let bootstrap = ctx
.open_session(CU, SessionType::PlainText)
.expect("open bootstrap CU session");
ctx.psk_change(bootstrap.handshake(), &ROTATED_CU_PSK)
.expect("rotate CU PSK");
bootstrap.close().expect("close bootstrap CU session");
// Reopen CU under the rotated PSK.
let opts = SessionOpenInitOptions::new(CU, SessionType::PlainText).with_psk(&ROTATED_CU_PSK);
let pending = ctx
.session_open_init_with_options(opts)
.expect("open CU session under rotated PSK");
let cu_session = ctx.session_open_finish(pending).expect("finish CU session");
ddi/tbor/types/tests/commands/get_unwrapping_key.rs:311
- The CU PSK rotation + first-session setup duplicates
crate::harness::bootstrap_rotated_cu. Using that helper here would shrink the test and keep the rotation logic consistent with other command tests.
// Rotate the CU PSK.
let bootstrap = ctx
.open_session(CU, SessionType::PlainText)
.expect("open bootstrap CU session");
ctx.psk_change(bootstrap.handshake(), &ROTATED_CU_PSK)
.expect("rotate CU PSK");
bootstrap.close().expect("close bootstrap CU session");
// First CU session.
let opts = SessionOpenInitOptions::new(CU, SessionType::PlainText).with_psk(&ROTATED_CU_PSK);
let pending = ctx
.session_open_init_with_options(opts)
.expect("open first CU session");
let first_session = ctx
.session_open_finish(pending)
.expect("finish first CU session");
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
No description provided.