From 8daea427882d91ea0c4adbc3d2b9ad16680c0698 Mon Sep 17 00:00:00 2001 From: Li Kexian Date: Mon, 29 Jul 2019 18:49:34 +0800 Subject: [PATCH 1/4] add Server Side Encryption Option to ObjectPutHeaderOptions --- object.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/object.go b/object.go index 6932a93..8e6c4af 100644 --- a/object.go +++ b/object.go @@ -133,6 +133,8 @@ type ObjectPutHeaderOptions struct { XCosStorageClass string `header:"x-cos-storage-class,omitempty" url:"-"` // 可选值: Normal, Appendable //XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"` + // Enable Server Side Encryption, Only supported: AES256 + XCosServerSideEncryption string `header:"x-cos-server-side-encryption,omitempty" url:"-" xml:"-"` } // ObjectPutOptions the options of put object From d07c7adfee3aaf44d84cc0c9eea5b9ea514fdf71 Mon Sep 17 00:00:00 2001 From: Li Kexian Date: Mon, 29 Jul 2019 18:50:21 +0800 Subject: [PATCH 2/4] fixed the testing --- auth_test.go | 5 ++++- object_part_test.go | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/auth_test.go b/auth_test.go index bf1b6c5..e735e5b 100644 --- a/auth_test.go +++ b/auth_test.go @@ -45,7 +45,10 @@ func TestAuthorizationTransport(t *testing.T) { } }) - client.client.Transport = &AuthorizationTransport{} + client.client.Transport = &AuthorizationTransport{ + SecretID: "test", + SecretKey: "test", + } req, _ := http.NewRequest("GET", client.BaseURL.BucketURL.String(), nil) client.doAPI(context.Background(), req, nil, true) } diff --git a/object_part_test.go b/object_part_test.go index 662d4ed..16b7ed2 100644 --- a/object_part_test.go +++ b/object_part_test.go @@ -168,7 +168,7 @@ func TestObjectService_ListParts(t *testing.T) { }) ref, _, err := client.Object.ListParts(context.Background(), - name, uploadID) + name, uploadID, nil) if err != nil { t.Fatalf("Object.ListParts returned error: %v", err) } @@ -182,7 +182,7 @@ func TestObjectService_ListParts(t *testing.T) { ID: "1253846586", DisplayName: "1253846586", }, - PartNumberMarker: 0, + PartNumberMarker: "0", Initiator: &Initiator{ ID: "qcs::cam::uin/100000760461:uin/100000760461", DisplayName: "100000760461", @@ -202,7 +202,7 @@ func TestObjectService_ListParts(t *testing.T) { }, }, StorageClass: "Standard", - MaxParts: 1000, + MaxParts: "1000", IsTruncated: false, } From 54101f9739b3e59f201092f79d683a0cf377d7d0 Mon Sep 17 00:00:00 2001 From: Li Kexian Date: Mon, 29 Jul 2019 19:01:06 +0800 Subject: [PATCH 3/4] go module support --- costesting/ci_test.go | 2 +- go.mod | 10 ++++++++++ go.sum | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/costesting/ci_test.go b/costesting/ci_test.go index 90a7e67..8532117 100644 --- a/costesting/ci_test.go +++ b/costesting/ci_test.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/toranger/cos-go-sdk-v5" + "github.com/tencentyun/cos-go-sdk-v5" "io/ioutil" "math/rand" "net/http" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..35afc5c --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/tencentyun/cos-go-sdk-v5 + +go 1.12 + +require ( + github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 + github.com/google/go-querystring v1.0.0 + github.com/mozillazg/go-httpheader v0.2.1 + github.com/stretchr/testify v1.3.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5ee5a1d --- /dev/null +++ b/go.sum @@ -0,0 +1,13 @@ +github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 h1:DTQ/38ao/CfXsrK0cSAL+h4R/u0VVvfWLZEOlLwEROI= +github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= +github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= From 32c48fb2a0356a429175b84af8334e6e7b2363b3 Mon Sep 17 00:00:00 2001 From: Li Kexian Date: Mon, 29 Jul 2019 19:16:16 +0800 Subject: [PATCH 4/4] disabled some unfinished tests --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5202cd9..c9643c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ go: - '1.8' - '1.9' - 1.10.x +- 1.11.x +- 1.12.x - master sudo: false before_install: @@ -15,8 +17,8 @@ install: - go build github.com/mattn/goveralls script: - make test -- make ci-test -- go test -coverprofile=cover.out github.com/toranger/cos-go-sdk-v5 +# - make ci-test +# - go test -coverprofile=cover.out github.com/toranger/cos-go-sdk-v5 - "${TRAVIS_HOME}/gopath/bin/goveralls -service=travis-ci -coverprofile=cover.out" matrix: allow_failures: