Merge pull request #3306 from aramase/update-e2e-test
Update e2e test to verify redirect code
This commit is contained in:
commit
d0e63ce15f
2 changed files with 10 additions and 15 deletions
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||||
package annotations
|
package annotations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -58,18 +57,15 @@ var _ = framework.IngressNginxDescribe("Annotations - Forcesslredirect", func()
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, _, errs := gorequest.New().
|
resp, _, errs := gorequest.New().
|
||||||
Get(f.IngressController.HTTPURL).
|
Get(f.IngressController.HTTPURL).
|
||||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||||
|
RedirectPolicy(noRedirectPolicyFunc).
|
||||||
Set("Host", host).
|
Set("Host", host).
|
||||||
End()
|
End()
|
||||||
|
|
||||||
Expect(errs[0].Error()).Should(ContainSubstring(`https://forcesslredirect.bar.com/`))
|
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||||
|
Expect(resp.StatusCode).Should(Equal(http.StatusPermanentRedirect))
|
||||||
log, err := f.NginxLogs()
|
Expect(resp.Header.Get("Location")).Should(Equal("https://forcesslredirect.bar.com/"))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
Expect(log).ToNot(BeEmpty())
|
|
||||||
|
|
||||||
Expect(log).To(ContainSubstring(fmt.Sprintf(` "GET / HTTP/1.1" 308 171 "-" "Go-http-client/1.1"`)))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -61,16 +61,15 @@ var _ = framework.IngressNginxDescribe("Annotations - Fromtowwwredirect", func()
|
||||||
|
|
||||||
By("sending request to www.fromtowwwredirect.bar.com")
|
By("sending request to www.fromtowwwredirect.bar.com")
|
||||||
|
|
||||||
gorequest.New().
|
resp, _, errs := gorequest.New().
|
||||||
Get(fmt.Sprintf("%s/%s", f.IngressController.HTTPURL, "foo")).
|
Get(fmt.Sprintf("%s/%s", f.IngressController.HTTPURL, "foo")).
|
||||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||||
|
RedirectPolicy(noRedirectPolicyFunc).
|
||||||
Set("Host", fmt.Sprintf("%s.%s", "www", host)).
|
Set("Host", fmt.Sprintf("%s.%s", "www", host)).
|
||||||
End()
|
End()
|
||||||
|
|
||||||
log, err := f.NginxLogs()
|
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(resp.StatusCode).Should(Equal(http.StatusPermanentRedirect))
|
||||||
Expect(log).ToNot(BeEmpty())
|
Expect(resp.Header.Get("Location")).Should(Equal("http://fromtowwwredirect.bar.com/foo"))
|
||||||
|
|
||||||
Expect(log).To(ContainSubstring(fmt.Sprintf(` "GET /foo HTTP/1.1" 308 171 "-" "Go-http-client/1.1"`)))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue