@@ -11,10 +11,8 @@ package runner
1111import (
1212 "context"
1313 "fmt"
14- "strings"
1514 "time"
1615
17- "github.com/Azure/go-autorest/autorest/to"
1816 . "github.com/onsi/ginkgo"
1917 . "github.com/onsi/gomega"
2018
@@ -43,33 +41,8 @@ var _ = Describe("networking-v1-LFU", func() {
4341 cleanUp (clientset )
4442 })
4543
46- It ("[prohibited-target-test] prohibited service should be available to be accessed" , func () {
47- // get ip address for 1 ingress
48- klog .Info ("Getting public IP from blacklisted Ingress..." )
49- publicIP , _ := getPublicIP (clientset , "test-brownfield-ns" )
50- Expect (publicIP ).ToNot (Equal ("" ))
51-
52- //prohibited service will be kept by agic
53- url_blacklist := fmt .Sprintf ("http://%s/blacklist" , publicIP )
54- _ , err = makeGetRequest (url_blacklist , "brownfield-blacklist-ns.host" , 200 , true )
55- Expect (err ).To (BeNil ())
56-
57- //delete namespaces for blacklist testing
58- deleteOptions := metav1.DeleteOptions {
59- GracePeriodSeconds : to .Int64Ptr (0 ),
60- }
61-
62- klog .Info ("Delete namespaces test-brownfield-ns after blacklist testing..." )
63- err = clientset .CoreV1 ().Namespaces ().Delete (context .TODO (), "test-brownfield-ns" , deleteOptions )
64- Expect (err ).To (BeNil ())
65- })
66-
67- It ("[sub-resource-prefix] should be use the sub-resource-prefix to prefix sub-resources" , func () {
68- env := GetEnv ()
69- klog .Infof ("'subResourceNamePrefix': %s" , env .SubResourceNamePrefix )
70- Expect (env .SubResourceNamePrefix ).ToNot (Equal ("" ), "Please make sure that environment variable 'subResourceNamePrefix' is set" )
71-
72- namespaceName := "e2e-sub-resource-prefix"
44+ It ("[prohibited-target-test] prohibited target should be available to be accessed" , func () {
45+ namespaceName := "e2e-prohibited-target"
7346 ns := & v1.Namespace {
7447 ObjectMeta : metav1.ObjectMeta {
7548 Name : namespaceName ,
@@ -79,26 +52,38 @@ var _ = Describe("networking-v1-LFU", func() {
7952 _ , err = clientset .CoreV1 ().Namespaces ().Create (context .TODO (), ns , metav1.CreateOptions {})
8053 Expect (err ).To (BeNil ())
8154
82- SSLE2ERedirectYamlPath := "testdata/networking-v1/one-namespace-one-ingress/ssl-e2e-redirect /app.yaml"
83- klog .Info ("Applying yaml: " , SSLE2ERedirectYamlPath )
84- err = applyYaml (clientset , crdClient , namespaceName , SSLE2ERedirectYamlPath )
55+ appYamlPath := "testdata/networking-v1/one-namespace-one-ingress/prohibited-target /app.yaml"
56+ klog .Info ("Applying yaml: " , appYamlPath )
57+ err = applyYaml (clientset , crdClient , namespaceName , appYamlPath )
8558 Expect (err ).To (BeNil ())
8659 time .Sleep (30 * time .Second )
8760
88- gateway , err := getGateway ()
61+ // get ip address for 1 ingress
62+ klog .Info ("Getting public IP of the app gateway" )
63+ ip , err := getPublicIPAddress ()
64+ Expect (err ).To (BeNil ())
65+
66+ publicIP := * ip .IPAddress
67+ klog .Infof ("Public IP: %s" , publicIP )
68+
69+ protectedPath := fmt .Sprintf ("http://%s/landing/" , publicIP )
70+ _ , err = makeGetRequest (protectedPath , "www.microsoft.com" , 302 , true )
8971 Expect (err ).To (BeNil ())
9072
91- prefixUsed := false
92- for _ , listener := range * gateway .HTTPListeners {
93- klog .Infof ("checking listener %s for %s" , * listener .Name , env .SubResourceNamePrefix )
94- if strings .HasPrefix (* listener .Name , env .SubResourceNamePrefix ) {
95- klog .Infof ("found %s that uses the prefix" , * listener .Name )
96- prefixUsed = true
97- break
98- }
99- }
73+ ingressPath := fmt .Sprintf ("http://%s/aspnet" , publicIP )
74+ _ , err = makeGetRequest (ingressPath , "www.microsoft.com" , 200 , true )
75+ Expect (err ).To (BeNil ())
10076
101- Expect (prefixUsed ).To (BeTrue (), "%s wasn't used for naming the sub-resource of app gateway. Currently, this check looks at HTTP listener only" , env .SubResourceNamePrefix )
77+ klog .Info ("Deleting yaml: " , appYamlPath )
78+ err = deleteYaml (clientset , crdClient , namespaceName , appYamlPath )
79+ Expect (err ).To (BeNil ())
80+ time .Sleep (30 * time .Second )
81+
82+ _ , err = makeGetRequest (protectedPath , "www.microsoft.com" , 302 , true )
83+ Expect (err ).To (BeNil ())
84+
85+ _ , err = makeGetRequest (ingressPath , "www.microsoft.com" , 502 , true )
86+ Expect (err ).To (BeNil ())
10287 })
10388
10489 AfterEach (func () {
0 commit comments