예제 #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)
}
예제 #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())
}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("FindsUserGUIDs", func() {
	var (
		finder services.FindsUserGUIDs
		cc     *mocks.CloudController
		uaa    *mocks.ZonedUAAClient
	)

	BeforeEach(func() {
		cc = mocks.NewCloudController()
		uaa = mocks.NewZonedUAAClient()
		finder = services.NewFindsUserGUIDs(cc, uaa)
	})

	Context("UserGUIDsBelongingToScope", func() {
		BeforeEach(func() {
			uaa.UsersGUIDsByScopeCall.Returns.UserGUIDs = []string{"user-402", "user-525"}
		})

		It("returns the userGUIDs that have that scope", func() {
			guids, err := finder.UserGUIDsBelongingToScope("token", "this.scope")

			Expect(guids).To(Equal([]string{"user-402", "user-525"}))
			Expect(err).NotTo(HaveOccurred())

			Expect(uaa.UsersGUIDsByScopeCall.Receives.Token).To(Equal("token"))
			Expect(uaa.UsersGUIDsByScopeCall.Receives.Scope).To(Equal("this.scope"))