Skip to content

Commit 061fea1

Browse files
iago1501cursoragent
andcommitted
fix: point bucket-policy client calls at the renamed vtex.file-manager route
vtex.file-manager renamed its private policy routes' literal path segment from "policies" to "bucket-access-policies" to fix a routing collision (the platform's injected router was matching by trailing path segments, so a public GET to a bucket literally named "policies" got hijacked to the private policy-read action). Update listPolicies, getPolicy, setAdminPolicy and deleteAdminPolicy to call the new path, and update the matching test assertions. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a716ddc commit 061fea1

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

node/FileManager.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('FileManager policies methods', () => {
126126
'AUTHENTICATED'
127127
)
128128

129-
expect(http.post).toHaveBeenCalledWith('/policies/mybucket/admin', {
129+
expect(http.post).toHaveBeenCalledWith('/bucket-access-policies/mybucket/admin', {
130130
readAccess: 'public',
131131
writeAccess: 'authenticated',
132132
})
@@ -174,7 +174,7 @@ describe('FileManager policies methods', () => {
174174

175175
const result = await fileManager.listPolicies()
176176

177-
expect(http.get).toHaveBeenCalledWith('/policies')
177+
expect(http.get).toHaveBeenCalledWith('/bucket-access-policies')
178178
expect(result.nextMarker).toBeNull()
179179
expect(result.policies).toHaveLength(2)
180180
expect(result.policies[0]).toEqual({
@@ -213,7 +213,7 @@ describe('FileManager policies methods', () => {
213213

214214
await fileManager.listPolicies('next-page-token')
215215

216-
expect(http.get).toHaveBeenCalledWith('/policies?marker=next-page-token')
216+
expect(http.get).toHaveBeenCalledWith('/bucket-access-policies?marker=next-page-token')
217217
})
218218

219219
it('getPolicy maps a single raw response and preserves null policies', async () => {
@@ -231,7 +231,7 @@ describe('FileManager policies methods', () => {
231231

232232
const result = await fileManager.getPolicy('b1')
233233

234-
expect(http.get).toHaveBeenCalledWith('/policies/b1')
234+
expect(http.get).toHaveBeenCalledWith('/bucket-access-policies/b1')
235235
expect(result).toEqual({
236236
bucket: 'b1',
237237
effectivePolicy: {
@@ -250,7 +250,7 @@ describe('FileManager policies methods', () => {
250250

251251
const result = await fileManager.deleteAdminPolicy('b1')
252252

253-
expect(http.delete).toHaveBeenCalledWith('/policies/b1/admin')
253+
expect(http.delete).toHaveBeenCalledWith('/bucket-access-policies/b1/admin')
254254
expect(result).toBeUndefined()
255255
})
256256

node/FileManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default class FileManager extends ExternalClient {
186186
marker?: string
187187
): Promise<{ policies: any[]; nextMarker: string | null }> => {
188188
const qs = marker ? `?marker=${encodeURIComponent(marker)}` : ''
189-
const raw = await this.http.get(`/policies${qs}`)
189+
const raw = await this.http.get(`/bucket-access-policies${qs}`)
190190
return {
191191
policies: Array.isArray(raw?.policies)
192192
? raw.policies.map(mapPolicyViewFromWire)
@@ -196,7 +196,7 @@ export default class FileManager extends ExternalClient {
196196
}
197197

198198
public getPolicy = async (bucket: string): Promise<any> => {
199-
const raw = await this.http.get(`/policies/${bucket}`)
199+
const raw = await this.http.get(`/bucket-access-policies/${bucket}`)
200200
return mapPolicyViewFromWire(raw)
201201
}
202202

@@ -205,13 +205,13 @@ export default class FileManager extends ExternalClient {
205205
readAccess: string,
206206
writeAccess: string
207207
): Promise<any> => {
208-
const raw = await this.http.post(`/policies/${bucket}/admin`, {
208+
const raw = await this.http.post(`/bucket-access-policies/${bucket}/admin`, {
209209
readAccess: toWireAccessLevel(readAccess as GraphQLAccessLevel),
210210
writeAccess: toWireAccessLevel(writeAccess as GraphQLAccessLevel),
211211
})
212212
return mapBucketPolicyFromWire(raw)
213213
}
214214

215215
public deleteAdminPolicy = async (bucket: string): Promise<any> =>
216-
this.http.delete(`/policies/${bucket}/admin`)
216+
this.http.delete(`/bucket-access-policies/${bucket}/admin`)
217217
}

0 commit comments

Comments
 (0)