_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})
			Expect(err).To(MatchError("user-creation-failed"))
		})

		Context("with error status code", func() {
			It("returns the status as error", func() {
				client.PutUserReturns(&http.Response{StatusCode: http.StatusInternalServerError}, nil)
				_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})
				Expect(err).To(MatchError("http request failed with status code: 500"))
			})
		})
	})

	Context("When the user already exists", func() {
		BeforeEach(func() {
			client.GetUserReturns(&rabbithole.UserInfo{}, nil)
		})

		It("returns an error", func() {
			_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})
			Expect(err).To(HaveOccurred())
		})
	})

	Context("when the grant permissions fail", func() {
		It("returns the error", func() {
			client.UpdatePermissionsInReturns(nil, fmt.Errorf("update-permissions-failed"))
			_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})
			Expect(err).To(MatchError("update-permissions-failed"))
		})
		client = new(fakes.FakeAPIClient)
		credentialsGenerator = new(fakes.FakeCredentialsGenerator)
		logger = lagertest.NewTestLogger("test")
		broker = rabbitbroker.New(config, client, credentialsGenerator, logger, nil)
	})

	Context("Provision", func() {

		BeforeEach(func() {
			client.GetVhostReturns(nil, fmt.Errorf("vhost does not exist"))
			client.PutVhostReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
			client.DeleteVhostReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
			client.UpdatePermissionsInReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
			client.PutPolicyReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
			client.PutUserReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
			client.GetUserReturns(nil, fmt.Errorf(rabbitbroker.NotFoundIdentifier))

			credentialsGenerator.GenerateReturns(rabbitbroker.Credentials{
				Username: "******",
				Password: "******",
			})
		})

		It("returns no error", func() {
			_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
			Expect(err).NotTo(HaveOccurred())
		})

		It("logs a message stating that it is provisioning", func() {
			_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
			Expect(err).NotTo(HaveOccurred())