Ejemplo n.º 1
0
		auth       AuthenticationRepository
	)

	BeforeEach(func() {
		config = testconfig.NewRepository()
		gateway = net.NewUAAGateway(config, &testterm.FakeUI{})
		auth = NewUAAAuthenticationRepository(gateway, config)
	})

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

	var setupTestServer = func(request testnet.TestRequest) {
		testServer, handler = testnet.NewServer([]testnet.TestRequest{request})
		config.SetAuthenticationEndpoint(testServer.URL)
	}

	Describe("authenticating", func() {
		var err error

		JustBeforeEach(func() {
			err = auth.Authenticate(map[string]string{
				"username": "******",
				"password": "******",
			})
		})

		Describe("when login succeeds", func() {
			BeforeEach(func() {
				setupTestServer(successfulLoginRequest)
Ejemplo n.º 2
0
			auth       AuthenticationRepository
		)

		BeforeEach(func() {
			config = testconfig.NewRepository()
			gateway = net.NewUAAGateway(config, &testterm.FakeUI{})
			auth = NewUAAAuthenticationRepository(gateway, config)
		})

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

		var setupTestServer = func(request testnet.TestRequest) {
			testServer, handler = testnet.NewServer([]testnet.TestRequest{request})
			config.SetAuthenticationEndpoint(testServer.URL)
		}

		Describe("authenticating", func() {
			var err error

			JustBeforeEach(func() {
				err = auth.Authenticate(map[string]string{
					"username": "******",
					"password": "******",
				})
			})

			Describe("when login succeeds", func() {
				BeforeEach(func() {
					setupTestServer(successfulLoginRequest)
Ejemplo n.º 3
0
			setupCCServer(ccReqs...)

			_, apiErr := repo.ListUsersInOrgForRole("my-org-guid", models.ORG_MANAGER)

			Expect(ccHandler).To(HaveAllRequestsCalled())
			httpErr, ok := apiErr.(errors.HttpError)
			Expect(ok).To(BeTrue())
			Expect(httpErr.StatusCode()).To(Equal(http.StatusGatewayTimeout))
		})

		It("returns an error when the UAA endpoint cannot be determined", func() {
			ccReqs, _ := createUsersByRoleEndpoints("/v2/organizations/my-org-guid/managers")

			setupCCServer(ccReqs...)

			config.SetAuthenticationEndpoint("")

			_, apiErr := repo.ListUsersInOrgForRole("my-org-guid", models.ORG_MANAGER)
			Expect(apiErr).To(HaveOccurred())
		})
	})

	Describe("listing the users with a given role using ListUsersInOrgForRoleWithNoUAA()", func() {
		Context("when there are users in the given org", func() {
			It("lists the users in an organization with a given role without hitting UAA endpoint", func() {
				ccReqs, uaaReqs := createUsersByRoleEndpoints("/v2/organizations/my-org-guid/managers")

				setupCCServer(ccReqs...)
				setupUAAServer(uaaReqs...)

				users, apiErr := repo.ListUsersInOrgForRoleWithNoUAA("my-org-guid", models.ORG_MANAGER)