github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/isolated/space_ssh_allowed_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	. "github.com/onsi/gomega/gbytes"
     8  	. "github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("space-ssh-allowed command", func() {
    12  	Describe("help", func() {
    13  		When("--help flag is set", func() {
    14  			It("Displays command usage to output", func() {
    15  				session := helpers.CF("space-ssh-allowed", "--help")
    16  				Eventually(session).Should(Say("NAME:"))
    17  				Eventually(session).Should(Say("space-ssh-allowed - Reports whether SSH is allowed in a space"))
    18  				Eventually(session).Should(Say("USAGE:"))
    19  				Eventually(session).Should(Say("cf space-ssh-allowed SPACE_NAME"))
    20  				Eventually(session).Should(Say("SEE ALSO:"))
    21  				Eventually(session).Should(Say("allow-space-ssh, ssh-enabled, ssh"))
    22  				Eventually(session).Should(Exit(0))
    23  			})
    24  		})
    25  	})
    26  
    27  	Describe("command behavior", func() {
    28  		var (
    29  			orgName   string
    30  			spaceName string
    31  			session   *Session
    32  		)
    33  
    34  		BeforeEach(func() {
    35  			orgName = helpers.NewOrgName()
    36  			spaceName = helpers.NewSpaceName()
    37  
    38  			helpers.SetupCF(orgName, spaceName)
    39  		})
    40  
    41  		AfterEach(func() {
    42  			helpers.QuickDeleteOrg(orgName)
    43  		})
    44  
    45  		JustBeforeEach(func() {
    46  			session = helpers.CF("space-ssh-allowed", spaceName)
    47  		})
    48  
    49  		It("reports that ssh is allowed", func() {
    50  			Eventually(session).Should(Say(`ssh support is enabled in space '%s'`, spaceName))
    51  			Eventually(session).Should(Exit(0))
    52  		})
    53  
    54  		When("ssh is not allowed", func() {
    55  			BeforeEach(func() {
    56  				session := helpers.CF("disallow-space-ssh", spaceName)
    57  				Eventually(session).Should(Exit(0))
    58  			})
    59  
    60  			It("reports that ssh is not allowed", func() {
    61  				Eventually(session).Should(Say(`ssh support is disabled in space '%s'`, spaceName))
    62  				Eventually(session).Should(Exit(0))
    63  			})
    64  		})
    65  
    66  		When("the space does not exist", func() {
    67  			BeforeEach(func() {
    68  				spaceName = "non-existent-space"
    69  			})
    70  
    71  			It("displays a missing space error message and fails", func() {
    72  				Eventually(session.Err).Should(Say("Space '%s' not found.", spaceName))
    73  				Eventually(session).Should(Say("FAILED"))
    74  				Eventually(session).Should(Exit(1))
    75  			})
    76  		})
    77  	})
    78  })