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

Function TestValidatePKCECodeChallengeMethod

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

Source from the content-addressed store, hash-verified

77}
78
79func TestValidatePKCECodeChallengeMethod(t *testing.T) {
80 t.Parallel()
81
82 tests := []struct {
83 name string
84 method string
85 expectError bool
86 errorContains string
87 }{
88 {
89 name: "EmptyIsValid",
90 method: "",
91 expectError: false,
92 },
93 {
94 name: "S256IsValid",
95 method: string(codersdk.OAuth2PKCECodeChallengeMethodS256),
96 expectError: false,
97 },
98 {
99 name: "PlainIsRejected",
100 method: string(codersdk.OAuth2PKCECodeChallengeMethodPlain),
101 expectError: true,
102 errorContains: "plain",
103 },
104 {
105 name: "UnknownIsRejected",
106 method: "unknown_method",
107 expectError: true,
108 errorContains: "unsupported",
109 },
110 }
111
112 for _, tt := range tests {
113 t.Run(tt.name, func(t *testing.T) {
114 t.Parallel()
115 err := codersdk.ValidatePKCECodeChallengeMethod(tt.method)
116 if tt.expectError {
117 require.Error(t, err)
118 if tt.errorContains != "" {
119 require.Contains(t, err.Error(), tt.errorContains)
120 }
121 } else {
122 require.NoError(t, err)
123 }
124 })
125 }
126}

Callers

nothing calls this directly

Calls 4

RunMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected