github.com/deis/workflow-e2e@v2.12.2-0.20180227201524-4105be7001fe+incompatible/tests/routing_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "net/http" 6 "strconv" 7 8 "github.com/deis/workflow-e2e/tests/cmd" 9 "github.com/deis/workflow-e2e/tests/cmd/apps" 10 "github.com/deis/workflow-e2e/tests/cmd/auth" 11 "github.com/deis/workflow-e2e/tests/cmd/builds" 12 "github.com/deis/workflow-e2e/tests/model" 13 "github.com/deis/workflow-e2e/tests/settings" 14 15 . "github.com/onsi/ginkgo" 16 . "github.com/onsi/ginkgo/extensions/table" 17 . "github.com/onsi/gomega" 18 . "github.com/onsi/gomega/gbytes" 19 . "github.com/onsi/gomega/gexec" 20 ) 21 22 var _ = Describe("deis routing", func() { 23 24 Context("with an existing user", func() { 25 26 var user model.User 27 28 BeforeEach(func() { 29 user = auth.RegisterAndLogin() 30 }) 31 32 AfterEach(func() { 33 auth.Cancel(user) 34 }) 35 36 Context("who owns an existing app that has already been deployed", func() { 37 38 var app model.App 39 40 BeforeEach(func() { 41 app = apps.Create(user, "--no-remote") 42 builds.Create(user, app) 43 }) 44 45 AfterEach(func() { 46 apps.Destroy(user, app) 47 }) 48 49 Specify("that user can list that app's routing info", func() { 50 sess, err := cmd.Start("deis routing:info --app=%s", &user, app.Name) 51 Eventually(sess).Should(Say("Routing is enabled.\n")) 52 Expect(err).NotTo(HaveOccurred()) 53 Eventually(sess).Should(Exit(0)) 54 }) 55 56 Specify("that user can view app when routing is enabled", func() { 57 cmdRetryTimeout := 60 58 curlCmd := model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 59 Eventually(cmd.Retry(curlCmd, strconv.Itoa(http.StatusOK), cmdRetryTimeout)).Should(BeTrue()) 60 }) 61 62 Specify("that user can disable routing", func() { 63 cmdRetryTimeout := 60 64 sess, err := cmd.Start("deis routing:disable --app=%s", &user, app.Name) 65 Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("done")) 66 Expect(err).NotTo(HaveOccurred()) 67 Eventually(sess).Should(Exit(0)) 68 69 sess, err = cmd.Start("deis routing:info --app=%s", &user, app.Name) 70 Eventually(sess).Should(Say("Routing is disabled.\n")) 71 Expect(err).NotTo(HaveOccurred()) 72 Eventually(sess).Should(Exit(0)) 73 74 curlCmd := model.Cmd{CommandLineString: fmt.Sprintf(`curl -sL -w "%%{http_code}\\n" "%s" -o /dev/null`, app.URL)} 75 Eventually(cmd.Retry(curlCmd, strconv.Itoa(http.StatusNotFound), cmdRetryTimeout)).Should(BeTrue()) 76 }) 77 }) 78 }) 79 80 DescribeTable("any user can get command-line help for routing", func(command string, expected string) { 81 sess, err := cmd.Start(command, nil) 82 Eventually(sess).Should(Say(expected)) 83 Expect(err).NotTo(HaveOccurred()) 84 Eventually(sess).Should(Exit(0)) 85 // TODO: test that help output was more than five lines long 86 }, 87 Entry("helps on \"help routing\"", 88 "deis help routing", "Valid commands for routing:"), 89 Entry("helps on \"routing -h\"", 90 "deis routing -h", "Valid commands for routing:"), 91 Entry("helps on \"routing --help\"", 92 "deis routing --help", "Valid commands for routing:"), 93 Entry("helps on \"help routing:info\"", 94 "deis help routing:info", "Prints info about the current application's routability."), 95 Entry("helps on \"routing:info -h\"", 96 "deis routing:info -h", "Prints info about the current application's routability."), 97 Entry("helps on \"routing:info --help\"", 98 "deis routing:info --help", "Prints info about the current application's routability."), 99 Entry("helps on \"help routing:enable\"", 100 "deis help routing:enable", "Enables routability for an app."), 101 Entry("helps on \"routing:enable -h\"", 102 "deis routing:enable -h", "Enables routability for an app."), 103 Entry("helps on \"routing:enable --help\"", 104 "deis routing:enable --help", "Enables routability for an app."), 105 Entry("helps on \"help routing:disable\"", 106 "deis help routing:disable", "Disables routability for an app."), 107 Entry("helps on \"routing:disable -h\"", 108 "deis routing:disable -h", "Disables routability for an app."), 109 Entry("helps on \"routing:disable --help\"", 110 "deis routing:disable --help", "Disables routability for an app."), 111 ) 112 113 })