Пример #1
0
func setUpLoginTestContext() (c *LoginTestContext) {
	c = new(LoginTestContext)
	c.Config = testconfig.NewRepository()

	c.ui = &testterm.FakeUI{}

	c.authRepo = &testapi.FakeAuthenticationRepository{
		AccessToken:  "my_access_token",
		RefreshToken: "my_refresh_token",
		Config:       c.Config,
	}
	c.endpointRepo = &testapi.FakeEndpointRepo{Config: c.Config}

	org := models.Organization{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	c.orgRepo = &testapi.FakeOrgRepository{
		Organizations: []models.Organization{org},
	}

	space := models.Space{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	c.spaceRepo = &testapi.FakeSpaceRepository{
		Spaces: []models.Space{space},
	}

	return
}
Пример #2
0
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Describe("when the user provides fewer than two args", func() {
		It("fails with usage", func() {
			callRenameSpace([]string{"foo"})
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Describe("when the user is logged in and has provided an old and new space name", func() {
		BeforeEach(func() {
			space := models.Space{}
			space.Name = "the-old-space-name"
			space.Guid = "the-old-space-guid"
			reqFactory.Space = space
		})

		It("renames a space", func() {
			originalSpaceName := configRepo.SpaceFields().Name
			callRenameSpace([]string{"the-old-space-name", "my-new-space"})

			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
				{"OK"},
			})

			Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
			Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
			Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
Пример #3
0
		It("TestTargetSpaceWhenNoOrganizationIsSelected", func() {
			config.SetOrganizationFields(models.OrganizationFields{})

			ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)

			testassert.SliceContains(ui.Outputs, testassert.Lines{
				{"FAILED"},
				{"An org must be targeted before targeting a space"},
			})
			Expect(config.OrganizationFields().Guid).To(Equal(""))
		})

		It("TestTargetSpaceWhenUserHasAccess", func() {
			space := models.Space{}
			space.Name = "my-space"
			space.Guid = "my-space-guid"

			spaceRepo.Spaces = []models.Space{space}
			spaceRepo.FindByNameSpace = space

			ui := callTarget([]string{"-s", "my-space"}, reqFactory, config, orgRepo, spaceRepo)

			Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
			Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("TestTargetSpaceWhenUserDoesNotHaveAccess", func() {
			config.SetSpaceFields(models.SpaceFields{})
			spaceRepo.FindByNameErr = true
Пример #4
0
			RefreshToken: "my_refresh_token",
			Config:       Config,
		}
		endpointRepo = &testapi.FakeEndpointRepo{}

		org := models.Organization{}
		org.Name = "my-new-org"
		org.Guid = "my-new-org-guid"

		orgRepo = &testapi.FakeOrgRepository{
			Organizations:          []models.Organization{org},
			FindByNameOrganization: models.Organization{},
		}

		space := models.Space{}
		space.Guid = "my-space-guid"
		space.Name = "my-space"

		spaceRepo = &testapi.FakeSpaceRepository{
			Spaces: []models.Space{space},
		}

		authRepo.GetLoginPromptsReturns.Prompts = map[string]configuration.AuthPrompt{
			"username": configuration.AuthPrompt{
				DisplayName: "Username",
				Type:        configuration.AuthPromptTypeText,
			},
			"password": configuration.AuthPrompt{
				DisplayName: "Password",
				Type:        configuration.AuthPromptTypePassword,
			},
Пример #5
0
func defaultDeleteSpaceSpace() models.Space {
	space := models.Space{}
	space.Name = "space-to-delete"
	space.Guid = "space-to-delete-guid"
	return space
}
Пример #6
0
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		requirementsFactory.LoginSuccess = true
		callSpaceUsers(args, requirementsFactory, spaceRepo, userRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeTrue())

		Expect("my-org").To(Equal(requirementsFactory.OrganizationName))
	})
	It("TestSpaceUsers", func() {

		org := models.Organization{}
		org.Name = "Org1"
		org.Guid = "org1-guid"
		space := models.Space{}
		space.Name = "Space1"
		space.Guid = "space1-guid"

		requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
		spaceRepo := &testapi.FakeSpaceRepository{FindByNameInOrgSpace: space}
		userRepo := &testapi.FakeUserRepository{}

		user := models.UserFields{}
		user.Username = "******"
		user2 := models.UserFields{}
		user2.Username = "******"
		user3 := models.UserFields{}
		user3.Username = "******"
		user4 := models.UserFields{}
		user4.Username = "******"
		userRepo.ListUsersByRole = map[string][]models.UserFields{
			models.SPACE_MANAGER:   []models.UserFields{user, user2},