Skip to content

test(xtest): DSPX-1561 cover assertion verification key selection - #706

Draft
dmihalcik-virtru wants to merge 1 commit into
DSPX-5520-assertion-vectorsfrom
DSPX-1561-key-selection-xtest
Draft

dmihalcik-virtru wants to merge 1 commit into
DSPX-5520-assertion-vectorsfrom
DSPX-1561-key-selection-xtest

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Split out of #702 (draft; the complete change). Stacked on #705.

test_assertion_verification.py builds assertions into TDFs that each SDK wrote. It checks that each reader verifies an assertion only with the key it selects from its own configuration: the per-ID key, else the default key, else the payload key with HS256. The cases cover:

  • embedded jwk and x5c headers, which may only match the selected key;
  • a failure with the selected key does not fall through to another source;
  • the default key, including through each CLI's verification-keys file;
  • the documented default-key behaviour (spec 6.1): a Java-written TDF read with only a default RS256 key fails on its payload-key system-metadata assertion, while an empty keys file reads it.

Every rejection is matched by its reported reason=<code> and has a positive control under the same configuration. Before any SDK sees a built assertion, the reference reader checks it.

  • Feature gate. assertion_header_key_pinning. It is force-only until the SDK releases ship: every cli.sh answers no.
  • Helpers. tdfs.update_manifest_text rewrites a manifest's raw JSON text, for changes the Manifest model cannot represent.
  • CI. xtest.yml runs the module in the standard and focused steps.

Testing

  • cd xtest && uv run ruff check . && uv run ruff format --check . && uv run pyright, plus the offline unit tests from check.yml.
  • XT_FORCE_SUPPORTS=assertion_header_key_pinning uv run pytest test_assertion_verification.py --sdks "go java js" against the SDK branches.

Related pull requests

Adds the Phase 0 feature gate assertion_header_key_pinning. Every cli.sh
answers no until a release ships; branch builds run the cases with
XT_FORCE_SUPPORTS=assertion_header_key_pinning.

test_assertion_verification.py builds assertions into TDFs that each SDK
wrote and checks that each reader verifies them only with the key it
selects from its configuration: the per-ID key, else the default key, else
the payload key with HS256. It covers embedded jwk and x5c headers, a
failure with the selected key not falling through to another source, the
default key through each CLI's verification-keys file, and the documented
default-key behaviour (spec 6.1): a Java-written TDF read with only a
default RS256 key fails with algorithm-mismatch on its payload-key
system-metadata assertion, while an empty keys file reads it.

Every rejection is matched by its reported reason and has a positive
control under the same configuration. The reference reader in
assertions.py checks each built assertion before an SDK sees it. The
module runs in the standard and focused xtest steps.

tdfs.update_manifest_text rewrites a manifest's raw JSON text, for
changes the Manifest model cannot represent.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

dmihalcik-virtru added a commit that referenced this pull request Nov 9, 2026
Every CI step named its test files, so each new suite edited the same lines of
xtest.yml or check.yml (see #703, #706, #705) and conflicted with every other
PR doing the same. Worse, a forgotten entry looks exactly like a pass:
test_root_signature.py and test_audit_logs_integration.py are on main and run
in no workflow at all.

Each test module now declares one tier -- units, harness, core, legacy,
multikas, benchmark, zip64 -- with pytestmark, *_units.py files are units by
name, and each step selects with -m. conftest.py fails collection on any test
without exactly one tier. check.yml's -m units step collects every module, so
an untiered suite fails every PR rather than going unrun.

Behaviour changes:
- test_root_signature.py (core) and test_audit_logs_integration.py (multikas)
  now run in CI for the first time.
- test_audit_logs.py runs offline in check.yml (units) instead of in the
  platform-backed helper step; it never needed the platform.
- test_audit_logs_on_tampered_file is xfail(strict=True) pending #709: it
  has failed since it was written, unseen because nothing ran it.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
dmihalcik-virtru added a commit that referenced this pull request Nov 9, 2026
Every CI step named its test files, so each new suite edited the same lines of
xtest.yml or check.yml (see #703, #706, #705) and conflicted with every other
PR doing the same. Worse, a forgotten entry looks exactly like a pass:
test_root_signature.py and test_audit_logs_integration.py are on main and run
in no workflow at all.

Each test module now declares one tier -- units, harness, core, legacy,
multikas, benchmark, zip64 -- with pytestmark, *_units.py files are units by
name, and each step selects with -m. conftest.py fails collection on any test
without exactly one tier. check.yml's -m units step collects every module, so
an untiered suite fails every PR rather than going unrun.

Behaviour changes:
- test_root_signature.py (core) and test_audit_logs_integration.py (multikas)
  now run in CI for the first time.
- test_audit_logs.py runs offline in check.yml (units) instead of in the
  platform-backed helper step; it never needed the platform.
- test_audit_logs_on_tampered_file xfails its audit assertion pending #709:
  it has failed since it was written, unseen because nothing ran it. The
  decrypt-rejection check stays blocking, and an audit pass fails the test
  so the xfail gets removed.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
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.

1 participant