github.com/loafoe/cli@v7.1.0+incompatible/integration/v7/global/running_security_groups_command_test.go (about)

     1  package global
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  	"code.cloudfoundry.org/cli/resources"
     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("running-security-groups command", func() {
    13  	Describe("help", func() {
    14  		When("--help flag is set", func() {
    15  			It("Displays command usage to output", func() {
    16  				session := helpers.CF("running-security-groups", "--help")
    17  				Eventually(session).Should(Say("NAME:"))
    18  				Eventually(session).Should(Say("running-security-groups - List security groups globally configured for running applications"))
    19  				Eventually(session).Should(Say("USAGE:"))
    20  				Eventually(session).Should(Say("cf running-security-groups"))
    21  				Eventually(session).Should(Say("SEE ALSO:"))
    22  				Eventually(session).Should(Say("bind-running-security-group, security-group, unbind-running-security-group"))
    23  				Eventually(session).Should(Exit(0))
    24  			})
    25  		})
    26  	})
    27  
    28  	When("the environment is not setup correctly", func() {
    29  		It("fails with the appropriate errors", func() {
    30  			helpers.CheckEnvironmentTargetedCorrectly(false, false, "", "running-security-groups")
    31  		})
    32  	})
    33  
    34  	When("the environment is set up correctly", func() {
    35  		var userName string
    36  
    37  		BeforeEach(func() {
    38  			userName = helpers.LoginCF()
    39  		})
    40  
    41  		When("running security groups exists", func() {
    42  			var (
    43  				securityGroup resources.SecurityGroup
    44  				orgName       string
    45  				spaceName     string
    46  				ports         string
    47  				description   string
    48  			)
    49  
    50  			BeforeEach(func() {
    51  				orgName = helpers.NewOrgName()
    52  				spaceName = helpers.NewSpaceName()
    53  				helpers.CreateOrg(orgName)
    54  				helpers.TargetOrg(orgName)
    55  				helpers.CreateSpace(spaceName)
    56  
    57  				ports = "3360"
    58  				description = "Test security group"
    59  				securityGroup = helpers.NewSecurityGroup(
    60  					helpers.PrefixedRandomName("INTEGRATION-SECURITY-GROUP"),
    61  					"tcp",
    62  					"10.244.1.18",
    63  					&ports,
    64  					&description,
    65  				)
    66  				helpers.CreateSecurityGroup(securityGroup)
    67  				session := helpers.CF(`bind-running-security-group`, securityGroup.Name)
    68  				Eventually(session).Should(Exit(0))
    69  			})
    70  
    71  			AfterEach(func() {
    72  				helpers.DeleteSecurityGroup(securityGroup)
    73  			})
    74  
    75  			It("displays the globally enabled running security groups exits 0", func() {
    76  				session := helpers.CF("running-security-groups")
    77  
    78  				Eventually(session).Should(Say(`Getting global running security groups as %s\.\.\.`, userName))
    79  				Eventually(session).Should(Say(`name`))
    80  				Eventually(session).Should(Say(`public_networks`))
    81  				Eventually(session).Should(Say(`dns`))
    82  				Eventually(session).Should(Say(securityGroup.Name))
    83  
    84  				Eventually(session).Should(Exit(0))
    85  			})
    86  		})
    87  
    88  	})
    89  })