Commit graph

2 commits

Author SHA1 Message Date
Leonardo Francisco
08ef87a80c validity: fix code style (uncrustify) and test assertions
Apply uncrustify formatting to all validity driver and test files
to pass the CI test_indent check.

Fix two pre-existing test failures:
- test-validity-capture: LED command blobs are 125 bytes, not 128
- test-validity-enroll: add 2-byte length prefix to test data to
  match parser's expected format, fix empty-data assertion (parser
  returns FALSE for data_len < 2)

All 41 tests pass, 0 failures.
2026-04-10 22:18:43 +00:00
Leonardo Francisco
c120ef0797 validity: add 16 regression tests for Iter6 audit fixes
Adds test-validity-verify.c with 16 unit tests that prevent regression
of all 8 issues found during the Iteration 6 code audit (b05657f):

  R1: parse_match_result TLV parsing (5 tests)
    - valid payload with all fields extracted correctly
    - multi-tag iteration (tag ordering independence)
    - empty dict returns no-match
    - truncated/malformed data handled gracefully
    - unknown tags skipped without error

  R1f: match_result_clear frees hash and zeros struct

  R2: identity builder NULL rejection (2 tests)
    - NULL uuid returns NULL (prevented g_variant_new_string crash)
    - valid UUID produces correct identity bytes

  R3: gallery matching by subtype (3 tests)
    - matches correct print by finger subtype
    - falls back to first entry when subtype not found
    - returns NULL for empty/NULL gallery

  R4: struct field separation — enroll_user_dbid != delete_storage_dbid

  R5: del_record command format — cmd 0x48 with dbid(2LE)

  R6: match_finger single allocation — exactly 13 bytes

  R7: SSM state enums exist (2 tests)
    - CLEAR_* states 0-5
    - DELETE_* states 0-7

To make the tests possible, extracted previously-static functions:
  - parse_match_result → validity_parse_match_result (public)
  - ValidityMatchResult struct moved to validity_db.h
  - validity_match_result_clear added to validity_db.c
  - validity_find_gallery_match helper extracted from verify SSM
2026-04-10 22:18:43 +00:00