Skip to content

fix(sdk): exp SDK tests and fix#3077

Open
pflynn-virtru wants to merge 3 commits intomainfrom
fix/exp-sdk
Open

fix(sdk): exp SDK tests and fix#3077
pflynn-virtru wants to merge 3 commits intomainfrom
fix/exp-sdk

Conversation

@pflynn-virtru
Copy link
Member

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

This pull request adds comprehensive regression and compatibility tests to the experimental TDF SDK, focusing on key management edge cases and ensuring encryption format compatibility with the production SDK. The new tests verify correct handling of legacy attribute grants, segment integrity hashing, and cross-decryption between SDKs. Additionally, new imports were added to support these tests.

See xtest failure: opentdf/tests#414

Regression and Compatibility Testing Enhancements:

  • Added regression tests to xor_splitter_test.go to ensure that when an attribute grant references a KAS URL by URI only (without an embedded public key), the default KAS public key is correctly merged, and that existing keys are not overwritten by the default.
  • Added end-to-end regression tests in writer_test.go to verify that segment hashes include both nonce and ciphertext (not just ciphertext), and that finalization succeeds for URI-only grants by leveraging the default KAS public key.

Cross-SDK Compatibility:

  • Introduced a new test in writer_test.go to validate that the experimental writer's output is fully compatible with the production SDK's decryption and segment hash verification, including full TDF ZIP assembly and parsing with the production ZIP reader.

Test Infrastructure Improvements:

  • Registered the new regression and compatibility tests in the main test suite.
  • Added necessary imports for cryptographic operations and ZIP parsing to support the new tests. [1] [2]

@pflynn-virtru pflynn-virtru requested review from a team as code owners February 13, 2026 17:29
@github-actions github-actions bot added comp:sdk A software development kit, including library, for client applications and inter-service communicati size/xs labels Feb 13, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pflynn-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 significantly enhances the robustness and compatibility of the experimental TDF SDK by introducing a suite of new regression and cross-SDK compatibility tests. These additions address critical edge cases in key management, particularly concerning legacy attribute grants and the merging of default KAS public keys, while also ensuring the integrity of segment hashing. Furthermore, the changes validate that data encrypted by the experimental SDK can be seamlessly decrypted and processed by the production SDK, reinforcing the reliability of the experimental implementation.

Highlights

  • KAS URL Handling Regression: Added tests to ensure the experimental SDK correctly merges default KAS public keys for URI-only attribute grants and does not overwrite existing KAS keys.
  • Segment Integrity Hashing: Introduced regression tests to verify that HS256 segment hashes correctly include both the nonce and ciphertext, not just the ciphertext.
  • Cross-SDK Compatibility: Implemented tests to confirm that the experimental writer's output is fully compatible with the production SDK's decryption and TDF ZIP parsing.
  • Test Infrastructure: Added new imports for cryptographic operations and ZIP stream handling to support the new tests.

🧠 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
  • sdk/experimental/tdf/keysplit/xor_splitter_test.go
    • Added regression tests for KAS URL handling with URI-only grants.
    • Added regression tests to ensure default KAS does not overwrite existing keys.
  • sdk/experimental/tdf/writer_test.go
    • Imported necessary cryptographic and I/O packages.
    • Imported "zipstream" for TDF ZIP parsing.
    • Added "testSegmentHashCoversNonceAndCipher" to verify segment hash integrity.
    • Added "testFinalizeWithURIOnlyGrant" for KAS URI-only grant handling.
    • Added "TestCrossDecryptWithSharedDEK" for cross-SDK compatibility testing.
Activity
  • No human activity has been recorded on this pull request yet.
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.


A bug, a feature, hard to tell, A test now written, all is well. With hashes strong and keys aligned, No more regressions, peace of mind.

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 introduces valuable regression and compatibility tests for the experimental TDF SDK. The new tests cover important edge cases like URI-only attribute grants and ensure segment integrity hashing is correct. A comprehensive cross-decryption test suite has also been added to validate compatibility with the production SDK. The changes are well-structured and significantly improve test coverage. I've found a minor but repeated issue in the test implementation related to slice indexing, which would cause compilation errors.

@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 191.981422ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 92.7698ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 370.585368ms
Throughput 269.84 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.341772089s
Average Latency 391.952311ms
Throughput 127.09 requests/second

@github-actions
Copy link
Contributor

X-Test Failure Report

opentdfplatformQOVREZ.dockerbuild
cukes-report

…y hashing

Signed-off-by: Paul Flynn <pflynn@virtru.com>
@github-actions
Copy link
Contributor

X-Test Failure Report

opentdfplatform3X98QK.dockerbuild

@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 196.562346ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 98.118505ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 377.224499ms
Throughput 265.09 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.669998084s
Average Latency 394.731374ms
Throughput 126.04 requests/second

@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 209.50834ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 96.105623ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 372.918961ms
Throughput 268.15 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.008286209s
Average Latency 408.137269ms
Throughput 121.93 requests/second

@pflynn-virtru
Copy link
Member Author

/gemini review

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 introduces valuable regression and compatibility tests for the experimental TDF SDK. The changes to the production code are well-targeted, correctly addressing legacy attribute grant handling and ensuring segment hash compatibility with the production SDK. The new tests are particularly impressive in their thoroughness, covering important edge cases for key management and verifying cross-decryption and TDF format compatibility. Overall, this is a high-quality contribution that significantly strengthens the reliability of the experimental SDK. I have one minor suggestion to improve code readability.

@pflynn-virtru pflynn-virtru changed the title fix(sdk): exp SDK regression tests fix(sdk): exp SDK tests and fix Feb 13, 2026
pflynn-virtru and others added 2 commits February 13, 2026 14:08
…ental benchmark

Fix multiple concurrency bugs in the experimental TDF writer benchmark:
- goroutine captured loop variable by closure reference (data race on index)
- goroutine wrote to outer `err` variable (data race)
- shared payload sub-slices passed to EncryptInPlace which overwrites input buffer
- remainder segment truncated when payload not evenly divisible by chunk size

Also add TLS skip support (--insecureSkipVerify), save TDF to disk, and
verify decrypt roundtrip with the production SDK.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paul Flynn <pflynn@virtru.com>
Reduce repeated GetPublicKey() calls by assigning to a local variable,
improving readability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paul Flynn <pflynn@virtru.com>
@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 200.617285ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 99.993923ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 364.659148ms
Throughput 274.23 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.37236801s
Average Latency 391.788332ms
Throughput 126.99 requests/second

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

Labels

comp:sdk A software development kit, including library, for client applications and inter-service communicati size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants