mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #55461 from hzxuzhonghu/authorize
Automatic merge from submit-queue (batch tested with PRs 55283, 55461, 55288, 53970, 55487). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. [authorize] rename test file and remove unused code **What this PR does / why we need it**: rename go test filename and remove unused code in builtin.go **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: nit fix, no impact to function. **Release note**: ```release-note NONE ```
This commit is contained in:
commit
14674f4508
@ -8,7 +8,7 @@ load(
|
|||||||
|
|
||||||
go_test(
|
go_test(
|
||||||
name = "go_default_test",
|
name = "go_default_test",
|
||||||
srcs = ["authz_test.go"],
|
srcs = ["builtin_test.go"],
|
||||||
importpath = "k8s.io/apiserver/pkg/authorization/authorizerfactory",
|
importpath = "k8s.io/apiserver/pkg/authorization/authorizerfactory",
|
||||||
library = ":go_default_library",
|
library = ":go_default_library",
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -68,19 +68,6 @@ func NewAlwaysDenyAuthorizer() *alwaysDenyAuthorizer {
|
|||||||
return new(alwaysDenyAuthorizer)
|
return new(alwaysDenyAuthorizer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// alwaysFailAuthorizer is an implementation of authorizer.Attributes
|
|
||||||
// which always says no to an authorization request.
|
|
||||||
// It is useful in unit tests to force an operation to fail with error.
|
|
||||||
type alwaysFailAuthorizer struct{}
|
|
||||||
|
|
||||||
func (alwaysFailAuthorizer) Authorize(a authorizer.Attributes) (authorized authorizer.Decision, reason string, err error) {
|
|
||||||
return authorizer.DecisionNoOpinion, "", errors.New("Authorization failure.")
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAlwaysFailAuthorizer() authorizer.Authorizer {
|
|
||||||
return new(alwaysFailAuthorizer)
|
|
||||||
}
|
|
||||||
|
|
||||||
type privilegedGroupAuthorizer struct {
|
type privilegedGroupAuthorizer struct {
|
||||||
groups []string
|
groups []string
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewAlwaysAllowAuthorizer must return a struct which implements authorizer.Authorizer
|
|
||||||
// and always return nil.
|
|
||||||
func TestNewAlwaysAllowAuthorizer(t *testing.T) {
|
func TestNewAlwaysAllowAuthorizer(t *testing.T) {
|
||||||
aaa := NewAlwaysAllowAuthorizer()
|
aaa := NewAlwaysAllowAuthorizer()
|
||||||
if decision, _, _ := aaa.Authorize(nil); decision != authorizer.DecisionAllow {
|
if decision, _, _ := aaa.Authorize(nil); decision != authorizer.DecisionAllow {
|
||||||
@ -32,8 +30,6 @@ func TestNewAlwaysAllowAuthorizer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAlwaysDenyAuthorizer must return a struct which implements authorizer.Authorizer
|
|
||||||
// and always return an error as everything is forbidden.
|
|
||||||
func TestNewAlwaysDenyAuthorizer(t *testing.T) {
|
func TestNewAlwaysDenyAuthorizer(t *testing.T) {
|
||||||
ada := NewAlwaysDenyAuthorizer()
|
ada := NewAlwaysDenyAuthorizer()
|
||||||
if decision, _, _ := ada.Authorize(nil); decision == authorizer.DecisionAllow {
|
if decision, _, _ := ada.Authorize(nil); decision == authorizer.DecisionAllow {
|
Loading…
Reference in New Issue
Block a user