github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/isolated/ssh_code_command_test.go (about) 1 package isolated 2 3 import ( 4 "code.cloudfoundry.org/cli/integration/helpers" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 . "github.com/onsi/gomega/gbytes" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("ssh-code command", func() { 13 Describe("help", func() { 14 Context("when --help flag is set", func() { 15 It("displays command usage to output", func() { 16 session := helpers.CF("ssh-code", "--help") 17 Eventually(session).Should(Say("NAME:")) 18 Eventually(session).Should(Say("ssh-code - Get a one time password for ssh clients")) 19 Eventually(session).Should(Say("USAGE:")) 20 Eventually(session).Should(Say("cf ssh-code")) 21 Eventually(session).Should(Say("SEE ALSO:")) 22 Eventually(session).Should(Say("curl, ssh")) 23 Eventually(session).Should(Exit(0)) 24 }) 25 }) 26 }) 27 28 Context("when the environment is not setup correctly", func() { 29 Context("when no API endpoint is set", func() { 30 BeforeEach(func() { 31 helpers.UnsetAPI() 32 }) 33 34 It("fails with no API endpoint set message", func() { 35 session := helpers.CF("ssh-code") 36 Eventually(session.Out).Should(Say("FAILED")) 37 Eventually(session.Err).Should(Say("No API endpoint set. Use 'cf login' or 'cf api' to target an endpoint.")) 38 Eventually(session).Should(Exit(1)) 39 }) 40 }) 41 42 Context("when not logged in", func() { 43 BeforeEach(func() { 44 helpers.LogoutCF() 45 }) 46 47 It("fails with not logged in message", func() { 48 session := helpers.CF("ssh-code") 49 Eventually(session.Out).Should(Say("FAILED")) 50 Eventually(session.Err).Should(Say("Not logged in. Use 'cf login' to log in.")) 51 Eventually(session).Should(Exit(1)) 52 }) 53 }) 54 }) 55 56 Context("when the environment is setup correctly", func() { 57 BeforeEach(func() { 58 helpers.LoginCF() 59 }) 60 61 It("returns a one time passcode for ssh", func() { 62 session := helpers.CF("ssh-code") 63 Eventually(session.Out).Should(Say("[A-Za-z0-9]+")) 64 Eventually(session).Should(Exit(0)) 65 }) 66 }) 67 })