Ejemplo n.º 1
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())
}
		}
		tokenLoader = mocks.NewTokenLoader()
		token = helpers.BuildToken(tokenHeader, tokenClaims)
		tokenLoader.LoadCall.Returns.Token = token
		v1Enqueuer = mocks.NewEnqueuer()
		v2Enqueuer = mocks.NewV2Enqueuer()

		findsUserGUIDs = mocks.NewFindsUserGUIDs()
		findsUserGUIDs.UserGUIDsBelongingToOrganizationCall.Returns.UserGUIDs = []string{"user-123", "user-456"}

		organizationLoader = mocks.NewOrganizationLoader()
		organizationLoader.LoadCall.Returns.Organization = cf.CloudControllerOrganization{
			Name: "my-org",
			GUID: "org-001",
		}
		strategy = services.NewOrganizationStrategy(tokenLoader, organizationLoader, findsUserGUIDs, v1Enqueuer, v2Enqueuer)
	})

	Describe("Dispatch", func() {
		Context("when the dispatch JobType is unspecified", func() {
			Context("when the request is valid", func() {
				It("call enqueuer.Enqueue with the correct arguments for an organization", func() {
					_, err := strategy.Dispatch(services.Dispatch{
						GUID:       "org-001",
						Connection: conn,
						Message: services.DispatchMessage{
							To:      "*****@*****.**",
							ReplyTo: "*****@*****.**",
							Subject: "this is the subject",
							Text:    "Please reset your password by clicking on this link...",
							HTML: services.HTML{