[ARVADOS] updated: 2.1.0-216-g2f8da8b76

Git user git at public.arvados.org
Fri Dec 11 05:44:01 UTC 2020


Summary of changes:
 services/keep-web/s3_test.go | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

       via  2f8da8b76071a44b0ce28638cf5322b24e15c73d (commit)
      from  8d4900e4c7db1ec09aec4bd54e94052b5d2b5c57 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 2f8da8b76071a44b0ce28638cf5322b24e15c73d
Author: Tom Clegg <tom at curii.com>
Date:   Fri Dec 11 00:43:40 2020 -0500

    17208: Add test case.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/keep-web/s3_test.go b/services/keep-web/s3_test.go
index 3a06270b0..52ef79509 100644
--- a/services/keep-web/s3_test.go
+++ b/services/keep-web/s3_test.go
@@ -7,6 +7,7 @@ package main
 import (
 	"bytes"
 	"crypto/rand"
+	"crypto/sha256"
 	"fmt"
 	"io/ioutil"
 	"net/http"
@@ -545,6 +546,38 @@ func (s *IntegrationSuite) TestS3VirtualHostStyleRequests(c *check.C) {
 	}
 }
 
+func (s *IntegrationSuite) TestS3NormalizeURIForSignature(c *check.C) {
+	stage := s.s3setup(c)
+	defer stage.teardown(c)
+	for _, trial := range []struct {
+		rawPath        string
+		normalizedPath string
+	}{
+		{"/foo", "/foo"},             // boring case
+		{"/foo%5fbar", "/foo_bar"},   // _ must not be escaped
+		{"/foo%2fbar", "/foo/bar"},   // / must not be escaped
+		{"/(foo)", "/%28foo%29"},     // () must be escaped
+		{"/foo%5bbar", "/foo%5Bbar"}, // %XX must be uppercase
+	} {
+		date := time.Now().UTC().Format("20060102T150405Z")
+		scope := "20200202/fakeregion/S3/aws4_request"
+		canonicalRequest := fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s", "GET", trial.normalizedPath, "", "host:host.example.com\n", "host", "")
+		c.Logf("canonicalRequest %q", canonicalRequest)
+		expect := fmt.Sprintf("%s\n%s\n%s\n%s", s3SignAlgorithm, date, scope, hashdigest(sha256.New(), canonicalRequest))
+		c.Logf("expected stringToSign %q", expect)
+
+		req, err := http.NewRequest("GET", "https://host.example.com"+trial.rawPath, nil)
+		req.Header.Set("X-Amz-Date", date)
+		req.Host = "host.example.com"
+
+		obtained, err := s3stringToSign(s3SignAlgorithm, scope, "host", req)
+		if !c.Check(err, check.IsNil) {
+			continue
+		}
+		c.Check(obtained, check.Equals, expect)
+	}
+}
+
 func (s *IntegrationSuite) TestS3GetBucketVersioning(c *check.C) {
 	stage := s.s3setup(c)
 	defer stage.teardown(c)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list