Ejemplo n.º 1
0
	"github.com/pivotal-cf-experimental/warrant"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Account Exists", func() {
	var (
		warrantUserService   *mocks.WarrantUserService
		warrantClientService *mocks.WarrantClientService
		userFinder           uaa.UserFinder
	)

	BeforeEach(func() {
		warrantUserService = mocks.NewWarrantUserService()
		warrantClientService = mocks.NewWarrantClientService()
		warrantClientService.GetTokenCall.Returns.Token = "client-token"

		userFinder = uaa.NewUserFinder("client-id", "client-secret", warrantUserService, warrantClientService)
	})

	It("determines whether a user exists or not", func() {
		exists, err := userFinder.Exists("some-guid")
		Expect(err).NotTo(HaveOccurred())
		Expect(exists).To(BeTrue())

		Expect(warrantClientService.GetTokenCall.Receives.ID).To(Equal("client-id"))
		Expect(warrantClientService.GetTokenCall.Receives.Secret).To(Equal("client-secret"))

		Expect(warrantUserService.GetCall.Receives.Token).To(Equal("client-token"))
	})
Ejemplo n.º 2
0
	"github.com/cloudfoundry-incubator/notifications/testing/mocks"
	"github.com/pivotal-cf-experimental/rainmaker"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("OrgFinder", func() {
	var (
		tokenGetter *mocks.WarrantClientService
		orgGetter   *mocks.RainmakerOrganizationsService
		finder      cf.OrgFinder
	)

	BeforeEach(func() {
		tokenGetter = mocks.NewWarrantClientService()
		tokenGetter.GetTokenCall.Returns.Token = "some-token"
		orgGetter = mocks.NewRainmakerOrganizationsService()
		orgGetter.GetCall.Returns.Organization = rainmaker.Organization{
			GUID: "some-guid",
		}
		finder = cf.NewOrgFinder("some-id", "some-secret", tokenGetter, orgGetter)
	})

	It("finds an org given a guid", func() {
		exists, err := finder.Exists("some-guid")
		Expect(err).NotTo(HaveOccurred())
		Expect(exists).To(BeTrue())

		Expect(orgGetter.GetCall.Receives.GUID).To(Equal("some-guid"))
		Expect(orgGetter.GetCall.Receives.Token).To(Equal("some-token"))