Skip to content

test(identity): malformed-bytes rejection paths (#424)#463

Merged
intendednull merged 1 commit into
claude/friendly-maxwell-Oggvwfrom
auto-fix/issue-424-identity-malformed-tests
Apr 28, 2026
Merged

test(identity): malformed-bytes rejection paths (#424)#463
intendednull merged 1 commit into
claude/friendly-maxwell-Oggvwfrom
auto-fix/issue-424-identity-malformed-tests

Conversation

@intendednull
Copy link
Copy Markdown
Owner

what

three new unit tests in crates/identity/src/lib.rs mod tests, cover malformed-bytes paths that round-trip + tamper tests miss:

  • endpoint_id_rejects_malformed_hexEndpointId::from_str rejects non-hex, wrong-length, non-z32 inputs. delegates to iroh-base PublicKey FromStr.
  • profile_decode_rejects_invalid_cbor — garbage bytes and empty slice through unpack_profile surface as IdentityError::Serde from bincode decode failure. no panic, no silent default profile.
  • unpack_rejects_truncated_envelope_bytes — two sub-cases:
    • truncated envelope: outer SignedMessage decode fails -> IdentityError::Serde.
    • well-framed envelope with too-short public_key field: reaches SignedMessage::verify, fails with IdentityError::PublicKeyDecode. distinct from tampered_payload_fails_verification which exercises InvalidSignature on intact framing.

why

issue #424 (TC-10): identity crate had happy-path round-trip + tampered + wrong-key but nothing for malformed serialized bytes, malformed hex, or garbage profile bytes. these tests close those gaps and pin the contracts at the public-API boundary so a future refactor of the wire format or verify flow can't silently break the rejection behaviour.

verification

  • cargo test -p willow-identity -> 29 passed, 0 failed.
  • cargo clippy --workspace --all-targets -- -D warnings -> clean.
  • cargo fmt --check -> clean.
  • cargo check --target wasm32-unknown-unknown -p willow-identity -> clean.
  • cargo test --workspace -> all green.

tests-only change. no source code touched.

Refs #424


Generated by Claude Code

add three unit tests covering untested malformed-input paths in
willow-identity:

- endpoint_id_rejects_malformed_hex: EndpointId::from_str must reject
  non-hex / wrong-length / non-z32 inputs (delegates to iroh-base
  PublicKey FromStr).
- profile_decode_rejects_invalid_cbor: garbage and empty bytes through
  unpack_profile must surface as IdentityError::Serde from
  willow-transport bincode decoding, not panic or default-construct.
- unpack_rejects_truncated_envelope_bytes: truncated envelope hits the
  outer SignedMessage decode and returns Serde; a well-framed envelope
  with a too-short public_key field hits SignedMessage::verify and
  returns PublicKeyDecode. Distinct from tampered_payload_fails_verification
  which exercises the InvalidSignature path on intact framing.

tests-only change. cargo test -p willow-identity green (29/29).
cargo clippy --workspace -- -D warnings clean.
cargo check --target wasm32-unknown-unknown -p willow-identity clean.

Refs #424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants