broker.Create() broker.PublicizePlans() }) AfterEach(func() { broker.Destroy() }) It("removes all instances and plans of the service, then removes the service offering", func() { instanceName := "purge-offering-instance" marketplace := cf.Cf("marketplace").Wait(DEFAULT_TIMEOUT) Expect(marketplace).To(Exit(0)) Expect(marketplace).To(Say(broker.Plan.Name)) broker.CreateServiceInstance(instanceName) services := cf.Cf("services").Wait(DEFAULT_TIMEOUT) Expect(marketplace).To(Exit(0)) Expect(services).To(Say(instanceName)) Expect(cf.Cf("delete", broker.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0)) cf.AsUser(context.AdminUserContext(), func() { Expect(cf.Cf("purge-service-offering", broker.Service.Name, "-f").Wait(DEFAULT_TIMEOUT)).To(Exit(0)) }) services = cf.Cf("services").Wait(DEFAULT_TIMEOUT) Expect(services).To(Exit(0)) Expect(services.Out.Contents()).NotTo(ContainSubstring(instanceName)) //TODO: Say?
config.RequestedScopes = `openid,cloud_controller_service_permissions.read` shelpers.SetOauthEndpoints(apiEndpoint, &config) }) AfterEach(func() { broker.Destroy() }) Context("When a service broker is created", func() { It("can perform an operation on a user's behalf using sso", func() { broker.Create() //create a service instance broker.PublicizePlans() serviceInstanceGuid := broker.CreateServiceInstance(generator.RandomName()) // perform the OAuth lifecycle to obtain an access token userSessionCookie := shelpers.AuthenticateUser(config.AuthorizationEndpoint, context.RegularUserContext().Username, context.RegularUserContext().Password) authCode, _ := shelpers.RequestScopes(userSessionCookie, config) Expect(authCode).ToNot(BeNil(), `Failed to request and authorize scopes.`) accessToken := shelpers.GetAccessToken(authCode, config) Expect(accessToken).ToNot(BeNil(), `Failed to obtain an access token.`) // use the access token to perform an operation on the user's behalf canManage, httpCode := shelpers.QueryServiceInstancePermissionEndpoint(apiEndpoint, accessToken, serviceInstanceGuid) Expect(httpCode).To(Equal(`200`), `The provided access token was not valid.`) Expect(canManage).To(Equal(`true`))