generated from TrueCloudLab/basic
[#56] storage: Allow to remove all chains by target
All checks were successful
DCO action / DCO (pull_request) Successful in 1m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m20s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m24s
Tests and linters / Tests with -race (pull_request) Successful in 1m36s
Tests and linters / Staticcheck (pull_request) Successful in 1m38s
Tests and linters / Lint (pull_request) Successful in 2m38s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m20s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m24s
Tests and linters / Tests with -race (pull_request) Successful in 1m36s
Tests and linters / Staticcheck (pull_request) Successful in 1m38s
Tests and linters / Lint (pull_request) Successful in 2m38s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
8cb2de05ab
commit
2ec958cbfd
6 changed files with 145 additions and 20 deletions
|
@ -245,6 +245,48 @@ func TestInmemory(t *testing.T) {
|
|||
require.False(t, ok)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("remove all", func(t *testing.T) {
|
||||
s := NewInMemoryLocalOverrides()
|
||||
_, _, err := s.MorphRuleChainStorage().AddMorphRuleChain(chain.Ingress, engine.NamespaceTarget(namespace), &chain.Chain{
|
||||
Rules: []chain.Rule{
|
||||
{
|
||||
Status: chain.AccessDenied,
|
||||
Actions: chain.Actions{Inverted: true, Names: []string{"native::object::get"}},
|
||||
Resources: chain.Resources{Inverted: true, Names: []string{object}},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, _, err = s.MorphRuleChainStorage().AddMorphRuleChain(chain.Ingress, engine.NamespaceTarget(namespace2), &chain.Chain{
|
||||
Rules: []chain.Rule{
|
||||
{
|
||||
Status: chain.Allow,
|
||||
Actions: chain.Actions{Inverted: true, Names: []string{"native::object::get"}},
|
||||
Resources: chain.Resources{Inverted: true, Names: []string{object}},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, _, err = s.MorphRuleChainStorage().AddMorphRuleChain(chain.Ingress, engine.NamespaceTarget(namespace2), &chain.Chain{
|
||||
Rules: []chain.Rule{
|
||||
{
|
||||
Status: chain.AccessDenied,
|
||||
Actions: chain.Actions{Inverted: true, Names: []string{"native::object::get"}},
|
||||
Resources: chain.Resources{Inverted: true, Names: []string{object}},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, _, err = s.MorphRuleChainStorage().RemoveMorphRuleChainsByTarget(chain.Ingress, engine.NamespaceTarget(namespace2))
|
||||
require.NoError(t, err)
|
||||
chains, err := s.MorphRuleChainStorage().ListMorphRuleChains(chain.Ingress, engine.NamespaceTarget(namespace2))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(chains))
|
||||
chains, err = s.MorphRuleChainStorage().ListMorphRuleChains(chain.Ingress, engine.NamespaceTarget(namespace))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(chains))
|
||||
})
|
||||
}
|
||||
|
||||
func itemStacksEqual(t *testing.T, got []stackitem.Item, expected []stackitem.Item) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue