From 1c01d0b84aabfd0367b3de73a238a0eed06da285 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 26 Dec 2018 15:17:03 +0000 Subject: [PATCH] vendor: update dropbox SDK to fix failing integration tests #2829 --- go.mod | 2 +- go.sum | 2 ++ .../dropbox/auth/sdk.go | 33 +++++++++++++++++-- .../dropbox/files/client.go | 18 +++++----- .../dropbox-sdk-go-unofficial/dropbox/sdk.go | 2 +- vendor/modules.txt | 2 +- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 8045b87f2..762c84e1b 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/cpuguy83/go-md2man v1.0.8 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/djherbis/times v1.1.0 - github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible + github.com/dropbox/dropbox-sdk-go-unofficial v5.4.0+incompatible github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9 // indirect github.com/goftp/server v0.0.0-20180914132916-1fd52c8552f1 github.com/google/go-querystring v1.0.0 // indirect diff --git a/go.sum b/go.sum index 46f11519c..eeada2786 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/dropbox/dropbox-sdk-go-unofficial v4.1.0+incompatible/go.mod h1:lr+Lh github.com/dropbox/dropbox-sdk-go-unofficial v5.0.0+incompatible h1:FQu9Ef2dkC8g2rQmcQmpXXeoRegXHODBfveKKZu6+e8= github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible h1:4HSS6BiPqvgsn/zrwt6KOYY+mw153zmhvewZIRh1+Ds= github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible/go.mod h1:lr+LhMM3F6Y3lW1T9j2U5l7QeuWm87N9+PPXo3yH4qY= +github.com/dropbox/dropbox-sdk-go-unofficial v5.4.0+incompatible h1:9jnukMIowLSo3SY7+GTwxmYJv4QC0LxXbo97zHWCyoc= +github.com/dropbox/dropbox-sdk-go-unofficial v5.4.0+incompatible/go.mod h1:lr+LhMM3F6Y3lW1T9j2U5l7QeuWm87N9+PPXo3yH4qY= github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9 h1:cC0Hbb+18DJ4i6ybqDybvj4wdIDS4vnD0QEci98PgM8= github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9/go.mod h1:GpOj6zuVBG3Inr9qjEnuVTgBlk2lZ1S9DcoFiXWyKss= github.com/goftp/server v0.0.0-20180914132916-1fd52c8552f1 h1:WjgeEHEDLGx56ndxS6FYi6qFjZGajSVHPuEPdpJ60cI= diff --git a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth/sdk.go b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth/sdk.go index c99539bcf..88564d9ae 100644 --- a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth/sdk.go +++ b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth/sdk.go @@ -9,6 +9,19 @@ import ( "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" ) +// AuthAPIError wraps AuthError +type AuthAPIError struct { + dropbox.APIError + AuthError *AuthError `json:"error"` +} + +// AccessAPIError wraps AccessError +type AccessAPIError struct { + dropbox.APIError + AccessError *AccessError `json:"error"` +} + +// RateLimitAPIError wraps RateLimitError type RateLimitAPIError struct { dropbox.APIError RateLimitError *RateLimitError `json:"error"` @@ -16,7 +29,22 @@ type RateLimitAPIError struct { // HandleCommonAuthErrors handles common authentication errors func HandleCommonAuthErrors(c dropbox.Config, resp *http.Response, body []byte) error { - if resp.StatusCode == http.StatusTooManyRequests { + switch resp.StatusCode { + case http.StatusUnauthorized: + var apiError AuthAPIError + if err := json.Unmarshal(body, &apiError); err != nil { + c.LogDebug("Error unmarshaling '%s' into JSON", body) + return err + } + return apiError + case http.StatusForbidden: + var apiError AccessAPIError + if err := json.Unmarshal(body, &apiError); err != nil { + c.LogDebug("Error unmarshaling '%s' into JSON", body) + return err + } + return apiError + case http.StatusTooManyRequests: var apiError RateLimitAPIError // Check content-type contentType, _, _ := mime.ParseMediaType(resp.Header.Get("content-type")) @@ -33,6 +61,7 @@ func HandleCommonAuthErrors(c dropbox.Config, resp *http.Response, body []byte) apiError.RateLimitError.RetryAfter = uint64(timeout) } return apiError + default: + return nil } - return nil } diff --git a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files/client.go b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files/client.go index 55c53fe9e..828fb7285 100644 --- a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files/client.go +++ b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files/client.go @@ -549,7 +549,7 @@ func (dbx *apiImpl) CopyV2(arg *RelocationArg) (res *RelocationResult, err error headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -695,7 +695,7 @@ func (dbx *apiImpl) CopyBatchV2(arg *RelocationBatchArgBase) (res *RelocationBat headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -830,7 +830,7 @@ func (dbx *apiImpl) CopyBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2 headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch/check", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch/check_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -1097,7 +1097,7 @@ func (dbx *apiImpl) CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResul headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -1364,7 +1364,7 @@ func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) { headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -2515,7 +2515,7 @@ func (dbx *apiImpl) MoveV2(arg *RelocationArg) (res *RelocationResult, err error headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -2661,7 +2661,7 @@ func (dbx *apiImpl) MoveBatchV2(arg *MoveBatchArg) (res *RelocationBatchV2Launch headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -2793,7 +2793,7 @@ func (dbx *apiImpl) MoveBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2 headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch/check", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch/check_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -3698,7 +3698,7 @@ func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content i headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append", headers, content) + req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append_v2", headers, content) if err != nil { return } diff --git a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sdk.go b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sdk.go index f13592b2a..6744fd4ce 100644 --- a/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sdk.go +++ b/vendor/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sdk.go @@ -37,7 +37,7 @@ const ( hostAPI = "api" hostContent = "content" hostNotify = "notify" - sdkVersion = "5.2.0" + sdkVersion = "5.4.0" specVersion = "097e9ba" ) diff --git a/vendor/modules.txt b/vendor/modules.txt index 5dd4f52f4..a8e155977 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -63,7 +63,7 @@ github.com/cpuguy83/go-md2man/md2man github.com/davecgh/go-spew/spew # github.com/djherbis/times v1.1.0 github.com/djherbis/times -# github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible +# github.com/dropbox/dropbox-sdk-go-unofficial v5.4.0+incompatible github.com/dropbox/dropbox-sdk-go-unofficial/dropbox github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common