github.com/deiscc/workflow-e2e@v0.0.0-20181208071258-117299af888f/tests/tls_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/deiscc/workflow-e2e/tests/cmd" 8 "github.com/deiscc/workflow-e2e/tests/cmd/apps" 9 "github.com/deiscc/workflow-e2e/tests/cmd/auth" 10 "github.com/deiscc/workflow-e2e/tests/cmd/builds" 11 "github.com/deiscc/workflow-e2e/tests/model" 12 "github.com/deiscc/workflow-e2e/tests/settings" 13 14 . "github.com/onsi/ginkgo" 15 . "github.com/onsi/gomega" 16 . "github.com/onsi/gomega/gbytes" 17 . "github.com/onsi/gomega/gexec" 18 ) 19 20 var _ = Describe("deis tls", func() { 21 22 Context("with an existing user", func() { 23 24 var user model.User 25 26 BeforeEach(func() { 27 user = auth.RegisterAndLogin() 28 }) 29 30 AfterEach(func() { 31 auth.Cancel(user) 32 }) 33 34 Context("who owns an existing app that has already been deployed", func() { 35 36 var app model.App 37 38 BeforeEach(func() { 39 app = apps.Create(user, "--no-remote") 40 builds.Create(user, app) 41 }) 42 43 AfterEach(func() { 44 apps.Destroy(user, app) 45 }) 46 47 Specify("can enable/disable tls", func() { 48 sess, err := cmd.Start("deis tls:enable --app=%s", &user, app.Name) 49 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 50 Expect(err).NotTo(HaveOccurred()) 51 Eventually(sess).Should(Exit(0)) 52 53 // curl the app's root URL and ensure we get a 301 redirect 54 cmdRetryTimeout := 60 55 curlCmd := model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 56 Eventually(cmd.Retry(curlCmd, strconv.Itoa(301), cmdRetryTimeout)).Should(BeTrue()) 57 58 sess, err = cmd.Start("deis tls:disable --app=%s", &user, app.Name) 59 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 60 Expect(err).NotTo(HaveOccurred()) 61 Eventually(sess).Should(Exit(0)) 62 63 cmdRetryTimeout = 60 64 curlCmd = model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 65 Eventually(cmd.Retry(curlCmd, strconv.Itoa(200), cmdRetryTimeout)).Should(BeTrue()) 66 }) 67 }) 68 }) 69 })