A community based topic aggregation platform built on atproto

test(auth): add SetTestUserDID helper for integration tests

Add SetTestUserDID() function to inject user DID into context for testing.

Purpose:
- Mock authenticated users in integration tests without full OAuth flow
- Used by post handler tests to simulate authenticated requests
- Marked with comment: "ONLY be used in tests"

This enables testing authenticated endpoints (like post creation)
without requiring real PDS authentication in test environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+6
internal
api
middleware
+6
internal/api/middleware/auth.go
···
return claims
}
+
// SetTestUserDID sets the user DID in the context for testing purposes
+
// This function should ONLY be used in tests to mock authenticated users
+
func SetTestUserDID(ctx context.Context, userDID string) context.Context {
+
return context.WithValue(ctx, UserDIDKey, userDID)
+
}
+
// GetUserAccessToken extracts the user's access token from the request context
// Returns empty string if not authenticated
func GetUserAccessToken(r *http.Request) string {