Repository navigation
test: add credential-free wire tests for client options, key lifetime, list locker and status - #255
Open
sophiecarreras wants to merge 1 commit into
Conversation
…, list locker and status Cover paths that no offline test reached: - base: the X-Bz-Test-Mode headers set by FailSomeUploads, ExpireSomeAuthTokens and ForceCapExceeded appear on authorize, JSON and download requests; UserAgent options are prepended to the default in order; Bucket.BaseURL and Bucket.S3URL come from the authorize response. - b2: the same client options reach the wire through NewClient; Lifetime and Deadline set validDurationInSeconds on b2_create_key and no option omits it; ListLocker is held during every list request and released after; Status reports RPC counts by method. Test-only change, so no changelog entry. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
0 Important, 3 Nit, 0 Pre-existing Independent review per REVIEW.md, from a fresh context that read only the diff and the PR text. Checked against f90171a on
|
This branch has not been deployed
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.
Summary: add credential-free wire tests for client options, key lifetime,
ListLockerandStatus, which no offline test reached before.Motivation
Most of the offline wire tests for
baseandb2already landed (#205, #206, #210, #231). A coverage run on currentmainstill shows these paths with no offline test, so they were only reachable with live credentials or not at all:FailSomeUploads,ExpireSomeAuthTokens,ForceCapExceededinbaseandb2(0% covered in either package's own tests)UserAgentcomposition (80% inbase, 0% inb2)Bucket.BaseURLandBucket.S3URLinbaseDeadline(0%) onb2_create_key(Lifetimealready had offline tests increate_key_wire_test.go; thelifetimeand no-option subtests here overlap them)ListLocker(0%)MethodList.CountByMethodthroughClient.Status(0%)Changes
Two new test files, no library code:
base/session_options_wire_test.go: theX-Bz-Test-Modevalues (each option alone, none, and all three) onb2_authorize_account, a JSON call and a download;UserAgentorder againstDefaultUserAgent;BaseURLandS3URLtaken from distinct values in the authorize response.b2/client_options_wire_test.go: the same client options throughNewClient;validDurationInSecondsforLifetime,Deadlineand no option (omitted);ListLockerheld during every list request and released and balanced afterwards;Status().RPCscounts by method.All tests use
internal/b2wiretestand need no network or credentials.Testing
make build vet fmt-check tidy-check verify test b2keys crosscompile changelog-check scripts-testwithBASE_REF=upstream/main, Go 1.26.10: all passed (testisgo test -race -shuffle=on ./...).make lintwas NOT RUN here (it builds golangci-lint, which does not fit on this machine); CI's lint job is the check.Coverage,
go test -coverpkg=./... ./...onmainvs this branch: 86.2% to 86.9% of statements. Package alone:b289.7% to 90.6%,base71.3% to 73.0%.Each test fails when the behavior it pins is broken. I broke the code one line at a time in a throwaway copy and ran the matching test; every one failed:
expire_some_account_authorization_tokensheader inaddHeadersTestTestModeOptionsSendHeaderOnEveryRequestKindbase.UserAgentTestUserAgentOptionsArePrependedToTheDefaultBucket.S3URLreturns the download URLTestBucketURLsComeFromTheAuthorizeResponseauthOptionsdropsbase.ForceCapExceeded()TestClientTestModeOptionsReachTheWireauthOptionsdropsbase.UserAgent(agent)TestClientUserAgentOptionsReachTheWireDeadlinereturnsLifetime(0)TestKeyLifetimeAndDeadlineSendValidDuration/deadline_is_converted_to_the_time_leftLifetimeignores its argumentTestKeyLifetimeAndDeadlineSendValidDurationpageno longer callslocker.Lock()TestListLockerIsHeldDuringEachListRequestpageunlocks before the request instead of deferringTestListLockerIsHeldDuringEachListRequestCountByMethodstops countingTestStatusCountsRPCsByMethodLive test: none needed. The tests pin what blazer sends and how it reads the authorize response; nothing depends on how B2 answers. The simulator contract is NOT RUN for the same reason as #205: only
_test.gofiles change.Risk
None for callers: test files only, no exported API or request changes. The riskiest part is
TestKeyLifetimeAndDeadlineSendValidDuration/deadline_is_converted_to_the_time_left, which allows 30 seconds between theDeadlinecall and the request.How to revert
Reverting this commit is enough.
Checklist
make cipasses locally, exceptlint(see Testing).Deadlinewindow) are intentional: the order is the oneaddHeadershas always sent, and the window passed 30 runs under-race -shuffle=on -cpu 1,4..changes/unreleasedentry exists, or the PR is labelledskip-changelog. (Not needed: only_test.gofiles change, whichchangelog-checkexcludes.)AGENTS.mdare updated if needed. (None needed.)🤖 Generated with Claude Code