Skip to content

test(go): cover access token command serialization - #4640

Open
p4rtridge wants to merge 4 commits into
apache:masterfrom
p4rtridge:go-access-token-serialization-2883
Open

p4rtridge wants to merge 4 commits into
apache:masterfrom
p4rtridge:go-access-token-serialization-2883

Conversation

@p4rtridge

Copy link
Copy Markdown

Which issue does this PR address?

Relates to #2883

Rationale

The personal access token command encoders in the Go SDK had only partial
serialization coverage. The existing test checked the CreatePersonalAccessToken
expiry encoding with a single fixed name. It did not check the command code,
the name length prefix for other name lengths, or the other two access token
commands. Exact-byte assertions catch protocol compatibility regressions.

What changed?

Reworked access_token_test.go into table-driven serialization tests for all
three commands in access_token.go. Each case checks the command code and the
complete request body.

  • CreatePersonalAccessToken (code 42): the four existing expiry cases (server
    default, little-endian layout, values past 32 bits, never expire), plus an
    empty name and a longer name, to cover the u8 length prefix.
  • GetPersonalAccessTokens (code 41): the body is empty.
  • DeletePersonalAccessToken (code 43): short, empty and longer names.

That is 10 cases. No production code changed.

Local Execution

  • Passed go test -count=1 ./..., go test -race -count=1 ./... and
    go vet ./... from foreign/go.
  • Passed the applicable prek pre-commit hooks for the changed file.
  • Passed the prek pre-push Go lint hook.

AI Usage

  • Tool: Claude Code
  • Scope: Assisted with reviewing my changes
  • Verification: I ran the checks above and compared each expected byte layout
    against the encoders in access_token.go and the server's protocol
    definitions.
  • I can explain each assertion and the wire layout it checks.

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI was used to create this PR, you must run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@justinmclean

Copy link
Copy Markdown
Member

Thanks @p4rtridge, and for picking up access_token.go from #2883. I checked the expected bytes against the three encoders in access_token.go and the command codes against core/binary_protocol/src/codes.rs (41, 42, 43), and they match. One small thing: the old failure message printed the bodies with % x, which is easier to read for byte layouts than %v. Could you keep % x?

@p4rtridge

Copy link
Copy Markdown
Author

Thanks @p4rtridge, and for picking up access_token.go from #2883. I checked the expected bytes against the three encoders in access_token.go and the command codes against core/binary_protocol/src/codes.rs (41, 42, 43), and they match. One small thing: the old failure message printed the bodies with % x, which is easier to read for byte layouts than %v. Could you keep % x?

Thanks for reviewing! I’ve changed the failure message from %v to %x.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.71%. Comparing base (922c6d1) to head (3322fda).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master    #4640       +/-   ##
=============================================
- Coverage     90.86%   80.71%   -10.16%     
- Complexity     3104     3107        +3     
=============================================
  Files          1479     1467       -12     
  Lines        361309   356151     -5158     
  Branches     305179   300040     -5139     
=============================================
- Hits         328296   287453    -40843     
- Misses        26111    61873    +35762     
+ Partials       6902     6825       -77     
Components Coverage Δ
Rust Core 80.15% <ø> (-12.05%) ⬇️
Java SDK 78.15% <ø> (+<0.01%) ⬆️
C# SDK 83.70% <ø> (+0.09%) ⬆️
Python SDK 85.67% <ø> (ø)
PHP SDK 90.67% <ø> (-0.05%) ⬇️
Node SDK 96.44% <ø> (ø)
Go SDK 63.53% <ø> (-5.78%) ⬇️
C++ SDK 85.50% <ø> (-0.05%) ⬇️
see 532 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hubcio

hubcio commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

/skill team-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: The new access-token serialization tests match the command codes, byte layout, and server wire format. The added name rows miss the 255-byte boundary, the empty-name rows encode a rejected name, and the three tests duplicate one harness.

Counts: critical 0, warning 0, nit 2, simplification 1


This review was generated by Claude Code 2.1.310 on deepseek-flash[1m]. Review the output before you act on it.

},
{
name: "empty name",
request: &CreatePersonalAccessToken{Name: "", Expiry: 0x01020304},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: The empty name rows assert a body the server rejects, because WireName requires 1 to 255 bytes (core/binary_protocol/src/primitives/identifier.rs:105). Replace them with a one-character name, the shortest name WireName accepts. Also at line 130.

},
{
name: "longer name",
request: &CreatePersonalAccessToken{Name: "my-access-token", Expiry: iggcon.IggyExpiryServerDefault},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: The name rows stop at 15 bytes, so the 255-byte wire limit and the byte(len(name)) wrap above 255 stay untested (foreign/go/internal/command/access_token.go:38). Add a 255-byte case and a case above 255 that expects an error.

}

for _, test := range tests {
func TestGetPersonalAccessTokensMarshalBinary(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

simplification: The three new tests repeat the same table, code check, and marshal loop. Fold them into one table over Command, as TestPartitionCommandsMarshalBinary does at foreign/go/internal/command/partition_test.go:27, to remove about 50 lines.

This branch has not been deployed

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

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants