@@ -264,6 +264,32 @@ func TestExternalAuthManagement(t *testing.T) {
264
264
265
265
func TestExternalAuthDevice (t * testing.T ) {
266
266
t .Parallel ()
267
+ // This is an example test on how to do device auth flow using our fake idp.
268
+ t .Run ("WithFakeIDP" , func (t * testing.T ) {
269
+ t .Parallel ()
270
+ fake := oidctest .NewFakeIDP (t , oidctest .WithServing ())
271
+ externalID := "fake-idp"
272
+ cfg := fake .ExternalAuthConfig (t , externalID , & oidctest.ExternalAuthConfigOptions {
273
+ UseDeviceAuth : true ,
274
+ })
275
+
276
+ client := coderdtest .New (t , & coderdtest.Options {
277
+ ExternalAuthConfigs : []* externalauth.Config {cfg },
278
+ })
279
+ coderdtest .CreateFirstUser (t , client )
280
+ device , err := client .ExternalAuthDeviceByID (context .Background (), externalID )
281
+ require .NoError (t , err )
282
+
283
+ ctx := testutil .Context (t , testutil .WaitShort )
284
+ resp , err := client .Request (ctx , http .MethodPost , device .VerificationURI , nil )
285
+ require .NoError (t , err )
286
+ fmt .Println (resp .StatusCode )
287
+
288
+ extAuth , err := client .ExternalAuthByID (context .Background (), externalID )
289
+ require .NoError (t , err )
290
+ require .True (t , extAuth .Authenticated )
291
+ })
292
+
267
293
t .Run ("NotSupported" , func (t * testing.T ) {
268
294
t .Parallel ()
269
295
client := coderdtest .New (t , & coderdtest.Options {
0 commit comments