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>

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