Skip to content

test: add full OIDC fake IDP #9317

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 20 commits into from
Aug 25, 2023
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
Fix import
  • Loading branch information
Emyrk committed Aug 24, 2023
commit dffeb16bb4ef240181d9ad3ddcfd14b37df30b71
4 changes: 1 addition & 3 deletions coderd/coderdtest/oidctest/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ func (f *FakeIDP) authenticateOIDClientRequest(t testing.TB, req *http.Request)
values, err := url.ParseQuery(string(data))
if !assert.NoError(t, err, "parse token request values") {
return nil, xerrors.New("invalid token request")

}

if !assert.Equal(t, f.clientID, values.Get("client_id"), "client_id mismatch") {
Expand Down Expand Up @@ -419,7 +418,7 @@ func (f *FakeIDP) httpHandler(t testing.TB) http.Handler {
state := r.URL.Query().Get("state")

scope := r.URL.Query().Get("scope")
var _ = scope
_ = scope

responseType := r.URL.Query().Get("response_type")
switch responseType {
Expand Down Expand Up @@ -557,7 +556,6 @@ func (f *FakeIDP) httpHandler(t testing.TB) http.Handler {
http.Error(rw, fmt.Sprintf("invalid user info request: %s", err.Error()), http.StatusBadRequest)
return
}
var _ = token

email, ok := f.accessTokens.Load(token)
if !ok {
Expand Down
14 changes: 2 additions & 12 deletions coderd/userauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"github.com/coder/coder/v2/coderd/database/dbgen"
"github.com/coder/coder/v2/coderd/database/dbtestutil"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
"github.com/coder/coder/v2/enterprise/coderd/license"
"github.com/coder/coder/v2/testutil"
)

Expand All @@ -49,16 +47,8 @@ func TestOIDCOauthLoginWithExisting(t *testing.T) {
cfg.IgnoreUserInfo = true
})

client, _, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
Options: &coderdtest.Options{
OIDCConfig: cfg,
},
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureUserRoleManagement: 1,
codersdk.FeatureTemplateRBAC: 1,
},
},
client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
OIDCConfig: cfg,
})

const username = "alice"
Expand Down