mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
* fix(controller): decode old object for delete requests Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * fix(config): remove usergroups default Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * fix(config): remove usergroups default Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * sec(ghsa-2ww6-hf35-mfjm): intercept namespace subresource Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: conflicts Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * feat(api): add rulestatus api Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> --------- Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
76 lines
1.4 KiB
Go
76 lines
1.4 KiB
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//nolint:dupl
|
|
package api_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/projectcapsule/capsule/pkg/api"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAllowedListSpec_ExactMatch(t *testing.T) {
|
|
type tc struct {
|
|
In []string
|
|
True []string
|
|
False []string
|
|
}
|
|
|
|
for _, tc := range []tc{
|
|
{
|
|
[]string{"foo", "bar", "bizz", "buzz"},
|
|
[]string{"foo", "bar", "bizz", "buzz"},
|
|
[]string{"bing", "bong"},
|
|
},
|
|
{
|
|
[]string{"one", "two", "three"},
|
|
[]string{"one", "two", "three"},
|
|
[]string{"a", "b", "c"},
|
|
},
|
|
{
|
|
nil,
|
|
nil,
|
|
[]string{"any", "value"},
|
|
},
|
|
} {
|
|
a := api.AllowedListSpec{
|
|
Exact: tc.In,
|
|
}
|
|
|
|
for _, ok := range tc.True {
|
|
assert.True(t, a.ExactMatch(ok))
|
|
}
|
|
|
|
for _, ko := range tc.False {
|
|
assert.False(t, a.ExactMatch(ko))
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAllowedListSpec_RegexMatch(t *testing.T) {
|
|
type tc struct {
|
|
Regex string
|
|
True []string
|
|
False []string
|
|
}
|
|
|
|
for _, tc := range []tc{
|
|
{`first-\w+-pattern`, []string{"first-date-pattern", "first-year-pattern"}, []string{"broken", "first-year", "second-date-pattern"}},
|
|
{``, nil, []string{"any", "value"}},
|
|
} {
|
|
a := api.AllowedListSpec{
|
|
Regex: tc.Regex,
|
|
}
|
|
|
|
for _, ok := range tc.True {
|
|
assert.True(t, a.RegexMatch(ok))
|
|
}
|
|
|
|
for _, ko := range tc.False {
|
|
assert.False(t, a.RegexMatch(ko))
|
|
}
|
|
}
|
|
}
|