Implement Policy Enforcer Plugin
- Added a new Policy Enforcer plugin to evaluate incoming messages against OPA policies. - Configurable via YAML with options for policy sources, actions, and query. - Integrated into existing configuration files for BAP and BPP. - Updated related tests and documentation for the new functionality. - Enhanced plugin manager to support Policy Enforcer instantiation.
This commit is contained in:
@@ -83,6 +83,11 @@ func (m *MockPluginManager) SchemaValidator(ctx context.Context, cfg *plugin.Con
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// PolicyEnforcer returns a mock implementation of the PolicyEnforcer interface.
|
||||
func (m *MockPluginManager) PolicyEnforcer(ctx context.Context, cfg *plugin.Config) (definition.PolicyEnforcer, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// mockRun is a mock implementation of the `run` function, simulating a successful run.
|
||||
func mockRun(ctx context.Context, configPath string) error {
|
||||
return nil // Simulate a successful run
|
||||
@@ -186,8 +191,8 @@ func TestRunFailure(t *testing.T) {
|
||||
}
|
||||
defer func() { newManagerFunc = originalNewManager }()
|
||||
|
||||
originalNewServer := newServerFunc
|
||||
newServerFunc = func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) {
|
||||
originalNewServer := newServerFunc
|
||||
newServerFunc = func(ctx context.Context, mgr handler.PluginManager, cfg *Config) (http.Handler, error) {
|
||||
return tt.mockServer(ctx, mgr, cfg)
|
||||
}
|
||||
defer func() { newServerFunc = originalNewServer }()
|
||||
|
||||
Reference in New Issue
Block a user