Skip to content

Instantly share code, notes, and snippets.

@noamt
Created February 18, 2020 16:20
Show Gist options
  • Save noamt/2d98f38f2df78ac79774cdd1ae594246 to your computer and use it in GitHub Desktop.
Save noamt/2d98f38f2df78ac79774cdd1ae594246 to your computer and use it in GitHub Desktop.
For blog post "Simulating SSL outages with Go"
package reachout_test
import (
"net/http"
"net/http/httptest"
"os"
"testing"
)
func Test_ReachOut_SSLExpired(t *testing.T) {
certificate, _ := expiredSSLCertificate()
handlerFunc := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// handle test request
})
tlsServer := httptest.NewTLSServer(handlerFunc)
tlsServer.TLS.Certificates = []tls.Certificate{*cert}
defer tlsServer.Close()
os.Setenv("API_HOST", server.URL)
response := reachout.ReachOut()
// assert response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment