Ejemplo n.º 1
0
// Confirm the targetURL is valid and can be listened on before running tests.
func init() {
	u, err := url.Parse(targetURL)
	if err != nil {
		panic(fmt.Sprintf("Invalid target URL: %s", err))
	}
	ln, err := net.Listen("tcp", u.Host)
	if err != nil {
		panic(fmt.Sprintf("Unable to listen on address (%s): %s", targetURL, err))
	}
	ln.Close()
}

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

	BeforeEach(func() {
		logger = &fakelogger.FakeLogger{}
		serverURL, err := url.Parse(targetURL)
		Expect(err).ToNot(HaveOccurred())
		dispatcher = boshdispatcher.NewHTTPSDispatcher(serverURL, logger)

		errChan := make(chan error)
		go func() {
			errChan <- dispatcher.Start()
		}()

		select {
		case err := <-errChan:
Ejemplo n.º 2
0
import (
	"crypto/tls"
	"net/http"
	"net/url"
	"time"

	. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
	. "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)
	})
Ejemplo n.º 3
0
// Confirm the targetURL is valid and can be listened on before running tests.
func init() {
	u, err := url.Parse(targetURL)
	if err != nil {
		panic(fmt.Sprintf("Invalid target URL: %s", err))
	}
	ln, err := net.Listen("tcp", u.Host)
	if err != nil {
		panic(fmt.Sprintf("Unable to listen on address (%s): %s", targetURL, err))
	}
	ln.Close()
}

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

	BeforeEach(func() {
		logger := boshlog.NewLogger(boshlog.LevelNone)
		serverURL, err := url.Parse(targetURL)
		Expect(err).ToNot(HaveOccurred())
		dispatcher = boshdispatcher.NewHTTPSDispatcher(serverURL, logger)

		errChan := make(chan error)
		go func() {
			errChan <- dispatcher.Start()
		}()

		select {
		case err := <-errChan: