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

Function TestExchangeWithClientSecret

coderd/externalauth/externalauth_test.go:1169–1202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1167}
1168
1169func TestExchangeWithClientSecret(t *testing.T) {
1170 t.Parallel()
1171 instrument := promoauth.NewFactory(prometheus.NewRegistry())
1172 // This ensures a provider that requires the custom
1173 // client secret exchange works.
1174 configs, err := externalauth.ConvertConfig(instrument, []codersdk.ExternalAuthConfig{{
1175 // JFrog just happens to require this custom type.
1176
1177 Type: codersdk.EnhancedExternalAuthProviderJFrog.String(),
1178 ClientID: "id",
1179 ClientSecret: "secret",
1180 }}, &url.URL{})
1181 require.NoError(t, err)
1182 config := configs[0]
1183
1184 client := &http.Client{
1185 Transport: roundTripper(func(req *http.Request) (*http.Response, error) {
1186 require.Equal(t, "Bearer secret", req.Header.Get("Authorization"))
1187 rec := httptest.NewRecorder()
1188 rec.WriteHeader(http.StatusOK)
1189 body, err := json.Marshal(&oauth2.Token{
1190 AccessToken: "bananas",
1191 })
1192 if err != nil {
1193 return nil, err
1194 }
1195 _, err = rec.Write(body)
1196 return rec.Result(), err
1197 }),
1198 }
1199
1200 _, err = config.Exchange(context.WithValue(context.Background(), oauth2.HTTPClient, client), "code")
1201 require.NoError(t, err)
1202}
1203
1204func TestTokenRevocationResponseOk(t *testing.T) {
1205 t.Parallel()

Callers

nothing calls this directly

Calls 11

NewFactoryFunction · 0.92
ConvertConfigFunction · 0.92
roundTripperFuncType · 0.70
GetMethod · 0.65
WriteMethod · 0.65
ExchangeMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45
WriteHeaderMethod · 0.45
MarshalMethod · 0.45
ResultMethod · 0.45

Tested by

no test coverage detected