BeforeEach(func() { config = testconfig.NewRepository() fakePrinter = new(tracefakes.FakePrinter) gateway = net.NewUAAGateway(config, new(terminalfakes.FakeUI), fakePrinter, "") dumper = net.NewRequestDumper(fakePrinter) auth = NewUAARepository(gateway, config, dumper) }) AfterEach(func() { testServer.Close() }) var setupTestServer = func(request testnet.TestRequest) { testServer, handler = testnet.NewServer([]testnet.TestRequest{request}) config.SetAuthenticationEndpoint(testServer.URL) } Describe("authenticating", func() { var err error JustBeforeEach(func() { err = auth.Authenticate(map[string]string{ "username": "******", "password": "******", }) }) Describe("when login succeeds", func() { BeforeEach(func() { setupTestServer(successfulLoginRequest)