From 161947921dfdf561b88e3636b3f5e8108b47d974 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Thu, 24 Apr 2025 10:39:58 -0700 Subject: [PATCH 1/2] add obj storage quotas tests --- .../TestObjectStorageQuotaUsage_Get.yaml | 65 +++++ .../fixtures/TestObjectStorageQuotas_Get.yaml | 68 +++++ .../TestObjectStorageQuotas_List.yaml | 275 ++++++++++++++++++ test/integration/object_storage_quota_test.go | 84 ++++++ 4 files changed, 492 insertions(+) create mode 100644 test/integration/fixtures/TestObjectStorageQuotaUsage_Get.yaml create mode 100644 test/integration/fixtures/TestObjectStorageQuotas_Get.yaml create mode 100644 test/integration/fixtures/TestObjectStorageQuotas_List.yaml create mode 100644 test/integration/object_storage_quota_test.go diff --git a/test/integration/fixtures/TestObjectStorageQuotaUsage_Get.yaml b/test/integration/fixtures/TestObjectStorageQuotaUsage_Get.yaml new file mode 100644 index 000000000..04a756093 --- /dev/null +++ b/test/integration/fixtures/TestObjectStorageQuotaUsage_Get.yaml @@ -0,0 +1,65 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com/usage + method: GET + response: + body: '{"quota_limit": 100000000, "usage": 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 + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "38" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Thu, 24 Apr 2025 17:38:48 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestObjectStorageQuotas_Get.yaml b/test/integration/fixtures/TestObjectStorageQuotas_Get.yaml new file mode 100644 index 000000000..0da3e1d1f --- /dev/null +++ b/test/integration/fixtures/TestObjectStorageQuotas_Get.yaml @@ -0,0 +1,68 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/quotas/obj-objects-us-ord-1.linodeobjects.com + method: GET + response: + body: '{"quota_id": "obj-objects-us-ord-1.linodeobjects.com", "quota_name": "max_objects", + "endpoint_type": "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", "description": + "Maximum number of objects this customer is allowed to have on this endpoint", + "quota_limit": 100000000, "resource_metric": "object"}' + 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 + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "300" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Thu, 24 Apr 2025 17:38:46 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - object_storage:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestObjectStorageQuotas_List.yaml b/test/integration/fixtures/TestObjectStorageQuotas_List.yaml new file mode 100644 index 000000000..36c050a78 --- /dev/null +++ b/test/integration/fixtures/TestObjectStorageQuotas_List.yaml @@ -0,0 +1,275 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/object-storage/quotas?page=1 + method: GET + response: + body: '{"data": [{"quota_id": "obj-buckets-br-gru-1.linodeobjects.com", "quota_name": + "max_buckets", "endpoint_type": "E1", "s3_endpoint": "br-gru-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-br-gru-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "br-gru-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-br-gru-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "br-gru-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-us-iad-10.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "us-iad-10.linodeobjects.com", "description": "Maximum + number of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-us-iad-10.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "us-iad-10.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-us-iad-10.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "us-iad-10.linodeobjects.com", "description": "Maximum + number of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-nl-ams-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "nl-ams-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-nl-ams-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "nl-ams-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-nl-ams-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "nl-ams-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-us-east-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E0", "s3_endpoint": "us-east-1.linodeobjects.com", "description": "Maximum + number of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-us-east-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E0", "s3_endpoint": "us-east-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 5368709120, "resource_metric": "byte"}, {"quota_id": + "obj-objects-us-east-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E0", "s3_endpoint": "us-east-1.linodeobjects.com", "description": "Maximum + number of objects this customer is allowed to have on this endpoint", "quota_limit": + 50000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-us-mia-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "us-mia-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-us-mia-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "us-mia-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-us-mia-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "us-mia-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-us-lax-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "us-lax-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-us-lax-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "us-lax-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-us-lax-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "us-lax-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-es-mad-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "es-mad-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-es-mad-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "es-mad-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-es-mad-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "es-mad-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-us-southeast-1.linodeobjects.com", "quota_name": "max_buckets", + "endpoint_type": "E0", "s3_endpoint": "us-southeast-1.linodeobjects.com", "description": + "Maximum number of buckets this customer is allowed to have on this endpoint", + "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-us-southeast-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E0", "s3_endpoint": "us-southeast-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 5368709120, "resource_metric": "byte"}, {"quota_id": + "obj-objects-us-southeast-1.linodeobjects.com", "quota_name": "max_objects", + "endpoint_type": "E0", "s3_endpoint": "us-southeast-1.linodeobjects.com", "description": + "Maximum number of objects this customer is allowed to have on this endpoint", + "quota_limit": 50000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-ap-south-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E0", "s3_endpoint": "ap-south-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-ap-south-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E0", "s3_endpoint": "ap-south-1.linodeobjects.com", "description": "Maximum + number of bytes this customer is allowed to have on this endpoint", "quota_limit": + 5368709120, "resource_metric": "byte"}, {"quota_id": "obj-objects-ap-south-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E0", "s3_endpoint": "ap-south-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 50000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-gb-lon-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E3", "s3_endpoint": "gb-lon-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-gb-lon-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E3", "s3_endpoint": "gb-lon-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 536870912000, "resource_metric": "byte"}, {"quota_id": + "obj-objects-gb-lon-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E3", "s3_endpoint": "gb-lon-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 500000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-us-ord-10.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E3", "s3_endpoint": "us-ord-10.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-us-ord-10.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E3", "s3_endpoint": "us-ord-10.linodeobjects.com", "description": "Maximum + number of bytes this customer is allowed to have on this endpoint", "quota_limit": + 536870912000, "resource_metric": "byte"}, {"quota_id": "obj-objects-us-ord-10.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E3", "s3_endpoint": "us-ord-10.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 500000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-fr-par-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "fr-par-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-fr-par-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "fr-par-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-fr-par-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "fr-par-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-us-ord-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-us-ord-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-us-ord-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "us-ord-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-in-maa-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "in-maa-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-in-maa-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "in-maa-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-in-maa-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "in-maa-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-se-sto-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "se-sto-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-se-sto-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "se-sto-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-se-sto-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "se-sto-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-it-mil-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "it-mil-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-it-mil-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "it-mil-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-it-mil-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "it-mil-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-eu-central-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E0", "s3_endpoint": "eu-central-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-eu-central-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E0", "s3_endpoint": "eu-central-1.linodeobjects.com", "description": "Maximum + number of bytes this customer is allowed to have on this endpoint", "quota_limit": + 5368709120, "resource_metric": "byte"}, {"quota_id": "obj-objects-eu-central-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E0", "s3_endpoint": "eu-central-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 50000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-us-sea-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "us-sea-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-us-sea-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "us-sea-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-us-sea-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "us-sea-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}, {"quota_id": "obj-buckets-id-cgk-1.linodeobjects.com", + "quota_name": "max_buckets", "endpoint_type": "E1", "s3_endpoint": "id-cgk-1.linodeobjects.com", + "description": "Maximum number of buckets this customer is allowed to have on + this endpoint", "quota_limit": 1000, "resource_metric": "bucket"}, {"quota_id": + "obj-bytes-id-cgk-1.linodeobjects.com", "quota_name": "max_bytes", "endpoint_type": + "E1", "s3_endpoint": "id-cgk-1.linodeobjects.com", "description": "Maximum number + of bytes this customer is allowed to have on this endpoint", "quota_limit": + 107374182400, "resource_metric": "byte"}, {"quota_id": "obj-objects-id-cgk-1.linodeobjects.com", + "quota_name": "max_objects", "endpoint_type": "E1", "s3_endpoint": "id-cgk-1.linodeobjects.com", + "description": "Maximum number of objects this customer is allowed to have on + this endpoint", "quota_limit": 100000000, "resource_metric": "object"}, {"quota_id": + "obj-buckets-jp-osa-1.linodeobjects.com", "quota_name": "max_buckets", "endpoint_type": + "E1", "s3_endpoint": "jp-osa-1.linodeobjects.com", "description": "Maximum number + of buckets this customer is allowed to have on this endpoint", "quota_limit": + 1000, "resource_metric": "bucket"}, {"quota_id": "obj-bytes-jp-osa-1.linodeobjects.com", + "quota_name": "max_bytes", "endpoint_type": "E1", "s3_endpoint": "jp-osa-1.linodeobjects.com", + "description": "Maximum number of bytes this customer is allowed to have on + this endpoint", "quota_limit": 107374182400, "resource_metric": "byte"}, {"quota_id": + "obj-objects-jp-osa-1.linodeobjects.com", "quota_name": "max_objects", "endpoint_type": + "E1", "s3_endpoint": "jp-osa-1.linodeobjects.com", "description": "Maximum number + of objects this customer is allowed to have on this endpoint", "quota_limit": + 100000000, "resource_metric": "object"}], "page": 1, "pages": 1, "results": + 60}' + 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 + Akamai-Internal-Account: + - '*' + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Thu, 24 Apr 2025 17:38:47 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - object_storage:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/object_storage_quota_test.go b/test/integration/object_storage_quota_test.go new file mode 100644 index 000000000..70d7fd90e --- /dev/null +++ b/test/integration/object_storage_quota_test.go @@ -0,0 +1,84 @@ +package integration + +import ( + "context" + "github.com/stretchr/testify/assert" + "testing" + + "github.com/linode/linodego" +) + +func TestObjectStorageQuotas_Get(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestObjectStorageQuotas_Get") + defer teardown() + + quota, err := client.GetObjectStorageQuota(context.Background(), "obj-objects-us-ord-1.linodeobjects.com") + assert.NoError(t, err) + + expected := linodego.ObjectStorageQuota{ + QuotaID: "obj-objects-us-ord-1.linodeobjects.com", + QuotaName: "max_objects", + EndpointType: "E1", + S3Endpoint: "us-ord-1.linodeobjects.com", + Description: "Maximum number of objects this customer is allowed to have on this endpoint", + QuotaLimit: 100000000, + ResourceMetric: "object", + } + + assert.Equal(t, expected.QuotaID, quota.QuotaID) + assert.Equal(t, expected.QuotaName, quota.QuotaName) + assert.Equal(t, expected.EndpointType, quota.EndpointType) + assert.Equal(t, expected.S3Endpoint, quota.S3Endpoint) + assert.Equal(t, expected.Description, quota.Description) + assert.Equal(t, expected.QuotaLimit, quota.QuotaLimit) + assert.Equal(t, expected.ResourceMetric, quota.ResourceMetric) +} + +func TestObjectStorageQuotas_List(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestObjectStorageQuotas_List") + defer teardown() + + quotas, err := client.ListObjectStorageQuotas(context.Background(), &linodego.ListOptions{}) + assert.NoError(t, err, "Error listing ObjectStorageQuotas") + + targetQuotaID := "obj-buckets-us-mia-1.linodeobjects.com" + var foundQuota *linodego.ObjectStorageQuota + + for _, quota := range quotas { + if quota.QuotaID == targetQuotaID { + foundQuota = "a + break + } + } + + if assert.NotNil(t, foundQuota, "Expected quota_id %q not found", targetQuotaID) { + expected := linodego.ObjectStorageQuota{ + QuotaID: "obj-buckets-us-mia-1.linodeobjects.com", + QuotaName: "max_buckets", + EndpointType: "E1", + S3Endpoint: "us-mia-1.linodeobjects.com", + Description: "Maximum number of buckets this customer is allowed to have on this endpoint", + QuotaLimit: 1000, + ResourceMetric: "bucket", + } + + assert.Equal(t, expected.QuotaID, foundQuota.QuotaID) + assert.Equal(t, expected.QuotaName, foundQuota.QuotaName) + assert.Equal(t, expected.EndpointType, foundQuota.EndpointType) + assert.Equal(t, expected.S3Endpoint, foundQuota.S3Endpoint) + assert.Equal(t, expected.Description, foundQuota.Description) + assert.Equal(t, expected.QuotaLimit, foundQuota.QuotaLimit) + assert.Equal(t, expected.ResourceMetric, foundQuota.ResourceMetric) + } +} + +func TestObjectStorageQuotaUsage_Get(t *testing.T) { + client, teardown := createTestClient(t, "fixtures/TestObjectStorageQuotaUsage_Get") + defer teardown() + + quotaUsage, err := client.GetObjectStorageQuotaUsage(context.Background(), "obj-objects-us-ord-1.linodeobjects.com") + assert.NoError(t, err) + + assert.Equal(t, 100000000, quotaUsage.QuotaLimit) + assert.GreaterOrEqual(t, *quotaUsage.Usage, 0) +} From 49df09ee07ae08cc664642f3608bd17631c9bf98 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Thu, 24 Apr 2025 10:40:20 -0700 Subject: [PATCH 2/2] format --- test/integration/object_storage_quota_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/object_storage_quota_test.go b/test/integration/object_storage_quota_test.go index 70d7fd90e..109a198cc 100644 --- a/test/integration/object_storage_quota_test.go +++ b/test/integration/object_storage_quota_test.go @@ -2,9 +2,10 @@ package integration import ( "context" - "github.com/stretchr/testify/assert" "testing" + "github.com/stretchr/testify/assert" + "github.com/linode/linodego" )