Skip to content

Commit

Permalink
Add support for object list using certain Admin SDKs (#5209)
Browse files Browse the repository at this point in the history
* Add support for object list using certain Admin SDKs
  • Loading branch information
abhis3 committed Nov 3, 2022
1 parent b02065f commit ea2a9ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -0,0 +1 @@
- Add support for object list using certain Admin SDKs (#5208)
Expand Up @@ -293,4 +293,30 @@ describe("GCS endpoint conformance tests", () => {
});
});
});

describe("List protocols", () => {
describe("list objects", () => {
// This test is for the '/storage/v1/b/:bucketId/o' url pattern, which is used specifically by the GO Admin SDK
it("should list objects in the provided bucket", async () => {
await supertest(storageHost)
.post(`/upload/storage/v1/b/${storageBucket}/o?name=${TEST_FILE_NAME}`)
.set(authHeader)
.send(Buffer.from("hello world"))
.expect(200);

await supertest(storageHost)
.post(`/upload/storage/v1/b/${storageBucket}/o?name=${TEST_FILE_NAME}2`)
.set(authHeader)
.send(Buffer.from("hello world"))
.expect(200);

const data = await supertest(storageHost)
.get(`/storage/v1/b/${storageBucket}/o`)
.set(authHeader)
.expect(200)
.then((res) => res.body);
expect(data.items.length).to.equal(2);
});
});
});
});
2 changes: 1 addition & 1 deletion src/emulator/storage/apis/gcloud.ts
Expand Up @@ -135,7 +135,7 @@ export function createCloudEndpoints(emulator: StorageEmulator): Router {
return res.json(new CloudStorageObjectMetadata(updatedMetadata));
});

gcloudStorageAPI.get("/b/:bucketId/o", async (req, res) => {
gcloudStorageAPI.get(["/b/:bucketId/o", "/storage/v1/b/:bucketId/o"], async (req, res) => {
let listResponse: ListObjectsResponse;
// TODO validate that all query params are single strings and are not repeated.
try {
Expand Down

0 comments on commit ea2a9ec

Please sign in to comment.