@@ -21,8 +21,8 @@ import (
21
21
"testing"
22
22
23
23
"github.com/stretchr/testify/assert"
24
+ "github.com/stretchr/testify/require"
24
25
v1 "k8s.io/api/core/v1"
25
- "k8s.io/kubernetes/test/e2e/framework"
26
26
"sigs.k8s.io/controller-runtime/pkg/client"
27
27
28
28
"sigs.k8s.io/network-policy-api/apis/v1alpha1"
@@ -55,15 +55,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
55
55
Namespace : "network-policy-conformance-gryffindor" ,
56
56
Name : "harry-potter-0" ,
57
57
}, serverPod )
58
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
58
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
59
59
// luna-lovegood-0 is our client pod in ravenclaw namespace
60
60
// ensure egress is ALLOWED to gryffindor from ravenclaw
61
61
// egressRule at index0 will take precedence over egressRule at index1; thus ALLOW takes precedence over DENY since rules are ordered
62
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
62
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
63
63
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
64
64
assert .Equal (t , true , success )
65
65
// luna-lovegood-1 is our client pod in ravenclaw namespace
66
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
66
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
67
67
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
68
68
assert .Equal (t , true , success )
69
69
})
@@ -78,15 +78,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
78
78
Namespace : "network-policy-conformance-hufflepuff" ,
79
79
Name : "cedric-diggory-1" ,
80
80
}, serverPod )
81
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
81
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
82
82
// luna-lovegood-0 is our client pod in ravenclaw namespace
83
83
// ensure egress is ALLOWED to hufflepuff from ravenclaw at port 9003; egressRule at index5 should take effect
84
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
84
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
85
85
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
86
86
assert .Equal (t , true , success )
87
87
// luna-lovegood-1 is our client pod in ravenclaw namespace
88
88
// ensure egress is DENIED to hufflepuff from ravenclaw for rest of the traffic; egressRule at index6 should take effect
89
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
89
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
90
90
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , false )
91
91
assert .Equal (t , true , success )
92
92
})
@@ -101,26 +101,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
101
101
Namespace : "network-policy-conformance-gryffindor" ,
102
102
Name : "harry-potter-1" ,
103
103
}, serverPod )
104
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
104
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
105
105
anp := & v1alpha1.AdminNetworkPolicy {}
106
106
err = s .Client .Get (ctx , client.ObjectKey {
107
107
Name : "egress-sctp" ,
108
108
}, anp )
109
- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
109
+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
110
110
// swap rules at index0 and index1
111
111
allowRule := anp .DeepCopy ().Spec .Egress [0 ]
112
112
anp .Spec .Egress [0 ] = anp .DeepCopy ().Spec .Egress [1 ]
113
113
anp .Spec .Egress [1 ] = allowRule
114
114
err = s .Client .Update (ctx , anp )
115
- framework . ExpectNoError ( err , "unable to update the admin network policy" )
115
+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
116
116
// luna-lovegood-0 is our client pod in gryffindor namespace
117
117
// ensure egress is DENIED to gryffindor from ravenclaw
118
118
// egressRule at index0 will take precedence over egressRule at index1; thus DENY takes precedence over ALLOW since rules are ordered
119
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
119
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
120
120
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , false )
121
121
assert .Equal (t , true , success )
122
122
// luna-lovegood-1 is our client pod in ravenclaw namespace
123
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
123
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
124
124
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , false )
125
125
assert .Equal (t , true , success )
126
126
})
@@ -135,15 +135,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
135
135
Namespace : "network-policy-conformance-slytherin" ,
136
136
Name : "draco-malfoy-0" ,
137
137
}, serverPod )
138
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
138
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
139
139
// luna-lovegood-0 is our client pod in ravenclaw namespace
140
140
// ensure egress to slytherin is DENIED from ravenclaw at port 9003; egressRule at index3 should take effect
141
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
141
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
142
142
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , false )
143
143
assert .Equal (t , true , success )
144
144
// luna-lovegood-1 is our client pod in ravenclaw namespace
145
145
// ensure egress to slytherin is ALLOWED from ravenclaw for rest of the traffic; matches no rules hence allowed
146
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
146
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
147
147
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
148
148
assert .Equal (t , true , success )
149
149
})
@@ -158,26 +158,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
158
158
Namespace : "network-policy-conformance-gryffindor" ,
159
159
Name : "harry-potter-1" ,
160
160
}, serverPod )
161
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
161
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
162
162
anp := & v1alpha1.AdminNetworkPolicy {}
163
163
err = s .Client .Get (ctx , client.ObjectKey {
164
164
Name : "egress-sctp" ,
165
165
}, anp )
166
- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
166
+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
167
167
// swap rules at index0 and index2
168
168
denyRule := anp .DeepCopy ().Spec .Egress [0 ]
169
169
anp .Spec .Egress [0 ] = anp .DeepCopy ().Spec .Egress [2 ]
170
170
anp .Spec .Egress [2 ] = denyRule
171
171
err = s .Client .Update (ctx , anp )
172
- framework . ExpectNoError ( err , "unable to update the admin network policy" )
172
+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
173
173
// luna-lovegood-0 is our client pod in ravenclaw namespace
174
174
// ensure egress is PASSED from gryffindor to ravenclaw
175
175
// egressRule at index0 will take precedence over egressRule at index1&index2; thus PASS takes precedence over ALLOW/DENY since rules are ordered
176
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
176
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
177
177
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
178
178
assert .Equal (t , true , success )
179
179
// luna-lovegood-1 is our client pod in ravenclaw namespace
180
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
180
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
181
181
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
182
182
assert .Equal (t , true , success )
183
183
})
@@ -192,26 +192,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
192
192
Namespace : "network-policy-conformance-slytherin" ,
193
193
Name : "draco-malfoy-0" ,
194
194
}, serverPod )
195
- framework . ExpectNoError ( err , "unable to fetch the server pod" )
195
+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
196
196
anp := & v1alpha1.AdminNetworkPolicy {}
197
197
err = s .Client .Get (ctx , client.ObjectKey {
198
198
Name : "egress-sctp" ,
199
199
}, anp )
200
- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
200
+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
201
201
// swap rules at index3 and index4
202
202
denyRule := anp .DeepCopy ().Spec .Egress [3 ]
203
203
anp .Spec .Egress [3 ] = anp .DeepCopy ().Spec .Egress [4 ]
204
204
anp .Spec .Egress [4 ] = denyRule
205
205
err = s .Client .Update (ctx , anp )
206
- framework . ExpectNoError ( err , "unable to update the admin network policy" )
206
+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
207
207
// luna-lovegood-0 is our client pod in ravenclaw namespace
208
208
// ensure egress to slytherin is PASSED from ravenclaw at port 9003; egressRule at index3 should take effect
209
- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
209
+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
210
210
serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
211
211
assert .Equal (t , true , success )
212
212
// luna-lovegood-1 is our client pod in ravenclaw namespace
213
213
// ensure egress to slytherin is ALLOWED from ravenclaw for rest of the traffic; matches no rules hence allowed
214
- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
214
+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
215
215
serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
216
216
assert .Equal (t , true , success )
217
217
})
0 commit comments