func getPasswordDeps() passwordDeps { return passwordDeps{ ReqFactory: new(requirementsfakes.FakeFactory), PwdRepo: &apifakes.OldFakePasswordRepo{UpdateUnauthorized: true}, Config: testconfig.NewRepository(), } }
func createAuthenticationRepository(apiServer *httptest.Server, authServer *httptest.Server) (coreconfig.ReadWriter, authentication.Repository) { config := testconfig.NewRepository() config.SetAuthenticationEndpoint(authServer.URL) config.SetAPIEndpoint(apiServer.URL) config.SetAccessToken("bearer initial-access-token") config.SetRefreshToken("initial-refresh-token") authGateway := NewUAAGateway(config, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "") authGateway.SetTrustedCerts(authServer.TLS.Certificates) fakePrinter := new(tracefakes.FakePrinter) dumper := NewRequestDumper(fakePrinter) authenticator := authentication.NewUAARepository(authGateway, config, dumper) return config, authenticator }
"authorization_endpoint": "https://login.example.com", "api_version": "42.0.0" }`) } var _ = Describe("Endpoints Repository", func() { var ( coreConfig coreconfig.ReadWriter gateway net.Gateway testServer *httptest.Server repo RemoteInfoRepository testServerFn func(w http.ResponseWriter, r *http.Request) ) BeforeEach(func() { coreConfig = testconfig.NewRepository() testServer = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { testServerFn(w, r) })) gateway = net.NewCloudControllerGateway(coreConfig, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "") gateway.SetTrustedCerts(testServer.TLS.Certificates) repo = NewEndpointRepository(gateway) }) AfterEach(func() { testServer.Close() }) Describe("updating the endpoints", func() { Context("when the API request is successful", func() { var (
service2 = models.ServiceOffering{ Plans: []models.ServicePlanFields{ {Name: "service-plan-c", Free: true}, {Name: "service-plan-d", Free: true}}, ServiceOfferingFields: models.ServiceOfferingFields{ Label: "aaa-my-service-offering", Description: "service offering 2 description", }, } fakeServiceOfferings = []models.ServiceOffering{serviceWithAPaidPlan, service2} }) Describe("Requirements", func() { Context("when the an API endpoint is not targeted", func() { It("does not meet its requirements", func() { config = testconfig.NewRepository() requirementsFactory.NewAPIEndpointRequirementReturns(requirements.Failing{Message: "no api"}) Expect(testcmd.RunCLICommand("marketplace", []string{}, requirementsFactory, updateCommandDependency, false, ui)).To(BeFalse()) }) Context("when arguments are provided", func() { var cmd commandregistry.Command var flagContext flags.FlagContext BeforeEach(func() { cmd = &service.MarketplaceServices{} cmd.SetDependency(deps, false) flagContext = flags.NewFlagContext(cmd.MetaData().Flags) })
} } return instances, apiErr } AfterEach(func() { commandregistry.Register(originalAppCommand) }) BeforeEach(func() { deps = commandregistry.NewDependency(os.Stdout, new(tracefakes.FakePrinter), "") ui = new(testterm.FakeUI) requirementsFactory = new(requirementsfakes.FakeFactory) configRepo = testconfig.NewRepository() appInstancesRepo = new(appinstancesfakes.FakeAppInstancesRepository) appRepo = new(applicationsfakes.FakeRepository) displayApp = new(applicationfakes.FakeAppDisplayer) //save original command dependency and restore later originalAppCommand = commandregistry.Commands.FindCommand("app") defaultInstanceErrorCodes = []string{"", ""} defaultAppForStart = models.Application{ ApplicationFields: models.ApplicationFields{ Name: "my-app", GUID: "my-app-guid",
func newCurlDependencies() (deps curlDependencies) { deps.config = testconfig.NewRepository() deps.config.SetAccessToken("BEARER my_access_token") deps.gateway = net.NewCloudControllerGateway(deps.config, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "") return }