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

Function TestVerifyPKCE

coderd/oauth2provider/pkce_test.go:14–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestVerifyPKCE(t *testing.T) {
15 t.Parallel()
16
17 tests := []struct {
18 name string
19 verifier string
20 challenge string
21 expectValid bool
22 }{
23 {
24 name: "ValidPKCE",
25 verifier: "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
26 challenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
27 expectValid: true,
28 },
29 {
30 name: "InvalidPKCE",
31 verifier: "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
32 challenge: "wrong_challenge",
33 expectValid: false,
34 },
35 {
36 name: "EmptyChallenge",
37 verifier: "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
38 challenge: "",
39 expectValid: false,
40 },
41 {
42 name: "EmptyVerifier",
43 verifier: "",
44 challenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
45 expectValid: false,
46 },
47 {
48 name: "BothEmpty",
49 verifier: "",
50 challenge: "",
51 expectValid: false,
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 t.Parallel()
58 result := oauth2provider.VerifyPKCE(tt.challenge, tt.verifier)
59 require.Equal(t, tt.expectValid, result)
60 })
61 }
62}
63
64func TestPKCES256Generation(t *testing.T) {
65 t.Parallel()

Callers

nothing calls this directly

Calls 3

VerifyPKCEFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected