diff --git a/api/handlers/service_binding_test.go b/api/handlers/service_binding_test.go index 0d46ba13f..923c42f52 100644 --- a/api/handlers/service_binding_test.go +++ b/api/handlers/service_binding_test.go @@ -91,44 +91,6 @@ var _ = Describe("ServiceBinding", func() { requestValidator.DecodeAndValidateJSONPayloadStub = decodeAndValidatePayloadStub(&payload) }) - When("binding to a managed service instance", func() { - BeforeEach(func() { - serviceInstanceRepo.GetServiceInstanceReturns(repositories.ServiceInstanceRecord{ - GUID: "service-instance-guid", - SpaceGUID: "space-guid", - Type: korifiv1alpha1.ManagedType, - }, nil) - - serviceBindingRepo.CreateServiceBindingReturns(repositories.ServiceBindingRecord{ - GUID: "service-binding-guid", - Type: korifiv1alpha1.CFServiceBindingTypeKey, - }, nil) - }) - - It("creates a binding", func() { - Expect(serviceInstanceRepo.GetServiceInstanceCallCount()).To(Equal(1)) - Expect(serviceBindingRepo.CreateServiceBindingCallCount()).To(Equal(1)) - _, actualAuthInfo, createServiceBindingMessage := serviceBindingRepo.CreateServiceBindingArgsForCall(0) - Expect(actualAuthInfo).To(Equal(authInfo)) - Expect(createServiceBindingMessage.ServiceInstanceGUID).To(Equal("service-instance-guid")) - Expect(createServiceBindingMessage.SpaceGUID).To(Equal("space-guid")) - Expect(createServiceBindingMessage.Type).To(Equal(korifiv1alpha1.CFServiceBindingTypeKey)) - Expect(rr).To(HaveHTTPStatus(http.StatusAccepted)) - Expect(rr).To(HaveHTTPHeaderWithValue("Location", - ContainSubstring("/v3/jobs/managed_service_binding.create~service-binding-guid"))) - }) - - When("creating the ServiceBinding errors", func() { - BeforeEach(func() { - serviceBindingRepo.CreateServiceBindingReturns(repositories.ServiceBindingRecord{}, errors.New("boom")) - }) - - It("returns an error", func() { - expectUnknownError() - }) - }) - }) - When("binding to a user provided service instance", func() { BeforeEach(func() { serviceInstanceRepo.GetServiceInstanceReturns(repositories.ServiceInstanceRecord{ @@ -138,55 +100,11 @@ var _ = Describe("ServiceBinding", func() { }, nil) }) - It("returns an error", func() { + It("returns an unprocessable entity error", func() { Expect(serviceBindingRepo.CreateServiceBindingCallCount()).To(Equal(0)) expectUnprocessableEntityError("Service credential bindings of type 'key' are not supported for user-provided service instances.") }) }) - - It("validates the payload", func() { - Expect(requestValidator.DecodeAndValidateJSONPayloadCallCount()).To(Equal(1)) - actualReq, _ := requestValidator.DecodeAndValidateJSONPayloadArgsForCall(0) - Expect(bodyString(actualReq)).To(Equal("the-json-body")) - }) - - When("the request body is invalid json", func() { - BeforeEach(func() { - requestValidator.DecodeAndValidateJSONPayloadReturns(errors.New("boom")) - }) - - It("returns an error", func() { - expectUnknownError() - }) - }) - - It("gets the service instance", func() { - Expect(serviceInstanceRepo.GetServiceInstanceCallCount()).To(Equal(1)) - _, actualAuthInfo, actualServiceInstanceGUID := serviceInstanceRepo.GetServiceInstanceArgsForCall(0) - Expect(actualAuthInfo).To(Equal(authInfo)) - Expect(actualServiceInstanceGUID).To(Equal("service-instance-guid")) - }) - - When("getting the service instance is forbidden", func() { - BeforeEach(func() { - serviceInstanceRepo.GetServiceInstanceReturns(repositories.ServiceInstanceRecord{}, apierrors.NewForbiddenError(nil, repositories.ServiceInstanceResourceType)) - }) - - It("returns a not found error", func() { - expectNotFoundError(repositories.ServiceInstanceResourceType) - }) - }) - - When("getting the ServiceInstance errors", func() { - BeforeEach(func() { - serviceInstanceRepo.GetServiceInstanceReturns(repositories.ServiceInstanceRecord{}, errors.New("boom")) - }) - - It("returns an error and doesn't create the ServiceBinding", func() { - expectUnknownError() - Expect(serviceBindingRepo.CreateServiceBindingCallCount()).To(Equal(0)) - }) - }) }) When("creating a service binding of type app", func() {