| 1234567891011121314151617181920212223242526272829303132 |
- package webhooks
- import (
- "testing"
- "github.com/stretchr/testify/assert"
- config "github.com/OliveTin/OliveTin/internal/config"
- )
- func TestFilterToDefinedArguments(t *testing.T) {
- action := &config.Action{
- Arguments: []config.ActionArgument{
- {Name: "repo", Type: "ascii_identifier"},
- {Name: "branch", Type: "ascii_identifier"},
- },
- }
- args := map[string]string{
- "repo": "my-repo",
- "branch": "main",
- "webhook_path": "/deploy/prod",
- "webhook_header_x_custom": "malicious",
- }
- filtered := filterToDefinedArguments(args, action)
- assert.Equal(t, "my-repo", filtered["repo"])
- assert.Equal(t, "main", filtered["branch"])
- assert.Empty(t, filtered["webhook_path"])
- assert.Empty(t, filtered["webhook_header_x_custom"])
- assert.Len(t, filtered, 2)
- }
|