diff --git a/api_test.go b/api_test.go index b5ef8333..dc8766dd 100644 --- a/api_test.go +++ b/api_test.go @@ -1841,6 +1841,7 @@ var _ = Describe("Service Broker API", func() { Expect(response.StatusCode).To(Equal(http.StatusPreconditionFailed)) response = makeLastBindingOperationRequestWithSpecificAPIVersion(instanceID, bindingID, "2.13") Expect(response.StatusCode).To(Equal(http.StatusPreconditionFailed)) + Expect(response.Body).To(MatchJSON(`{"description":"get binding endpoint only supported starting with OSB version 2.14"}`)) }) It("fails for GetBinding request", func() { @@ -1871,6 +1872,23 @@ var _ = Describe("Service Broker API", func() { Expect(response.StatusCode).To(Equal(http.StatusOK)) Expect(response.Body).To(MatchJSON(fixture("binding.json"))) }) + + It("returns 500 when lastBindingOperation returns an unknown error", func() { + fakeAsyncServiceBroker.LastBindingOperationError = errors.New("unknown error") + + response := makeLastBindingOperationRequestWithSpecificAPIVersion(instanceID, bindingID, "2.14") + Expect(response.StatusCode).To(Equal(http.StatusInternalServerError)) + }) + + It("returns the appropriate when lastBindingOperation returns a known error", func() { + fakeAsyncServiceBroker.LastBindingOperationError = brokerapi.NewFailureResponse( + errors.New("I failed in unique and interesting ways"), + http.StatusTeapot, + "interesting-failure", + ) + response := makeLastBindingOperationRequestWithSpecificAPIVersion(instanceID, bindingID, "2.14") + Expect(response.StatusCode).To(Equal(http.StatusTeapot)) + }) }) }) }) diff --git a/fakes/fake_service_broker.go b/fakes/fake_service_broker.go index 2f06d816..f66b1fbc 100644 --- a/fakes/fake_service_broker.go +++ b/fakes/fake_service_broker.go @@ -33,6 +33,7 @@ type FakeServiceBroker struct { UnbindError error DeprovisionError error LastOperationError error + LastBindingOperationError error UpdateError error GetInstanceError error GetBindingError error @@ -412,8 +413,8 @@ func (fakeBroker *FakeServiceBroker) LastBindingOperation(context context.Contex fakeBroker.ReceivedContext = val } - if fakeBroker.LastOperationError != nil { - return brokerapi.LastOperation{}, fakeBroker.LastOperationError + if fakeBroker.LastBindingOperationError != nil { + return brokerapi.LastOperation{}, fakeBroker.LastBindingOperationError } return brokerapi.LastOperation{State: fakeBroker.LastOperationState, Description: fakeBroker.LastOperationDescription}, nil