summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/minio/minio-go/pkg/s3signer
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/minio-go/pkg/s3signer')
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go109
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go36
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go50
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go71
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go104
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go75
6 files changed, 0 insertions, 445 deletions
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go
deleted file mode 100644
index 297ab97be..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-streaming_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "bytes"
- "io/ioutil"
- "testing"
- "time"
-)
-
-func TestGetSeedSignature(t *testing.T) {
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- dataLen := 66560
- data := bytes.Repeat([]byte("a"), dataLen)
- body := ioutil.NopCloser(bytes.NewReader(data))
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", body)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.Host = "s3.amazonaws.com"
-
- reqTime, err := time.Parse("20060102T150405Z", "20130524T000000Z")
- if err != nil {
- t.Fatalf("Failed to parse time - %v", err)
- }
-
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", "us-east-1", int64(dataLen), reqTime)
- actualSeedSignature := req.Body.(*StreamingReader).seedSignature
-
- expectedSeedSignature := "38cab3af09aa15ddf29e26e36236f60fb6bfb6243a20797ae9a8183674526079"
- if actualSeedSignature != expectedSeedSignature {
- t.Errorf("Expected %s but received %s", expectedSeedSignature, actualSeedSignature)
- }
-}
-
-func TestChunkSignature(t *testing.T) {
- chunkData := bytes.Repeat([]byte("a"), 65536)
- reqTime, _ := time.Parse(iso8601DateFormat, "20130524T000000Z")
- previousSignature := "4f232c4386841ef735655705268965c44a0e4690baa4adea153f7db9fa80a0a9"
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- expectedSignature := "ad80c730a21e5b8d04586a2213dd63b9a0e99e0e2307b0ade35a65485a288648"
- actualSignature := buildChunkSignature(chunkData, reqTime, location, previousSignature, secretAccessKeyID)
- if actualSignature != expectedSignature {
- t.Errorf("Expected %s but received %s", expectedSignature, actualSignature)
- }
-}
-
-func TestSetStreamingAuthorization(t *testing.T) {
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", nil)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.Host = ""
- req.URL.Host = "s3.amazonaws.com"
-
- dataLen := int64(65 * 1024)
- reqTime, _ := time.Parse(iso8601DateFormat, "20130524T000000Z")
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", location, dataLen, reqTime)
-
- expectedAuthorization := "AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-decoded-content-length;x-amz-storage-class,Signature=38cab3af09aa15ddf29e26e36236f60fb6bfb6243a20797ae9a8183674526079"
-
- actualAuthorization := req.Header.Get("Authorization")
- if actualAuthorization != expectedAuthorization {
- t.Errorf("Expected %s but received %s", expectedAuthorization, actualAuthorization)
- }
-}
-
-func TestStreamingReader(t *testing.T) {
- reqTime, _ := time.Parse("20060102T150405Z", "20130524T000000Z")
- location := "us-east-1"
- secretAccessKeyID := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
- accessKeyID := "AKIAIOSFODNN7EXAMPLE"
- dataLen := int64(65 * 1024)
-
- req := NewRequest("PUT", "/examplebucket/chunkObject.txt", nil)
- req.Header.Set("x-amz-storage-class", "REDUCED_REDUNDANCY")
- req.ContentLength = 65 * 1024
- req.Host = ""
- req.URL.Host = "s3.amazonaws.com"
-
- baseReader := ioutil.NopCloser(bytes.NewReader(bytes.Repeat([]byte("a"), 65*1024)))
- req.Body = baseReader
- req = StreamingSignV4(req, accessKeyID, secretAccessKeyID, "", location, dataLen, reqTime)
-
- b, err := ioutil.ReadAll(req.Body)
- if err != nil {
- t.Errorf("Expected no error but received %v %d", err, len(b))
- }
- req.Body.Close()
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go
deleted file mode 100644
index 042b6e65c..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v2_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "sort"
- "testing"
-)
-
-// Tests for 'func TestResourceListSorting(t *testing.T)'.
-func TestResourceListSorting(t *testing.T) {
- sortedResourceList := make([]string, len(resourceList))
- copy(sortedResourceList, resourceList)
- sort.Strings(sortedResourceList)
- for i := 0; i < len(resourceList); i++ {
- if resourceList[i] != sortedResourceList[i] {
- t.Errorf("Expected resourceList[%d] = \"%s\", resourceList is not correctly sorted.", i, sortedResourceList[i])
- break
- }
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go
deleted file mode 100644
index a109a4f2a..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature-v4_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "io"
- "net/http"
- "strings"
- "testing"
-)
-
-func TestRequestHost(t *testing.T) {
- req, _ := buildRequest("dynamodb", "us-east-1", "{}")
- req.URL.RawQuery = "Foo=z&Foo=o&Foo=m&Foo=a"
- req.Host = "myhost"
- canonicalHeaders := getCanonicalHeaders(*req, v4IgnoredHeaders)
-
- if !strings.Contains(canonicalHeaders, "host:"+req.Host) {
- t.Errorf("canonical host header invalid")
- }
-}
-
-func buildRequest(serviceName, region, body string) (*http.Request, io.ReadSeeker) {
- endpoint := "https://" + serviceName + "." + region + ".amazonaws.com"
- reader := strings.NewReader(body)
- req, _ := http.NewRequest("POST", endpoint, reader)
- req.URL.Opaque = "//example.org/bucket/key-._~,!@#$%^&*()"
- req.Header.Add("X-Amz-Target", "prefix.Operation")
- req.Header.Add("Content-Type", "application/x-amz-json-1.0")
- req.Header.Add("Content-Length", string(len(body)))
- req.Header.Add("X-Amz-Meta-Other-Header", "some-value=!@#$%^&* (+)")
- req.Header.Add("X-Amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
- req.Header.Add("X-amz-Meta-Other-Header_With_Underscore", "some-value=!@#$%^&* (+)")
- return req, reader
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go
deleted file mode 100644
index d53483e4e..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/request-signature_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "net/http"
- "strings"
- "testing"
-)
-
-// Tests signature calculation.
-func TestSignatureCalculation(t *testing.T) {
- req, err := http.NewRequest("GET", "https://s3.amazonaws.com", nil)
- if err != nil {
- t.Fatal("Error:", err)
- }
- req = SignV4(*req, "", "", "", "us-east-1")
- if req.Header.Get("Authorization") != "" {
- t.Fatal("Error: anonymous credentials should not have Authorization header.")
- }
-
- req = PreSignV4(*req, "", "", "", "us-east-1", 0)
- if strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
- t.Fatal("Error: anonymous credentials should not have Signature query resource.")
- }
-
- req = SignV2(*req, "", "")
- if req.Header.Get("Authorization") != "" {
- t.Fatal("Error: anonymous credentials should not have Authorization header.")
- }
-
- req = PreSignV2(*req, "", "", 0)
- if strings.Contains(req.URL.RawQuery, "Signature") {
- t.Fatal("Error: anonymous credentials should not have Signature query resource.")
- }
-
- req = SignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1")
- if req.Header.Get("Authorization") == "" {
- t.Fatal("Error: normal credentials should have Authorization header.")
- }
-
- req = PreSignV4(*req, "ACCESS-KEY", "SECRET-KEY", "", "us-east-1", 0)
- if !strings.Contains(req.URL.RawQuery, "X-Amz-Signature") {
- t.Fatal("Error: normal credentials should have Signature query resource.")
- }
-
- req = SignV2(*req, "ACCESS-KEY", "SECRET-KEY")
- if req.Header.Get("Authorization") == "" {
- t.Fatal("Error: normal credentials should have Authorization header.")
- }
-
- req = PreSignV2(*req, "ACCESS-KEY", "SECRET-KEY", 0)
- if !strings.Contains(req.URL.RawQuery, "Signature") {
- t.Fatal("Error: normal credentials should not have Signature query resource.")
- }
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go
deleted file mode 100644
index cf96d66c8..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/test-utils_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "bufio"
- "bytes"
- "crypto/tls"
- "io"
- "io/ioutil"
- "net/http"
- "strings"
-)
-
-// N B minio-go should compile on go1.5.3 onwards and httptest package is
-// available only from go.1.7.x. The following function is taken from
-// Go httptest package to be able to build on older versions of Go.
-
-// NewRequest returns a new incoming server Request, suitable
-// for passing to an http.Handler for testing.
-//
-// The target is the RFC 7230 "request-target": it may be either a
-// path or an absolute URL. If target is an absolute URL, the host name
-// from the URL is used. Otherwise, "example.com" is used.
-//
-// The TLS field is set to a non-nil dummy value if target has scheme
-// "https".
-//
-// The Request.Proto is always HTTP/1.1.
-//
-// An empty method means "GET".
-//
-// The provided body may be nil. If the body is of type *bytes.Reader,
-// *strings.Reader, or *bytes.Buffer, the Request.ContentLength is
-// set.
-//
-// NewRequest panics on error for ease of use in testing, where a
-// panic is acceptable.
-func NewRequest(method, target string, body io.Reader) *http.Request {
- if method == "" {
- method = "GET"
- }
- req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(method + " " + target + " HTTP/1.0\r\n\r\n")))
- if err != nil {
- panic("invalid NewRequest arguments; " + err.Error())
- }
-
- // HTTP/1.0 was used above to avoid needing a Host field. Change it to 1.1 here.
- req.Proto = "HTTP/1.1"
- req.ProtoMinor = 1
- req.Close = false
-
- if body != nil {
- switch v := body.(type) {
- case *bytes.Buffer:
- req.ContentLength = int64(v.Len())
- case *bytes.Reader:
- req.ContentLength = int64(v.Len())
- case *strings.Reader:
- req.ContentLength = int64(v.Len())
- default:
- req.ContentLength = -1
- }
- if rc, ok := body.(io.ReadCloser); ok {
- req.Body = rc
- } else {
- req.Body = ioutil.NopCloser(body)
- }
- }
-
- // 192.0.2.0/24 is "TEST-NET" in RFC 5737 for use solely in
- // documentation and example source code and should not be
- // used publicly.
- req.RemoteAddr = "192.0.2.1:1234"
-
- if req.Host == "" {
- req.Host = "example.com"
- }
-
- if strings.HasPrefix(target, "https://") {
- req.TLS = &tls.ConnectionState{
- Version: tls.VersionTLS12,
- HandshakeComplete: true,
- ServerName: req.Host,
- }
- }
-
- return req
-}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go b/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go
deleted file mode 100644
index 407eddab3..000000000
--- a/vendor/github.com/minio/minio-go/pkg/s3signer/utils_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package s3signer
-
-import (
- "fmt"
- "net/http"
- "net/url"
- "testing"
-)
-
-// Tests url encoding.
-func TestEncodeURL2Path(t *testing.T) {
- type urlStrings struct {
- bucketName string
- objName string
- encodedObjName string
- }
-
- bucketName := "bucketName"
- want := []urlStrings{
- {
- bucketName: "bucketName",
- objName: "本語",
- encodedObjName: "%E6%9C%AC%E8%AA%9E",
- },
- {
- bucketName: "bucketName",
- objName: "本語.1",
- encodedObjName: "%E6%9C%AC%E8%AA%9E.1",
- },
- {
- objName: ">123>3123123",
- bucketName: "bucketName",
- encodedObjName: "%3E123%3E3123123",
- },
- {
- bucketName: "bucketName",
- objName: "test 1 2.txt",
- encodedObjName: "test%201%202.txt",
- },
- {
- bucketName: "test.bucketName",
- objName: "test++ 1.txt",
- encodedObjName: "test%2B%2B%201.txt",
- },
- }
-
- for _, o := range want {
- u, err := url.Parse(fmt.Sprintf("https://%s.s3.amazonaws.com/%s", bucketName, o.objName))
- if err != nil {
- t.Fatal("Error:", err)
- }
- urlPath := "/" + bucketName + "/" + o.encodedObjName
- if urlPath != encodeURL2Path(&http.Request{URL: u}) {
- t.Fatal("Error")
- }
- }
-
-}