Пример #1
0
func fakeDomainRepo() *testapi.FakeDomainRepository {
	domain := models.DomainFields{}
	domain.Name = "foo.com"
	domain.Guid = "foo-guid"
	domain.Shared = true

	return &testapi.FakeDomainRepository{
		FindByNameInOrgDomain: domain,
	}
}
Пример #2
0
func (resource RouteSummary) ToModel() (route models.RouteSummary) {
	domain := models.DomainFields{}
	domain.Guid = resource.Domain.Guid
	domain.Name = resource.Domain.Name
	domain.Shared = resource.Domain.OwningOrganizationGuid != ""

	route.Guid = resource.Guid
	route.Host = resource.Host
	route.Domain = domain
	return
}
Пример #3
0
		manifestRepo.ReadManifestReturns.Manifest = singleAppManifest()

		callPush("existing-app")

		updatedAppEnvVars := *appRepo.UpdateParams.EnvironmentVars
		Expect(updatedAppEnvVars["crazy"]).To(Equal("pants"))
		Expect(updatedAppEnvVars["FOO"]).To(Equal("baz"))
		Expect(updatedAppEnvVars["foo"]).To(Equal("manchu"))
		Expect(updatedAppEnvVars["PATH"]).To(Equal("/u/apps/my-app/bin"))
	})

	It("pushes an app when provided a manifest with one app defined", func() {
		domain := models.DomainFields{}
		domain.Name = "manifest-example.com"
		domain.Guid = "bar-domain-guid"
		domainRepo.FindByNameInOrgDomain = domain
		routeRepo.FindByHostAndDomainErr = true
		appRepo.ReadNotFound = true

		manifestRepo.ReadManifestReturns.Manifest = singleAppManifest()

		callPush()
		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Creating route", "manifest-host.manifest-example.com"},
			{"OK"},
			{"Binding", "manifest-host.manifest-example.com"},
			{"manifest-app-name"},
		})

		Expect(*appRepo.CreatedAppParams().Name).To(Equal("manifest-app-name"))
Пример #4
0
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		testcmd.CommandDidPassRequirements = true

		reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: false}
		testcmd.RunCommand(cmd, ctxt, reqFactory)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})

	It("TestPushingAppWithOldV2DomainsEndpoint", func() {
		deps := getPushDependencies()

		privateDomain := models.DomainFields{}
		privateDomain.Shared = false
		privateDomain.Name = "private.cf-app.com"
		privateDomain.Guid = "private-domain-guid"

		sharedDomain := models.DomainFields{}
		sharedDomain.Name = "shared.cf-app.com"
		sharedDomain.Shared = true
		sharedDomain.Guid = "shared-domain-guid"

		deps.domainRepo.ListSharedDomainsApiResponse = net.NewNotFoundApiResponse("whoopsie")
		deps.domainRepo.ListDomainsDomains = []models.DomainFields{privateDomain, sharedDomain}
		deps.routeRepo.FindByHostAndDomainErr = true
		deps.appRepo.ReadNotFound = true

		ui := callPush([]string{"-t", "111", "my-new-app"}, deps)

		Expect(deps.routeRepo.FindByHostAndDomainHost).To(Equal("my-new-app"))
		Expect(deps.routeRepo.CreatedHost).To(Equal("my-new-app"))
Пример #5
0
		Expect(handler).To(testnet.HaveAllRequestsCalled())
		Expect(apiErr).NotTo(BeNil())
	})

	It("finds a route by host and domain", func() {
		request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "GET",
			Path:     "/v2/routes?q=host%3Amy-cool-app%3Bdomain_guid%3Amy-domain-guid",
			Response: findRouteByHostResponse,
		})

		ts, handler, repo, domainRepo := createRoutesRepo(request)
		defer ts.Close()

		domain := models.DomainFields{}
		domain.Guid = "my-domain-guid"
		domainRepo.FindByNameDomain = domain

		route, apiErr := repo.FindByHostAndDomain("my-cool-app", "my-domain.com")

		Expect(apiErr).NotTo(HaveOccurred())
		Expect(handler).To(testnet.HaveAllRequestsCalled())
		Expect(domainRepo.FindByNameName).To(Equal("my-domain.com"))
		Expect(route.Host).To(Equal("my-cool-app"))
		Expect(route.Guid).To(Equal("my-route-guid"))
		Expect(route.Domain.Guid).To(Equal(domain.Guid))
	})

	It("returns 'not found' response when there is no route w/ the given domain and host", func() {
		request := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "GET",
Пример #6
0
		callShowSpace(args, reqFactory)
		Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
	})
	It("TestShowSpaceInfoSuccess", func() {

		org := models.OrganizationFields{}
		org.Name = "my-org"

		app := models.ApplicationFields{}
		app.Name = "app1"
		app.Guid = "app1-guid"
		apps := []models.ApplicationFields{app}

		domain := models.DomainFields{}
		domain.Name = "domain1"
		domain.Guid = "domain1-guid"
		domains := []models.DomainFields{domain}

		serviceInstance := models.ServiceInstanceFields{}
		serviceInstance.Name = "service1"
		serviceInstance.Guid = "service1-guid"
		services := []models.ServiceInstanceFields{serviceInstance}

		space := models.Space{}
		space.Name = "space1"
		space.Organization = org
		space.Applications = apps
		space.Domains = domains
		space.ServiceInstances = services

		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, Space: space}
Пример #7
0
			{"Creating route"},
			{"OK"},
			{"host.example.com", "already exists"},
		})

		Expect(routeRepo.CreateInSpaceHost).To(Equal("host"))
		Expect(routeRepo.CreateInSpaceDomainGuid).To(Equal("domain-guid"))
		Expect(routeRepo.CreateInSpaceSpaceGuid).To(Equal("my-space-guid"))
	})

	It("TestRouteCreator", func() {
		space := models.SpaceFields{}
		space.Guid = "my-space-guid"
		space.Name = "my-space"
		domain := models.DomainFields{}
		domain.Guid = "domain-guid"
		domain.Name = "example.com"

		createdRoute := models.Route{}
		createdRoute.Host = "my-host"
		createdRoute.Guid = "my-route-guid"
		routeRepo := &testapi.FakeRouteRepository{
			CreateInSpaceCreatedRoute: createdRoute,
		}

		ui := new(testterm.FakeUI)
		configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"})
		orgFields := models.OrganizationFields{}
		orgFields.Name = "my-org"
		configRepo.SetOrganizationFields(orgFields)
Пример #8
0
		callDeleteDomain([]string{"foo.com"}, []string{"y"}, reqFactory, domainRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeTrue())

		reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: false}
		callDeleteDomain([]string{"foo.com"}, []string{"y"}, reqFactory, domainRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		reqFactory = &testreq.FakeReqFactory{LoginSuccess: false, TargetedOrgSuccess: true}
		callDeleteDomain([]string{"foo.com"}, []string{"y"}, reqFactory, domainRepo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
	})
	It("TestDeleteDomainSuccess", func() {

		domain := models.DomainFields{}
		domain.Name = "foo.com"
		domain.Guid = "foo-guid"
		domainRepo := &testapi.FakeDomainRepository{
			FindByNameInOrgDomain: domain,
		}
		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}

		ui := callDeleteDomain([]string{"foo.com"}, []string{"y"}, reqFactory, domainRepo)

		Expect(domainRepo.DeleteDomainGuid).To(Equal("foo-guid"))

		testassert.SliceContains(ui.Prompts, testassert.Lines{
			{"delete", "foo.com"},
		})

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Deleting domain", "foo.com", "my-user"},