Skip to content

Commit

Permalink
v7: Update set-{org,space}-role global integration tests
Browse files Browse the repository at this point in the history
We made some changes on the API side to improve the error message when
the user does not exist. Also, the commands now look for the org/space
by name before trying to do anything with the user, so we have to make
sure the org/space actually exist in our test. This gets past the
"org/space not found" error to let us really test the user-not-found
case.

Authored-by: Reid Mitchell <[email protected]>
  • Loading branch information
reidmit committed Nov 4, 2019
1 parent 228e48b commit 1ea93d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions integration/v7/global/set_org_role_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ import (
)

var _ = Describe("set-org-role command", func() {
var orgName string

When("the set_roles_by_username flag is disabled", func() {
BeforeEach(func() {
orgName = helpers.NewOrgName()
helpers.LoginCF()
helpers.CreateOrg(orgName)
helpers.DisableFeatureFlag("set_roles_by_username")
})

AfterEach(func() {
helpers.QuickDeleteOrg(orgName)
helpers.EnableFeatureFlag("set_roles_by_username")
})

When("the user does not exist", func() {
It("prints the error from UAA and exits 1", func() {
session := helpers.CF("set-org-role", "not-exists", "some-org", "OrgAuditor")
session := helpers.CF("set-org-role", "not-exists", orgName, "OrgAuditor")
Eventually(session).Should(Say("FAILED"))
Eventually(session.Err).Should(Say("User 'not-exists' does not exist"))
Eventually(session.Err).Should(Say("No user exists with the username 'not-exists' and origin 'uaa'."))
Eventually(session).Should(Exit(1))
})
})
Expand Down
12 changes: 10 additions & 2 deletions integration/v7/global/set_space_role_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ import (
)

var _ = Describe("set-space-role command", func() {
var (
orgName string
spaceName string
)

When("the set_roles_by_username flag is disabled", func() {
BeforeEach(func() {
spaceName = helpers.NewSpaceName()
helpers.LoginCF()
orgName = helpers.CreateAndTargetOrg()
helpers.CreateSpace(spaceName)
helpers.DisableFeatureFlag("set_roles_by_username")
})

Expand All @@ -22,9 +30,9 @@ var _ = Describe("set-space-role command", func() {

When("the user does not exist", func() {
It("prints the error from UAA and exits 1", func() {
session := helpers.CF("set-space-role", "not-exists", "some-org", "some-space", "SpaceDeveloper")
session := helpers.CF("set-space-role", "not-exists", orgName, spaceName, "SpaceDeveloper")
Eventually(session).Should(Say("FAILED"))
Eventually(session.Err).Should(Say("User 'not-exists' does not exist"))
Eventually(session.Err).Should(Say("No user exists with the username 'not-exists' and origin 'uaa'."))
Eventually(session).Should(Exit(1))
})
})
Expand Down

0 comments on commit 1ea93d8

Please sign in to comment.