func Init(config configuration.ReadWriter) go_i18n.TranslateFunc { var T go_i18n.TranslateFunc var err error locale := config.Locale() if locale != "" { pieces := strings.Split(locale, "_") err = loadFromAsset(locale, pieces[1]) if err == nil { T, err = go_i18n.Tfunc(config.Locale(), DEFAULT_LOCALE) } } else { var userLocale string userLocale, err = initWithUserLocale() if err != nil { userLocale = mustLoadDefaultLocale() } T, err = go_i18n.Tfunc(userLocale, DEFAULT_LOCALE) } if err != nil { panic(err) } return T }
func NewRepositoryLocator(config configuration.ReadWriter, gatewaysByName map[string]net.Gateway) (loc RepositoryLocator) { strategy := strategy.NewEndpointStrategy(config.ApiVersion()) authGateway := gatewaysByName["auth"] cloudControllerGateway := gatewaysByName["cloud-controller"] uaaGateway := gatewaysByName["uaa"] loc.authRepo = authentication.NewUAAAuthenticationRepository(authGateway, config) // ensure gateway refreshers are set before passing them by value to repositories cloudControllerGateway.SetTokenRefresher(loc.authRepo) uaaGateway.SetTokenRefresher(loc.authRepo) tlsConfig := net.NewTLSConfig([]tls.Certificate{}, config.IsSSLDisabled()) loggregatorConsumer := consumer.New(config.LoggregatorEndpoint(), tlsConfig, http.ProxyFromEnvironment) loggregatorConsumer.SetDebugPrinter(terminal.DebugPrinter{}) loc.appBitsRepo = application_bits.NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway) loc.appEventsRepo = app_events.NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy) loc.appFilesRepo = NewCloudControllerAppFilesRepository(config, cloudControllerGateway) loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway) loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway) loc.appInstancesRepo = NewCloudControllerAppInstancesRepository(config, cloudControllerGateway) loc.authTokenRepo = NewCloudControllerServiceAuthTokenRepository(config, cloudControllerGateway) loc.curlRepo = NewCloudControllerCurlRepository(config, cloudControllerGateway) loc.domainRepo = NewCloudControllerDomainRepository(config, cloudControllerGateway, strategy) loc.endpointRepo = NewEndpointRepository(config, cloudControllerGateway) loc.logsRepo = NewLoggregatorLogsRepository(config, loggregatorConsumer, loc.authRepo) loc.organizationRepo = organizations.NewCloudControllerOrganizationRepository(config, cloudControllerGateway) loc.passwordRepo = NewCloudControllerPasswordRepository(config, uaaGateway) loc.quotaRepo = quotas.NewCloudControllerQuotaRepository(config, cloudControllerGateway) loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway) loc.stackRepo = NewCloudControllerStackRepository(config, cloudControllerGateway) loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway) loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway) loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway) loc.servicePlanRepo = NewCloudControllerServicePlanRepository(config, cloudControllerGateway) loc.servicePlanVisibilityRepo = NewCloudControllerServicePlanVisibilityRepository(config, cloudControllerGateway) loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway) loc.spaceRepo = spaces.NewCloudControllerSpaceRepository(config, cloudControllerGateway) loc.userProvidedServiceInstanceRepo = NewCCUserProvidedServiceInstanceRepository(config, cloudControllerGateway) loc.userRepo = NewCloudControllerUserRepository(config, uaaGateway, cloudControllerGateway) loc.buildpackRepo = NewCloudControllerBuildpackRepository(config, cloudControllerGateway) loc.buildpackBitsRepo = NewCloudControllerBuildpackBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{}) loc.securityGroupRepo = security_groups.NewSecurityGroupRepo(config, cloudControllerGateway) loc.stagingSecurityGroupRepo = staging.NewStagingSecurityGroupsRepo(config, cloudControllerGateway) loc.runningSecurityGroupRepo = running.NewRunningSecurityGroupsRepo(config, cloudControllerGateway) loc.securityGroupSpaceBinder = securitygroupspaces.NewSecurityGroupSpaceBinder(config, cloudControllerGateway) loc.spaceQuotaRepo = space_quotas.NewCloudControllerSpaceQuotaRepository(config, cloudControllerGateway) loc.featureFlagRepo = feature_flags.NewCloudControllerFeatureFlagRepository(config, cloudControllerGateway) loc.environmentVariableGroupRepo = environment_variable_groups.NewCloudControllerEnvironmentVariableGroupsRepository(config, cloudControllerGateway) return }
func NewRepositoryLocator(config configuration.ReadWriter, gatewaysByName map[string]net.Gateway) (loc RepositoryLocator) { strategy := strategy.NewEndpointStrategy(config.ApiVersion()) authGateway := gatewaysByName["auth"] cloudControllerGateway := gatewaysByName["cloud-controller"] uaaGateway := gatewaysByName["uaa"] loc.authRepo = NewUAAAuthenticationRepository(authGateway, config) // ensure gateway refreshers are set before passing them by value to repositories cloudControllerGateway.SetTokenRefresher(loc.authRepo) uaaGateway.SetTokenRefresher(loc.authRepo) tlsConfig := net.NewTLSConfig([]tls.Certificate{}, config.IsSSLDisabled()) loggregatorConsumer := consumer.New(config.LoggregatorEndpoint(), tlsConfig, nil) loc.appBitsRepo = NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{}) loc.appEventsRepo = NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy) loc.appFilesRepo = NewCloudControllerAppFilesRepository(config, cloudControllerGateway) loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway) loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway) loc.appInstancesRepo = NewCloudControllerAppInstancesRepository(config, cloudControllerGateway) loc.authTokenRepo = NewCloudControllerServiceAuthTokenRepository(config, cloudControllerGateway) loc.curlRepo = NewCloudControllerCurlRepository(config, cloudControllerGateway) loc.domainRepo = NewCloudControllerDomainRepository(config, cloudControllerGateway, strategy) loc.endpointRepo = NewEndpointRepository(config, cloudControllerGateway) loc.logsRepo = NewLoggregatorLogsRepository(config, loggregatorConsumer, loc.authRepo) loc.organizationRepo = NewCloudControllerOrganizationRepository(config, cloudControllerGateway) loc.passwordRepo = NewCloudControllerPasswordRepository(config, uaaGateway) loc.quotaRepo = NewCloudControllerQuotaRepository(config, cloudControllerGateway) loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway) loc.stackRepo = NewCloudControllerStackRepository(config, cloudControllerGateway) loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway) loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway) loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway) loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway) loc.spaceRepo = NewCloudControllerSpaceRepository(config, cloudControllerGateway) loc.userProvidedServiceInstanceRepo = NewCCUserProvidedServiceInstanceRepository(config, cloudControllerGateway) loc.userRepo = NewCloudControllerUserRepository(config, uaaGateway, cloudControllerGateway) loc.buildpackRepo = NewCloudControllerBuildpackRepository(config, cloudControllerGateway) loc.buildpackBitsRepo = NewCloudControllerBuildpackBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{}) loc.appSecurityGroupRepo = NewSecurityGroupRepo(config, cloudControllerGateway) loc.stagingSecurityGroupRepo = NewStagingSecurityGroupsRepo(config, cloudControllerGateway) return }
testapi "github.com/cloudfoundry/cli/testhelpers/api" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "net/http" "net/http/httptest" "net/url" "time" ) var _ = Describe("User Repository", func() { var ( ccServer *httptest.Server ccHandler *testnet.TestHandler uaaServer *httptest.Server uaaHandler *testnet.TestHandler repo UserRepository config configuration.ReadWriter ) BeforeEach(func() { config = testconfig.NewRepositoryWithDefaults() ccGateway := net.NewCloudControllerGateway((config), time.Now) uaaGateway := net.NewUAAGateway(config) repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway) }) AfterEach(func() { if uaaServer != nil { uaaServer.Close() }
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("target command", func() { var ( orgRepo *testapi.FakeOrgRepository spaceRepo *testapi.FakeSpaceRepository requirementsFactory *testreq.FakeReqFactory config configuration.ReadWriter ui *testterm.FakeUI ) BeforeEach(func() { ui = new(testterm.FakeUI) orgRepo = new(testapi.FakeOrgRepository) spaceRepo = new(testapi.FakeSpaceRepository) requirementsFactory = new(testreq.FakeReqFactory) config = testconfig.NewRepositoryWithDefaults() }) var callTarget = func(args []string) { cmd := NewTarget(ui, config, orgRepo, spaceRepo) testcmd.RunCommand(cmd, args, requirementsFactory)
config = testconfig.NewRepository() }) It("prompts the user to login", func() { output := io_helpers.CaptureOutput(func() { ui := NewUI((os.Stdin)) ui.ShowConfiguration(config) }) Expect(output).ToNot(ContainSubstrings([]string{"API endpoint:"})) Expect(output).To(ContainSubstrings([]string{"Not logged in", "Use", "log in"})) }) }) Context("when an api endpoint is set and the user logged in", func() { var config configuration.ReadWriter BeforeEach(func() { accessToken := configuration.TokenInfo{ UserGuid: "my-user-guid", Username: "******", Email: "my-user-email", } config = testconfig.NewRepositoryWithAccessToken(accessToken) config.SetApiEndpoint("https://test.example.org") config.SetApiVersion("☃☃☃") }) Describe("tells the user what is set in the config", func() { var output []string
import ( "github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/models" . "github.com/cloudfoundry/cli/cf/requirements" testassert "github.com/cloudfoundry/cli/testhelpers/assert" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("TargetedSpaceRequirement", func() { var ( ui *testterm.FakeUI config configuration.ReadWriter ) BeforeEach(func() { ui = new(testterm.FakeUI) config = testconfig.NewRepositoryWithDefaults() }) Context("when the user has targeted a space", func() { It("succeeds", func() { req := NewTargetedSpaceRequirement(ui, config) Expect(req.Execute()).To(BeTrue()) }) }) Context("when the user does not have a space targeted", func() {
. "github.com/cloudfoundry/cli/testhelpers/matchers" ) func callApi(args []string, config configuration.ReadWriter, endpointRepo *testapi.FakeEndpointRepo) (ui *testterm.FakeUI) { ui = new(testterm.FakeUI) cmd := NewApi(ui, config, endpointRepo) requirementsFactory := &testreq.FakeReqFactory{} testcmd.RunCommand(cmd, args, requirementsFactory) return } var _ = Describe("api command", func() { var ( config configuration.ReadWriter endpointRepo *testapi.FakeEndpointRepo ) BeforeEach(func() { config = testconfig.NewRepository() endpointRepo = &testapi.FakeEndpointRepo{} }) Context("when the api endpoint's ssl certificate is invalid", func() { It("warns the user and prints out a tip", func() { endpointRepo.UpdateEndpointError = errors.NewInvalidSSLCert("https://buttontomatoes.org", "why? no. go away") ui := callApi([]string{"https://buttontomatoes.org"}, config, endpointRepo) Expect(ui.Outputs).To(ContainSubstrings( []string{"FAILED"}, []string{"SSL Cert", "https://buttontomatoes.org"},
"github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/models" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("rename-space command", func() { var ( ui *testterm.FakeUI configRepo configuration.ReadWriter requirementsFactory *testreq.FakeReqFactory spaceRepo *testapi.FakeSpaceRepository ) BeforeEach(func() { ui = new(testterm.FakeUI) configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true} spaceRepo = &testapi.FakeSpaceRepository{} }) var callRenameSpace = func(args []string) { cmd := NewRenameSpace(ui, configRepo, spaceRepo) testcmd.RunCommand(cmd, args, requirementsFactory) }
import ( "os" "path/filepath" "github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/i18n" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" "github.com/pivotal-cf-experimental/jibber_jabber" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("i18n.Init() function", func() { var ( configRepo configuration.ReadWriter ) BeforeEach(func() { i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures") configRepo = testconfig.NewRepositoryWithDefaults() }) Describe("When a user has a locale configuration set", func() { Context("creates a valid T function", func() { BeforeEach(func() { configRepo.SetLocale("en_US") }) It("returns a usable T function for simple strings", func() { T := i18n.Init(configRepo)
"github.com/cloudfoundry/cli/cf/models" "github.com/cloudfoundry/cli/cf/net" testapi "github.com/cloudfoundry/cli/testhelpers/api" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" "github.com/cloudfoundry/cli/testhelpers/maker" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/cloudfoundry/cli/cf/api" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Services Repo", func() { var ( testServer *httptest.Server testHandler *testnet.TestHandler configRepo configuration.ReadWriter repo ServiceRepository ) setupTestServer := func(reqs ...testnet.TestRequest) { testServer, testHandler = testnet.NewServer(reqs) configRepo.SetApiEndpoint(testServer.URL) } BeforeEach(func() { configRepo = testconfig.NewRepositoryWithDefaults() configRepo.SetAccessToken("BEARER my_access_token") gateway := net.NewCloudControllerGateway((configRepo), time.Now) repo = NewCloudControllerServiceRepository(configRepo, gateway) })
"github.com/cloudfoundry/cli/cf/configuration" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/cloudfoundry/cli/cf/commands" . "github.com/cloudfoundry/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("config command", func() { var ( ui *testterm.FakeUI configRepo configuration.ReadWriter requirementsFactory *testreq.FakeReqFactory ) BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{} }) runCommand := func(args ...string) { cmd := NewConfig(ui, configRepo) testcmd.RunCommand(cmd, args, requirementsFactory) } It("fails requirements when no flags are provided", func() { runCommand()
{ "name": "vcap", "build": "2222", "support": "http://support.cloudfoundry.com", "version": 2, "description": "Cloud Foundry sponsored by Pivotal", "authorization_endpoint": "https://login.example.com", "api_version": "42.0.0" }`) } var _ = Describe("Endpoints Repository", func() { var ( config configuration.ReadWriter gateway net.Gateway testServer *httptest.Server repo EndpointRepository testServerFn func(w http.ResponseWriter, r *http.Request) ) BeforeEach(func() { config = testconfig.NewRepository() testServer = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { testServerFn(w, r) })) gateway = net.NewCloudControllerGateway((config), time.Now) gateway.SetTrustedCerts(testServer.TLS.Certificates) repo = NewEndpointRepository(config, gateway) }) AfterEach(func() {
testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/cloudfoundry/cli/cf/commands/organization" . "github.com/cloudfoundry/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("delete-org command", func() { var ( config configuration.ReadWriter ui *testterm.FakeUI requirementsFactory *testreq.FakeReqFactory orgRepo *test_org.FakeOrganizationRepository org models.Organization ) BeforeEach(func() { ui = &testterm.FakeUI{ Inputs: []string{"y"}, } config = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{} org = models.Organization{} org.Name = "org-to-delete" org.Guid = "org-to-delete-guid" orgRepo = &test_org.FakeOrganizationRepository{}
testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("Login Command", func() { var ( Flags []string Config configuration.ReadWriter ui *testterm.FakeUI authRepo *testapi.FakeAuthenticationRepository endpointRepo *testapi.FakeEndpointRepo orgRepo *fake_organizations.FakeOrganizationRepository spaceRepo *testapi.FakeSpaceRepository org models.Organization ) BeforeEach(func() { Flags = []string{} Config = testconfig.NewRepository() ui = &testterm.FakeUI{} authRepo = &testapi.FakeAuthenticationRepository{ AccessToken: "my_access_token", RefreshToken: "my_refresh_token", Config: Config, }
"github.com/cloudfoundry/cli/cf/models" testapi "github.com/cloudfoundry/cli/testhelpers/api" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("rename-org command", func() { var ( requirementsFactory *testreq.FakeReqFactory orgRepo *testapi.FakeOrgRepository ui *testterm.FakeUI configRepo configuration.ReadWriter ) BeforeEach(func() { requirementsFactory = &testreq.FakeReqFactory{} orgRepo = &testapi.FakeOrgRepository{} ui = new(testterm.FakeUI) configRepo = testconfig.NewRepositoryWithDefaults() }) var callRenameOrg = func(args []string) { cmd := organization.NewRenameOrg(ui, configRepo, orgRepo) testcmd.RunCommand(cmd, args, requirementsFactory) }
import ( "github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/errors" "github.com/cloudfoundry/cli/cf/models" . "github.com/cloudfoundry/cli/cf/requirements" testapi "github.com/cloudfoundry/cli/testhelpers/api" testassert "github.com/cloudfoundry/cli/testhelpers/assert" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Testing with ginkgo", func() { var config configuration.ReadWriter var ui *testterm.FakeUI BeforeEach(func() { ui = new(testterm.FakeUI) config = testconfig.NewRepository() config.SetOrganizationFields(models.OrganizationFields{Guid: "the-org-guid"}) }) It("succeeds when the domain is found", func() { domain := models.DomainFields{Name: "example.com", Guid: "domain-guid"} domainRepo := &testapi.FakeDomainRepository{FindByNameInOrgDomain: domain} domainReq := NewDomainRequirement("example.com", ui, config, domainRepo) success := domainReq.Execute() Expect(success).To(BeTrue())
"github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/net" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/cloudfoundry/cli/cf/api/authentication" . "github.com/cloudfoundry/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("AuthenticationRepository", func() { var ( gateway net.Gateway testServer *httptest.Server handler *testnet.TestHandler config configuration.ReadWriter auth AuthenticationRepository ) BeforeEach(func() { config = testconfig.NewRepository() gateway = net.NewUAAGateway(config) auth = NewUAAAuthenticationRepository(gateway, config) }) AfterEach(func() { testServer.Close() }) var setupTestServer = func(request testnet.TestRequest) {
"github.com/cloudfoundry/cli/cf/configuration" testapi "github.com/cloudfoundry/cli/testhelpers/api" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("Create user command", func() { var ( requirementsFactory *testreq.FakeReqFactory ui *testterm.FakeUI userRepo *testapi.FakeUserRepository configRepo configuration.ReadWriter ) BeforeEach(func() { requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true} ui = new(testterm.FakeUI) userRepo = &testapi.FakeUserRepository{} configRepo = testconfig.NewRepositoryWithDefaults() accessToken, _ := testconfig.EncodeAccessToken(configuration.TokenInfo{ Username: "******", }) configRepo.SetAccessToken(accessToken) }) runCommand := func(args ...string) {
"github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/models" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("marketplace command", func() { var ui *testterm.FakeUI var requirementsFactory *testreq.FakeReqFactory var config configuration.ReadWriter var serviceRepo *testapi.FakeServiceRepo var fakeServiceOfferings []models.ServiceOffering BeforeEach(func() { serviceRepo = &testapi.FakeServiceRepo{} ui = &testterm.FakeUI{} requirementsFactory = &testreq.FakeReqFactory{ApiEndpointSuccess: true} fakeServiceOfferings = []models.ServiceOffering{ models.ServiceOffering{ Plans: []models.ServicePlanFields{ models.ServicePlanFields{Name: "service-plan-a"}, models.ServicePlanFields{Name: "service-plan-b"}, }, ServiceOfferingFields: models.ServiceOfferingFields{
"os" "path/filepath" "github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/i18n" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" go_i18n "github.com/nicksnyder/go-i18n/i18n" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("i18n.Init() function", func() { var ( oldResourcesPath string configRepo configuration.ReadWriter T go_i18n.TranslateFunc ) BeforeEach(func() { configRepo = testconfig.NewRepositoryWithDefaults() oldResourcesPath = i18n.GetResourcesPath() i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures") }) JustBeforeEach(func() { T = i18n.Init(configRepo) }) Describe("When a user has a locale configuration set", func() { It("panics when the translation files cannot be loaded", func() {
"github.com/cloudfoundry/cli/cf/configuration" "github.com/cloudfoundry/cli/cf/errors" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" "github.com/cloudfoundry/loggregator_consumer" "github.com/cloudfoundry/loggregatorlib/logmessage" "time" . "github.com/cloudfoundry/cli/cf/api" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("loggregator logs repository", func() { var ( fakeConsumer *testapi.FakeLoggregatorConsumer logsRepo LogsRepository configRepo configuration.ReadWriter fakeTokenRefresher *testapi.FakeAuthenticationRepository ) BeforeEach(func() { BufferTime = 1 * time.Millisecond fakeConsumer = testapi.NewFakeLoggregatorConsumer() configRepo = testconfig.NewRepositoryWithDefaults() configRepo.SetLoggregatorEndpoint("loggregator-server.test.com") configRepo.SetAccessToken("the-access-token") fakeTokenRefresher = &testapi.FakeAuthenticationRepository{} }) JustBeforeEach(func() { logsRepo = NewLoggregatorLogsRepository(configRepo, fakeConsumer, fakeTokenRefresher) })
import ( "github.com/cloudfoundry/cli/cf/configuration" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/cloudfoundry/cli/cf/commands" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("config command", func() { var ( ui *testterm.FakeUI configRepo configuration.ReadWriter requirementsFactory *testreq.FakeReqFactory ) BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{} }) runCommand := func(args ...string) { cmd := NewConfig(ui, configRepo) testcmd.RunCommand(cmd, args, requirementsFactory) } It("fails requirements when no flags are provided", func() { runCommand()
"github.com/cloudfoundry/cli/cf/errors" "github.com/cloudfoundry/cli/cf/models" "github.com/cloudfoundry/cli/cf/net" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/cloudfoundry/cli/cf/api" . "github.com/cloudfoundry/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Buildpacks repo", func() { var ( ts *httptest.Server handler *testnet.TestHandler config configuration.ReadWriter repo BuildpackRepository ) BeforeEach(func() { config = testconfig.NewRepositoryWithDefaults() gateway := net.NewCloudControllerGateway((config), time.Now) repo = NewCloudControllerBuildpackRepository(config, gateway) }) AfterEach(func() { ts.Close() }) var setupTestServer = func(requests ...testnet.TestRequest) { ts, handler = testnet.NewServer(requests)
. "github.com/onsi/gomega" "io/ioutil" "net/http" "net/http/httptest" "net/url" "os" "runtime" "strings" "time" ) var _ = Describe("Gateway", func() { var ( ccGateway Gateway uaaGateway Gateway config configuration.ReadWriter authRepo api.AuthenticationRepository currentTime time.Time clock func() time.Time ) BeforeEach(func() { currentTime = time.Unix(0, 0) clock = func() time.Time { return currentTime } config = testconfig.NewRepository() ccGateway = NewCloudControllerGateway(config, clock) uaaGateway = NewUAAGateway(config) }) Describe("async timeout", func() { It("has an async timeout that defaults to a sane value", func() {
testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" "github.com/cloudfoundry/cli/testhelpers/maker" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("delete-space command", func() { var ( ui *testterm.FakeUI space models.Space config configuration.ReadWriter spaceRepo *testapi.FakeSpaceRepository requirementsFactory *testreq.FakeReqFactory ) runCommand := func(args ...string) { cmd := NewDeleteSpace(ui, config, spaceRepo) testcmd.RunCommand(cmd, args, requirementsFactory) return } BeforeEach(func() { ui = &testterm.FakeUI{} spaceRepo = &testapi.FakeSpaceRepository{} config = testconfig.NewRepositoryWithDefaults()
"github.com/cloudfoundry/cli/cf/errors" "github.com/cloudfoundry/cli/cf/models" "github.com/cloudfoundry/cli/cf/net" testapi "github.com/cloudfoundry/cli/testhelpers/api" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/cloudfoundry/cli/cf/api" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("DomainRepository", func() { var ( ts *httptest.Server handler *testnet.TestHandler repo DomainRepository config configuration.ReadWriter ) BeforeEach(func() { config = testconfig.NewRepositoryWithDefaults() }) JustBeforeEach(func() { gateway := net.NewCloudControllerGateway((config), time.Now) strategy := strategy.NewEndpointStrategy(config.ApiVersion()) repo = NewCloudControllerDomainRepository(config, gateway, strategy) }) AfterEach(func() { ts.Close()
"github.com/cloudfoundry/cli/cf/models" "github.com/cloudfoundry/cli/cf/net" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" testtime "github.com/cloudfoundry/cli/testhelpers/time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "net/http" "net/http/httptest" "time" ) var _ = Describe("App Events Repo", func() { var ( server *httptest.Server handler *testnet.TestHandler config configuration.ReadWriter repo AppEventsRepository ) BeforeEach(func() { config = testconfig.NewRepository() config.SetAccessToken("BEARER my_access_token") config.SetApiVersion("2.2.0") }) JustBeforeEach(func() { strategy := strategy.NewEndpointStrategy(config.ApiVersion()) gateway := net.NewCloudControllerGateway(config, time.Now) repo = NewCloudControllerAppEventsRepository(config, gateway, strategy) })
"github.com/cloudfoundry/cli/cf/models" "github.com/cloudfoundry/cli/cf/net" testapi "github.com/cloudfoundry/cli/testhelpers/api" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testnet "github.com/cloudfoundry/cli/testhelpers/net" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "net/http" "net/http/httptest" "time" ) var _ = Describe("Testing with ginkgo", func() { var ( testServer *httptest.Server testHandler *testnet.TestHandler configRepo configuration.ReadWriter repo CloudControllerServiceBindingRepository ) setupTestServer := func(reqs ...testnet.TestRequest) { testServer, testHandler = testnet.NewServer(reqs) configRepo.SetApiEndpoint(testServer.URL) } BeforeEach(func() { configRepo = testconfig.NewRepositoryWithDefaults() gateway := net.NewCloudControllerGateway((configRepo), time.Now) repo = NewCloudControllerServiceBindingRepository(configRepo, gateway) })
testapi "github.com/cloudfoundry/cli/testhelpers/api" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("auth command", func() { var ( ui *testterm.FakeUI cmd Authenticate config configuration.ReadWriter repo *testapi.FakeAuthenticationRepository requirementsFactory *testreq.FakeReqFactory ) BeforeEach(func() { ui = &testterm.FakeUI{} config = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{} repo = &testapi.FakeAuthenticationRepository{ Config: config, AccessToken: "my-access-token", RefreshToken: "my-refresh-token", } cmd = NewAuthenticate(ui, config, repo) })