@@ -95,7 +95,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router] openshift rou
95
95
defer func () { oc .AdminKubeClient ().Core ().Pods (ns ).Delete (execPodName , metav1 .NewDeleteOptions (1 )) }()
96
96
97
97
g .By ("preventing access without a username and password" )
98
- err = expectURLStatusCodeExec (ns , execPodName , fmt .Sprintf ("http://%s:%d/metrics" , host , statsPort ), 401 )
98
+ err = expectURLStatusCodeExec (ns , execPodName , fmt .Sprintf ("http://%s:%d/metrics" , host , statsPort ), 401 , 403 )
99
99
o .Expect (err ).NotTo (o .HaveOccurred ())
100
100
101
101
g .By ("checking for the expected metrics" )
@@ -180,7 +180,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router] openshift rou
180
180
defer func () { oc .AdminKubeClient ().Core ().Pods (ns ).Delete (execPodName , metav1 .NewDeleteOptions (1 )) }()
181
181
182
182
g .By ("preventing access without a username and password" )
183
- err := expectURLStatusCodeExec (ns , execPodName , fmt .Sprintf ("http://%s:%d/debug/pprof/heap" , host , statsPort ), 401 )
183
+ err := expectURLStatusCodeExec (ns , execPodName , fmt .Sprintf ("http://%s:%d/debug/pprof/heap" , host , statsPort ), 401 , 403 )
184
184
o .Expect (err ).NotTo (o .HaveOccurred ())
185
185
186
186
g .By ("at /debug/pprof" )
@@ -263,16 +263,18 @@ func findMetricLabels(f *dto.MetricFamily, labels map[string]string, match strin
263
263
return result
264
264
}
265
265
266
- func expectURLStatusCodeExec (ns , execPodName , url string , statusCode int ) error {
266
+ func expectURLStatusCodeExec (ns , execPodName , url string , statusCodes ... int ) error {
267
267
cmd := fmt .Sprintf ("curl -s -o /dev/null -w '%%{http_code}' %q" , url )
268
268
output , err := e2e .RunHostCmd (ns , execPodName , cmd )
269
269
if err != nil {
270
270
return fmt .Errorf ("host command failed: %v\n %s" , err , output )
271
271
}
272
- if output != strconv .Itoa (statusCode ) {
273
- return fmt .Errorf ("last response from server was not %d: %s" , statusCode , output )
272
+ for _ , statusCode := range statusCodes {
273
+ if output == strconv .Itoa (statusCode ) {
274
+ return nil
275
+ }
274
276
}
275
- return nil
277
+ return fmt . Errorf ( "last response from server was not any of %v: %s" , statusCodes , output )
276
278
}
277
279
278
280
func getAuthenticatedURLViaPod (ns , execPodName , url , user , pass string ) (string , error ) {
0 commit comments