Created
February 18, 2020 16:20
-
-
Save noamt/2d98f38f2df78ac79774cdd1ae594246 to your computer and use it in GitHub Desktop.
For blog post "Simulating SSL outages with Go"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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