vendor: update dropbox SDK to fix failing integration tests #2829

This commit is contained in:
Nick Craig-Wood 2018-12-26 15:17:03 +00:00
parent 39eac7a765
commit 1c01d0b84a
6 changed files with 45 additions and 14 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -37,7 +37,7 @@ const (
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "5.2.0"
sdkVersion = "5.4.0"
specVersion = "097e9ba"
)