diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-01-29 14:17:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 14:17:40 -0800 |
commit | 961c04cae992eadb42d286d2f85f8a675bdc68c8 (patch) | |
tree | 3408f2d06f847e966c53485e2d54c692cdd037c1 /vendor/github.com/minio/minio-go/utils_test.go | |
parent | 8d66523ba7d9a77129844be476732ebfd5272d64 (diff) | |
download | chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.gz chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.tar.bz2 chat-961c04cae992eadb42d286d2f85f8a675bdc68c8.zip |
Upgrading server dependancies (#8154)
Diffstat (limited to 'vendor/github.com/minio/minio-go/utils_test.go')
-rw-r--r-- | vendor/github.com/minio/minio-go/utils_test.go | 116 |
1 files changed, 114 insertions, 2 deletions
diff --git a/vendor/github.com/minio/minio-go/utils_test.go b/vendor/github.com/minio/minio-go/utils_test.go index ba297112e..5411cc91a 100644 --- a/vendor/github.com/minio/minio-go/utils_test.go +++ b/vendor/github.com/minio/minio-go/utils_test.go @@ -1,5 +1,6 @@ /* - * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc. + * 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. @@ -13,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package minio import ( @@ -80,8 +82,10 @@ func TestGetEndpointURL(t *testing.T) { }{ {"s3.amazonaws.com", true, "https://s3.amazonaws.com", nil, true}, {"s3.cn-north-1.amazonaws.com.cn", true, "https://s3.cn-north-1.amazonaws.com.cn", nil, true}, + {"s3.cn-northwest-1.amazonaws.com.cn", true, "https://s3.cn-northwest-1.amazonaws.com.cn", nil, true}, {"s3.amazonaws.com", false, "http://s3.amazonaws.com", nil, true}, {"s3.cn-north-1.amazonaws.com.cn", false, "http://s3.cn-north-1.amazonaws.com.cn", nil, true}, + {"s3.cn-northwest-1.amazonaws.com.cn", false, "http://s3.cn-northwest-1.amazonaws.com.cn", nil, true}, {"192.168.1.1:9000", false, "http://192.168.1.1:9000", nil, true}, {"192.168.1.1:9000", true, "https://192.168.1.1:9000", nil, true}, {"s3.amazonaws.com:443", true, "https://s3.amazonaws.com:443", nil, true}, @@ -198,7 +202,13 @@ func TestDefaultBucketLocation(t *testing.T) { regionOverride: "", expectedLocation: "cn-north-1", }, - // No region provided, no standard region strings provided as well. - Test 5. + // China region should be honored, region override not provided. - Test 5. + { + endpointURL: url.URL{Host: "s3.cn-northwest-1.amazonaws.com.cn"}, + regionOverride: "", + expectedLocation: "cn-northwest-1", + }, + // No region provided, no standard region strings provided as well. - Test 6. { endpointURL: url.URL{Host: "s3.amazonaws.com"}, regionOverride: "", @@ -289,3 +299,105 @@ func TestIsValidBucketName(t *testing.T) { } } + +// Tests if header is standard supported header +func TestIsStandardHeader(t *testing.T) { + testCases := []struct { + // Input. + header string + // Expected result. + expectedValue bool + }{ + {"content-encoding", true}, + {"content-type", true}, + {"cache-control", true}, + {"content-disposition", true}, + {"random-header", false}, + } + + for i, testCase := range testCases { + actual := isStandardHeader(testCase.header) + if actual != testCase.expectedValue { + t.Errorf("Test %d: Expected to pass, but failed", i+1) + } + } + +} + +// Tests if header is server encryption header +func TestIsSSEHeader(t *testing.T) { + testCases := []struct { + // Input. + header string + // Expected result. + expectedValue bool + }{ + {"x-amz-server-side-encryption", true}, + {"x-amz-server-side-encryption-aws-kms-key-id", true}, + {"x-amz-server-side-encryption-context", true}, + {"x-amz-server-side-encryption-customer-algorithm", true}, + {"x-amz-server-side-encryption-customer-key", true}, + {"x-amz-server-side-encryption-customer-key-MD5", true}, + {"random-header", false}, + } + + for i, testCase := range testCases { + actual := isSSEHeader(testCase.header) + if actual != testCase.expectedValue { + t.Errorf("Test %d: Expected to pass, but failed", i+1) + } + } +} + +// Tests if header is client encryption header +func TestIsCSEHeader(t *testing.T) { + testCases := []struct { + // Input. + header string + // Expected result. + expectedValue bool + }{ + {"x-amz-iv", true}, + {"x-amz-key", true}, + {"x-amz-matdesc", true}, + {"x-amz-meta-x-amz-iv", true}, + {"x-amz-meta-x-amz-key", true}, + {"x-amz-meta-x-amz-matdesc", true}, + {"random-header", false}, + } + + for i, testCase := range testCases { + actual := isCSEHeader(testCase.header) + if actual != testCase.expectedValue { + t.Errorf("Test %d: Expected to pass, but failed", i+1) + } + } + +} + +// Tests if header is x-amz-meta or x-amz-acl +func TestIsAmzHeader(t *testing.T) { + testCases := []struct { + // Input. + header string + // Expected result. + expectedValue bool + }{ + {"x-amz-iv", false}, + {"x-amz-key", false}, + {"x-amz-matdesc", false}, + {"x-amz-meta-x-amz-iv", true}, + {"x-amz-meta-x-amz-key", true}, + {"x-amz-meta-x-amz-matdesc", true}, + {"x-amz-acl", true}, + {"random-header", false}, + } + + for i, testCase := range testCases { + actual := isAmzHeader(testCase.header) + if actual != testCase.expectedValue { + t.Errorf("Test %d: Expected to pass, but failed", i+1) + } + } + +} |