aboutsummaryrefslogtreecommitdiff
path: root/routers/web/auth/oauth_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/auth/oauth_test.go')
-rw-r--r--routers/web/auth/oauth_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/routers/web/auth/oauth_test.go b/routers/web/auth/oauth_test.go
index 5a09a9510..57f2477db 100644
--- a/routers/web/auth/oauth_test.go
+++ b/routers/web/auth/oauth_test.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/auth/source/oauth2"
"github.com/golang-jwt/jwt/v4"
@@ -66,6 +67,24 @@ func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
// Scopes: openid profile email
oidcToken = createAndParseToken(t, grants[0])
+ assert.Equal(t, user.Name, oidcToken.Name)
+ assert.Equal(t, user.Name, oidcToken.PreferredUsername)
+ assert.Equal(t, user.HTMLURL(), oidcToken.Profile)
+ assert.Equal(t, user.AvatarLink(), oidcToken.Picture)
+ assert.Equal(t, user.Website, oidcToken.Website)
+ assert.Equal(t, user.UpdatedUnix, oidcToken.UpdatedAt)
+ assert.Equal(t, user.Email, oidcToken.Email)
+ assert.Equal(t, user.IsActive, oidcToken.EmailVerified)
+
+ // set DefaultShowFullName to true
+ oldDefaultShowFullName := setting.UI.DefaultShowFullName
+ setting.UI.DefaultShowFullName = true
+ defer func() {
+ setting.UI.DefaultShowFullName = oldDefaultShowFullName
+ }()
+
+ // Scopes: openid profile email
+ oidcToken = createAndParseToken(t, grants[0])
assert.Equal(t, user.FullName, oidcToken.Name)
assert.Equal(t, user.Name, oidcToken.PreferredUsername)
assert.Equal(t, user.HTMLURL(), oidcToken.Profile)