From 1a94ad14bd3df5fd794e04bc3db3b7b52caebd48 Mon Sep 17 00:00:00 2001 From: Davi Vidal Date: Tue, 5 Mar 2019 14:37:37 +0100 Subject: [PATCH] Adds test for insecure_skip_tls_verify --- .../vagrant-cloud/post-processor_test.go | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index c21a2fd2a..e038c7786 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -41,6 +41,32 @@ func newSecureServer(token string, handler http.HandlerFunc) *httptest.Server { })) } +func newSelfSignedSslServer(token string, handler http.HandlerFunc) *httptest.Server { + token = fmt.Sprintf("Bearer %s", token) + return httptest.NewTLSServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if req.Header.Get("authorization") != token { + http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) + return + } + if handler != nil { + handler(rw, req) + } + })) +} + +func TestPostProcessor_Insecure_Ssl(t *testing.T) { + var p PostProcessor + server := newSelfSignedSslServer("foo", nil) + defer server.Close() + + config := testGoodConfig() + config["vagrant_cloud_url"] = server.URL + config["insecure_skip_tls_verify"] = true + if err := p.Configure(config); err != nil { + t.Fatalf("err: %s", err) + } +} + func TestPostProcessor_Configure_fromVagrantEnv(t *testing.T) { var p PostProcessor config := testGoodConfig()