MCPcopy Index your code
hub / github.com/coder/coder / setupOIDCTest

Function setupOIDCTest

enterprise/coderd/userauth_test.go:1179–1228  ·  view source on GitHub ↗
(t *testing.T, settings oidcTestConfig)

Source from the content-addressed store, hash-verified

1177}
1178
1179func setupOIDCTest(t *testing.T, settings oidcTestConfig) *oidcTestRunner {
1180 t.Helper()
1181
1182 fake := oidctest.NewFakeIDP(t,
1183 append([]oidctest.FakeIDPOpt{
1184 oidctest.WithStaticUserInfo(settings.Userinfo),
1185 oidctest.WithLogging(t, nil),
1186 // Run fake IDP on a real webserver
1187 oidctest.WithServing(),
1188 }, settings.FakeOpts...)...,
1189 )
1190
1191 ctx := testutil.Context(t, testutil.WaitMedium)
1192 cfg := fake.OIDCConfig(t, nil, settings.Config)
1193 dv := coderdtest.DeploymentValues(t)
1194 if settings.DeploymentValues != nil {
1195 settings.DeploymentValues(dv)
1196 }
1197 owner, _, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
1198 Options: &coderdtest.Options{
1199 OIDCConfig: cfg,
1200 DeploymentValues: dv,
1201 },
1202 LicenseOptions: &coderdenttest.LicenseOptions{
1203 Features: license.Features{
1204 codersdk.FeatureUserRoleManagement: 1,
1205 codersdk.FeatureTemplateRBAC: 1,
1206 codersdk.FeatureMultipleOrganizations: 1,
1207 },
1208 },
1209 })
1210 admin, err := owner.User(ctx, "me")
1211 require.NoError(t, err)
1212
1213 helper := oidctest.NewLoginHelper(owner, fake)
1214
1215 return &oidcTestRunner{
1216 AdminClient: owner,
1217 AdminUser: admin,
1218 API: api,
1219 Login: helper.Login,
1220 AttemptLogin: helper.AttemptLogin,
1221 ForceRefresh: func(t *testing.T, client *codersdk.Client, idToken jwt.MapClaims) {
1222 helper.ForceRefresh(t, api.Database, client, idToken)
1223 },
1224 ExpireOauthToken: func(t *testing.T, client *codersdk.Client) {
1225 helper.ExpireOauthToken(t, api.Database, client)
1226 },
1227 }
1228}

Callers 2

TestUserOIDCFunction · 0.85
TestGroupSyncFunction · 0.85

Calls 14

OIDCConfigMethod · 0.95
ForceRefreshMethod · 0.95
ExpireOauthTokenMethod · 0.95
NewFakeIDPFunction · 0.92
WithStaticUserInfoFunction · 0.92
WithLoggingFunction · 0.92
WithServingFunction · 0.92
ContextFunction · 0.92
DeploymentValuesFunction · 0.92
NewWithAPIFunction · 0.92
NewLoginHelperFunction · 0.92
DeploymentValuesMethod · 0.80

Tested by

no test coverage detected