@@ -1248,7 +1248,7 @@ func TestTranslatePolicy(t *testing.T) {
12481248}
12491249allowToFrontendPolicy := & networkingv1.NetworkPolicy {
12501250ObjectMeta : metav1.ObjectMeta {
1251- Name : "ALLOW-all-TO-app:frontend-FROM-all-namespaces- policy" ,
1251+ Name : "ALLOW-all-TO-app:frontend-policy" ,
12521252Namespace : "testnamespace" ,
12531253},
12541254Spec : networkingv1.NetworkPolicySpec {
@@ -1269,16 +1269,14 @@ func TestTranslatePolicy(t *testing.T) {
12691269"ns-testnamespace" ,
12701270}
12711271if ! reflect .DeepEqual (sets , expectedSets ) {
1272- t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-FROM-all-namespaces- policy sets comparison" )
1272+ t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-policy sets comparison" )
12731273t .Errorf ("sets: %v" , sets )
12741274t .Errorf ("expectedSets: %v" , expectedSets )
12751275}
12761276
1277- expectedLists = []string {
1278- util .KubeAllNamespacesFlag ,
1279- }
1277+ expectedLists = []string {}
12801278if ! reflect .DeepEqual (lists , expectedLists ) {
1281- t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-FROM-all-namespaces- policy lists comparison" )
1279+ t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-policy lists comparison" )
12821280t .Errorf ("lists: %v" , lists )
12831281t .Errorf ("expectedLists: %v" , expectedLists )
12841282}
@@ -1289,11 +1287,6 @@ func TestTranslatePolicy(t *testing.T) {
12891287& iptm.IptEntry {
12901288Chain : util .IptablesAzureIngressPortChain ,
12911289Specs : []string {
1292- util .IptablesModuleFlag ,
1293- util .IptablesSetModuleFlag ,
1294- util .IptablesMatchSetFlag ,
1295- util .GetHashedName (util .KubeAllNamespacesFlag ),
1296- util .IptablesSrcFlag ,
12971290util .IptablesModuleFlag ,
12981291util .IptablesSetModuleFlag ,
12991292util .IptablesMatchSetFlag ,
@@ -1304,14 +1297,14 @@ func TestTranslatePolicy(t *testing.T) {
13041297util .IptablesModuleFlag ,
13051298util .IptablesCommentModuleFlag ,
13061299util .IptablesCommentFlag ,
1307- "ALLOW-ALL-TO-app:frontend-FROM-all-namespaces " ,
1300+ "ALLOW-ALL-TO-app:frontend" ,
13081301},
13091302},
13101303}
13111304expectedIptEntries = append (expectedIptEntries , nonKubeSystemEntries ... )
13121305expectedIptEntries = append (expectedIptEntries , getDefaultDropEntries ("testnamespace" , targetSelector , false , false )... )
13131306if ! reflect .DeepEqual (iptEntries , expectedIptEntries ) {
1314- t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-FROM-all-namespaces- policy policy comparison" )
1307+ t .Errorf ("translatedPolicy failed @ ALLOW-all-TO-app:frontend-policy policy comparison" )
13151308marshalledIptEntries , _ := json .Marshal (iptEntries )
13161309marshalledExpectedIptEntries , _ := json .Marshal (expectedIptEntries )
13171310t .Errorf ("iptEntries: %s" , marshalledIptEntries )
@@ -2633,9 +2626,7 @@ func TestTranslatePolicy(t *testing.T) {
26332626t .Errorf ("expectedSets: %v" , expectedSets )
26342627}
26352628
2636- expectedLists = []string {
2637- util .KubeAllNamespacesFlag ,
2638- }
2629+ expectedLists = []string {}
26392630if ! reflect .DeepEqual (lists , expectedLists ) {
26402631t .Errorf ("translatedPolicy failed @ ALLOW-all-FROM-app:backend-policy lists comparison" )
26412632t .Errorf ("lists: %v" , lists )
@@ -2652,18 +2643,28 @@ func TestTranslatePolicy(t *testing.T) {
26522643util .IptablesMatchSetFlag ,
26532644util .GetHashedName ("app:backend" ),
26542645util .IptablesSrcFlag ,
2646+ util .IptablesJumpFlag ,
2647+ util .IptablesAccept ,
2648+ util .IptablesModuleFlag ,
2649+ util .IptablesCommentModuleFlag ,
2650+ util .IptablesCommentFlag ,
2651+ "ALLOW-ALL-FROM-app:backend" ,
2652+ },
2653+ },
2654+ & iptm.IptEntry {
2655+ Chain : util .IptablesAzureEgressPortChain ,
2656+ Specs : []string {
26552657util .IptablesModuleFlag ,
26562658util .IptablesSetModuleFlag ,
26572659util .IptablesMatchSetFlag ,
2658- util .GetHashedName (util . KubeAllNamespacesFlag ),
2659- util .IptablesDstFlag ,
2660+ util .GetHashedName ("app:backend" ),
2661+ util .IptablesSrcFlag ,
26602662util .IptablesJumpFlag ,
2661- util .IptablesAccept ,
2663+ util .IptablesAzureTargetSetsChain ,
26622664util .IptablesModuleFlag ,
26632665util .IptablesCommentModuleFlag ,
26642666util .IptablesCommentFlag ,
2665- "ALLOW-ALL-FROM-app:backend-TO-" +
2666- util .KubeAllNamespacesFlag ,
2667+ "ALLOW-ALL-FROM-app:backend-TO-JUMP-TO-AZURE-NPM-TARGET-SETS" ,
26672668},
26682669},
26692670}
0 commit comments