Exemple #1
0
func (m *Mother) UAAScopeStrategy() services.UAAScopeStrategy {
	env := NewEnvironment()
	uaaClient := uaa.NewZonedUAAClient(env.UAAClientID, env.UAAClientSecret, env.VerifySSL, UAAPublicKey)
	cloudController := cf.NewCloudController(env.CCHost, !env.VerifySSL)

	tokenLoader := uaa.NewTokenLoader(uaaClient)
	findsUserGUIDs := services.NewFindsUserGUIDs(cloudController, uaaClient)
	enqueuer := m.Enqueuer()

	return services.NewUAAScopeStrategy(tokenLoader, findsUserGUIDs, enqueuer, m.V2Enqueuer(), env.DefaultUAAScopes)
}
Exemple #2
0
func (m *Mother) OrganizationStrategy() services.OrganizationStrategy {
	env := NewEnvironment()
	cloudController := cf.NewCloudController(env.CCHost, !env.VerifySSL)

	uaaClient := uaa.NewZonedUAAClient(env.UAAClientID, env.UAAClientSecret, env.VerifySSL, UAAPublicKey)
	tokenLoader := uaa.NewTokenLoader(uaaClient)
	organizationLoader := services.NewOrganizationLoader(cloudController)
	findsUserGUIDs := services.NewFindsUserGUIDs(cloudController, uaaClient)
	enqueuer := m.Enqueuer()

	return services.NewOrganizationStrategy(tokenLoader, organizationLoader, findsUserGUIDs, enqueuer, m.V2Enqueuer())
}
})

var _ = Describe("CloudController", func() {
	var CCServer *httptest.Server

	Describe("GetUsersBySpaceGuid", func() {
		BeforeEach(func() {
			CCServer = httptest.NewServer(UsersEndpoint)
		})

		AfterEach(func() {
			CCServer.Close()
		})

		It("returns a list of users for the given space guid", func() {
			cloudController := cf.NewCloudController(CCServer.URL, false)
			users, err := cloudController.GetUsersBySpaceGuid(testSpaceGuid, testUAAToken)
			if err != nil {
				panic(err)
			}

			Expect(len(users)).To(Equal(2))

			Expect(users).To(ContainElement(cf.CloudControllerUser{
				GUID: "user-123",
			}))

			Expect(users).To(ContainElement(cf.CloudControllerUser{
				GUID: "user-456",
			}))
		})