func NewHTTPSHandler(
	parsedURL *url.URL,
	logger boshlog.Logger,
	fs boshsys.FileSystem,
	dirProvider boshdir.Provider,
) (handler HTTPSHandler) {
	handler.parsedURL = parsedURL
	handler.logger = logger
	handler.fs = fs
	handler.dirProvider = dirProvider
	handler.dispatcher = boshdispatcher.NewHTTPSDispatcher(parsedURL, logger)
	return
}
Ejemplo n.º 2
0
	. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"

	boshdispatcher "github.com/cloudfoundry/bosh-agent/httpsdispatcher"
	boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
)

var _ = Describe("HTTPSDispatcher", func() {
	var (
		dispatcher *boshdispatcher.HTTPSDispatcher
	)

	BeforeEach(func() {
		logger := boshlog.NewLogger(boshlog.LevelNone)
		serverURL, err := url.Parse("https://127.0.0.1:7788")
		Expect(err).ToNot(HaveOccurred())
		dispatcher = boshdispatcher.NewHTTPSDispatcher(serverURL, logger)
		go dispatcher.Start()
		time.Sleep(1 * time.Second)
	})

	AfterEach(func() {
		dispatcher.Stop()
		time.Sleep(1 * time.Second)
	})

	It("calls the handler function for the route", func() {
		var hasBeenCalled = false
		handler := func(w http.ResponseWriter, r *http.Request) {
			hasBeenCalled = true
			w.WriteHeader(201)
		}