Skip to content

feat(xtest): improve TDF test stability and add ec-wrapped schema support#412

Open
dmihalcik-virtru wants to merge 1 commit intoopentdf:mainfrom
dmihalcik-virtru:feat/xtest-tdf-improvements
Open

feat(xtest): improve TDF test stability and add ec-wrapped schema support#412
dmihalcik-virtru wants to merge 1 commit intoopentdf:mainfrom
dmihalcik-virtru:feat/xtest-tdf-improvements

Conversation

@dmihalcik-virtru
Copy link
Member

@dmihalcik-virtru dmihalcik-virtru commented Feb 13, 2026

Summary

  • Use explicit RSA attribute mapping in TDF tests to prevent base_key interference
    • Uses the recently added attribute_default_rsa parameter throughout do_encrypt_with
  • Add "ec-wrapped" to manifest schema type enum

Parent PRs

Test plan

  • cd xtest && uv run ruff check . && uv run pyright
  • With platform: uv run pytest test_tdfs.py --sdks go -v --no-audit-logs

🤖 Generated with Claude Code

Part of stacked PR series decomposing chore/the-claudiest-day-tmux

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dmihalcik-virtru, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on improving the stability and robustness of the TDF test suite by introducing explicit RSA key mapping for encryption operations, thereby mitigating potential flakiness caused by default key configurations. Concurrently, it expands the TDF manifest schema to support ec-wrapped key access objects and refines the audit log collection and testing framework for greater efficiency and accuracy.

Highlights

  • TDF Test Stability Improvements: Implemented explicit RSA attribute mapping in TDF tests to prevent interference from the platform's base_key configuration, enhancing test reliability and determinism. This includes a new attribute_default_rsa fixture and attr_values parameter in the do_encrypt_with helper function.
  • Manifest Schema Update: Extended the manifest.schema.json to include "ec-wrapped" as a valid type for key access objects, supporting new encryption wrapping mechanisms.
  • Audit Log Collection Enhancements: Refactored audit log constants from Literal types to frozenset and named string constants for better maintainability and clarity. Introduced a threading.Condition and wait_for_new_data mechanism in the AuditLogCollector to improve the efficiency and responsiveness of log tailing, replacing inefficient polling with time.sleep().
  • Audit Log Test Suite Refinements: Updated audit log integration tests to skip when audit collection is disabled, renamed CRUD tests for clarity, and adjusted assertions for decision logs to account for varying platform configurations.
  • Dependency Update: Updated the pyright development dependency to a newer version.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • xtest/audit_logs.py
    • Refactored audit event constants from Literal types to frozenset and named string constants.
    • Improved timezone handling for datetime objects by explicitly checking for tzinfo before conversion.
    • Introduced a threading.Condition (_new_data) to enable efficient waiting for new log data.
    • Modified _tail_file to batch-read lines and notify waiting threads upon new data arrival.
    • Added wait_for_new_data method for more efficient log polling.
    • Updated start method to handle log files that may not exist initially and to use existing_files for thread creation.
    • Ensured stop method notifies waiting threads to prevent potential deadlocks.
  • xtest/fixtures/attributes.py
    • Added attribute_default_rsa fixture to create an attribute with explicit RSA key mapping for TDF tests.
  • xtest/manifest.schema.json
    • Extended the enum for key access object type to include 'ec-wrapped'.
  • xtest/pyproject.toml
    • Updated pyright development dependency version to >=1.1.408.
  • xtest/test_audit_logs.py
    • Imported new audit log constants (ACTION_RESULTS, ACTION_TYPES, OBJECT_TYPES, VERB_DECISION, VERB_POLICY_CRUD, VERB_REWRAP).
    • Added TestAuditConstants class to verify the new frozenset and named verb constants.
    • Removed pytest.approx from assertions for exact float values in clock skew tests.
  • xtest/test_audit_logs_integration.py
    • Added skip_if_audit_disabled fixture to skip integration tests if audit logging is disabled.
    • Removed unused base64 import.
    • Modified several TDF tests to use the attribute_default_rsa fixture and attr_values parameter in do_encrypt_with.
    • Updated test_rewrap_success_with_attributes to test_rewrap_failure_access_denied and adjusted its logic.
    • Renamed test_namespace_create_audit to test_namespace_crud_audit and test_attribute_create_audit to test_attribute_crud_audit.
    • Adjusted attribute value verification in test_attribute_crud_audit to account for values embedded in the attribute definition event.
    • Wrapped decision log assertion in test_decision_on_successful_access in a try-except block for robustness.
  • xtest/test_tdfs.py
    • Imported Attribute from abac.
    • Modified do_encrypt_with to accept an optional attr_values parameter for explicit attribute FQNs during encryption.
    • Updated numerous TDF tests to use the new attribute_default_rsa fixture and pass attr_values to do_encrypt_with for improved test stability.
  • xtest/uv.lock
    • Updated pyright dependency version to >=1.1.408.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the stability of TDF tests by using an explicit RSA attribute mapping, preventing interference from base_key configurations. It also enhances the audit log assertion framework by replacing polling with a more efficient threading.Condition-based notification system, which should make tests faster and more reliable. Additionally, it adds support for "ec-wrapped" in the manifest schema.

My review has identified a few areas for improvement:

  • There is some redundant code in the timezone conversion logic.
  • A test case has a misleading name and docstring that does not match its implementation.
  • There is a style issue with an import statement being placed inside a function.

Overall, these are great improvements for test stability and efficiency. Addressing the identified issues will further improve the code quality.

@dmihalcik-virtru dmihalcik-virtru force-pushed the feat/xtest-tdf-improvements branch from 85cd52c to 28bdbc5 Compare February 23, 2026 20:09
…port

Use explicit RSA attribute mapping to prevent base_key interference.
Add ec-wrapped to manifest schema type enum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: David Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru dmihalcik-virtru force-pushed the feat/xtest-tdf-improvements branch from 28bdbc5 to f26772e Compare February 23, 2026 20:10
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
9.8% Duplication on New Code (required ≤ 8%)

See analysis details on SonarQube Cloud

@dmihalcik-virtru dmihalcik-virtru marked this pull request as ready for review February 23, 2026 20:11
@dmihalcik-virtru dmihalcik-virtru requested review from a team as code owners February 23, 2026 20:11
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