func TestServerHTTPS(t *testing.T) {
	require := test.NewRequire(t)

	certFile := "../../certs/conformancesuite_cert.pem"
	keyFile := "../../certs/conformancesuite_key.pem"
	transport := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	httpClient := client.NewHTTPClientWithTransport(client.DefaultTimeout, transport)

	server := NewServer(testJourney(), nullLogger(), &mocks.Version{})
	defer func() {
		require.NoError(server.Shutdown(context.TODO()))
	}()
	require.NotNil(server)

	// For how random port works: https://github.com/labstack/echo/issues/1065#issuecomment-367961653

	// Start HTTPS server
	go func() {
		require.EqualError(server.StartTLS(":0", certFile, keyFile), "http: Server closed")
	}()
	time.Sleep(100 * time.Millisecond)

	tcpAddr, ok := server.TLSListener.Addr().(*net.TCPAddr)
	require.True(ok)
	require.NotNil(tcpAddr)
	url := fmt.Sprintf("https://localhost:%d/", tcpAddr.Port)
	res, err := httpClient.Get(url)
	require.NoError(err)
	require.NotNil(res)
	require.Equal(http.StatusOK, res.StatusCode)

	require.NotNil(res.Body)
	defer func() {
		require.NoError(res.Body.Close())
	}()
	bodyActual, err := ioutil.ReadAll(res.Body)
	require.NoError(err)

	bodyExpected, err := ioutil.ReadFile("./web/dist/index.html")
	require.NoError(err)

	require.Equal(string(bodyExpected), string(bodyActual))
}
// TestServerHTTPS - tests that TLS works.
tests that TLS works.
// TestServerHTTPS - tests that TLS works .
func TestServerHTTPS(t *testing.T) {
	require := test.NewRequire(t)
	certFile := "../../certs/conformancesuite_cert.pem"
	keyFile := "../../certs/conformancesuite_key.pem"
	transport := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	httpClient := client.NewHTTPClientWithTransport(client.DefaultTimeout, transport)
	server := NewServer(testJourney(), nullLogger(), &mocks.Version{})
	defer func() {
		require.NoError(server.Shutdown(context.TODO()))
	}()
	require.NotNil(server)
	go func() {
		require.EqualError(server.StartTLS(":0", certFile, keyFile), "http: Server closed")
	}()
	time.Sleep(100 * time.Millisecond)
	tcpAddr, ok := server.TLSListener.Addr().(*net.TCPAddr)
	require.True(ok)
	require.NotNil(tcpAddr)
	url := fmt.Sprintf("https://localhost:%d/", tcpAddr.Port)
	res, err := httpClient.Get(url)
	require.NoError(err)
	require.NotNil(res)
	require.Equal(http.StatusOK, res.StatusCode)
	require.NotNil(res.Body)
	defer func() {
		require.NoError(res.Body.Close())
	}()
	bodyActual, err := ioutil.ReadAll(res.Body)
	require.NoError(err)
	bodyExpected, err := ioutil.ReadFile("./web/dist/index.html")
	require.NoError(err)
	require.Equal(string(bodyExpected), string(bodyActual))
}
func TestServerHTTPS ( t * testing . T ) { require := test . NewRequire ( t ) certFile := " " keyFile := " " transport := & http . Transport { Proxy : http . ProxyFromEnvironment , TLSClientConfig : & tls . Config { InsecureSkipVerify : true , } , } httpClient := client . NewHTTPClientWithTransport ( client . DefaultTimeout , transport ) server := NewServer ( testJourney ( ) , nullLogger ( ) , & mocks . Version { } ) defer func ( ) { require . NoError ( server . Shutdown ( context . TODO ( ) ) ) } ( ) require . NotNil ( server ) go func ( ) { require . EqualError ( server . StartTLS ( " " , certFile , keyFile ) , " " ) } ( ) time . Sleep ( 100 * time . Millisecond ) tcpAddr , ok := server . TLSListener . Addr ( ) . ( * net . TCPAddr ) require . True ( ok ) require . NotNil ( tcpAddr ) url := fmt . Sprintf ( " " , tcpAddr . Port ) res , err := httpClient . Get ( url ) require . NoError ( err ) require . NotNil ( res ) require . Equal ( http . StatusOK , res . StatusCode ) require . NotNil ( res . Body ) defer func ( ) { require . NoError ( res . Body . Close ( ) ) } ( ) bodyActual , err := ioutil . ReadAll ( res . Body ) require . NoError ( err ) bodyExpected , err := ioutil . ReadFile ( " " ) require . NoError ( err ) require . Equal ( string ( bodyExpected ) , string ( bodyActual ) ) }
tests that TLS works.
tests that TLS works .
// For how random port works: https://github.com/labstack/echo/issues/1065#issuecomment-367961653 // Start HTTPS server