test(identity): malformed-bytes rejection paths (#424)#463
Merged
intendednull merged 1 commit intoApr 28, 2026
Merged
Conversation
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
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
three new unit tests in
crates/identity/src/lib.rsmod tests, cover malformed-bytes paths that round-trip + tamper tests miss:endpoint_id_rejects_malformed_hex—EndpointId::from_strrejects non-hex, wrong-length, non-z32 inputs. delegates to iroh-basePublicKeyFromStr.profile_decode_rejects_invalid_cbor— garbage bytes and empty slice throughunpack_profilesurface asIdentityError::Serdefrom bincode decode failure. no panic, no silent default profile.unpack_rejects_truncated_envelope_bytes— two sub-cases:SignedMessagedecode fails ->IdentityError::Serde.public_keyfield: reachesSignedMessage::verify, fails withIdentityError::PublicKeyDecode. distinct fromtampered_payload_fails_verificationwhich exercisesInvalidSignatureon 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
verifyflow 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