diff options
author | Igor <idrozdov@gitlab.com> | 2019-05-01 15:31:32 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-01 15:31:32 +0000 |
commit | cffbe0ebd86a71ce719767153d1f227172646be5 (patch) | |
tree | 70c44f6e6af2f10379bfc2d288ee300b9c160346 /go/internal/gitlabnet/client_test.go | |
parent | 805bdd0d333a047b5fb92a4feb075a7db95cba56 (diff) | |
download | gitlab-shell-cffbe0ebd86a71ce719767153d1f227172646be5.tar.gz |
Support calling internal API using HTTPS
Diffstat (limited to 'go/internal/gitlabnet/client_test.go')
-rw-r--r-- | go/internal/gitlabnet/client_test.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/go/internal/gitlabnet/client_test.go b/go/internal/gitlabnet/client_test.go index f9aa289..d817239 100644 --- a/go/internal/gitlabnet/client_test.go +++ b/go/internal/gitlabnet/client_test.go @@ -6,15 +6,21 @@ import ( "fmt" "io/ioutil" "net/http" + "path" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/go/internal/config" "gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet/testserver" + "gitlab.com/gitlab-org/gitlab-shell/go/internal/testhelper" ) func TestClients(t *testing.T) { + testDirCleanup, err := testhelper.PrepareTestRootDir() + require.NoError(t, err) + defer testDirCleanup() + requests := []testserver.TestRequestHandler{ { Path: "/api/v4/internal/hello", @@ -64,19 +70,26 @@ func TestClients(t *testing.T) { testCases := []struct { desc string - secret string + config *config.Config server func([]testserver.TestRequestHandler) (func(), string, error) }{ { desc: "Socket client", - secret: "sssh, it's a secret", + config: &config.Config{}, server: testserver.StartSocketHttpServer, }, { desc: "Http client", - secret: "sssh, it's a secret", + config: &config.Config{}, server: testserver.StartHttpServer, }, + { + desc: "Https client", + config: &config.Config{ + HttpSettings: config.HttpSettingsConfig{CaFile: path.Join(testhelper.TestRoot, "certs/valid/server.crt")}, + }, + server: testserver.StartHttpsServer, + }, } for _, tc := range testCases { @@ -85,7 +98,10 @@ func TestClients(t *testing.T) { defer cleanup() require.NoError(t, err) - client, err := GetClient(&config.Config{GitlabUrl: url, Secret: tc.secret}) + tc.config.GitlabUrl = url + tc.config.Secret = "sssh, it's a secret" + + client, err := GetClient(tc.config) require.NoError(t, err) testBrokenRequest(t, client) |