Skip to content

Commit

Permalink
Additional ACL response attributes (#1594)
Browse files Browse the repository at this point in the history
Include these attributes in the JSON response for access control lists.

* `etag`
* `kind`

Some [client libraries][1] expect them to be present, and fail to
deserialize the response otherwise.

The value for `kind` matches what the real GCS API returns. We don't
care too much about the ETag value at this stage, so we just picked a
valid constant.

[1]: https://crates.io/crates/google-cloud-storage
  • Loading branch information
manuteleco authored May 7, 2024
1 parent 84b2c78 commit d719225
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fakestorage/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,8 +1919,8 @@ func TestServerClientObjectProjection(t *testing.T) {

url := fmt.Sprintf("https://storage.googleapis.com/storage/v1/b/%s/o/%s", bucketName, objectName)
fullACL := []objectAccessControl{
{Bucket: bucketName, Object: objectName, Entity: "user-1", Role: "OWNER"},
{Bucket: bucketName, Object: objectName, Entity: "user-2", Role: "READER"},
{Bucket: bucketName, Object: objectName, Entity: "user-1", Role: "OWNER", Etag: "RVRhZw==", Kind: "storage#objectAccessControl"},
{Bucket: bucketName, Object: objectName, Entity: "user-2", Role: "READER", Etag: "RVRhZw==", Kind: "storage#objectAccessControl"},
}

t.Run("full projection", func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions fakestorage/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ func getAccessControlsListFromObject(obj ObjectAttrs) []*objectAccessControl {
Entity: string(aclRule.Entity),
Object: obj.Name,
Role: string(aclRule.Role),
Etag: "RVRhZw==",
Kind: "storage#objectAccessControl",
}
}
return aclItems
Expand Down

0 comments on commit d719225

Please sign in to comment.