Fix authentication test API key formats and resolve test failures#18
Merged
jonwraymond merged 1 commit intoSep 18, 2025
Merged
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Copilot
AI
changed the title
[WIP] Go through all my prs that are open and let's get them merged and fixed
Fix authentication test API key formats and resolve test failures
Sep 18, 2025
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.
Problem
The authentication package tests were failing due to invalid API key formats that didn't match the validation requirements. The validator expects API keys to follow the pattern
sk-ant-[a-zA-Z0-9\-_]+, but test cases were using keys liketest-api-key-not-real-valid-test-key-123456789which lack the requiredsk-ant-prefix.This was causing systematic test failures across the auth package:
=== FAIL: TestNewAPIKeyAuthenticator/valid_api_key (0.00s) auth_test.go:47: NewAPIKeyAuthenticator() error = invalid API key: invalid API key format: API key must match pattern, wantErr falseSolution
Updated all test API keys across the authentication package to use proper
sk-ant-prefixed formats while maintaining test coverage and security:sk-ant-api03-validtestkey1234567890abcdefghijklmnopqrstuvwxyzThe new test keys:
sk-ant-prefix patternapi03-andvalidtestprefixesTesting
All authentication tests now pass successfully:
$ go test -v ./pkg/auth/ === RUN TestNewAPIKeyAuthenticator === RUN TestAPIKeyAuthenticator_Authenticate === RUN TestValidator_ValidateAPIKey --- PASS: TestValidator_ValidateAPIKey (0.00s) PASS ok github.com/jonwraymond/go-claude-code-sdk/pkg/auth 0.006sFull test suite also passes with no failures across all packages (auth, client, errors, mocks, types).
Impact
This fix unblocks the repository for merging other pending dependency updates and improvements.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.