Benign repos Download

oidc_test.go

imports encoding/jsonimports net/http
SHA-256f0cd20f1b4eedeb5218daeeea6c2bee54e81ea42f4ef874169f261e6d8e05e76

Evidence

imports encoding/json lines 1–22
1package auth_test
2
3import (
4 "context"
5 "encoding/json"
6 "net/http"
7 "net/http/httptest"
8 "sync/atomic"
9 "testing"
10 "time"
11
12 "github.com/coreos/go-oidc/v3/oidc"
13 "github.com/stretchr/testify/require"
14
15 "github.com/fatedier/frp/pkg/auth"
16 v1 "github.com/fatedier/frp/pkg/config/v1"
17 "github.com/fatedier/frp/pkg/msg"
18)
19
20type mockTokenVerifier struct{}
21
22func (m *mockTokenVerifier) Verify(ctx context.Context, s …
Go test function name lines 23–30
23:7… n &oidc.IDToken{
24 Subject: subject,
25 }, nil
26}
27
28func TestPingWithEmptySubjectFromLoginFails(t *testing.T) {
29 r := require.New(t)
30 consumer := auth.NewOidcAuthVerifier([]v1.AuthScope{v1.AuthScopeHeartB …
English function-word token "with" lines 57–63
57:17… .VerifyLogin(&msg.Login{
58 PrivilegeKey: "login-with-first-subject",
59 })
60 r.NoError(err)
61
62 err = consumer.VerifyPing(&msg.Ping{
63 PrivilegeKey: "pin …
Native HTTP JSON content type lines 74–82
74:78… r, req *http.Request) {
75 requestCount.Add(1)
76 w.Header().Set("Content-Type", "application/json")
77 _ = json.NewEncoder(w).Encode(map[string]any{ //nolint:gosec // test-only dummy token response
78 "access_token": "fresh-test-token",
⋯4 lines
English function-word token "the" lines 87–95
⋯5 lines
92 r.NoError(err)
93
94 // Constructor fetches the initial token (1 request).
95 // Each subsequent call should also fetch a fresh token since there …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.