Пример #1
0
func NewBBS(c BBSConfig) (bbs.Client, error) {
	c.PopulateFromEnv()
	err := c.Validate()
	if err != nil {
		return nil, err
	}

	if c.IsSecure() {
		return bbs.NewSecureSkipVerifyClient(c.URL, c.CertFile, c.KeyFile, 0, 0)
	} else {
		return bbs.NewClient(c.URL), nil
	}
}
Пример #2
0
		It("fails to create the client if certs are not valid", func() {
			client, err = bbs.NewSecureClient(bbsURL.String(), "", "", "", 0, 0)
			Expect(err).To(HaveOccurred())
		})
	})

	Context("when configuring a client without mutual SSL (skipping verification)", func() {
		BeforeEach(func() {
			bbsArgs.RequireSSL = true
			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() {
			certFile := path.Join(basePath, "green-certs", "client.crt")
			keyFile := path.Join(basePath, "green-certs", "client.key")
			client, err = bbs.NewSecureSkipVerifyClient(bbsURL.String(), certFile, keyFile, 0, 0)
			Expect(err).NotTo(HaveOccurred())
		})

		It("fails for a client configured with the wrong certificates", func() {
			certFile := path.Join(basePath, "blue-certs", "client.crt")
			keyFile := path.Join(basePath, "blue-certs", "client.key")
			client, err = bbs.NewSecureSkipVerifyClient(bbsURL.String(), certFile, keyFile, 0, 0)
			Expect(err).NotTo(HaveOccurred())
			Expect(client.Ping(logger)).To(BeFalse())
		})
	})
})