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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
@ -58,18 +57,15 @@ var _ = framework.IngressNginxDescribe("Annotations - Forcesslredirect", func()
|
|||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, _, errs := gorequest.New().
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.IngressController.HTTPURL).
|
||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||
RedirectPolicy(noRedirectPolicyFunc).
|
||||
Set("Host", host).
|
||||
End()
|
||||
|
||||
Expect(errs[0].Error()).Should(ContainSubstring(`https://forcesslredirect.bar.com/`))
|
||||
|
||||
log, err := f.NginxLogs()
|
||||
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"`)))
|
||||
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusPermanentRedirect))
|
||||
Expect(resp.Header.Get("Location")).Should(Equal("https://forcesslredirect.bar.com/"))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -61,16 +61,15 @@ var _ = framework.IngressNginxDescribe("Annotations - Fromtowwwredirect", func()
|
|||
|
||||
By("sending request to www.fromtowwwredirect.bar.com")
|
||||
|
||||
gorequest.New().
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(fmt.Sprintf("%s/%s", f.IngressController.HTTPURL, "foo")).
|
||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||
RedirectPolicy(noRedirectPolicyFunc).
|
||||
Set("Host", fmt.Sprintf("%s.%s", "www", host)).
|
||||
End()
|
||||
|
||||
log, err := f.NginxLogs()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(log).ToNot(BeEmpty())
|
||||
|
||||
Expect(log).To(ContainSubstring(fmt.Sprintf(` "GET /foo HTTP/1.1" 308 171 "-" "Go-http-client/1.1"`)))
|
||||
Expect(len(errs)).Should(BeNumerically("==", 0))
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusPermanentRedirect))
|
||||
Expect(resp.Header.Get("Location")).Should(Equal("http://fromtowwwredirect.bar.com/foo"))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue