github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v6/isolated/ssh_enabled_command_test.go (about) 1 package isolated 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("ssh-enabled command", func() { 14 var ( 15 orgName string 16 spaceName string 17 appName string 18 ) 19 20 BeforeEach(func() { 21 orgName = helpers.NewOrgName() 22 spaceName = helpers.NewSpaceName() 23 appName = helpers.PrefixedRandomName("app") 24 }) 25 26 Describe("help", func() { 27 When("--help flag is set", func() { 28 It("appears in cf help -a", func() { 29 session := helpers.CF("help", "-a") 30 Eventually(session).Should(Exit(0)) 31 Expect(session).To(HaveCommandInCategoryWithDescription("ssh-enabled", "APPS", "Reports whether SSH is enabled on an application container instance")) 32 }) 33 34 It("displays command usage to output", func() { 35 session := helpers.CF("ssh-enabled", "--help") 36 37 Eventually(session).Should(Say("NAME:")) 38 Eventually(session).Should(Say("ssh-enabled - Reports whether SSH is enabled on an application container instance")) 39 Eventually(session).Should(Say("USAGE:")) 40 Eventually(session).Should(Say("cf ssh-enabled APP_NAME")) 41 Eventually(session).Should(Say("SEE ALSO:")) 42 Eventually(session).Should(Say("enable-ssh, space-ssh-allowed, ssh")) 43 Eventually(session).Should(Exit(0)) 44 }) 45 }) 46 }) 47 48 When("the app name is not provided", func() { 49 It("tells the user that the app name is required, prints help text, and exits 1", func() { 50 session := helpers.CF("ssh-enabled") 51 52 Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `APP_NAME` was not provided")) 53 Eventually(session).Should(Say("NAME:")) 54 Eventually(session).Should(Exit(1)) 55 }) 56 }) 57 58 When("the environment is set up correctly", func() { 59 60 BeforeEach(func() { 61 helpers.SetupCF(orgName, spaceName) 62 }) 63 64 AfterEach(func() { 65 helpers.QuickDeleteOrg(orgName) 66 }) 67 68 When("the app does not exist", func() { 69 It("displays app not found and exits 1", func() { 70 invalidAppName := "invalid-app-name" 71 session := helpers.CF("ssh-enabled", invalidAppName) 72 73 Eventually(session).Should(Say("FAILED")) 74 Eventually(session).Should(Say("App %s not found", invalidAppName)) 75 Eventually(session).Should(Exit(1)) 76 }) 77 }) 78 79 When("the app exists", func() { 80 // Consider using cf curl /v3/apps 81 BeforeEach(func() { 82 helpers.WithHelloWorldApp(func(appDir string) { 83 Eventually(helpers.CF("push", appName, "-p", appDir, "--no-start")).Should(Exit(0)) 84 }) 85 }) 86 87 When("when ssh is enabled", func() { 88 It("informs the user ssh is disabled", func() { 89 session := helpers.CF("ssh-enabled", appName) 90 91 Eventually(session).Should(Say("ssh support is enabled for '%s'", appName)) 92 Eventually(session).Should(Exit(0)) 93 }) 94 }) 95 96 When("ssh is disabled", func() { 97 BeforeEach(func() { 98 Eventually(helpers.CF("disable-ssh", appName)).Should(Exit(0)) 99 }) 100 101 It("informs the user and exits 0", func() { 102 session := helpers.CF("ssh-enabled", appName) 103 104 Eventually(session).Should(Say("ssh support is disabled for '%s'", appName)) 105 }) 106 }) 107 }) 108 }) 109 })