chore: testIDP to be usable as primary auth (#13132)

Flags printed to console show as external or primary auth.
Usage assumes only 1 static oidc_member for now
This commit is contained in:
Steven Masley 2024-05-02 11:19:19 -05:00 committed by GitHub
parent 3de737fdc8
commit c2cb0e9fe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -84,7 +84,14 @@ func RunIDP() func(t *testing.T) {
return func(t *testing.T) {
idp := oidctest.NewFakeIDP(t,
oidctest.WithServing(),
oidctest.WithStaticUserInfo(jwt.MapClaims{}),
oidctest.WithStaticUserInfo(jwt.MapClaims{
// This is a static set of auth fields. Might be beneficial to make flags
// to allow different values here. This is only required for using the
// testIDP as primary auth. External auth does not ever fetch these fields.
"email": "oidc_member@coder.com",
"preferred_username": "oidc_member",
"email_verified": true,
}),
oidctest.WithDefaultIDClaims(jwt.MapClaims{}),
oidctest.WithDefaultExpire(*expiry),
oidctest.WithStaticCredentials(*clientID, *clientSecret),
@ -133,6 +140,8 @@ func RunIDP() func(t *testing.T) {
data, err := json.Marshal([]withClientSecret{cfg})
require.NoError(t, err)
log.Printf(`--external-auth-providers='%s'`, string(data))
log.Println("As primary OIDC auth")
log.Printf(`--oidc-issuer-url=%s --oidc-client-id=%s --oidc-client-secret=%s`, idp.IssuerURL().String(), *clientID, *clientSecret)
log.Println("Press Ctrl+C to exit")
c := make(chan os.Signal, 1)