@ -14,6 +14,7 @@ func TestGrantAdditionalScopes(t *testing.T) {
grantScopes string
grantScopes string
expectedScopes string
expectedScopes string
} {
} {
{ "" , "all" } , // for old tokens without scope, treat it as "all"
{ "openid profile email" , "all" } ,
{ "openid profile email" , "all" } ,
{ "openid profile email groups" , "all" } ,
{ "openid profile email groups" , "all" } ,
{ "openid profile email all" , "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 read:repository" , "read:repository,read:user" } ,
{ "read:user write:issue public-only" , "public-only,write:issue,read:user" } ,
{ "read:user write:issue public-only" , "public-only,write:issue,read:user" } ,
{ "openid profile email read:user" , "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" , "all" } ,
{ "read:invalid_scope,write:scope_invalid,just-plain-wrong" , "all" } ,
{ "read:invalid_scope,write:scope_invalid,just-plain-wrong" , "all" } ,
}
}
for _ , test := range tests {
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 )
result := GrantAdditionalScopes ( test . grantScopes )
assert . Equal ( t , test . expectedScopes , string ( result ) )
assert . Equal ( t , test . expectedScopes , string ( result ) )
} )
} )