MCPcopy
hub / github.com/yusing/godoxy / setupMockOIDC

Function setupMockOIDC

internal/auth/oidc_test.go:24–48  ·  view source on GitHub ↗

setupMockOIDC configures mock OIDC provider for testing.

(t *testing.T)

Source from the content-addressed store, hash-verified

22
23// setupMockOIDC configures mock OIDC provider for testing.
24func setupMockOIDC(t *testing.T) {
25 t.Helper()
26
27 provider := (&oidc.ProviderConfig{}).NewProvider(t.Context())
28 defaultAuth = &OIDCProvider{
29 oauthConfig: &oauth2.Config{
30 ClientID: "test-client",
31 ClientSecret: "test-secret",
32 RedirectURL: "http://localhost/callback",
33 Endpoint: oauth2.Endpoint{
34 AuthURL: "http://mock-provider/auth",
35 TokenURL: "http://mock-provider/token",
36 },
37 Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
38 },
39 endSessionURL: expect.Must(url.Parse("http://mock-provider/logout")),
40 oidcProvider: provider,
41 oidcVerifier: provider.Verifier(&oidc.Config{
42 ClientID: "test-client",
43 }),
44 allowedUsers: []string{"test-user"},
45 allowedGroups: []string{"test-group1", "test-group2"},
46 rateLimit: rate.NewLimiter(rate.Every(common.OIDCRateLimitPeriod), common.OIDCRateLimit),
47 }
48}
49
50// discoveryDocument returns a mock OIDC discovery document.
51func discoveryDocument(t *testing.T, server *httptest.Server) map[string]any {

Callers 4

TestOIDCLoginHandlerFunction · 0.85
TestOIDCCallbackHandlerFunction · 0.85
TestInitOIDCFunction · 0.85
TestLogoutHandlerFunction · 0.85

Calls 2

ContextMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected