Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for object list using certain Admin SDKs #5209

Merged
merged 4 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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