Esempio n. 1
0
			Expect(requirementsFactory.OrganizationName).To(Equal("org"))
		})
	})

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true

			user := models.UserFields{}
			user.Username = "******"
			user.Guid = "some-user-guid"
			org := models.Organization{}
			org.Name = "some-org"
			org.Guid = "some-org-guid"

			requirementsFactory.UserFields = user
			requirementsFactory.Organization = org
		})

		It("unsets a user's org role", func() {
			runCommand("my-username", "my-org", "OrgManager")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Removing role", "OrgManager", "my-username", "my-org", "my-user"},
				[]string{"OK"},
			))

			Expect(userRepo.UnsetOrgRoleRole).To(Equal(models.ORG_MANAGER))
			Expect(userRepo.UnsetOrgRoleUserGuid).To(Equal("some-user-guid"))
			Expect(userRepo.UnsetOrgRoleOrganizationGuid).To(Equal("some-org-guid"))
		})
Esempio n. 2
0
			})
		})

		Context("when the space is found", func() {
			BeforeEach(func() {
				space := models.Space{}
				space.Guid = "the-space-guid"
				space.Name = "the-space-name"
				space.Organization = org.OrganizationFields
				spaceRepo.FindByNameInOrgReturns(space, nil)
			})

			Context("when the UserRequirement returns a user with a GUID", func() {
				BeforeEach(func() {
					userFields := models.UserFields{Guid: "the-user-guid", Username: "******"}
					requirementsFactory.UserFields = userFields
				})

				It("tells the user it is assigning the role", func() {
					cmd.Execute(flagContext)
					Expect(ui.Outputs).To(ContainSubstrings(
						[]string{"Assigning role", "SpaceManager", "the-username", "the-org", "the-username"},
						[]string{"OK"},
					))
				})

				It("sets the role using the GUID", func() {
					cmd.Execute(flagContext)
					Expect(userRepo.SetSpaceRoleByGuidCallCount()).To(Equal(1))
					actualUserGUID, actualSpaceGUID, actualOrgGUID, actualRole := userRepo.SetSpaceRoleByGuidArgsForCall(0)
					Expect(actualUserGUID).To(Equal("the-user-guid"))
Esempio n. 3
0
		})

		It("fails with usage when not provided exactly three args", func() {
			runCommand("one fish", "two fish") // red fish, blue fish
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true

			org := models.Organization{}
			org.Guid = "my-org-guid"
			org.Name = "my-org"
			requirementsFactory.UserFields = models.UserFields{Guid: "my-user-guid", Username: "******"}
			requirementsFactory.Organization = org
		})

		It("sets the given org role on the given user", func() {
			runCommand("some-user", "some-org", "OrgManager")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Assigning role", "OrgManager", "my-user", "my-org", "my-user"},
				[]string{"OK"},
			))
			Expect(userRepo.SetOrgRoleUserGuid).To(Equal("my-user-guid"))
			Expect(userRepo.SetOrgRoleOrganizationGuid).To(Equal("my-org-guid"))
			Expect(userRepo.SetOrgRoleRole).To(Equal(models.ORG_MANAGER))
		})
	})