Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a553df

Browse files
committed
chore: work on unit test for device auth
1 parentda21464 commit9a553df

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎coderd/externalauth_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,32 @@ func TestExternalAuthManagement(t *testing.T) {
264264

265265
funcTestExternalAuthDevice(t*testing.T) {
266266
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+
267293
t.Run("NotSupported",func(t*testing.T) {
268294
t.Parallel()
269295
client:=coderdtest.New(t,&coderdtest.Options{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp