forgejo_a_10.0.1/services/auth/additional_scopes_test.go
David Rotermund 3ce683f79b
Some checks failed
Integration tests for the release process / release-simulation (push) Has been cancelled
Init
2025-02-23 03:12:21 +01:00

32 lines
903 B
Go

package auth
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGrantAdditionalScopes(t *testing.T) {
tests := []struct {
grantScopes string
expectedScopes string
}{
{"openid profile email", ""},
{"openid profile email groups", ""},
{"openid profile email all", "all"},
{"openid profile email read:user all", "read:user,all"},
{"openid profile email groups read:user", "read:user"},
{"read:user read:repository", "read:user,read:repository"},
{"read:user write:issue public-only", "read:user,write:issue,public-only"},
{"openid profile email read:user", "read:user"},
{"read:invalid_scope", ""},
{"read:invalid_scope,write:scope_invalid,just-plain-wrong", ""},
}
for _, test := range tests {
t.Run(test.grantScopes, func(t *testing.T) {
result := grantAdditionalScopes(test.grantScopes)
assert.Equal(t, test.expectedScopes, result)
})
}
}