Files
kubesphere/pkg/apiserver/authentication/oauth/oidc_test.go
KubeSphere CI Bot 447a51f08b feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
2024-09-06 11:05:52 +08:00

67 lines
1.3 KiB
Go

/*
* Please refer to the LICENSE file in the root directory of the project.
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
*/
package oauth
import "testing"
func TestIsValidResponseTypes(t *testing.T) {
type args struct {
responseTypes []string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "valid response type",
args: args{responseTypes: []string{"code", "id_token"}},
want: true,
},
{
name: "invalid response type",
args: args{responseTypes: []string{"value"}},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsValidResponseTypes(tt.args.responseTypes); got != tt.want {
t.Errorf("IsValidResponseTypes() = %v, want %v", got, tt.want)
}
})
}
}
func TestIsValidScopes(t *testing.T) {
type args struct {
scopes []string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "valid scope",
args: args{scopes: []string{"openid", "email"}},
want: true,
},
{
name: "invalid scope",
args: args{scopes: []string{"user"}},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsValidScopes(tt.args.scopes); got != tt.want {
t.Errorf("IsValidScopes() = %v, want %v", got, tt.want)
}
})
}
}