mirror of
https://github.com/go-gitea/gitea
synced 2025-07-12 13:37:20 +00:00
Improve oauth2 scope token handling (#32633)
This commit is contained in:
@ -14,6 +14,7 @@ func TestGrantAdditionalScopes(t *testing.T) {
|
||||
grantScopes string
|
||||
expectedScopes string
|
||||
}{
|
||||
{"", "all"}, // for old tokens without scope, treat it as "all"
|
||||
{"openid profile email", "all"},
|
||||
{"openid profile email groups", "all"},
|
||||
{"openid profile email all", "all"},
|
||||
@ -22,12 +23,14 @@ func TestGrantAdditionalScopes(t *testing.T) {
|
||||
{"read:user read:repository", "read:repository,read:user"},
|
||||
{"read:user write:issue public-only", "public-only,write:issue,read:user"},
|
||||
{"openid profile email read:user", "read:user"},
|
||||
|
||||
// TODO: at the moment invalid tokens are treated as "all" to avoid breaking 1.22 behavior (more details are in GrantAdditionalScopes)
|
||||
{"read:invalid_scope", "all"},
|
||||
{"read:invalid_scope,write:scope_invalid,just-plain-wrong", "all"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.grantScopes, func(t *testing.T) {
|
||||
t.Run("scope:"+test.grantScopes, func(t *testing.T) {
|
||||
result := GrantAdditionalScopes(test.grantScopes)
|
||||
assert.Equal(t, test.expectedScopes, string(result))
|
||||
})
|
||||
|
Reference in New Issue
Block a user