Per field tokenization - #9
Merged
Merged
Conversation
json.dumps renders Python None as JSON null, so a key assigned
options.get(k) was still present on the wire. The server builds its
required-parameter set by testing key presence, so a null counted as
supplied and got validated:
- create_shared_record sent "appname": null and was rejected every
time with "The appname parameter has an incorrect format", making
the method unusable unless the caller passed an appname.
- create_legal_basis sent "requiredflag": null, which panicked the
server outright.
The sibling SDKs avoid this for free — JSON.stringify drops undefined,
PHP guards with isset(), Java checks != null — so Python needs the
guard spelled out. _add_options() copies only supplied options into the
body; an AST scan for keys assigned a possibly-None value found seven
methods, all now routed through it.
tests/test_field_tokenization.py covers the two flows a customer needs
for per-field tokenization, each with single and bulk requests:
- Per-field shared identities: a 10-field profile exposed through one
SharedRecordCreate UUID per field, redeemed with no X-Bunker-Token,
including field scoping and expiry.
- Format-preserving tokenization: every value stringified through
TokenCreate/TokenCreateBulk with unique set, round-tripped, with
Luhn and length checks on the card token.
Two tests track server-side work that is fixed in source but not yet
deployed to pro.databunker.org: the bulk `unique` dedup assertion
fails, and the `string` type alias skips.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
FORMAT_PRESERVING_TYPES listed unixtimestamp, uint64 and uint32 alongside creditcard, but _token_type only ever returns creditcard or text, so those three could never be reached. The set documented the server's wider capabilities rather than anything this file exercises. Drop it and test the one distinction that applies here: the card gets a tokenbase, every string field does not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The customer's "create a user token" is the record token UserCreate returns, which is what the shared records are keyed on. Minting a login xtoken as well tested authenticated access, which is beside the point of a flow whose whole premise is retrieval without a credential. Replace it with a check that the record token reads back the stored profile. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The test sent "string" only to prove it aliases "text", which made the file depend on a pro.databunker.org deploy and put a skipTest in the way of a real assertion. The alias belongs to the server and is covered there by TestV2StringTokenTypeAlias. Every field here goes through the canonical "text". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This reverts commit 608fdf2.
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.
No description provided.