Skip to content

Commit 974b051

Browse files
committed
policy: Fix pass precedence test
Leave enough space after the pass verdict for all the passed rules to fit in before the following rules on the same tier. This is the requirement of the current API for correct behavior. Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
1 parent 714c0ef commit 974b051

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

tests/cilium_network_policy_test.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ TEST_F(CiliumNetworkPolicyTest, Precedence) {
19281928
remote_policies: [ 42 ]
19291929
- port: 80
19301930
rules:
1931-
- precedence: 850
1931+
- precedence: 750
19321932
deny: true
19331933
- precedence: 600
19341934
remote_policies: [ 41, 42, 43 ]
@@ -1947,10 +1947,16 @@ TEST_F(CiliumNetworkPolicyTest, Precedence) {
19471947
- rules:
19481948
- remotes: [41]
19491949
deny: true
1950-
precedence: 1150
1950+
precedence: 1050
1951+
- remotes: [42]
1952+
precedence: 800
1953+
http_rules:
1954+
- headers:
1955+
- name: ":path"
1956+
value: "/multi-tier"
19511957
- remotes: []
19521958
deny: true
1953-
precedence: 850
1959+
precedence: 750
19541960
egress:
19551961
rules: []
19561962
)EOF";
@@ -1959,8 +1965,8 @@ TEST_F(CiliumNetworkPolicyTest, Precedence) {
19591965

19601966
// Remote 41 hits the promoted deny from tier 1.
19611967
EXPECT_FALSE(ingressAllowed("10.1.2.3", 41, 80, {{":path", "/multi-tier"}}));
1962-
// Remote 42 is promoted by the lower wildcard tier, but remains below deny.
1963-
EXPECT_FALSE(ingressAllowed("10.1.2.3", 42, 80, {{":path", "/multi-tier"}}));
1968+
// Remote 42 is promoted by the lower wildcard tier
1969+
EXPECT_TRUE(ingressAllowed("10.1.2.3", 42, 80, {{":path", "/multi-tier"}}));
19641970
// Remote 43 is not promoted and is denied.
19651971
EXPECT_FALSE(ingressAllowed("10.1.2.3", 43, 80, {{":path", "/multi-tier"}}));
19661972

@@ -1998,10 +2004,10 @@ TEST_F(CiliumNetworkPolicyTest, Precedence) {
19982004
EnvoyException,
19992005
"PortNetworkPolicy: Inconsistent pass precedence 600 != 700");
20002006

2001-
// Failed update must leave policy unchanged from version 10.
2007+
// Failed update must leave policy unchanged from version 14.
20022008
EXPECT_TRUE(validate("10.1.2.3", expected14));
20032009
EXPECT_FALSE(ingressAllowed("10.1.2.3", 41, 80, {{":path", "/multi-tier"}}));
2004-
EXPECT_FALSE(ingressAllowed("10.1.2.3", 42, 80, {{":path", "/multi-tier"}}));
2010+
EXPECT_TRUE(ingressAllowed("10.1.2.3", 42, 80, {{":path", "/multi-tier"}}));
20052011

20062012
//
20072013
// 16th update: inherited wildcard pass skips remaining rules on that tier

0 commit comments

Comments
 (0)