diff options
author | Vishal Tak <vtak@gitlab.com> | 2022-05-26 11:40:09 +0300 |
---|---|---|
committer | Vishal Tak <vtak@gitlab.com> | 2022-06-02 09:12:29 +0300 |
commit | 8488ef56611256c1761f93de5f8df23e07b86af4 (patch) | |
tree | 76be69593e86ae2cbf0bcac28585b0e262e9952b /test/acceptance | |
parent | 2fe03721dbc6abb0240a284186a4bc4f4545d008 (diff) |
Add support for tls for metrics
Changelog: added
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/config_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/acceptance/config_test.go b/test/acceptance/config_test.go index 95be6e17..011b4c73 100644 --- a/test/acceptance/config_test.go +++ b/test/acceptance/config_test.go @@ -1,6 +1,7 @@ package acceptance_test import ( + "crypto/tls" "fmt" "net" "net/http" @@ -8,6 +9,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) func TestEnvironmentVariablesConfig(t *testing.T) { @@ -86,3 +88,28 @@ func TestUnixSocketListener(t *testing.T) { rsp.Body.Close() require.Equal(t, http.StatusOK, rsp.StatusCode) } + +func TestMetricsHTTPSConfig(t *testing.T) { + keyFile, certFile := CreateHTTPSFixtureFiles(t) + + RunPagesProcess(t, + withExtraArgument("metrics-address", ":42345"), + withExtraArgument("metrics-certificate", certFile), + withExtraArgument("metrics-key", keyFile), + ) + require.NoError(t, httpsListener.WaitUntilRequestSucceeds(nil)) + + tlsConfig := &tls.Config{InsecureSkipVerify: true} + transport := &http.Transport{TLSClientConfig: tlsConfig} + client := &http.Client{Transport: transport} + + res, err := client.Get("https://127.0.0.1:42345/metrics") + require.NoError(t, err) + testhelpers.Close(t, res.Body) + require.Equal(t, http.StatusOK, res.StatusCode) + + res, err = client.Get("http://127.0.0.1:42345/metrics") + require.NoError(t, err) + testhelpers.Close(t, res.Body) + require.Equal(t, http.StatusBadRequest, res.StatusCode) +} |