BeforeEach(func() {
		config = &rabbitbroker.Config{}
		client = new(fakes.FakeAPIClient)
		client.PutUserReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
		client.UpdatePermissionsInReturns(&http.Response{StatusCode: http.StatusNoContent}, nil)
		credentialsGenerator = new(fakes.FakeCredentialsGenerator)
		binder = new(fakes.FakeBindingInfoBuilder)
		broker = rabbitbroker.New(config, client, credentialsGenerator, lagertest.NewTestLogger("test"), binder)
	})

	It("uses generated user credentials", func() {
		credentialsGenerator.GenerateReturns(rabbitbroker.Credentials{Username: "******", Password: "******"})
		_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})
		Expect(err).NotTo(HaveOccurred())

		Expect(client.PutUserCallCount()).To(Equal(1))
		username, userInfo := client.PutUserArgsForCall(0)
		Expect(username).To(Equal("bob"))
		Expect(userInfo.Name).To(Equal("bob"))
		Expect(userInfo.Password).To(Equal("sekrit"))
	})

	It("constructs a binding using the Binder", func() {
		credentialsGenerator.GenerateReturns(rabbitbroker.Credentials{Username: "******", Password: "******"})
		config.Rabbitmq = rabbitbroker.RabbitmqConfig{ManagementDomain: "some-domain"}
		expectedConfig := rabbitbroker.RabbitmqConfig{
			ManagementDomain: "some-domain",
		}
		protocols := map[string]rabbithole.Port{"my-protocol": 12}
		client.ProtocolPortsReturns(protocols, nil)
		_, err := broker.Bind("my-instance", "my-binding", brokerapi.BindDetails{})