9001+config.GinkgoConfig.ParallelNode*consulrunner.PortOffsetLength,
		1,
		"http",
	)

	consulRunner.Start()
	consulRunner.WaitUntilReady()
	consulRunner.Reset()

	etcdRunner.Start()
	etcdRunner.Reset()

	etcdClient = etcdRunner.Client()
	etcdClient.SetConsistency(etcdclient.STRONG_CONSISTENCY)

	bbsArgs.ConsulCluster = consulRunner.ConsulCluster()
	bbsArgs.EtcdCluster = etcdUrl

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

	basePath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "cloudfoundry-incubator", "bbs", "cmd", "bbs", "fixtures")
	caFile := path.Join(basePath, "green-certs", "server-ca.crt")
	certFile := path.Join(basePath, "green-certs", "client.crt")
	keyFile := path.Join(basePath, "green-certs", "client.key")

	var err error
	bbsClient, err = bbs.NewSecureClient(bbsURL.String(), caFile, certFile, keyFile, 1, 1)
	Expect(err).NotTo(HaveOccurred())
})
Esempio n. 2
0
			bbsRunner = testrunner.New(bbsBinPath, bbsArgs)
			bbsProcess = ginkgomon.Invoke(bbsRunner)
		})

		BeforeEach(func() {
			bbsArgs.RequireSSL = true
			bbsArgs.CAFile = path.Join(basePath, "green-certs", "server-ca.crt")
			bbsArgs.CertFile = path.Join(basePath, "green-certs", "server.crt")
			bbsArgs.KeyFile = path.Join(basePath, "green-certs", "server.key")
		})

		It("succeeds for a client configured with the right certificate", func() {
			caFile := path.Join(basePath, "green-certs", "server-ca.crt")
			certFile := path.Join(basePath, "green-certs", "client.crt")
			keyFile := path.Join(basePath, "green-certs", "client.key")
			client, err = bbs.NewSecureClient(bbsURL.String(), caFile, certFile, keyFile, 0, 0)
			Expect(err).NotTo(HaveOccurred())
			Expect(client.Ping(logger)).To(BeTrue())
		})

		It("fails for a client with no SSL", func() {
			client = bbs.NewClient(bbsURL.String())
			Expect(client.Ping(logger)).To(BeFalse())
		})

		It("fails for a client configured with the wrong certificates", func() {
			caFile := path.Join(basePath, "green-certs", "server-ca.crt")
			certFile := path.Join(basePath, "blue-certs", "client.crt")
			keyFile := path.Join(basePath, "blue-certs", "client.key")
			client, err = bbs.NewSecureClient(bbsURL.String(), caFile, certFile, keyFile, 0, 0)
			Expect(err).NotTo(HaveOccurred())