func startRecordingServer(tls bool) (server *ghttp.Server) { if tls { server = ghttp.NewTLSServer() } else { server = ghttp.NewServer() } server.AllowUnhandledRequests = true server.UnhandledRequestStatusCode = http.StatusOK return server }
Expect(server.ReceivedRequests()).To(HaveLen(1)) Expect(responseStruct.SomeResponseField).To(Equal("some value")) }) Context("when the request cannot be created", func() { It("should return an error", func() { err := c.Get("%%%", &responseStruct) Expect(err).To(MatchError(ContainSubstring("parse"))) }) }) Context("when the server is TLS with a self-signed cert", func() { var tlsServer *ghttp.Server BeforeEach(func() { tlsServer = ghttp.NewTLSServer() tlsServer.AppendHandlers(ghttp.CombineHandlers(serverHandler)) c.BaseURL = tlsServer.URL() }) AfterEach(func() { tlsServer.Close() }) Context("when SkipTLSVerify is true", func() { It("should succeed", func() { c.SkipTLSVerify = true err := c.Get(route, &responseStruct) Expect(err).NotTo(HaveOccurred()) Expect(responseStruct.SomeResponseField).To(Equal("some value")) })
uaaUsername string allowedCiphers string allowedMACs string allowedKeyExchanges string expectedGetActualLRPRequest *models.ActualLRPGroupByProcessGuidAndIndexRequest actualLRPGroupResponse *models.ActualLRPGroupResponse getDesiredLRPRequest *models.DesiredLRPByProcessGuidRequest desiredLRPResponse *models.DesiredLRPResponse processGuid string clientConfig *ssh.ClientConfig ) BeforeEach(func() { fakeBBS = ghttp.NewServer() fakeUAA = ghttp.NewTLSServer() fakeCC = ghttp.NewTLSServer() privateKey, err := ssh.ParsePrivateKey([]byte(hostKeyPem)) Expect(err).NotTo(HaveOccurred()) hostKeyFingerprint = helpers.MD5Fingerprint(privateKey.PublicKey()) address = fmt.Sprintf("127.0.0.1:%d", sshProxyPort) bbsAddress = fakeBBS.URL() ccAPIURL = fakeCC.URL() diegoCredentials = "some-creds" enableCFAuth = true enableDiegoAuth = true hostKey = hostKeyPem skipCertVerify = true processGuid = "app-guid-app-version"
Expect(err).NotTo(HaveOccurred()) Expect(body).To(Equal(expectedBody)) }, ), ) }) It("sends the request payload to the CC without modification", func() { err := ccClient.StagingComplete(stagingGuid, expectedBody, logger) Expect(err).NotTo(HaveOccurred()) }) }) Describe("TLS certificate validation", func() { BeforeEach(func() { fakeCC = ghttp.NewTLSServer() // self-signed certificate fakeCC.AppendHandlers( ghttp.CombineHandlers( ghttp.VerifyRequest("POST", fmt.Sprintf("/internal/staging/%s/completed", stagingGuid)), ghttp.VerifyBasicAuth("username", "password"), ghttp.RespondWith(200, `{}`), ), ) // muffle server-side log of certificate error fakeCC.HTTPTestServer.Config.ErrorLog = log.New(ioutil.Discard, "", log.Flags()) }) Context("when certificate verfication is enabled", func() { BeforeEach(func() { ccClient = cc_client.NewCcClient(fakeCC.URL(), "username", "password", false)
newFly, err := os.Create(newFlyPath) Ω(err).ShouldNot(HaveOccurred()) oldFly, err := os.Open(flyPath) Ω(err).ShouldNot(HaveOccurred()) _, err = io.Copy(newFly, oldFly) Ω(err).ShouldNot(HaveOccurred()) newFly.Close() oldFly.Close() err = os.Chmod(newFlyPath, 0755) Ω(err).ShouldNot(HaveOccurred()) atcServer = ghttp.NewTLSServer() atcServer.AppendHandlers(cliHandler()) }) AfterEach(func() { os.RemoveAll(newFlyDir) }) It("downloads and replaces the currently running executable", func() { flyCmd := exec.Command(newFlyPath, "-t", atcServer.URL(), "-k", "sync") sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter) Ω(err).ShouldNot(HaveOccurred()) <-sess.Exited
Expect(string(body)).To(ContainSubstring(etcdVersion)) etcdAdapter = etcdRunner.Adapter(nil) routingAPIPort = uint16(6900 + GinkgoParallelNode()) routingAPIIP = "127.0.0.1" routingAPISystemDomain = "example.com" routingAPIAddress = fmt.Sprintf("%s:%d", routingAPIIP, routingAPIPort) routingAPIURL := &url.URL{ Scheme: "http", Host: routingAPIAddress, } client = routing_api.NewClient(routingAPIURL.String()) oauthServer = ghttp.NewTLSServer() oauthServer.AllowUnhandledRequests = true oauthServer.UnhandledRequestStatusCode = http.StatusOK oauthServerPort = getServerPort(oauthServer.URL()) routingAPIArgs = testrunner.Args{ Port: routingAPIPort, IP: routingAPIIP, SystemDomain: routingAPISystemDomain, ConfigPath: createConfig(), EtcdCluster: etcdUrl, DevMode: true, } }) var _ = AfterEach(func() {
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" . "github.com/xchapter7x/chaospeddler/service_broker" ) var _ = Describe("Given a AppKill", func() { Describe("Given a KillPercent Method", func() { var ( server *ghttp.Server appKill *AppKill ) BeforeEach(func() { server = NewTestServer(ghttp.NewTLSServer()) appKill = NewAppKill("", "", server.URL(), server.URL()) }) AfterEach(func() { server.Close() }) Context("when called with a service binding object representing a valid object", func() { var ( err error killRatio map[string]int ) for _, control := range []map[string]int{{"killed": 2, "of": 10, "percent": 10}} { BeforeEach(func() {