-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectivity: introduce host firewall tests
Introduce two new tests covering the host firewall functionality, i.e., asserting that both ingress and egress CiliumClusterwideNetworkPolicies specifying a NodeSelector correctly block the expected traffic. The tests are executed only when the unsafe tests are enabled, as potentially disruptive if executed against a live cluster. Signed-off-by: viktor-kurchenko <[email protected]>
- Loading branch information
1 parent
756ae50
commit 55ce847
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package builder | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/cilium/cilium-cli/connectivity/check" | ||
"github.com/cilium/cilium-cli/connectivity/tests" | ||
"github.com/cilium/cilium-cli/utils/features" | ||
) | ||
|
||
//go:embed manifests/host-firewall-egress.yaml | ||
var hostFirewallEgressPolicyYAML string | ||
|
||
type hostFirewallEgress struct{} | ||
|
||
func (t hostFirewallEgress) build(ct *check.ConnectivityTest, _ map[string]string) { | ||
newTest("host-firewall-egress", ct). | ||
WithCondition(func() bool { return ct.Params().IncludeUnsafeTests }). | ||
WithFeatureRequirements(features.RequireEnabled(features.HostFirewall)). | ||
WithCiliumClusterwidePolicy(hostFirewallEgressPolicyYAML). | ||
WithScenarios(tests.HostToPod()). | ||
WithExpectations(func(a *check.Action) (egress check.Result, ingress check.Result) { | ||
if a.Destination().HasLabel("name", "echo-other-node") { | ||
return check.ResultPolicyDenyEgressDrop, check.ResultOK | ||
} | ||
return check.ResultOK, check.ResultOK | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package builder | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/cilium/cilium-cli/connectivity/check" | ||
"github.com/cilium/cilium-cli/connectivity/tests" | ||
"github.com/cilium/cilium-cli/utils/features" | ||
) | ||
|
||
//go:embed manifests/host-firewall-ingress.yaml | ||
var hostFirewallIngressPolicyYAML string | ||
|
||
type hostFirewallIngress struct{} | ||
|
||
func (t hostFirewallIngress) build(ct *check.ConnectivityTest, _ map[string]string) { | ||
newTest("host-firewall-ingress", ct). | ||
WithCondition(func() bool { return ct.Params().IncludeUnsafeTests }). | ||
WithFeatureRequirements(features.RequireEnabled(features.HostFirewall)). | ||
WithCiliumClusterwidePolicy(hostFirewallIngressPolicyYAML). | ||
WithScenarios(tests.PodToHost()). | ||
WithExpectations(func(a *check.Action) (egress check.Result, ingress check.Result) { | ||
if a.Source().HasLabel("name", "client") { | ||
return check.ResultOK, check.ResultPolicyDenyIngressDrop | ||
} | ||
return check.ResultOK, check.ResultOK | ||
}) | ||
} |