github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/whitelist_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/deis/workflow-e2e/tests/cmd" 8 "github.com/deis/workflow-e2e/tests/cmd/apps" 9 "github.com/deis/workflow-e2e/tests/cmd/auth" 10 "github.com/deis/workflow-e2e/tests/cmd/builds" 11 "github.com/deis/workflow-e2e/tests/model" 12 "github.com/deis/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 whitelist", 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 list that app's whitelist list", func() { 48 sess, err := cmd.Start("deis whitelist:list --app=%s", &user, app.Name) 49 Expect(err).NotTo(HaveOccurred()) 50 Eventually(sess).Should(Exit(0)) 51 }) 52 53 Specify("can view app when no addresses whitelist", func() { 54 // curl the app's root URL and print just the HTTP response code 55 cmdRetryTimeout := 60 56 curlCmd := model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 57 Eventually(cmd.Retry(curlCmd, strconv.Itoa(200), cmdRetryTimeout)).Should(BeTrue()) 58 }) 59 60 Specify("can add/remove addresses from the whitelist", func() { 61 sess, err := cmd.Start("deis whitelist:add 1.2.3.4 --app=%s", &user, app.Name) 62 Expect(err).NotTo(HaveOccurred()) 63 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 64 Eventually(sess).Should(Exit(0)) 65 66 // curl the app's root URL and print just the HTTP response code 67 cmdRetryTimeout := 60 68 curlCmd := model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 69 Eventually(cmd.Retry(curlCmd, strconv.Itoa(403), cmdRetryTimeout)).Should(BeTrue()) 70 71 sess, err = cmd.Start("deis whitelist:add 0.0.0.0/0 --app=%s", &user, app.Name) 72 Expect(err).NotTo(HaveOccurred()) 73 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 74 Eventually(sess).Should(Exit(0)) 75 76 cmdRetryTimeout = 60 77 curlCmd = model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 78 Eventually(cmd.Retry(curlCmd, strconv.Itoa(200), cmdRetryTimeout)).Should(BeTrue()) 79 80 sess, err = cmd.Start("deis whitelist:remove 0.0.0.0/0 --app=%s", &user, app.Name) 81 Expect(err).NotTo(HaveOccurred()) 82 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 83 Eventually(sess).Should(Exit(0)) 84 85 // curl the app's root URL and print just the HTTP response code 86 cmdRetryTimeout = 60 87 curlCmd = model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 88 Eventually(cmd.Retry(curlCmd, strconv.Itoa(403), cmdRetryTimeout)).Should(BeTrue()) 89 }) 90 }) 91 }) 92 93 })