Skip to content

Commit 4b1b754

Browse files
fix(tests): management token fixes the 401 on bulk job status tests for custom regins
1 parent 2a04f4a commit 4b1b754

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/sanity-check/api/bulkOperation-test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ function assetsWithValidUids () {
4040
return [assetUid1, assetUid2].filter(uid => uid && String(uid).trim()).map(uid => ({ uid }))
4141
}
4242

43-
async function waitForJobReady (jobId, maxAttempts = 5) {
43+
async function waitForJobReady (jobId, maxAttempts = 3) {
4444
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
4545
try {
46-
const response = await doBulkOperation()
47-
.jobStatus({ job_id: jobId, api_version: '3.2' })
46+
// GET /v3/bulk/jobs/{job_id} on AM2.0 requires management token auth (authtoken returns 401)
47+
// Fall back to authtoken if management token not yet available
48+
const bulkOp = tokenUidDev
49+
? doBulkOperationWithManagementToken(tokenUidDev)
50+
: doBulkOperation()
51+
const response = await bulkOp.jobStatus({ job_id: jobId, api_version: '3.2' })
4852
if (response && response.status) {
4953
return response
5054
}
@@ -55,7 +59,7 @@ async function waitForJobReady (jobId, maxAttempts = 5) {
5559
}
5660
// For other errors (network, 5xx), retry
5761
}
58-
await delay(5000)
62+
await delay(3000)
5963
}
6064
throw new Error(`Job ${jobId} did not become ready after ${maxAttempts} attempts`)
6165
}

0 commit comments

Comments
 (0)