chore: deduplicate OAuth login code (#3575)

This commit is contained in:
Jon Ayers
2022-08-22 18:13:46 -05:00
committed by GitHub
parent a07ca946c3
commit a7b49788f5
3 changed files with 252 additions and 298 deletions
+7 -2
View File
@@ -150,7 +150,7 @@ func TestUserOAuth2Github(t *testing.T) {
})
_ = coderdtest.CreateFirstUser(t, client)
resp := oauth2Callback(t, client)
require.Equal(t, http.StatusForbidden, resp.StatusCode)
require.Equal(t, http.StatusPreconditionRequired, resp.StatusCode)
})
t.Run("BlockSignups", func(t *testing.T) {
t.Parallel()
@@ -169,7 +169,11 @@ func TestUserOAuth2Github(t *testing.T) {
return &github.User{}, nil
},
ListEmails: func(ctx context.Context, client *http.Client) ([]*github.UserEmail, error) {
return []*github.UserEmail{}, nil
return []*github.UserEmail{{
Email: github.String("testuser@coder.com"),
Verified: github.Bool(true),
Primary: github.Bool(true),
}}, nil
},
},
})
@@ -196,6 +200,7 @@ func TestUserOAuth2Github(t *testing.T) {
return []*github.UserEmail{{
Email: github.String("testuser@coder.com"),
Verified: github.Bool(true),
Primary: github.Bool(true),
}}, nil
},
},