@@ -149,7 +149,7 @@ func NewFakeIDP(t testing.TB, opts ...FakeIDPOpt) *FakeIDP {
149
149
150
150
idp .updateIssuerURL (t , idp .issuer )
151
151
if idp .serve {
152
- idp .Serve (t )
152
+ idp .realServer (t )
153
153
}
154
154
155
155
return idp
@@ -176,8 +176,8 @@ func (f *FakeIDP) updateIssuerURL(t testing.TB, issuer string) {
176
176
}
177
177
}
178
178
179
- // Serve is optional, but turns the FakeIDP into a real http server.
180
- func (f * FakeIDP ) Serve (t testing.TB ) * httptest.Server {
179
+ // realServer turns the FakeIDP into a real http server.
180
+ func (f * FakeIDP ) realServer (t testing.TB ) * httptest.Server {
181
181
t .Helper ()
182
182
183
183
ctx , cancel := context .WithCancel (context .Background ())
@@ -222,14 +222,14 @@ func (f *FakeIDP) AttemptLogin(t testing.TB, client *codersdk.Client, idTokenCla
222
222
unauthenticated := codersdk .New (client .URL )
223
223
unauthenticated .HTTPClient = shallowCpyCli
224
224
225
- return f .LoginClient (t , unauthenticated , idTokenClaims , opts ... )
225
+ return f .LoginWithClient (t , unauthenticated , idTokenClaims , opts ... )
226
226
}
227
227
228
- // LoginClient reuses the context of the passed in client. This means the same
228
+ // LoginWithClient reuses the context of the passed in client. This means the same
229
229
// cookies will be used. This should be an unauthenticated client in most cases.
230
230
//
231
231
// This is a niche case, but it is needed for testing ConvertLoginType.
232
- func (f * FakeIDP ) LoginClient (t testing.TB , client * codersdk.Client , idTokenClaims jwt.MapClaims , opts ... func (r * http.Request )) (* codersdk.Client , * http.Response ) {
232
+ func (f * FakeIDP ) LoginWithClient (t testing.TB , client * codersdk.Client , idTokenClaims jwt.MapClaims , opts ... func (r * http.Request )) (* codersdk.Client , * http.Response ) {
233
233
t .Helper ()
234
234
235
235
coderOauthURL , err := client .URL .Parse ("/api/v2/users/oidc/callback" )
@@ -285,6 +285,10 @@ func (f *FakeIDP) LoginClient(t testing.TB, client *codersdk.Client, idTokenClai
285
285
// The flow starts at the user hitting the OIDC login page.
286
286
func (f * FakeIDP ) OIDCCallback (t testing.TB , state string , idTokenClaims jwt.MapClaims ) (* http.Response , error ) {
287
287
t .Helper ()
288
+ if f .serve {
289
+ panic ("cannot use OIDCCallback with WithServing. This is only for the in memory usage" )
290
+ }
291
+
288
292
f .stateToIDTokenClaims .Store (state , idTokenClaims )
289
293
290
294
cli := f .HTTPClient (nil )
0 commit comments