X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/76e8998d9326da7d99bcf083bd7234d62c2af63c..1ca30429c393325a091e3f7e30b36e204bbe2fca:/services/arv-git-httpd/integration_test.go diff --git a/services/arv-git-httpd/integration_test.go b/services/arv-git-httpd/integration_test.go index 61d83ff8e8..12ddc5b770 100644 --- a/services/arv-git-httpd/integration_test.go +++ b/services/arv-git-httpd/integration_test.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -8,7 +12,10 @@ import ( "strings" "testing" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/lib/config" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/ctxlog" check "gopkg.in/check.v1" ) @@ -23,7 +30,7 @@ type IntegrationSuite struct { tmpRepoRoot string tmpWorkdir string testServer *server - Config *config + cluster *arvados.Cluster } func (s *IntegrationSuite) SetUpSuite(c *check.C) { @@ -36,7 +43,7 @@ func (s *IntegrationSuite) TearDownSuite(c *check.C) { func (s *IntegrationSuite) SetUpTest(c *check.C) { arvadostest.ResetEnv() - s.testServer = &server{} + var err error if s.tmpRepoRoot == "" { s.tmpRepoRoot, err = ioutil.TempDir("", "arv-git-httpd") @@ -55,6 +62,23 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) { _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo work >work && git add work && git -c user.name=Foo -c user.email=Foo commit -am 'workdir: test'").CombinedOutput() c.Assert(err, check.Equals, nil) + if s.cluster == nil { + cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load() + c.Assert(err, check.Equals, nil) + s.cluster, err = cfg.GetCluster("") + c.Assert(err, check.Equals, nil) + + s.cluster.Services.GitHTTP.InternalURLs = map[arvados.URL]arvados.ServiceInstance{{Host: "localhost:0"}: {}} + s.cluster.TLS.Insecure = true + s.cluster.Git.GitCommand = "/usr/bin/git" + s.cluster.Git.Repositories = s.tmpRepoRoot + s.cluster.ManagementToken = arvadostest.ManagementToken + } + + s.testServer = &server{cluster: s.cluster} + err = s.testServer.Start() + c.Assert(err, check.Equals, nil) + _, err = exec.Command("git", "config", "--file", s.tmpWorkdir+"/.git/config", "credential.http://"+s.testServer.Addr+"/.helper", @@ -66,20 +90,12 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) { "none").Output() c.Assert(err, check.Equals, nil) - if s.Config == nil { - s.Config = &config{ - Addr: ":0", - GitCommand: "/usr/bin/git", - Root: s.tmpRepoRoot, - } - } - theConfig = s.Config - err = s.testServer.Start() - c.Assert(err, check.Equals, nil) - - // Clear ARVADOS_API_TOKEN after starting up the server, to - // make sure arv-git-httpd doesn't use it. - os.Setenv("ARVADOS_API_TOKEN", "unused-token-placates-client-library") + // Clear ARVADOS_API_* env vars before starting up the server, + // to make sure arv-git-httpd doesn't use them or complain + // about them being missing. + os.Unsetenv("ARVADOS_API_HOST") + os.Unsetenv("ARVADOS_API_HOST_INSECURE") + os.Unsetenv("ARVADOS_API_TOKEN") } func (s *IntegrationSuite) TearDownTest(c *check.C) { @@ -102,7 +118,7 @@ func (s *IntegrationSuite) TearDownTest(c *check.C) { } s.tmpWorkdir = "" - s.Config = nil + s.cluster = nil } func (s *IntegrationSuite) RunGit(c *check.C, token, gitCmd, repo string, args ...string) error {