|
||
---|---|---|
.. | ||
bad-resources.yaml | ||
chainsaw-test.yaml | ||
good-resources.yaml | ||
policy.yaml | ||
README.md | ||
reports-assert.yaml | ||
reports-error.yaml |
Description
This test ensures that a policy with two rules with different modes is applied correctly on resources and reports are successfully created.
Expected Behavior
-
Create a policy that has two rules:
- The first rule is
require-ns-purpose-label
in theEnforce
mode that requires thepurpose
label to be set on namespaces. - The second rule is
require-ns-env-label
in theAudit
mode that requires theenvironment
field to be set on namespaces.
- The first rule is
-
Create a
good-ns-1
namespace that has thepurpose
label. It is expected that the namespace will be created successfully. -
Create a
good-ns-2
namespace that has both thepurpose
andenvironment
labels. It is expected that the namespace will be created successfully. -
Create a
bad-ns-1
namespace that doesn't have thepurpose
label. It is expected that the namespace will be blocked with a message reporting the violation of therequire-ns-purpose-label
rule. -
Create a
bad-ns-2
namespace that doesn't have any labels. It is expected that the namespace will be blocked with messages reporting the violations of both rules. -
Two ClusterPolicyReports will be created for each of the
good-ns-1
andgood-ns-2
namespaces.
Reference Issue(s)
#10682