6260: status check added; still not working completely since invoking datamanager...
[arvados.git] / services / arv-git-httpd / server_test.go
index e5ddc29dec93b2a9a2f08fef9d7f31b9706da2dc..c1364ca75b22ce18a72c74ffadf9667a69bf1225 100644 (file)
@@ -18,6 +18,7 @@ const (
        spectatorToken = "zw2f4gwx8hw8cjre7yp6v1zylhrhn3m5gvjq73rtpwhmknrybu"
        activeToken    = "3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi"
        anonymousToken = "4kg6k6lzmp9kj4cpkcoxie964cmvjahbt4fod9zru44k4jqdmi"
+       expiredToken   = "2ym314ysp27sk7h943q6vtc378srb06se3pq6ghurylyf3pdmx"
 )
 
 // IntegrationSuite tests need an API server and an arv-git-httpd server
@@ -70,10 +71,42 @@ func (s *IntegrationSuite) TestNoPermission(c *check.C) {
        }
 }
 
+func (s *IntegrationSuite) TestExpiredToken(c *check.C) {
+       for _, repo := range []string{"active/foo.git", "active/foo/.git"} {
+               err := s.runGit(c, expiredToken, "fetch", repo)
+               c.Assert(err, check.ErrorMatches, `.* 500 while accessing.*`)
+       }
+}
+
+func (s *IntegrationSuite) TestInvalidToken(c *check.C) {
+       for _, repo := range []string{"active/foo.git", "active/foo/.git"} {
+               err := s.runGit(c, "s3cr3tp@ssw0rd", "fetch", repo)
+               c.Assert(err, check.ErrorMatches, `.* requested URL returned error.*`)
+       }
+}
+
+func (s *IntegrationSuite) TestShortToken(c *check.C) {
+       for _, repo := range []string{"active/foo.git", "active/foo/.git"} {
+               err := s.runGit(c, "s3cr3t", "fetch", repo)
+               c.Assert(err, check.ErrorMatches, `.* 500 while accessing.*`)
+       }
+}
+
+func (s *IntegrationSuite) TestShortTokenBadReq(c *check.C) {
+       for _, repo := range []string{"bogus"} {
+               err := s.runGit(c, "s3cr3t", "fetch", repo)
+               c.Assert(err, check.ErrorMatches, `.* requested URL returned error.*`)
+       }
+}
+
 func (s *IntegrationSuite) SetUpSuite(c *check.C) {
        arvadostest.StartAPI()
 }
 
+func (s *IntegrationSuite) TearDownSuite(c *check.C) {
+       arvadostest.StopAPI()
+}
+
 func (s *IntegrationSuite) SetUpTest(c *check.C) {
        arvadostest.ResetEnv()
        s.testServer = &server{}
@@ -103,7 +136,7 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) {
        c.Assert(err, check.Equals, nil)
 
        theConfig = &config{
-               Addr:       ":",
+               Addr:       ":0",
                GitCommand: "/usr/bin/git",
                Root:       s.tmpRepoRoot,
        }