loading up the forgejo repo on tangled to test page performance
1package auth
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestGrantAdditionalScopes(t *testing.T) {
10 tests := []struct {
11 grantScopes string
12 expectedScopes string
13 }{
14 {"openid profile email", ""},
15 {"openid profile email groups", ""},
16 {"openid profile email all", "all"},
17 {"openid profile email read:user all", "read:user,all"},
18 {"openid profile email groups read:user", "read:user"},
19 {"read:user read:repository", "read:user,read:repository"},
20 {"read:user write:issue public-only", "read:user,write:issue,public-only"},
21 {"openid profile email read:user", "read:user"},
22 {"read:invalid_scope", ""},
23 {"read:invalid_scope,write:scope_invalid,just-plain-wrong", ""},
24 }
25
26 for _, test := range tests {
27 t.Run(test.grantScopes, func(t *testing.T) {
28 result := grantAdditionalScopes(test.grantScopes)
29 assert.Equal(t, test.expectedScopes, result)
30 })
31 }
32}