-
Notifications
You must be signed in to change notification settings - Fork 192
/
echo_ingress_from_other_client_deny.go
35 lines (29 loc) · 1.36 KB
/
echo_ingress_from_other_client_deny.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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"
)
//go:embed manifests/echo-ingress-from-other-client-deny.yaml
var echoIngressFromOtherClientDenyPolicyYAML string
type echoIngressFromOtherClientDeny struct{}
func (t echoIngressFromOtherClientDeny) build(ct *check.ConnectivityTest, _ map[string]string) {
// Tests with deny policy
newTest("echo-ingress-from-other-client-deny", ct).
WithCiliumPolicy(allowAllEgressPolicyYAML). // Allow all egress traffic
WithCiliumPolicy(allowAllIngressPolicyYAML). // Allow all ingress traffic
WithCiliumPolicy(echoIngressFromOtherClientDenyPolicyYAML). // Deny other client contact echo
WithScenarios(
tests.PodToPod(tests.WithSourceLabelsOption(clientLabel)), // Client to echo should be allowed
tests.PodToPod(tests.WithSourceLabelsOption(client2Label)), // Client2 to echo should be denied
tests.ClientToClient(), // Client to client should be allowed
).
WithExpectations(func(a *check.Action) (egress, ingress check.Result) {
if a.Source().HasLabel("other", "client") && a.Destination().HasLabel("kind", "echo") {
return check.ResultDrop, check.ResultPolicyDenyIngressDrop
}
return check.ResultOK, check.ResultOK
})
}