X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/df17ea1c927da5ac2955e9cc83b6d7ab88085fdb..1c50d29ea10fa90a379ee1d3fe7d8e05681d8622:/services/keep-web/s3_test.go diff --git a/services/keep-web/s3_test.go b/services/keep-web/s3_test.go index 21ad974bb9..aa91d82ae3 100644 --- a/services/keep-web/s3_test.go +++ b/services/keep-web/s3_test.go @@ -83,6 +83,10 @@ func (s *IntegrationSuite) s3setup(c *check.C) s3stage { "object": map[string]interface{}{"key": map[string]interface{}{"key2": "value⛵"}}, "nonascii": "⛵", "newline": "foo\r\nX-Bad: header", + // This key cannot be expressed as a MIME + // header key, so it will be silently skipped + // (see "Inject" in PropertiesAsMetadata test) + "a: a\r\nInject": "bogus", }, }}) c.Assert(err, check.IsNil) @@ -259,7 +263,7 @@ func (s *IntegrationSuite) TestS3PropertiesAsMetadata(c *check.C) { "Array": `["element1","element2"]`, "Object": mime.BEncoding.Encode("UTF-8", `{"key":{"key2":"value⛵"}}`), "Nonascii": "=?UTF-8?b?4pu1?=", - "Newline": "foo X-Bad: header", + "Newline": mime.BEncoding.Encode("UTF-8", "foo\r\nX-Bad: header"), } expectSubprojectTags := map[string]string{ "Subproject_properties_key": "subproject properties value", @@ -281,6 +285,7 @@ func (s *IntegrationSuite) TestS3PropertiesAsMetadata(c *check.C) { rdr.Close() c.Check(content, check.HasLen, 4) s.checkMetaEquals(c, hdr, expectCollectionTags) + c.Check(hdr["Inject"], check.IsNil) c.Log("HEAD bucket with metadata from collection") resp, err = stage.collbucket.Head("/", nil) @@ -311,14 +316,14 @@ func (s *IntegrationSuite) TestS3PropertiesAsMetadata(c *check.C) { func (s *IntegrationSuite) TestS3CollectionPutObjectSuccess(c *check.C) { stage := s.s3setup(c) defer stage.teardown(c) - s.testS3PutObjectSuccess(c, stage.collbucket, "") + s.testS3PutObjectSuccess(c, stage.collbucket, "", stage.coll.UUID) } func (s *IntegrationSuite) TestS3ProjectPutObjectSuccess(c *check.C) { stage := s.s3setup(c) defer stage.teardown(c) - s.testS3PutObjectSuccess(c, stage.projbucket, stage.coll.Name+"/") + s.testS3PutObjectSuccess(c, stage.projbucket, stage.coll.Name+"/", stage.coll.UUID) } -func (s *IntegrationSuite) testS3PutObjectSuccess(c *check.C, bucket *s3.Bucket, prefix string) { +func (s *IntegrationSuite) testS3PutObjectSuccess(c *check.C, bucket *s3.Bucket, prefix string, collUUID string) { for _, trial := range []struct { path string size int @@ -362,7 +367,7 @@ func (s *IntegrationSuite) testS3PutObjectSuccess(c *check.C, bucket *s3.Bucket, if !c.Check(err, check.NotNil) { continue } - c.Check(err.(*s3.Error).StatusCode, check.Equals, 404) + c.Check(err.(*s3.Error).StatusCode, check.Equals, http.StatusNotFound) c.Check(err.(*s3.Error).Code, check.Equals, `NoSuchKey`) if !c.Check(err, check.ErrorMatches, `The specified key does not exist.`) { continue @@ -385,6 +390,14 @@ func (s *IntegrationSuite) testS3PutObjectSuccess(c *check.C, bucket *s3.Bucket, c.Check(err, check.IsNil) c.Check(buf2, check.HasLen, len(buf)) c.Check(bytes.Equal(buf, buf2), check.Equals, true) + + // Check that the change is immediately visible via + // (non-S3) webdav request. + _, resp := s.do("GET", "http://"+collUUID+".keep-web.example/"+trial.path, arvadostest.ActiveTokenV2, nil) + c.Check(resp.Code, check.Equals, http.StatusOK) + if !strings.HasSuffix(trial.path, "/") { + c.Check(resp.Body.Len(), check.Equals, trial.size) + } } }