Exemple #1
0
		client = holler.NewYeller(
			"api-token", "staging",
			holler.UseCollectors(
				collector.URL(),
				otherCollector.URL(),
			),
			holler.UseRandomSource(
				rand.NewSource(1),
			),
		)
	})

	AfterEach(func() {
		if collector != nil {
			collector.Close()
		}

		if otherCollector != nil {
			otherCollector.Close()
		}
	})

	Context("when the first collector works", func() {
		BeforeEach(func() {
			collector.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/api-token"),
					ghttp.VerifyJSON(requestJSON("disaster")),
					ghttp.RespondWith(200, ""),
				),
Exemple #2
0
		repo       ServiceKeyRepository
	)

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetAccessToken("BEARER my_access_token")

		ccServer = ghttp.NewServer()
		configRepo.SetApiEndpoint(ccServer.URL())

		gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
		repo = NewCloudControllerServiceKeyRepository(configRepo, gateway)
	})

	AfterEach(func() {
		ccServer.Close()
	})

	Describe("CreateServiceKey", func() {
		It("tries to create the service key", func() {
			ccServer.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/v2/service_keys"),
					ghttp.RespondWith(http.StatusCreated, nil),
					ghttp.VerifyJSON(`{"service_instance_guid": "fake-instance-guid", "name": "fake-key-name"}`),
				),
			)

			err := repo.CreateServiceKey("fake-instance-guid", "fake-key-name", nil)
			Expect(err).NotTo(HaveOccurred())
			Expect(ccServer.ReceivedRequests()).To(HaveLen(1))
Exemple #3
0
					"app_ssh_host_key_fingerprint":"a6:d1:08:0b:b0:cb:9b:5f:c4:ba:44:2a:97:26:19:8a",
					"app_ssh_oauth_client":"ssh-proxy",
					"logging_endpoint":"wss://loggregator.APISERVER",
					"doppler_logging_endpoint":"wss://doppler.APISERVER"
				}`
				response = strings.Replace(response, "APISERVER", serverAPIURL, -1)
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/v2/info"),
						ghttp.RespondWith(http.StatusOK, response),
					),
				)
			})

			AfterEach(func() {
				server.Close()
			})

			It("falls back to http and gives a warning", func() {
				command := exec.Command("cf", "api", server.URL(), "--skip-ssl-validation")
				session, err := Start(command, GinkgoWriter, GinkgoWriter)
				Expect(err).NotTo(HaveOccurred())

				Eventually(session.Out).Should(Say("Setting api endpoint to %s...", server.URL()))
				Eventually(session.Out).Should(Say("Warning: Insecure http API endpoint detected: secure https API endpoints are recommended"))
				Eventually(session.Out).Should(Say("OK"))
				Eventually(session).Should(Exit(0))
			})
		})

		It("sets SSL Disabled in the config file to true", func() {
Exemple #4
0
			uaaServer.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyHeader(http.Header{"authorization": []string{"auth-token"}}),
					ghttp.VerifyRequest("GET", "/oauth/authorize",
						"response_type=code&grant_type=authorization_code&client_id=ssh-oauth-client",
					),
					ghttp.RespondWith(http.StatusFound, ``, http.Header{
						"Location": []string{"https://www.cloudfoundry.example.com?code=F45jH"},
					}),
				),
			)
		})

		AfterEach(func() {
			uaaServer.Close()
		})

		It("requests the one time code", func() {
			_, err := authRepo.Authorize("auth-token")
			Expect(err).NotTo(HaveOccurred())
			Expect(uaaServer.ReceivedRequests()).To(HaveLen(1))
		})

		It("returns the one time code", func() {
			code, err := authRepo.Authorize("auth-token")
			Expect(err).NotTo(HaveOccurred())
			Expect(code).To(Equal("F45jH"))
		})

		Context("when the authentication endpoint is malformed", func() {
Exemple #5
0
				LogLevel:          "debug",
				ConsulCluster:     consulRunner.ConsulCluster(),
				PollingInterval:   pollingInterval,
				EvacuationTimeout: evacuationTimeout,
			},
		)
	})

	JustBeforeEach(func() {
		runner.Start()
	})

	AfterEach(func(done Done) {
		close(flushEvents)
		runner.KillWithFire()
		fakeGarden.Close()
		close(done)
	})

	Context("when Garden is available", func() {
		BeforeEach(func() {
			fakeGarden.Start()
		})

		Describe("when an interrupt signal is sent to the representative", func() {
			JustBeforeEach(func() {
				if runtime.GOOS == "windows" {
					Skip("Interrupt isn't supported on windows")
				}

				runner.Stop()
Exemple #6
0
	etcdRunner.Reset()

	bbsRunner = bbstestrunner.New(bbsBinPath, bbsArgs)
	bbsProcess = ginkgomon.Invoke(bbsRunner)

	consulSession = consulRunner.NewSession("a-session")
})

var _ = AfterEach(func() {
	if bbsProcess != nil {
		ginkgomon.Kill(bbsProcess)
	}
})

var _ = SynchronizedAfterSuite(func() {
	if etcdRunner != nil {
		etcdRunner.KillWithFire()
	}
	if consulRunner != nil {
		consulRunner.Stop()
	}
	if runner != nil {
		runner.KillWithFire()
	}
	if auctioneerServer != nil {
		auctioneerServer.Close()
	}
}, func() {
	gexec.CleanupBuildArtifacts()
})
	team      concourse.Team
)

var _ = BeforeEach(func() {
	atcServer = ghttp.NewServer()

	client = concourse.NewClient(
		atcServer.URL(),
		&http.Client{},
	)

	team = client.Team("some-team")
})

var _ = AfterEach(func() {
	atcServer.Close()
})

func Change(fn func() int) *changeMatcher {
	return &changeMatcher{
		fn: fn,
	}
}

type changeMatcher struct {
	fn     func() int
	amount int

	before int
	after  int
}
			root     *httptest.Server
			recorder *ghttp.Server
		)

		BeforeEach(func() {
			root = startSimpleBackend("fallthrough")
			recorder = startRecordingBackend()
			addBackend("root", root.URL)
			addBackend("other", recorder.URL())
			addBackendRoute("/", "root", "prefix")
			addBackendRoute("/foo/bar", "other", "prefix")
			reloadRoutes()
		})
		AfterEach(func() {
			root.Close()
			recorder.Close()
		})

		It("should not be redirected by our simple test backend", func() {
			resp := routerRequest("//")
			Expect(readBody(resp)).To(Equal("fallthrough"))
		})

		It("should not be redirected by our recorder backend", func() {
			resp := routerRequest("/foo/bar/baz//qux")
			Expect(resp.StatusCode).To(Equal(200))
			Expect(recorder.ReceivedRequests()).To(HaveLen(1))
			Expect(recorder.ReceivedRequests()[0].URL.Path).To(Equal("/foo/bar/baz//qux"))
		})

		It("should collapse double slashes when looking up route, but pass request as-is", func() {
Exemple #9
0
				ghttp.VerifyRequest("POST", "/builds/some-guid/abort"),
			)
		})

		JustBeforeEach(func() {
			var err error

			req, err := http.NewRequest("POST", server.URL+"/api/v1/builds/128/abort", nil)
			Expect(err).NotTo(HaveOccurred())

			response, err = client.Do(req)
			Expect(err).NotTo(HaveOccurred())
		})

		AfterEach(func() {
			abortTarget.Close()
		})

		Context("when authenticated", func() {
			BeforeEach(func() {
				authValidator.IsAuthenticatedReturns(true)
			})

			Context("when the build can be found", func() {
				BeforeEach(func() {
					buildsDB.GetBuildReturns(db.Build{
						ID:     128,
						Status: db.StatusStarted,
					}, true, nil)
				})
			It("responds with correct body", func() {
				assertBodyEquals(resp.Body, RespBody)
			})

		})

		Context("when socket in reques URI is incorrect", func() {
			It("errors", func() {
				resp, err = client.Get("unix:///fake/socket.sock/_ping")
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("Wrong unix socket"))
			})
		})

		AfterEach(func() {
			unixSocketServer.Close()
		})
	})

	Context("with no server listening", func() {
		BeforeEach(func() {
			socket = "/not/existing.sock"
			client = http.Client{Transport: New(socket)}
		})

		It("errors", func() {
			_, err := client.Get("unix:///not/existing.sock/_ping")
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(Or(
				ContainSubstring(fmt.Sprintf("dial unix %s: connect: no such file or directory", socket)),
				ContainSubstring(fmt.Sprintf("dial unix %s: no such file or directory", socket)),
var _ = Describe("DockerSessionFactory", func() {
	Describe("MakeSession", func() {
		var (
			registryHost         string
			dockerRegistryServer *ghttp.Server
			sessionFactory       docker_metadata_fetcher.DockerSessionFactory
		)

		BeforeEach(func() {
			sessionFactory = docker_metadata_fetcher.NewDockerSessionFactory()
			dockerRegistryServer = ghttp.NewServer()
		})

		AfterEach(func() {
			dockerRegistryServer.Close()
		})

		Describe("creating registry sessions", func() {
			BeforeEach(func() {
				parts, err := url.Parse(dockerRegistryServer.URL())
				Expect(err).NotTo(HaveOccurred())
				registryHost = parts.Host

				dockerRegistryServer.RouteToHandler("GET", "/v1/_ping", ghttp.VerifyRequest("GET", "/v1/_ping"))
				dockerRegistryServer.RouteToHandler("GET", "/v2/", ghttp.VerifyRequest("GET", "/v2/"))
			})

			Context("when connecting to a secure registry", func() {
				It("creates a registry session for the given repo", func() {
					session, err := sessionFactory.MakeSession(registryHost+"/lattice-mappppppppppppappapapa", false)
	. "github.com/onsi/gomega"

	"github.com/onsi/gomega/ghttp"
	"github.com/rightscale/gdo/middleware"
)

const (
	doGetDropletActions      = `{"actions":[{"id":48912908,"status":"completed","type":"create","started_at":"2015-04-24T22:55:43Z","completed_at":"2015-04-24T22:56:39Z","resource_id":5004436,"resource_type":"droplet","region":{"name":"New York 3","slug":"nyc3","sizes":["512mb","1gb","2gb","4gb","8gb","16gb","32gb","48gb","64gb"],"features":["virtio","private_networking","backups","ipv6","metadata"],"available":true},"region_slug":"nyc3"}],"links":{},"meta":{"total":1}}`
	doGetDropletActionsEmpty = `{"actions":[],"links":{},"meta":{"total":0}}`
	doGetDropletAction       = `{"action":{"id":48913731,"status":"completed","type":"power_off","started_at":"2015-04-24T23:11:41Z","completed_at":"2015-04-24T23:12:01Z","resource_id":5004436,"resource_type":"droplet","region":{"name":"New York 3","slug":"nyc3","sizes":["512mb","1gb","2gb","4gb","8gb","16gb","32gb","48gb","64gb"],"features":["virtio","private_networking","backups","ipv6","metadata"],"available":true},"region_slug":"nyc3"}}`
)

var _ = Describe("droplet_actions", func() {

	var do *ghttp.Server
	var client *GDOClient

	BeforeEach(func() {
		do = ghttp.NewServer()
		u, err := url.Parse(do.URL())
		Expect(err).NotTo(HaveOccurred())
		middleware.DOBaseURL = u
		client = NewGDOClient()
	})

	AfterEach(func() {
		do.Close()
	})

})
	routingAPIArgs = testrunner.Args{
		Port:         routingAPIPort,
		IP:           routingAPIIP,
		SystemDomain: routingAPISystemDomain,
		ConfigPath:   createConfig(),
		EtcdCluster:  etcdUrl,
		DevMode:      true,
	}
})

var _ = AfterEach(func() {
	etcdAdapter.Disconnect()
	etcdRunner.Reset()
	etcdRunner.Stop()
	oauthServer.Close()
})

func createConfig() string {
	type customConfig struct {
		Port    int
		UAAPort string
	}
	actualStatsdConfig := customConfig{Port: 8125 + GinkgoParallelNode(), UAAPort: oauthServerPort}
	workingDir, _ := os.Getwd()
	template, err := template.ParseFiles(workingDir + "/../../example_config/example_template.yml")
	Expect(err).NotTo(HaveOccurred())
	configFilePath := fmt.Sprintf("/tmp/example_%d.yml", GinkgoParallelNode())
	configFile, err := os.Create(configFilePath)
	Expect(err).NotTo(HaveOccurred())
				BucketName:       "blah-bucket",
				Endpoint:         testS3Server.URL(),
				AccessKeyID:      "ABCD",
				SecretAccessKey:  "ABCD",
				ComparisonFile:   comparisonFilePath,
			}
		})

		JustBeforeEach(func() {
			runner = NewThroughputRamp(binPath, runnerArgs)
			process = ginkgomon.Invoke(runner)
		})

		AfterEach(func() {
			ginkgomon.Interrupt(process)
			testServer.Close()
			testS3Server.Close()
			close(bodyChan)
			err := os.Remove(comparisonFilePath)
			Expect(err).ToNot(HaveOccurred())
		})

		It("ramps up throughput over multiple tests", func() {
			Eventually(process.Wait(), "5s").Should(Receive())
			Expect(runner.ExitCode()).To(Equal(0))
			Expect(testServer.ReceivedRequests()).To(HaveLen(24))
		})

		Context("when cpu monitor server is configured", func() {
			var (
				cpumonitorServer *ghttp.Server
Exemple #15
0
	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetAccessToken("BEARER my_access_token")

		gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter))
		repo = NewCloudControllerStackRepository(configRepo, gateway)
	})

	BeforeEach(func() {
		testServer = ghttp.NewServer()
		configRepo.SetAPIEndpoint(testServer.URL())
	})

	AfterEach(func() {
		if testServer != nil {
			testServer.Close()
		}
	})

	Describe("FindByName", func() {
		Context("when a stack exists", func() {
			BeforeEach(func() {
				testServer.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/v2/stacks", "q=name%3Alinux"),
						ghttp.RespondWith(http.StatusOK, `{
							"resources": [
								{
									"metadata": { "guid": "custom-linux-guid" },
									"entity": { "name": "custom-linux" }
								}
Exemple #16
0
	var (
		repo             api.RoutingAPIRepository
		configRepo       coreconfig.Repository
		routingAPIServer *ghttp.Server
	)

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		gateway := net.NewRoutingAPIGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")

		repo = api.NewRoutingAPIRepository(configRepo, gateway)
	})

	AfterEach(func() {
		routingAPIServer.Close()
	})

	Describe("ListRouterGroups", func() {

		Context("when routing api return router groups", func() {
			BeforeEach(func() {
				routingAPIServer = ghttp.NewServer()
				routingAPIServer.RouteToHandler("GET", "/v1/router_groups",
					func(w http.ResponseWriter, req *http.Request) {
						responseBody := []byte(`[
			{
				  "guid": "bad25cff-9332-48a6-8603-b619858e7992",
					"name": "default-tcp",
					"type": "tcp"
			}]`)
Exemple #17
0
	)

	BeforeEach(func() {
		fakeCC = ghttp.NewServer()

		logger = lager.NewLogger("fakelogger")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))

		ccClient = cc_client.NewCcClient(fakeCC.URL(), "username", "password", true)

		stagingGuid = "the-staging-guid"
	})

	AfterEach(func() {
		if fakeCC.HTTPTestServer != nil {
			fakeCC.Close()
		}
	})

	Describe("Successfully calling the Cloud Controller", func() {
		var expectedBody = []byte(`{ "key": "value" }`)

		BeforeEach(func() {
			fakeCC.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", fmt.Sprintf("/internal/staging/%s/completed", stagingGuid)),
					ghttp.VerifyBasicAuth("username", "password"),
					ghttp.RespondWith(200, `{}`),
					func(w http.ResponseWriter, req *http.Request) {
						body, err := ioutil.ReadAll(req.Body)
						defer req.Body.Close()
		fakeCloudController = ghttp.NewServer()

		uploader := ccclient.NewUploader(logger, http.DefaultClient)
		poller := ccclient.NewPoller(logger, http.DefaultClient, 100*time.Millisecond)

		handler, err = handlers.New(uploader, poller, logger)
		Expect(err).NotTo(HaveOccurred())

		postStatusCode = http.StatusCreated
		uploadedBytes = nil
		uploadedFileName = ""
		uploadedHeaders = nil
	})

	AfterEach(func() {
		fakeCloudController.Close()
	})

	Describe("UploadDroplet", func() {
		var (
			timeClicker chan time.Time
			startTime   time.Time
			endTime     time.Time
		)

		BeforeEach(func() {
			var err error

			timeClicker = make(chan time.Time, 4)
			fakeCloudController.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("POST", "/staging/droplet/app-guid/upload"),
Exemple #19
0
			UAAPassword:         uaaPassword,
			UAAUsername:         uaaUsername,
			ConsulCluster:       consulRunner.URL(),
			AllowedCiphers:      allowedCiphers,
			AllowedMACs:         allowedMACs,
			AllowedKeyExchanges: allowedKeyExchanges,
		}

		runner = testrunner.New(sshProxyPath, args)
		process = ifrit.Invoke(runner)
	})

	AfterEach(func() {
		ginkgomon.Kill(process, 3*time.Second)

		fakeBBS.Close()
		fakeUAA.Close()
		fakeCC.Close()
	})

	Describe("argument validation", func() {
		Context("when the host key is not provided", func() {
			BeforeEach(func() {
				hostKey = ""
			})

			It("reports the problem and terminates", func() {
				Expect(runner).To(gbytes.Say("hostKey is required"))
				Expect(runner).NotTo(gexec.Exit(0))
			})
		})
			)

			BeforeEach(func() {
				etcd1 = ghttp.NewServer()
				etcd2 = ghttp.NewServer()
				etcd3 = ghttp.NewServer()

				etcdOptions.ClusterUrls = []string{
					etcd1.URL(),
					etcd2.URL(),
					etcd3.URL(),
				}
			})

			AfterEach(func() {
				etcd1.Close()
				etcd2.Close()
				etcd3.Close()
			})

			Context("when the etcd server gives valid JSON", func() {
				BeforeEach(func() {
					etcd1.RouteToHandler("GET", "/v2/stats/self", ghttp.RespondWith(200, `
            {
              "name": "node1",
							"id": "node1-id",
              "state": "StateFollower",

              "leaderInfo": {
                "leader": "node2-id",
								"uptime": "17h41m45.103057785s",
Exemple #21
0
		fakeServer *ghttp.Server
		logger     *lagertest.TestLogger
		timeout    time.Duration
	)

	BeforeEach(func() {
		timeout = 1 * time.Second
		cf_http.Initialize(timeout)
		fakeServer = ghttp.NewServer()

		logger = lagertest.NewTestLogger("test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))
	})

	AfterEach(func() {
		fakeServer.Close()
	})

	Describe("HandleCompletedTask", func() {
		var (
			callbackURL string
			taskDB      *dbfakes.FakeTaskDB
			statusCodes chan int
			reqCount    chan struct{}
			task        *models.Task

			httpClient *http.Client
		)

		BeforeEach(func() {
			httpClient = cf_http.NewClient()
var _ = Describe("Generate", func() {
	var outputDir string
	var script string
	var server *ghttp.Server
	var manifestYaml string
	var deployments []models.IndexDeployment
	var session *gexec.Session

	BeforeEach(func() {
		manifestYaml = "syslog_manifest.yml"
		deployments = DefaultIndexDeployment()
	})

	AfterEach(func() {
		server.Close()
		Expect(os.RemoveAll(outputDir)).To(Succeed())
	})

	JustBeforeEach(func() {
		server = CreateServer(manifestYaml, deployments)
	})

	Describe("UAA integration", func() {
		var oauthServer *ghttp.Server
		var uaaServer *ghttp.Server
		BeforeEach(func() {
			oauthServer = CreateOAuthServer()
			uaaServer = CreateUaaProtectedServer(manifestYaml, deployments, oauthServer.URL())
		})
		AfterEach(func() {
						"Authorization": []string{"bearer " + token},
					}),
					ghttp.RespondWithJSONEncoded(http.StatusOK, nil),
				),
			)

			flags = []string{
				"-api", server.URL(),
				"-client-id", "some-name",
				"-client-secret", "some-secret",
				"-oauth-url", authServer.URL(),
			}
		})

		AfterEach(func() {
			authServer.Close()
			server.Close()
		})

		It("registers a route to the routing api", func() {
			command := buildCommand("register", flags, []string{`[{"route":"zak.com","port":3,"ip":"4"}]`})

			server.SetHandler(0,
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/v1/routes"),
					ghttp.VerifyJSONRepresenting([]map[string]interface{}{
						{
							"route":    "zak.com",
							"port":     3,
							"ip":       "4",
							"ttl":      0,
Exemple #24
0
})

var _ = BeforeEach(func() {
	logger := lagertest.NewTestLogger("test")

	auctionRep = &repfakes.FakeClient{}
	fakeLRPStopper = &fake_lrp_stopper.FakeLRPStopper{}
	fakeExecutorClient = &executorfakes.FakeClient{}
	fakeEvacuatable = &fake_evacuation_context.FakeEvacuatable{}

	handler, err := rata.NewRouter(rep.Routes, handlers.New(auctionRep, fakeLRPStopper, fakeExecutorClient, fakeEvacuatable, logger))
	Expect(err).NotTo(HaveOccurred())
	server = httptest.NewServer(handler)

	client = rep.NewClient(&http.Client{}, server.URL)

	serverThatErrors = ghttp.NewServer()
	erroringHandler := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {
		serverThatErrors.CloseClientConnections()
	})
	//5 erroringHandlers should be more than enough: none of the individual tests should make more than 5 requests to this server
	serverThatErrors.AppendHandlers(erroringHandler, erroringHandler, erroringHandler, erroringHandler, erroringHandler)

	clientForServerThatErrors = rep.NewClient(&http.Client{}, serverThatErrors.URL())
})

var _ = AfterEach(func() {
	server.Close()
	serverThatErrors.Close()
})
		responseStruct struct {
			SomeResponseField string `json:"SomeResponseField"`
		}
	)

	BeforeEach(func() {
		server = ghttp.NewServer()

		c = &client.JSONClient{
			BaseURL: server.URL(),
		}

		route = "/some/route"
	})
	AfterEach(func() {
		server.Close()
	})

	Describe("Get", func() {
		BeforeEach(func() {
			serverHandler = ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", route),
				ghttp.RespondWith(http.StatusOK, `{ "SomeResponseField": "some value" }`),
			)
			server.AppendHandlers(serverHandler)
		})

		It("should make a get request to the given route", func() {
			err := c.Get(route, &responseStruct)
			Expect(err).NotTo(HaveOccurred())
			Expect(server.ReceivedRequests()).To(HaveLen(1))
Exemple #26
0
	var (
		repo             api.RoutingApiRepository
		configRepo       core_config.Repository
		routingApiServer *ghttp.Server
	)

	BeforeEach(func() {
		configRepo = testconfig.NewRepositoryWithDefaults()
		gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})

		repo = api.NewRoutingApiRepository(configRepo, gateway)
	})

	AfterEach(func() {
		routingApiServer.Close()
	})

	Describe("ListRouterGroups", func() {

		Context("when routing api return router groups", func() {
			BeforeEach(func() {
				routingApiServer = ghttp.NewServer()
				routingApiServer.RouteToHandler("GET", "/v1/router_groups",
					func(w http.ResponseWriter, req *http.Request) {
						responseBody := []byte(`[
			{
				  "guid": "bad25cff-9332-48a6-8603-b619858e7992",
					"name": "default-tcp",
					"type": "tcp"
			}]`)
Exemple #27
0
	consulRunner.Start()
	consulRunner.WaitUntilReady()

	bbsRunner = bbstestrunner.New(bbsPath, bbsArgs)
	bbsProcess = ginkgomon.Invoke(bbsRunner)

	fakeCC = ghttp.NewServer()

	listenerAddr = fmt.Sprintf("127.0.0.1:%d", uint16(listenerPort))

	runner = tpsrunner.NewListener(
		string(listenerPath),
		listenerAddr,
		bbsURL.String(),
		trafficControllerURL,
	)
})

var _ = AfterEach(func() {
	ginkgomon.Kill(bbsProcess)
	fakeCC.Close()
	etcdRunner.Stop()
	consulRunner.Stop()
})

var _ = SynchronizedAfterSuite(func() {
	auctioneerServer.Close()
}, func() {
	gexec.CleanupBuildArtifacts()
})
							{
								"name": "some-provider",
								"download_url": "some-other-download-url"
							},
							{
								"name": "aws",
								"download_url": "another-wrong-url"
							}
						]
					}
				]
			}`, fakeDownloadURL)
			atlasClient = lib.AtlasClient{jsonClient}
		})
		AfterEach(func() {
			fakeDownloadServer.Close()
		})

		It("should return the AMI used by the box in the specified region", func() {
			amiMap, err := atlasClient.GetAMIs("someuser/somebox", "some-special-version")
			Expect(err).NotTo(HaveOccurred())
			Expect(amiMap).To(Equal(map[string]string{
				"ap-northeast-1": "ami-58d24558",
				"ap-southeast-1": "ami-4a2e3b18",
				"ap-southeast-2": "ami-0dd89737",
				"eu-west-1":      "ami-4d8eac3a",
				"sa-east-1":      "ami-3370e52e",
				"us-east-1":      "ami-4f1e6a2a",
				"us-west-1":      "ami-5df23719",
				"us-west-2":      "ami-8b4956bb",
			}))
Exemple #29
0
				appResponses := make([]json.RawMessage, 0, len(processGuids))
				for _, processGuid := range processGuids {
					appResponses = append(appResponses, json.RawMessage(desiredAppResponses[processGuid]))
				}

				payload, err := json.Marshal(appResponses)
				Expect(err).NotTo(HaveOccurred())

				w.Write(payload)
			}),
		)
	})

	AfterEach(func() {
		defer fakeCC.Close()
	})

	Describe("when the CC polling interval elapses", func() {
		JustBeforeEach(func() {
			process = startBulker(true)
		})

		AfterEach(func() {
			ginkgomon.Interrupt(process, interruptTimeout)
		})

		Context("once the state has been synced with CC", func() {
			Context("lrps", func() {
				BeforeEach(func() {
					schedulingInfoResponse := models.DesiredLRPSchedulingInfosResponse{
			},
			Destination: config.Transaction{
				Url:         serviceCatalogServer.URL() + "/v2/catalog",
				HttpMethod:  "GET",
				Headers:     http.Header{},
				Mappings:    make(map[string]string),
				ExtraFields: make(map[string]string),
			},
			Proxy: proxy.Proxy{
				Url: proxyUrl,
			},
		}
	})

	AfterEach(func() {
		serviceCatalogServer.Close()
		serviceBrokerServer.Close()
	})

	Describe("Make an http requests", func() {
		Context("simulate a catalog fetch request", func() {

			BeforeEach(func() {
				serviceCatalogServer.AppendHandlers(
					ghttp.VerifyRequest("GET", "/v2/catalog"),
				)
			})

			It("should return with a status code of 200", func() {
				resp, err := interceptor.MakeRequest("GET", serviceCatalogServer.URL()+"/v2/catalog", http.Header{})
				Expect(err).NotTo(HaveOccurred())