Skip to content

Commit 7187ccb

Browse files
committed
grant additional scope and integration tests
1 parent e1c24f1 commit 7187ccb

File tree

2 files changed

+465
-0
lines changed

2 files changed

+465
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package oauth2_provider //nolint
5+
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestGrantAdditionalScopes(t *testing.T) {
13+
tests := []struct {
14+
grantScopes string
15+
expectedScopes string
16+
}{
17+
{"openid profile email", "all"},
18+
{"openid profile email groups", "all"},
19+
{"openid profile email all", "all"},
20+
{"openid profile email read:user all", "all"},
21+
{"openid profile email groups read:user", "read:user"},
22+
{"read:user read:repository", "read:repository,read:user"},
23+
{"read:user write:issue public-only", "public-only,write:issue,read:user"},
24+
{"openid profile email read:user", "read:user"},
25+
{"read:invalid_scope", "all"},
26+
{"read:invalid_scope,write:scope_invalid,just-plain-wrong", "all"},
27+
}
28+
29+
for _, test := range tests {
30+
t.Run(test.grantScopes, func(t *testing.T) {
31+
result := GrantAdditionalScopes(test.grantScopes)
32+
assert.Equal(t, test.expectedScopes, string(result))
33+
})
34+
}
35+
}

0 commit comments

Comments
 (0)