Skip to content

Commit

Permalink
grant additional scope and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellmars committed Nov 20, 2024
1 parent fb20f58 commit f7e9ae8
Show file tree
Hide file tree
Showing 2 changed files with 465 additions and 0 deletions.
35 changes: 35 additions & 0 deletions services/oauth2_provider/additional_scopes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package oauth2_provider //nolint

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestGrantAdditionalScopes(t *testing.T) {
tests := []struct {
grantScopes string
expectedScopes string
}{
{"openid profile email", "all"},
{"openid profile email groups", "all"},
{"openid profile email all", "all"},
{"openid profile email read:user all", "all"},
{"openid profile email groups read:user", "read:user"},
{"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"},
{"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) {
result := GrantAdditionalScopes(test.grantScopes)
assert.Equal(t, test.expectedScopes, string(result))
})
}
}
Loading

0 comments on commit f7e9ae8

Please sign in to comment.