Skip to content

Fix authentication test API key formats and resolve test failures#18

Merged
jonwraymond merged 1 commit into
mainfrom
copilot/fix-e55457fd-7508-407d-8d27-8f46aaec2ad0
Sep 18, 2025
Merged

Fix authentication test API key formats and resolve test failures#18
jonwraymond merged 1 commit into
mainfrom
copilot/fix-e55457fd-7508-407d-8d27-8f46aaec2ad0

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 18, 2025

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 like test-api-key-not-real-valid-test-key-123456789 which lack the required sk-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 false

Solution

Updated all test API keys across the authentication package to use proper sk-ant- prefixed formats while maintaining test coverage and security:

  • auth_test.go: Updated API key test cases to use sk-ant-api03-validtestkey1234567890abcdefghijklmnopqrstuvwxyz
  • manager_test.go: Fixed API key patterns in credential management tests
  • validator_test.go: Updated validation test cases to use compliant formats

The new test keys:

  • Follow the required sk-ant- prefix pattern
  • Are clearly marked as test keys with api03- and validtest prefixes
  • Meet length requirements (20-200 characters)
  • Pass entropy and security validation checks
  • Are safe for use in tests (not real API keys)

Testing

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.006s

Full test suite also passes with no failures across all packages (auth, client, errors, mocks, types).

Impact

  • ✅ Resolves all authentication test failures
  • ✅ Maintains existing test coverage and functionality
  • ✅ Enables CI/CD pipeline to proceed with other pending PRs
  • ✅ No breaking changes to public API
  • ✅ Test keys are clearly identified as non-production values

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.

@jonwraymond jonwraymond marked this pull request as ready for review September 18, 2025 02:19
Copilot AI review requested due to automatic review settings September 18, 2025 02:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@jonwraymond jonwraymond merged commit 68af407 into main Sep 18, 2025
2 checks passed
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
Copilot AI requested a review from jonwraymond September 18, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants