github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v7/isolated/share_private_domain_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"regexp"
     5  
     6  	. "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers"
     7  
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  	. "github.com/onsi/gomega/gbytes"
    12  	. "github.com/onsi/gomega/gexec"
    13  )
    14  
    15  var _ = Describe("share-private-domain command", func() {
    16  	Context("Help", func() {
    17  		When("--help flag is set", func() {
    18  			It("appears in cf help -a", func() {
    19  				session := helpers.CF("help", "-a")
    20  				Eventually(session).Should(Exit(0))
    21  				Expect(session).To(HaveCommandInCategoryWithDescription("share-private-domain", "ORG ADMIN", "Share a private domain with a specific org"))
    22  			})
    23  
    24  			It("displays the help information", func() {
    25  				session := helpers.CF("share-private-domain", "--help")
    26  				Eventually(session).Should(Say("NAME:\n"))
    27  				Eventually(session).Should(Say(regexp.QuoteMeta("share-private-domain - Share a private domain with a specific org")))
    28  				Eventually(session).Should(Say("USAGE:\n"))
    29  				Eventually(session).Should(Say(regexp.QuoteMeta("cf share-private-domain ORG DOMAIN")))
    30  				Eventually(session).Should(Say("SEE ALSO:\n"))
    31  				Eventually(session).Should(Say("create-private-domain, domains, unshare-private-domain"))
    32  				Eventually(session).Should(Exit(0))
    33  			})
    34  		})
    35  	})
    36  
    37  	var (
    38  		sharedWithOrgName string
    39  		orgName           string
    40  		spaceName         string
    41  		domainName        string
    42  		userName          string
    43  	)
    44  
    45  	BeforeEach(func() {
    46  		sharedWithOrgName = helpers.NewOrgName()
    47  		orgName = helpers.NewOrgName()
    48  		spaceName = helpers.NewSpaceName()
    49  		domainName = helpers.NewDomainName()
    50  	})
    51  
    52  	When("user is logged in", func() {
    53  		BeforeEach(func() {
    54  			userName, _ = helpers.GetCredentials()
    55  			helpers.SetupCF(orgName, spaceName)
    56  			helpers.CreateOrg(sharedWithOrgName)
    57  			domain := helpers.NewDomain(orgName, domainName)
    58  			domain.CreatePrivate()
    59  		})
    60  
    61  		It("should create the shared domain", func() {
    62  			session := helpers.CF("share-private-domain", sharedWithOrgName, domainName)
    63  
    64  			Eventually(session).Should(Say("Sharing domain %s with org %s as %s...", domainName, sharedWithOrgName, userName))
    65  			Eventually(session).Should(Say("OK"))
    66  			Eventually(session).Should(Exit(0))
    67  
    68  			session = helpers.CF("domains")
    69  			Eventually(session).Should(Say(`%s\s+private`, domainName))
    70  			Eventually(session).Should(Exit(0))
    71  		})
    72  	})
    73  
    74  	When("there is an error", func() {
    75  		It("should report failure and exit with non-zero exit code", func() {
    76  			session := helpers.CF("share-private-domain", orgName, domainName)
    77  
    78  			Eventually(session.Err).Should(Say("Not logged in. Use 'cf login' or 'cf login --sso' to log in."))
    79  			Eventually(session).Should(Say("FAILED"))
    80  			Eventually(session).Should(Exit(1))
    81  		})
    82  	})
    83  })