Combine RequestAuditConfig with RequestAuditConfigWithLevel

This commit is contained in:
Tim Allclair
2022-11-02 15:23:48 -07:00
parent de95671f0c
commit 1a1ca5173e
5 changed files with 29 additions and 44 deletions

View File

@@ -50,14 +50,14 @@ func TestWebhookLoopback(t *testing.T) {
// Hook into audit to watch requests
config.GenericConfig.AuditBackend = auditSinkFunc(func(events ...*auditinternal.Event) {})
config.GenericConfig.AuditPolicyRuleEvaluator = auditPolicyRuleEvaluator(func(attrs authorizer.Attributes) audit.RequestAuditConfigWithLevel {
config.GenericConfig.AuditPolicyRuleEvaluator = auditPolicyRuleEvaluator(func(attrs authorizer.Attributes) audit.RequestAuditConfig {
if attrs.GetPath() == webhookPath {
if attrs.GetUser().GetName() != "system:apiserver" {
t.Errorf("expected user %q, got %q", "system:apiserver", attrs.GetUser().GetName())
}
atomic.AddInt32(&called, 1)
}
return audit.RequestAuditConfigWithLevel{
return audit.RequestAuditConfig{
Level: auditinternal.LevelNone,
}
})
@@ -107,9 +107,9 @@ func TestWebhookLoopback(t *testing.T) {
}
}
type auditPolicyRuleEvaluator func(authorizer.Attributes) audit.RequestAuditConfigWithLevel
type auditPolicyRuleEvaluator func(authorizer.Attributes) audit.RequestAuditConfig
func (f auditPolicyRuleEvaluator) EvaluatePolicyRule(attrs authorizer.Attributes) audit.RequestAuditConfigWithLevel {
func (f auditPolicyRuleEvaluator) EvaluatePolicyRule(attrs authorizer.Attributes) audit.RequestAuditConfig {
return f(attrs)
}