Skip to content

chore: add unit test for pass through external auth query params #12928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove excess error return
  • Loading branch information
Emyrk committed Apr 10, 2024
commit cfc78f22dc415ea550cc66888f7d6a779e941f99
4 changes: 2 additions & 2 deletions coderd/coderdtest/oidctest/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (f *FakeIDP) CreateAuthCode(t testing.TB, state string) string {
// something.
// Essentially this is used to fake the Coderd side of the exchange.
// The flow starts at the user hitting the OIDC login page.
func (f *FakeIDP) OIDCCallback(t testing.TB, state string, idTokenClaims jwt.MapClaims) (*http.Response, error) {
func (f *FakeIDP) OIDCCallback(t testing.TB, state string, idTokenClaims jwt.MapClaims) *http.Response {
t.Helper()
if f.serve {
panic("cannot use OIDCCallback with WithServing. This is only for the in memory usage")
Expand All @@ -625,7 +625,7 @@ func (f *FakeIDP) OIDCCallback(t testing.TB, state string, idTokenClaims jwt.Map
_ = resp.Body.Close()
}
})
return resp, nil
return resp
}

// ProviderJSON is the .well-known/configuration JSON
Expand Down
5 changes: 2 additions & 3 deletions coderd/coderdtest/oidctest/idp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ func TestFakeIDPBasicFlow(t *testing.T) {
token = oauthToken
})

resp, err := fake.OIDCCallback(t, expectedState, jwt.MapClaims{})
require.NoError(t, err)
resp := fake.OIDCCallback(t, expectedState, jwt.MapClaims{})
require.Equal(t, http.StatusOK, resp.StatusCode)

// Test the user info
_, err = cfg.Provider.UserInfo(ctx, oauth2.StaticTokenSource(token))
_, err := cfg.Provider.UserInfo(ctx, oauth2.StaticTokenSource(token))
require.NoError(t, err)

// Now test it can refresh
Expand Down
4 changes: 2 additions & 2 deletions coderd/externalauth/externalauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@

// Actually run an auth request. Although it says OIDC, the flow is the same
// for oauth2.
cli, resp := fake.OIDCCallback(t, state, jwt.MapClaims{})
resp := fake.OIDCCallback(t, state, jwt.MapClaims{})

Check failure on line 489 in coderd/externalauth/externalauth_test.go

View workflow job for this annotation

GitHub Actions / lint

response body must be closed (bodyclose)
require.True(t, callbackCalled)

require.Equal(t, http.StatusOK, resp.StatusCode)
}

type testConfig struct {
Expand Down
Loading