github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/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  	BeforeEach(func() {
    14  		helpers.SkipIfClientCredentialsTestMode()
    15  	})
    16  
    17  	Describe("help", func() {
    18  		When("--help flag is set", func() {
    19  			It("displays command usage to output", func() {
    20  				session := helpers.CF("ssh-code", "--help")
    21  				Eventually(session).Should(Say("NAME:"))
    22  				Eventually(session).Should(Say("ssh-code - Get a one time password for ssh clients"))
    23  				Eventually(session).Should(Say("USAGE:"))
    24  				Eventually(session).Should(Say("cf ssh-code"))
    25  				Eventually(session).Should(Say("SEE ALSO:"))
    26  				Eventually(session).Should(Say("curl, ssh"))
    27  				Eventually(session).Should(Exit(0))
    28  			})
    29  		})
    30  	})
    31  
    32  	When("the environment is not setup correctly", func() {
    33  		It("fails with the appropriate errors", func() {
    34  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "ssh-code")
    35  		})
    36  	})
    37  
    38  	When("the environment is setup correctly", func() {
    39  		BeforeEach(func() {
    40  			helpers.LoginCF()
    41  		})
    42  
    43  		It("returns a one time passcode for ssh", func() {
    44  			session := helpers.CF("ssh-code")
    45  			Eventually(session).Should(Say("[A-Za-z0-9]+"))
    46  			Eventually(session).Should(Exit(0))
    47  		})
    48  	})
    49  })