Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Jan 30, 2026

Add integration test for the full OAuth 2.0 Authorization Code flow with PKCE using mockoidc as the upstream IDP.

TestIntegration_FullPKCEFlow validates the complete OAuth flow including authorization through the upstream IDP, client state preservation, token exchange with PKCE verification, and refresh token issuance via the offline_access scope. The test also verifies RFC 8707 resource parameter handling for audience binding and comprehensive JWT claims (iss, sub, aud, iat, exp, scp).

@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Jan 30, 2026
Add integration test for the full OAuth 2.0 Authorization Code flow with
PKCE using mockoidc as the upstream IDP.

TestIntegration_FullPKCEFlow validates the complete OAuth flow including
authorization through the upstream IDP, client state preservation, token
exchange with PKCE verification, and refresh token issuance via the
offline_access scope. The test also verifies RFC 8707 resource parameter
handling for audience binding and comprehensive JWT claims (iss, sub, aud,
iat, exp, scp).
@jhrozek jhrozek force-pushed the auth-proxy-pr-12-integration-test-1 branch from 2fc4b0a to fd666fb Compare January 30, 2026 12:25
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jan 30, 2026
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.31%. Comparing base (d7ee455) to head (3d40bf7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3531      +/-   ##
==========================================
- Coverage   65.35%   65.31%   -0.04%     
==========================================
  Files         403      403              
  Lines       39210    39210              
==========================================
- Hits        25625    25610      -15     
- Misses      11599    11614      +15     
  Partials     1986     1986              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// - Strategy: how to generate and validate tokens
// - Factories: which OAuth grant types to enable (each adds handlers for specific flows)
return compose.Compose(
provider := compose.Compose(
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just return the composer.Compose() without adding a var here

require.True(t, ok, "scp claim should be an array")
scopeStrings := make([]string, len(scope))
for i, s := range scope {
scopeStrings[i] = s.(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

you should validate the type here

}

tokenResp := makeTokenRequest(t, serverURL, params)
defer tokenResp.Body.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

we are closing the body twice... here and on parsetokenresponse

yrobla
yrobla previously approved these changes Jan 30, 2026
Copy link
Contributor

@yrobla yrobla left a comment

Choose a reason for hiding this comment

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

approved with some comments

jhrozek and others added 3 commits January 30, 2026 13:42
Remove defer resp.Body.Close() from parseTokenResponse since the caller
(exchangeCodeForTokens) is responsible for closing the body. Following
Go's convention that the caller of the function returning an *http.Response
owns the resource and handles cleanup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Check that each element in the scp claim array is a string, consistent
with how the outer array type assertion is validated. Provides a clear
test failure message instead of a panic if the token structure is
unexpected.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove intermediate variable assignment and return the result directly,
following idiomatic Go style.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants