diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a523a64cf..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/golang:1.12.6 - steps: - - checkout - - run: - name: "Install Dependencies" - command: | - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0 - touch .env - - run: - name: "Run Tests" - command: | - make test ARGS='-v -race -count=2 -coverprofile=coverage.txt -covermode=atomic ./...' - - run: - name: "Run Linter" - command: | - golangci-lint run --no-config --issues-exit-code=1 --enable-all --disable=vetshadow --disable=gocyclo --disable=unparam --disable=nakedret --disable=lll --disable=dupl --disable=gosec --disable=gochecknoinits --disable=gochecknoglobals --tests=false - golangci-lint run --no-config --issues-exit-code=0 --disable-all --enable=vetshadow --enable=gocyclo --enable=unparam --enable=nakedret --enable=lll --enable=dupl --enable=gosec --enable=gochecknoinits --enable=gochecknoglobals --deadline=120s - - run: - name: "Upload Coverage" - command: bash <(curl -s https://codecov.io/bash) diff --git a/.travis.yml b/.travis.yml index bf60f862d..2a89c13a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: - GO111MODULE=on go: - - "1.13" + - "1.15" before_script: - bash ./scripts/verify-gomod-tidy.sh diff --git a/go.mod b/go.mod index 526616884..5996aa468 100644 --- a/go.mod +++ b/go.mod @@ -6,4 +6,4 @@ require ( golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 ) -go 1.13 +go 1.15 diff --git a/k8s/go.mod b/k8s/go.mod index 992a911a5..26723554c 100644 --- a/k8s/go.mod +++ b/k8s/go.mod @@ -9,4 +9,4 @@ require ( replace github.com/linode/linodego => ../ -go 1.13 +go 1.15 diff --git a/object_storage_keys.go b/object_storage_keys.go index 9402963ff..bfe13b147 100644 --- a/object_storage_keys.go +++ b/object_storage_keys.go @@ -8,15 +8,26 @@ import ( // ObjectStorageKey represents a linode object storage key object type ObjectStorageKey struct { - ID int `json:"id"` - Label string `json:"label"` - AccessKey string `json:"access_key"` - SecretKey string `json:"secret_key"` + ID int `json:"id"` + Label string `json:"label"` + AccessKey string `json:"access_key"` + SecretKey string `json:"secret_key"` + Limited bool `json:"limited"` + BucketAccess *[]ObjectStorageKeyBucketAccess `json:"bucket_access"` +} + +// ObjectStorageKeyBucketAccess represents a linode limited object storage key's bucket access +type ObjectStorageKeyBucketAccess struct { + Cluster string `json:"cluster"` + BucketName string `json:"bucket_name"` + Permissions string `json:"permissions"` } // ObjectStorageKeyCreateOptions fields are those accepted by CreateObjectStorageKey type ObjectStorageKeyCreateOptions struct { - Label string `json:"label"` + Label string `json:"label"` + Limited bool `json:"limited,omitempty"` + BucketAccess *[]ObjectStorageKeyBucketAccess `json:"bucket_access"` } // ObjectStorageKeyUpdateOptions fields are those accepted by UpdateObjectStorageKey diff --git a/test/go.mod b/test/go.mod index a4b52f9de..7b0cbdfd5 100644 --- a/test/go.mod +++ b/test/go.mod @@ -1,15 +1,15 @@ module test -go 1.13 +go 1.15 require ( - github.com/dnaeon/go-vcr v1.0.1 - github.com/google/go-cmp v0.5.2 - github.com/linode/linodego v0.20.1 - github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000 - golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d - gopkg.in/yaml.v2 v2.3.0 // indirect - k8s.io/client-go v0.18.3 + github.com/dnaeon/go-vcr v1.0.1 + github.com/google/go-cmp v0.5.2 + github.com/linode/linodego v0.20.1 + github.com/linode/linodego/k8s v0.0.0-00010101000000-000000000000 + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d + gopkg.in/yaml.v2 v2.3.0 // indirect + k8s.io/client-go v0.18.3 ) replace github.com/linode/linodego => ../ diff --git a/test/integration/fixtures/TestCreateObjectStorageBucket.yaml b/test/integration/fixtures/TestCreateObjectStorageBucket.yaml index 98e4d2972..271a62f93 100644 --- a/test/integration/fixtures/TestCreateObjectStorageBucket.yaml +++ b/test/integration/fixtures/TestCreateObjectStorageBucket.yaml @@ -2,22 +2,19 @@ version: 1 interactions: - request: - body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}' + body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/buckets method: POST response: - body: '{"created": "2018-01-02T03:04:05", "hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com", - "label": "linodego-test-bucket-1570022485501837000", "cluster": "us-east-1"}' + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:30", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -31,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "201" + - "206" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:34 GMT - Retry-After: - - "117" Server: - nginx Strict-Transport-Security: @@ -59,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597872" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -77,13 +64,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 method: DELETE response: body: '{}' @@ -100,18 +85,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:34 GMT - Retry-After: - - "119" Server: - nginx Strict-Transport-Security: @@ -119,7 +98,7 @@ interactions: Vary: - Authorization, X-Filter X-Accepted-Oauth-Scopes: - - object_storage:read_only + - object_storage:read_write X-Content-Type-Options: - nosniff X-Frame-Options: @@ -128,13 +107,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597874" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestGetObjectStorageBucket_found.yaml b/test/integration/fixtures/TestGetObjectStorageBucket_found.yaml index 3aace4ee4..34ef8399f 100644 --- a/test/integration/fixtures/TestGetObjectStorageBucket_found.yaml +++ b/test/integration/fixtures/TestGetObjectStorageBucket_found.yaml @@ -2,23 +2,19 @@ version: 1 interactions: - request: - body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}' + body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/buckets method: POST response: - body: '{"cluster": "us-east-1", - "created": "2018-01-02T03:04:05", "label": "linodego-test-bucket-1570022485501837000", - "hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com"}' + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:35", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -32,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "201" + - "206" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:38 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -60,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597877" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -78,18 +64,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 method: GET response: - body: '{"hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com", - "label": "linodego-test-bucket-1570022485501837000", "cluster": - "us-east-1", "created": "2018-01-02T03:04:05"}' + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:35", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -104,18 +86,12 @@ interactions: Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "201" + - "206" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:38 GMT - Retry-After: - - "113" Server: - nginx Strict-Transport-Security: @@ -133,13 +109,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "398" - X-Ratelimit-Reset: - - "1569597872" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -151,13 +123,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 method: DELETE response: body: '{}' @@ -174,18 +144,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:39 GMT - Retry-After: - - "119" Server: - nginx Strict-Transport-Security: @@ -193,7 +157,7 @@ interactions: Vary: - Authorization, X-Filter X-Accepted-Oauth-Scopes: - - object_storage:read_only + - object_storage:read_write X-Content-Type-Options: - nosniff X-Frame-Options: @@ -202,13 +166,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597879" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestGetObjectStorageBucket_missing.yaml b/test/integration/fixtures/TestGetObjectStorageBucket_missing.yaml index 7088e6c63..614b21886 100644 --- a/test/integration/fixtures/TestGetObjectStorageBucket_missing.yaml +++ b/test/integration/fixtures/TestGetObjectStorageBucket_missing.yaml @@ -2,23 +2,19 @@ version: 1 interactions: - request: - body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}' + body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/buckets method: POST response: - body: '{"cluster": "us-east-1", - "created": "2018-01-02T03:04:05", "label": "linodego-test-bucket-1570022485501837000", - "hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com"}' + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:33", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -32,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "201" + - "206" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:36 GMT - Retry-After: - - "117" Server: - nginx Strict-Transport-Security: @@ -60,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597874" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -78,13 +64,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-west-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-west-1/linodego-test-bucket-1603309943521033000 method: GET response: body: '{"errors": [{"reason": "Not found"}]}' @@ -97,16 +81,10 @@ interactions: - '*' Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - Connection: - - keep-alive Content-Length: - "37" Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:36 GMT - Retry-After: - - "119" Server: - nginx Vary: @@ -118,14 +96,10 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597876" + - "800" X-Spec-Version: - - 4.5.0 - status: 404 NOT FOUND + - 4.78.3 + status: 404 Not Found code: 404 duration: "" - request: @@ -134,13 +108,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 method: DELETE response: body: '{}' @@ -157,18 +129,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:37 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -176,7 +142,7 @@ interactions: Vary: - Authorization, X-Filter X-Accepted-Oauth-Scopes: - - object_storage:read_only + - object_storage:read_write X-Content-Type-Options: - nosniff X-Frame-Options: @@ -185,13 +151,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597876" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestGetObjectStorageKey_found.yaml b/test/integration/fixtures/TestGetObjectStorageKey_found.yaml index f52bbe392..e9edecad0 100644 --- a/test/integration/fixtures/TestGetObjectStorageKey_found.yaml +++ b/test/integration/fixtures/TestGetObjectStorageKey_found.yaml @@ -2,22 +2,19 @@ version: 1 interactions: - request: - body: '{"label":"lpq6h62z88m4-linodego-testing"}' + body: '{"label":"lpq6h62z88m4-linodego-testing","bucket_access":null}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/keys method: POST response: - body: '{"label": "lpq6h62z88m4-linodego-testing", "id": 348, "access_key": "[REDACTED]", - "secret_key": "[REDACTED]"}' + body: '{"id": 48239, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": false, "bucket_access": null}' headers: Access-Control-Allow-Credentials: - "true" @@ -31,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "149" + - "192" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:42:03 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -59,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1563824575" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -77,17 +64,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/348 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48239 method: GET response: - body: '{"label": "lpq6h62z88m4-linodego-testing", "id": 348, "access_key": "[REDACTED]", - "secret_key": "[REDACTED]"}' + body: '{"id": 48239, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[REDACTED]", "limited": false, "bucket_access": null}' headers: Access-Control-Allow-Credentials: - "true" @@ -102,18 +86,12 @@ interactions: Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "119" + - "162" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:42:03 GMT - Retry-After: - - "43" Server: - nginx Strict-Transport-Security: @@ -131,13 +109,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "397" - X-Ratelimit-Reset: - - "1563824500" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -149,13 +123,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/348 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48239 method: DELETE response: body: '{}' @@ -172,18 +144,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:42:03 GMT - Retry-After: - - "103" Server: - nginx Strict-Transport-Security: @@ -200,13 +166,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "397" - X-Ratelimit-Reset: - - "1563824560" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestGetObjectStorageKey_missing.yaml b/test/integration/fixtures/TestGetObjectStorageKey_missing.yaml index 4c539bcbe..5968838c5 100644 --- a/test/integration/fixtures/TestGetObjectStorageKey_missing.yaml +++ b/test/integration/fixtures/TestGetObjectStorageKey_missing.yaml @@ -7,12 +7,10 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/keys/123 method: GET response: @@ -26,16 +24,10 @@ interactions: - '*' Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - Connection: - - keep-alive Content-Length: - "37" Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:42:02 GMT - Retry-After: - - "43" Server: - nginx Vary: @@ -47,13 +39,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "397" - X-Ratelimit-Reset: - - "1563824499" + - "800" X-Spec-Version: - - 4.2.3 - status: 404 NOT FOUND + - 4.78.3 + status: 404 Not Found code: 404 duration: "" diff --git a/test/integration/fixtures/TestLimitedObjectStorageKeys.yaml b/test/integration/fixtures/TestLimitedObjectStorageKeys.yaml new file mode 100644 index 000000000..e2c1c26a6 --- /dev/null +++ b/test/integration/fixtures/TestLimitedObjectStorageKeys.yaml @@ -0,0 +1,117 @@ +--- +version: 1 +interactions: +- request: + body: '{"label":"lpq6h62z88m4-linodego-testing","limited":true,"bucket_access":[{"cluster":"us-east-1","bucket_name":"linodego-test-bucket-1603309943521033000","permissions":"read_only"},{"cluster":"us-east-1","bucket_name":"linodego-test-bucket-1603309943521033000","permissions":"read_write"}]}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys + method: POST + response: + body: '{"id": 48242, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": true, "bucket_access": [{"cluster": "us-east-1", "bucket_name": "linodego-test-bucket-1603309943521033000", "permissions": "read_only"}, {"cluster": "us-east-1", "bucket_name": "linodego-test-bucket-1603309943521033000", "permissions": "read_write"}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "414" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48242 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestLimitedObjectStorageKeys_bucket.yaml b/test/integration/fixtures/TestLimitedObjectStorageKeys_bucket.yaml new file mode 100644 index 000000000..8b559058e --- /dev/null +++ b/test/integration/fixtures/TestLimitedObjectStorageKeys_bucket.yaml @@ -0,0 +1,117 @@ +--- +version: 1 +interactions: +- request: + body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets + method: POST + response: + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:57", "cluster": "us-east-1", "size": 0}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "206" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestLimitedObjectStorageKeys_noaccess.yaml b/test/integration/fixtures/TestLimitedObjectStorageKeys_noaccess.yaml new file mode 100644 index 000000000..eb48387cc --- /dev/null +++ b/test/integration/fixtures/TestLimitedObjectStorageKeys_noaccess.yaml @@ -0,0 +1,117 @@ +--- +version: 1 +interactions: +- request: + body: '{"label":"lpq6h62z88m4-linodego-testing","limited":true,"bucket_access":[]}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys + method: POST + response: + body: '{"id": 48243, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": true, "bucket_access": []}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "189" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48243 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "800" + X-Spec-Version: + - 4.78.3 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestListObjectStorageBucket.yaml b/test/integration/fixtures/TestListObjectStorageBucket.yaml index b939d034b..9ac37f917 100644 --- a/test/integration/fixtures/TestListObjectStorageBucket.yaml +++ b/test/integration/fixtures/TestListObjectStorageBucket.yaml @@ -2,23 +2,19 @@ version: 1 interactions: - request: - body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1570022485501837000"}' + body: '{"cluster":"us-east-1","label":"linodego-test-bucket-1603309943521033000"}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/buckets method: POST response: - body: '{"hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com", - "cluster": "us-east-1", "label": "linodego-test-bucket-1570022485501837000", - "created": "2018-01-02T03:04:05"}' + body: '{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:38", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -32,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "201" + - "206" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:41 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -60,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597880" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -78,19 +64,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/buckets method: GET response: - body: '{"data": [{"hostname": "linodego-test-bucket-1570022485501837000.us-east-1.linodeobjects.com", - "label": "linodego-test-bucket-1570022485501837000", "cluster": - "us-east-1", "created": "2018-01-02T03:04:05"}], - "pages": 1, "page": 1, "results": 1}' + body: '{"page": 1, "pages": 1, "results": 2, "data": [{"hostname": "linodego-test-bucket-1603309943521033000.us-east-1.linodeobjects.com", "label": "linodego-test-bucket-1603309943521033000", "created": "2020-10-21T19:52:38", "cluster": "us-east-1", "size": 0}, {"hostname": "testing-bucket-bosh-stemcells.us-east-1.linodeobjects.com", "label": "testing-bucket-bosh-stemcells", "created": "2020-05-27T12:31:57", "cluster": "us-east-1", "size": 108070491}]}' headers: Access-Control-Allow-Credentials: - "true" @@ -105,18 +86,12 @@ interactions: Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "250" + - "449" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:41 GMT - Retry-After: - - "119" Server: - nginx Strict-Transport-Security: @@ -134,13 +109,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569597881" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -152,13 +123,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1570022485501837000 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/buckets/us-east-1/linodego-test-bucket-1603309943521033000 method: DELETE response: body: '{}' @@ -175,18 +144,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 15:22:42 GMT - Retry-After: - - "113" Server: - nginx Strict-Transport-Security: @@ -194,7 +157,7 @@ interactions: Vary: - Authorization, X-Filter X-Accepted-Oauth-Scopes: - - object_storage:read_only + - object_storage:read_write X-Content-Type-Options: - nosniff X-Frame-Options: @@ -203,13 +166,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "398" - X-Ratelimit-Reset: - - "1569597876" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestListObjectStorageClusters.yaml b/test/integration/fixtures/TestListObjectStorageClusters.yaml index c5eb4be14..d2cb01941 100644 --- a/test/integration/fixtures/TestListObjectStorageClusters.yaml +++ b/test/integration/fixtures/TestListObjectStorageClusters.yaml @@ -7,18 +7,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/clusters method: GET response: - body: '{"pages": 1, "results": 1, "data": [{"domain": "us-east-1.linodeobjects.com", - "id": "us-east-1", "region": "us-east", "status": "available", "static_site_domain": - "website-us-east-1.linodeobjects.com"}], "page": 1}' + body: '{"data": [{"id": "us-east-1", "region": "us-east", "status": "available", "domain": "us-east-1.linodeobjects.com", "static_site_domain": "website-us-east-1.linodeobjects.com"}, {"id": "eu-central-1", "region": "eu-central", "status": "available", "domain": "eu-central-1.linodeobjects.com", "static_site_domain": "website-eu-central-1.linodeobjects.com"}, {"id": "ap-south-1", "region": "ap-south", "status": "available", "domain": "ap-south-1.linodeobjects.com", "static_site_domain": "website-ap-south-1.linodeobjects.com"}], "page": 1, "pages": 1, "results": 3}' headers: Access-Control-Allow-Credentials: - "true" @@ -33,18 +29,12 @@ interactions: Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "214" + - "564" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 20:04:06 GMT - Retry-After: - - "92" Server: - nginx Strict-Transport-Security: @@ -62,13 +52,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "398" - X-Ratelimit-Reset: - - "1563825939" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestListObjectStorageKey.yaml b/test/integration/fixtures/TestListObjectStorageKey.yaml index 44728d33a..cad5e43b7 100644 --- a/test/integration/fixtures/TestListObjectStorageKey.yaml +++ b/test/integration/fixtures/TestListObjectStorageKey.yaml @@ -2,22 +2,19 @@ version: 1 interactions: - request: - body: '{"label":"lpq6h62z88m4-linodego-testing"}' + body: '{"label":"lpq6h62z88m4-linodego-testing","bucket_access":null}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/keys method: POST response: - body: '{"label": "lpq6h62z88m4-linodego-testing", "id": 346, "secret_key": "[REDACTED]", - "access_key": "[REDACTED]"}' + body: '{"id": 48241, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": false, "bucket_access": null}' headers: Access-Control-Allow-Credentials: - "true" @@ -31,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "149" + - "192" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:41:41 GMT - Retry-After: - - "49" Server: - nginx Strict-Transport-Security: @@ -59,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "398" - X-Ratelimit-Reset: - - "1563824484" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -77,24 +64,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/keys method: GET response: - body: '{"pages": 1, "results": 6, "page": 1, "data": [{"label": "primary", "id": - 183, "access_key": "[REDACTED]", "secret_key": "[REDACTED]"}, {"label": - "some label", "id": 272, "access_key": "[REDACTED]", "secret_key": - "[REDACTED]"}, {"label": "some label", "id": 273, "access_key": "[REDACTED]", - "secret_key": "[REDACTED]"}, {"label": "[REDACTED]", "id": 275, "access_key": - "[REDACTED]", "secret_key": "[REDACTED]"}, {"label": "sauber2", "id": - 276, "access_key": "[READACTED]", "secret_key": "[REDACTED]"}, {"label": - "lpq6h62z88m4-linodego-testing", "id": 346, "access_key": "[REDACTED]", - "secret_key": "[REDACTED]"}]}' + body: '{"data": [{"id": 31356, "label": "", "access_key": "[SANITIZED]", "secret_key": "[REDACTED]", "limited": false, "bucket_access": null}, {"id": 36970, "label": "linode-cli-pcampbell@pcampbell-C02-1596478669", "access_key": "[SANITIZED]", "secret_key": "[REDACTED]", "limited": false, "bucket_access": null}, {"id": 48241, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[REDACTED]", "limited": false, "bucket_access": null}], "page": 1, "pages": 1, "results": 3}' headers: Access-Control-Allow-Credentials: - "true" @@ -109,18 +86,12 @@ interactions: Cache-Control: - private, max-age=0, s-maxage=0, no-cache, no-store - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "672" + - "526" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:41:41 GMT - Retry-After: - - "119" Server: - nginx Strict-Transport-Security: @@ -138,13 +109,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1563824554" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -156,13 +123,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.10.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/346 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48241 method: DELETE response: body: '{}' @@ -179,18 +144,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 22 Jul 2019 19:41:42 GMT - Retry-After: - - "87" Server: - nginx Strict-Transport-Security: @@ -207,13 +166,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "398" - X-Ratelimit-Reset: - - "1563824523" + - "800" X-Spec-Version: - - 4.2.3 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestObjectStorageBucketCert.yaml b/test/integration/fixtures/TestObjectStorageBucketCert.yaml index 3f1f9e0c0..898dac2df 100644 --- a/test/integration/fixtures/TestObjectStorageBucketCert.yaml +++ b/test/integration/fixtures/TestObjectStorageBucketCert.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/object-storage/buckets method: POST response: - body: '{"hostname": "linode-obj-bucket-cert-test.xyz.us-east-1.linodeobjects.com", "label": "linode-obj-bucket-cert-test.xyz", "created": "2018-01-02T03:04:05", "cluster": "us-east-1", "size": 0}' + body: '{"hostname": "linode-obj-bucket-cert-test.xyz.us-east-1.linodeobjects.com", "label": "linode-obj-bucket-cert-test.xyz", "created": "2020-10-21T19:52:24", "cluster": "us-east-1", "size": 0}' headers: Access-Control-Allow-Credentials: - "true" @@ -34,10 +34,6 @@ interactions: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 05 Oct 2020 18:46:29 GMT - Retry-After: - - "58" Server: - nginx Strict-Transport-Security: @@ -48,8 +44,6 @@ interactions: - object_storage:read_write X-Content-Type-Options: - nosniff - X-Customer-Uuid: - - D8949487-20FE-11EA-B88C0CC47AEB2714 X-Frame-Options: - DENY - DENY @@ -57,12 +51,8 @@ interactions: - '*' X-Ratelimit-Limit: - "800" - X-Ratelimit-Remaining: - - "799" - X-Ratelimit-Reset: - - "1601923648" X-Spec-Version: - - 4.77.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -101,10 +91,6 @@ interactions: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 05 Oct 2020 18:46:31 GMT - Retry-After: - - "56" Server: - nginx Strict-Transport-Security: @@ -115,8 +101,6 @@ interactions: - object_storage:read_write X-Content-Type-Options: - nosniff - X-Customer-Uuid: - - D8949487-20FE-11EA-B88C0CC47AEB2714 X-Frame-Options: - DENY - DENY @@ -124,12 +108,8 @@ interactions: - '*' X-Ratelimit-Limit: - "800" - X-Ratelimit-Remaining: - - "798" - X-Ratelimit-Reset: - - "1601923648" X-Spec-Version: - - 4.77.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -169,10 +149,6 @@ interactions: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 05 Oct 2020 18:46:32 GMT - Retry-After: - - "55" Server: - nginx Strict-Transport-Security: @@ -184,8 +160,6 @@ interactions: - object_storage:read_only X-Content-Type-Options: - nosniff - X-Customer-Uuid: - - D8949487-20FE-11EA-B88C0CC47AEB2714 X-Frame-Options: - DENY - DENY @@ -193,12 +167,8 @@ interactions: - '*' X-Ratelimit-Limit: - "800" - X-Ratelimit-Remaining: - - "797" - X-Ratelimit-Reset: - - "1601923648" X-Spec-Version: - - 4.77.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -237,10 +207,6 @@ interactions: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 05 Oct 2020 18:46:33 GMT - Retry-After: - - "54" Server: - nginx Strict-Transport-Security: @@ -251,8 +217,6 @@ interactions: - object_storage:read_write X-Content-Type-Options: - nosniff - X-Customer-Uuid: - - D8949487-20FE-11EA-B88C0CC47AEB2714 X-Frame-Options: - DENY - DENY @@ -260,12 +224,8 @@ interactions: - '*' X-Ratelimit-Limit: - "800" - X-Ratelimit-Remaining: - - "796" - X-Ratelimit-Reset: - - "1601923648" X-Spec-Version: - - 4.77.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -304,10 +264,6 @@ interactions: - default-src 'none' Content-Type: - application/json - Date: - - Mon, 05 Oct 2020 18:46:34 GMT - Retry-After: - - "53" Server: - nginx Strict-Transport-Security: @@ -318,8 +274,6 @@ interactions: - object_storage:read_write X-Content-Type-Options: - nosniff - X-Customer-Uuid: - - D8949487-20FE-11EA-B88C0CC47AEB2714 X-Frame-Options: - DENY - DENY @@ -327,12 +281,8 @@ interactions: - '*' X-Ratelimit-Limit: - "800" - X-Ratelimit-Remaining: - - "795" - X-Ratelimit-Reset: - - "1601923648" X-Spec-Version: - - 4.77.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/fixtures/TestUpdateObjectStorageKey.yaml b/test/integration/fixtures/TestUpdateObjectStorageKey.yaml index 35388f637..04114707b 100644 --- a/test/integration/fixtures/TestUpdateObjectStorageKey.yaml +++ b/test/integration/fixtures/TestUpdateObjectStorageKey.yaml @@ -2,22 +2,19 @@ version: 1 interactions: - request: - body: '{"label":"lpq6h62z88m4-linodego-testing"}' + body: '{"label":"lpq6h62z88m4-linodego-testing","bucket_access":null}' form: {} headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.11.0 https://github.com/linode/linodego + - linodego https://github.com/linode/linodego url: https://api.linode.com/v4beta/object-storage/keys method: POST response: - body: '{"id": 619, "access_key": "WHRKQO0EI02QGBFDH6XV", "label": "lpq6h62z88m4-linodego-testing", - "secret_key": "SH9fYcCfjdCYYfOOmyXetfDPpEzqLIP3zWqCVVCb"}' + body: '{"id": 48240, "label": "lpq6h62z88m4-linodego-testing", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": false, "bucket_access": null}' headers: Access-Control-Allow-Credentials: - "true" @@ -31,18 +28,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "149" + - "192" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 13:45:48 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -59,13 +50,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569592067" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -77,17 +64,14 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.11.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/619 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48240 method: PUT response: - body: '{"secret_key": "[REDACTED]", "id": 619, "access_key": "WHRKQO0EI02QGBFDH6XV", - "label": "lpq6h62z88m4-linodego-testing_r"}' + body: '{"id": 48240, "label": "lpq6h62z88m4-linodego-testing_r", "access_key": "[SANITIZED]", "secret_key": "[REDACTED]", "limited": false, "bucket_access": null}' headers: Access-Control-Allow-Credentials: - "true" @@ -101,18 +85,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - - "121" + - "164" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 13:45:48 GMT - Retry-After: - - "119" Server: - nginx Strict-Transport-Security: @@ -129,13 +107,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569592068" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK @@ -147,13 +121,11 @@ interactions: headers: Accept: - application/json - Authorization: - - Bearer awesometokenawesometokenawesometoken Content-Type: - application/json User-Agent: - - linodego 0.11.0 https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/619 + - linodego https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/keys/48240 method: DELETE response: body: '{}' @@ -170,18 +142,12 @@ interactions: - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status Cache-Control: - private, max-age=60, s-maxage=60 - Connection: - - keep-alive Content-Length: - "2" Content-Security-Policy: - default-src 'none' Content-Type: - application/json - Date: - - Fri, 27 Sep 2019 13:45:49 GMT - Retry-After: - - "118" Server: - nginx Strict-Transport-Security: @@ -198,13 +164,9 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "400" - X-Ratelimit-Remaining: - - "399" - X-Ratelimit-Reset: - - "1569592068" + - "800" X-Spec-Version: - - 4.5.0 + - 4.78.3 X-Xss-Protection: - 1; mode=block status: 200 OK diff --git a/test/integration/integration_suite_test.go b/test/integration/integration_suite_test.go index 1c5f1b22a..21e5a5188 100644 --- a/test/integration/integration_suite_test.go +++ b/test/integration/integration_suite_test.go @@ -4,6 +4,7 @@ import ( "log" "net/http" "os" + "regexp" "strconv" "testing" "time" @@ -65,6 +66,23 @@ func testRecorder(t *testing.T, fixturesYaml string, testingMode recorder.Mode, return nil }) + r.AddFilter(func(i *cassette.Interaction) error { + delete(i.Response.Headers, "Date") + delete(i.Response.Headers, "Retry-After") + delete(i.Response.Headers, "X-Customer-Uuid") + delete(i.Response.Headers, "X-Ratelimit-Reset") + delete(i.Response.Headers, "X-Ratelimit-Remaining") + return nil + }) + + r.AddFilter(func(i *cassette.Interaction) error { + accessKeyRe := regexp.MustCompile(`"access_key": "[[:alnum:]]*"`) + i.Response.Body = accessKeyRe.ReplaceAllString(i.Response.Body, `"access_key": "[SANITIZED]"`) + secretKeyRe := regexp.MustCompile(`"secret_key": "[[:alnum:]]*"`) + i.Response.Body = secretKeyRe.ReplaceAllString(i.Response.Body, `"secret_key": "[SANITIZED]"`) + return nil + }) + recordStopper = func() { r.Stop() } diff --git a/test/integration/object_storage_keys_test.go b/test/integration/object_storage_keys_test.go index 9c453c8e7..dbf796184 100644 --- a/test/integration/object_storage_keys_test.go +++ b/test/integration/object_storage_keys_test.go @@ -5,11 +5,13 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" + . "github.com/linode/linodego" ) var ( - testObjectStorageKeyCreateOpts = ObjectStorageKeyCreateOptions{ + testBasicObjectStorageKeyCreateOpts = ObjectStorageKeyCreateOptions{ Label: label, } ) @@ -34,7 +36,7 @@ func TestGetObjectStorageKey_missing(t *testing.T) { } func TestGetObjectStorageKey_found(t *testing.T) { - client, objectStorageKey, teardown, err := setupObjectStorageKey(t, "fixtures/TestGetObjectStorageKey_found") + client, objectStorageKey, teardown, err := setupObjectStorageKey(t, testBasicObjectStorageKeyCreateOpts, "fixtures/TestGetObjectStorageKey_found") defer teardown() if err != nil { t.Error(err) @@ -47,13 +49,16 @@ func TestGetObjectStorageKey_found(t *testing.T) { if i.ID != objectStorageKey.ID { t.Errorf("Expected objectStorageKey id %d, but got %d", i.ID, objectStorageKey.ID) } - if testObjectStorageKeyCreateOpts.Label != objectStorageKey.Label { - t.Errorf("Expected objectStorageKey label '%s', but got '%s'", testObjectStorageKeyCreateOpts.Label, objectStorageKey.Label) + if testBasicObjectStorageKeyCreateOpts.Label != objectStorageKey.Label { + t.Errorf("Expected objectStorageKey label '%s', but got '%s'", testBasicObjectStorageKeyCreateOpts.Label, objectStorageKey.Label) + } + if objectStorageKey.BucketAccess != nil || objectStorageKey.Limited { + t.Errorf("Expected objectStorageKey to have full permissions, but got %v, %v", objectStorageKey.Limited, objectStorageKey.BucketAccess) } } func TestUpdateObjectStorageKey(t *testing.T) { - client, objectStorageKey, teardown, err := setupObjectStorageKey(t, "fixtures/TestUpdateObjectStorageKey") + client, objectStorageKey, teardown, err := setupObjectStorageKey(t, testBasicObjectStorageKeyCreateOpts, "fixtures/TestUpdateObjectStorageKey") defer teardown() if err != nil { t.Error(err) @@ -70,12 +75,15 @@ func TestUpdateObjectStorageKey(t *testing.T) { } if !strings.Contains(objectStorageKey.Label, "-linodego-testing_r") { - t.Errorf("objectStorageKey returned does not match objectStorageKey update request") + t.Errorf("objectStorageKey returned does not match objectStorageKey update request, %v", objectStorageKey) + } + if objectStorageKey.BucketAccess != nil || objectStorageKey.Limited { + t.Errorf("Expected objectStorageKey to have full permissions, but got %v, %v", objectStorageKey.Limited, objectStorageKey.BucketAccess) } } func TestListObjectStorageKeys(t *testing.T) { - client, objkey, teardown, err := setupObjectStorageKey(t, "fixtures/TestListObjectStorageKey") + client, objkey, teardown, err := setupObjectStorageKey(t, testBasicObjectStorageKeyCreateOpts, "fixtures/TestListObjectStorageKey") defer teardown() if err != nil { t.Error(err) @@ -100,14 +108,58 @@ func TestListObjectStorageKeys(t *testing.T) { } } -func setupObjectStorageKey(t *testing.T, fixturesYaml string) (*Client, *ObjectStorageKey, func(), error) { +func TestLimitedObjectStorageKeys(t *testing.T) { + _, bucket, teardown, err := setupObjectStorageBucket(t, "fixtures/TestLimitedObjectStorageKeys_bucket") + defer teardown() + + createOpts := testBasicObjectStorageKeyCreateOpts + createOpts.Limited = true + createOpts.BucketAccess = &[]ObjectStorageKeyBucketAccess{ + { + Cluster: "us-east-1", + BucketName: bucket.Label, + Permissions: "read_only", + }, + { + Cluster: "us-east-1", + BucketName: bucket.Label, + Permissions: "read_write", + }, + } + + _, objectStorageKey, teardown, err := setupObjectStorageKey(t, createOpts, "fixtures/TestLimitedObjectStorageKeys") + defer teardown() + if err != nil { + t.Error(err) + } + if !objectStorageKey.Limited || !cmp.Equal(objectStorageKey.BucketAccess, createOpts.BucketAccess) { + t.Errorf("objectStorageKey returned (%v) does not match objectStorageKey creation request (%v)", *objectStorageKey.BucketAccess, *createOpts.BucketAccess) + } +} + +func TestLimitedObjectStorageKeys_noaccess(t *testing.T) { + createOpts := testBasicObjectStorageKeyCreateOpts + createOpts.Limited = true + createOpts.BucketAccess = &[]ObjectStorageKeyBucketAccess{} + + _, objectStorageKey, teardown, err := setupObjectStorageKey(t, createOpts, "fixtures/TestLimitedObjectStorageKeys_noaccess") + defer teardown() + if err != nil { + t.Error(err) + } + + if !objectStorageKey.Limited || objectStorageKey.BucketAccess == nil || len(*objectStorageKey.BucketAccess) != 0 { + t.Errorf("objectStorageKey returned access, %v, %v", objectStorageKey.Limited, objectStorageKey.BucketAccess) + } +} + +func setupObjectStorageKey(t *testing.T, createOpts ObjectStorageKeyCreateOptions, fixturesYaml string) (*Client, *ObjectStorageKey, func(), error) { t.Helper() var fixtureTeardown func() client, fixtureTeardown := createTestClient(t, fixturesYaml) - createOpts := testObjectStorageKeyCreateOpts objectStorageKey, err := client.CreateObjectStorageKey(context.Background(), createOpts) if err != nil { - t.Errorf("Error listing objectStorageKey, expected struct, got error %v", err) + t.Errorf("Error creating ObjectStorageKey: %v", err) } teardown := func() {