Skip to content

Commit fb7bdbc

Browse files
fix: address Copilot review — download assertions, EICAR gate, talismanrc, comment
1 parent d6f2610 commit fb7bdbc

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

.talismanrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
fileignoreconfig:
22
- filename: package-lock.json
33
checksum: 80c8eb5270a1c4a0fa244d0f001d15867449d44954eb4d3f1ab7fa68c6f5446d
4-
- filename: test/sanity-check/sanity.js
5-
checksum: f8b4b4b4492e04fd13338af9d99972807b4d61e2b0237a6c057d3f93d8c66d60
64
- filename: test/sanity-check/api/assetScanStatus-test.js
75
checksum: e3b1857fbe321e7125b55613acd58c3c0b2fd2462e7a14e48279ad35db4169e7
86
version: "1.0"

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,21 @@ describe('Asset Scan Status – Download Error Handling (§ 3.3)', () => {
473473
// NOT replace it with "Session timed out" or a generic SDK message.
474474

475475
// Use an invalid URL to trigger a predictable SDK error and verify propagation
476+
let errorThrown = false
476477
try {
477-
await stack.asset().download({ url: 'https://invalid-host.example.com/nonexistent-asset', responseType: 'blob' })
478+
await stack.asset().download({ url: 'https://invalid-host.example.com/nonexistent-asset', responseType: 'arraybuffer' })
478479
} catch (err) {
480+
errorThrown = true
479481
// Must expose the real error — not hide it behind a generic wrapper
480482
expect(err.message || err.errorMessage || err.code).to.not.equal(undefined,
481483
'SDK must surface download errors — error message must not be empty')
482-
expect(err.message).to.not.include('Session timed out',
483-
'SDK must not replace real download errors with generic session timeout message')
484+
if (err.message) {
485+
expect(err.message).to.not.include('Session timed out',
486+
'SDK must not replace real download errors with generic session timeout message')
487+
}
484488
}
489+
expect(errorThrown).to.equal(true,
490+
'download() must throw for an invalid host URL — SDK must not silently succeed')
485491
})
486492

487493
it('SDK asset.download() must propagate 422 status for scan-blocked downloads', async function () {
@@ -493,6 +499,7 @@ describe('Asset Scan Status – Download Error Handling (§ 3.3)', () => {
493499
// Fetch a real asset then attempt to call download with an injected bad URL
494500
// to confirm the SDK propagates the error with a proper status code.
495501
let assetUid
502+
let errorWasThrown = false
496503
try {
497504
const uploadResp = await stack.asset().create({
498505
upload: assetPath,
@@ -504,6 +511,7 @@ describe('Asset Scan Status – Download Error Handling (§ 3.3)', () => {
504511
const assetObj = await stack.asset(assetUid).fetch()
505512
await assetObj.download({ url: assetObj.url + '?__scan_error_test=1', responseType: 'arraybuffer' })
506513
} catch (err) {
514+
errorWasThrown = true
507515
// SDK must not swallow the status code
508516
if (err.status !== undefined) {
509517
expect(err.status).to.be.a('number',
@@ -517,6 +525,9 @@ describe('Asset Scan Status – Download Error Handling (§ 3.3)', () => {
517525
try { await stack.asset(assetUid).delete() } catch (e) { /* ignore */ }
518526
}
519527
}
528+
// CDN may serve the asset despite the injected query param — explicitly skip
529+
// rather than silently pass so the 422-propagation contract is clearly not exercised.
530+
if (!errorWasThrown) this.skip()
520531
})
521532
})
522533

@@ -535,6 +546,12 @@ describe('Asset Scan Status – Scan Lifecycle (clean + quarantined)', () => {
535546
before(function () {
536547
const apiKey = process.env.API_KEY
537548
if (!apiKey) return this.skip()
549+
// Gate behind explicit opt-in: EICAR upload can trigger AV controls in CI environments.
550+
// Set SCAN_LIFECYCLE_TESTS_ENABLED=true in the pipeline/env to enable this suite.
551+
if (!process.env.SCAN_LIFECYCLE_TESTS_ENABLED) {
552+
console.log(' [scan-test] Lifecycle tests skipped — set SCAN_LIFECYCLE_TESTS_ENABLED=true to enable')
553+
return this.skip()
554+
}
538555
stack = buildStack(apiKey)
539556
})
540557

test/sanity-check/sanity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import './api/environment-test.js'
8282
import './api/asset-test.js'
8383

8484
// Phase 6.5: Asset Scan Status - comprehensive tests for include_asset_scan_status param
85-
// Covers both ORGANIZATION stack (non-AM, scan enabled) and AM_ORG_UID stack (AM_API_KEY, scan enabled)
85+
// Covers both ORGANIZATION stack (non-AM, scan enabled) and AM_ORG_UID stack (dynamically created, no static key needed)
8686
import './api/assetScanStatus-test.js'
8787

8888
// Phase 7: Taxonomies (needed for content types with taxonomy fields)

0 commit comments

Comments
 (0)