Skip to content

Commit adf5d21

Browse files
feat: add Asset Scan Status integration tests to sanity suite
Add 3 integration tests under a new 'Asset Scan Status' describe block in asset-test.js: - Single fetch with include_asset_scan_status=true: validates the _asset_scan_status field (pending|clean|quarantined|not_scanned) when present; skips assertion when feature is not enabled for the stack. - List query with include_asset_scan_status=true: same opt-in validation on the first item returned. - Fetch without param: asserts _asset_scan_status is absent from response. Reuses the image asset uploaded by the Asset Upload block via testData.assets.image.uid to avoid extra uploads. Falls back to creating a fresh asset only if the upload block did not run. Related branch: feat/DX-8752-asset-scan
1 parent ea8de32 commit adf5d21

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,4 +981,71 @@ describe('Asset API Tests', () => {
981981
}
982982
})
983983
})
984+
985+
// ==========================================================================
986+
// ASSET SCAN STATUS
987+
// ==========================================================================
988+
989+
describe('Asset Scan Status', () => {
990+
let scanAssetUid
991+
992+
before(async function () {
993+
this.timeout(30000)
994+
// Reuse the image asset uploaded earlier — avoids a redundant upload
995+
if (testData.assets && testData.assets.image && testData.assets.image.uid) {
996+
scanAssetUid = testData.assets.image.uid
997+
return
998+
}
999+
// Fallback: create a fresh asset if the upload block didn't run
1000+
try {
1001+
const asset = await stack.asset().create({
1002+
upload: assetPath,
1003+
title: `Scan Status Asset ${Date.now()}`,
1004+
description: 'Fallback asset for scan-status tests'
1005+
})
1006+
scanAssetUid = asset.uid
1007+
} catch (err) {
1008+
// Individual tests will self-skip when scanAssetUid is unset
1009+
}
1010+
})
1011+
1012+
it('should accept include_asset_scan_status param on single asset fetch', async function () {
1013+
this.timeout(15000)
1014+
if (!scanAssetUid) return this.skip()
1015+
1016+
const asset = await stack.asset(scanAssetUid).fetch({ include_asset_scan_status: true })
1017+
1018+
expect(asset).to.be.an('object')
1019+
expect(asset.uid).to.equal(scanAssetUid)
1020+
// _asset_scan_status is opt-in: present only when asset scanning is enabled for the stack.
1021+
// Possible values: 'pending' | 'clean' | 'quarantined' | 'not_scanned'
1022+
if ('_asset_scan_status' in asset) {
1023+
expect(asset._asset_scan_status).to.be.a('string')
1024+
expect(['pending', 'clean', 'quarantined', 'not_scanned']).to.include(asset._asset_scan_status)
1025+
}
1026+
})
1027+
1028+
it('should accept include_asset_scan_status param on asset list query', async function () {
1029+
this.timeout(15000)
1030+
1031+
const response = await stack.asset().query({ include_asset_scan_status: true }).find()
1032+
1033+
expect(response).to.be.an('object')
1034+
expect(response.items).to.be.an('array')
1035+
if (response.items.length > 0 && '_asset_scan_status' in response.items[0]) {
1036+
expect(response.items[0]._asset_scan_status).to.be.a('string')
1037+
expect(['pending', 'clean', 'quarantined', 'not_scanned']).to.include(response.items[0]._asset_scan_status)
1038+
}
1039+
})
1040+
1041+
it('should NOT return _asset_scan_status when param is omitted', async function () {
1042+
this.timeout(15000)
1043+
if (!scanAssetUid) return this.skip()
1044+
1045+
const asset = await stack.asset(scanAssetUid).fetch()
1046+
1047+
expect(asset).to.be.an('object')
1048+
expect(asset).to.not.have.property('_asset_scan_status')
1049+
})
1050+
})
9841051
})

0 commit comments

Comments
 (0)