本文整理汇总了Golang中github.com/openshift/origin/pkg/authorization/registry/test.NewPolicyRegistry函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPolicyRegistry函数的具体用法?Golang NewPolicyRegistry怎么用?Golang NewPolicyRegistry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPolicyRegistry函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: makeTestStorage
func makeTestStorage() rolebindingregistry.Storage {
clusterBindingRegistry := test.NewClusterPolicyBindingRegistry(testNewClusterBindings(), nil)
bindingRegistry := test.NewPolicyBindingRegistry(testNewLocalBindings(), nil)
clusterPolicyRegistry := test.NewClusterPolicyRegistry(testNewClusterPolicies(), nil)
policyRegistry := test.NewPolicyRegistry([]authorizationapi.Policy{}, nil)
return NewVirtualStorage(bindingRegistry, rulevalidation.NewDefaultRuleResolver(policyRegistry, bindingRegistry, clusterPolicyRegistry, clusterBindingRegistry), nil, authorizationapi.Resource("rolebinding"))
}
示例2: makeTestStorage
func makeTestStorage() rolebindingregistry.Storage {
clusterBindingRegistry := test.NewClusterPolicyBindingRegistry(testNewClusterBindings(), nil)
bindingRegistry := test.NewPolicyBindingRegistry(testNewLocalBindings(), nil)
clusterPolicyRegistry := test.NewClusterPolicyRegistry(testNewClusterPolicies(), nil)
policyRegistry := test.NewPolicyRegistry([]authorizationapi.Policy{}, nil)
return NewVirtualStorage(policyRegistry, bindingRegistry, clusterPolicyRegistry, clusterBindingRegistry)
}
示例3: beforeTestingSetup_readonlypolicycache
func beforeTestingSetup_readonlypolicycache() (testCache *readOnlyPolicyCache, cacheChannel, testChannel chan struct{}) {
cacheChannel = make(chan struct{})
testRegistry := testregistry.NewPolicyRegistry(testPolicies, nil)
testCache = NewReadOnlyPolicyCache(testRegistry)
testCache.RunUntil(cacheChannel)
testChannel = make(chan struct{})
return
}
示例4: test
func (test *subjectsTest) test(t *testing.T) {
policyRegistry := testpolicyregistry.NewPolicyRegistry(test.policies, test.policyRetrievalError)
policyBindingRegistry := testpolicyregistry.NewPolicyBindingRegistry(test.bindings, test.bindingRetrievalError)
clusterPolicyRegistry := testpolicyregistry.NewClusterPolicyRegistry(test.clusterPolicies, test.policyRetrievalError)
clusterPolicyBindingRegistry := testpolicyregistry.NewClusterPolicyBindingRegistry(test.clusterBindings, test.bindingRetrievalError)
authorizer := NewAuthorizer(rulevalidation.NewDefaultRuleResolver(policyRegistry, policyBindingRegistry, clusterPolicyRegistry, clusterPolicyBindingRegistry), NewForbiddenMessageResolver(""))
actualUsers, actualGroups, actualError := authorizer.GetAllowedSubjects(test.context, *test.attributes)
matchStringSlice(test.expectedUsers.List(), actualUsers.List(), "users", t)
matchStringSlice(test.expectedGroups.List(), actualGroups.List(), "groups", t)
matchError(test.expectedError, actualError, "error", t)
}
示例5: beforeTestingSetup_readonlycache
func beforeTestingSetup_readonlycache() (testClient client.ReadOnlyPolicyClient, policyStopChannel, bindingStopChannel, testChannel chan struct{}) {
policyStopChannel = make(chan struct{})
bindingStopChannel = make(chan struct{})
testChannel = make(chan struct{})
policyRegistry := testregistry.NewPolicyRegistry(testPolicies, nil)
clusterPolicyRegistry := testregistry.NewClusterPolicyRegistry(testClusterPolicies, nil)
policyBindingRegistry := testregistry.NewPolicyBindingRegistry(testPolicyBindings, nil)
clusterPolicyBindingRegistry := testregistry.NewClusterPolicyBindingRegistry(testClusterPolicyBindings, nil)
testCache, testClient := NewReadOnlyCacheAndClient(policyBindingRegistry, policyRegistry, clusterPolicyBindingRegistry, clusterPolicyRegistry)
testCache.RunUntil(bindingStopChannel, policyStopChannel)
return
}
示例6: test
func (test *authorizeTest) test(t *testing.T) {
policyRegistry := testpolicyregistry.NewPolicyRegistry(test.policies, test.policyRetrievalError)
policyBindingRegistry := testpolicyregistry.NewPolicyBindingRegistry(test.bindings, test.bindingRetrievalError)
clusterPolicyRegistry := testpolicyregistry.NewClusterPolicyRegistry(test.clusterPolicies, test.policyRetrievalError)
clusterPolicyBindingRegistry := testpolicyregistry.NewClusterPolicyBindingRegistry(test.clusterBindings, test.bindingRetrievalError)
authorizer := NewAuthorizer(rulevalidation.NewDefaultRuleResolver(policyRegistry, policyBindingRegistry, clusterPolicyRegistry, clusterPolicyBindingRegistry), NewForbiddenMessageResolver(""))
actualAllowed, actualReason, actualError := authorizer.Authorize(test.context, *test.attributes)
matchBool(test.expectedAllowed, actualAllowed, "allowed", t)
if actualAllowed {
containsString(test.expectedReason, actualReason, "allowReason", t)
} else {
containsString(test.expectedReason, actualReason, "denyReason", t)
matchError(test.expectedError, actualError, "error", t)
}
}
示例7: makeLocalTestStorage
func makeLocalTestStorage() roleregistry.Storage {
policyRegistry := test.NewPolicyRegistry(testNewLocalPolicies(), nil)
return NewVirtualStorage(policyRegistry, rulevalidation.NewDefaultRuleResolver(policyRegistry, &test.PolicyBindingRegistry{}, &test.ClusterPolicyRegistry{}, &test.ClusterPolicyBindingRegistry{}), nil, authorizationapi.Resource("role"))
}
示例8: makeLocalTestStorage
func makeLocalTestStorage() roleregistry.Storage {
policyRegistry := test.NewPolicyRegistry(testNewLocalPolicies(), nil)
return NewVirtualStorage(policyRegistry)
}