Skip to content

Commit 21e6351

Browse files
feat: add test for input schema
1 parent ce2b50f commit 21e6351

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
11
import assert from 'node:assert/strict'
22
import { mandatoryTest_6_1_47 } from '../../csaf_2_1/mandatoryTests/mandatoryTest_6_1_47.js'
3+
import { expect } from 'chai'
4+
5+
const validInputSchemaTestWithEmptyVulnerability6_1_47 = {
6+
vulnerabilities: [
7+
{}, // even this vulnerability is empty, the test should not fail due to the inputSchema
8+
{
9+
cve: 'CVE-1900-0001',
10+
metrics: [
11+
{
12+
content: {
13+
ssvc_v1: {
14+
id: 'CVE-1900-0001',
15+
schemaVersion: '1-0-1',
16+
selections: [
17+
{
18+
name: 'Exploitation',
19+
namespace: 'ssvc',
20+
values: ['None'],
21+
version: '1.1.0',
22+
},
23+
],
24+
timestamp: '2024-01-24T10:00:00.000Z',
25+
},
26+
},
27+
products: ['CSAFPID-9080700'],
28+
},
29+
],
30+
},
31+
],
32+
}
333

434
describe('mandatoryTest_6_1_47', function () {
535
it('only runs on relevant documents', function () {
636
assert.equal(mandatoryTest_6_1_47({ document: 'mydoc' }).isValid, true)
737
})
38+
it('test input schema with empty json object in vulnerabilities', async function () {
39+
const result = mandatoryTest_6_1_47(
40+
validInputSchemaTestWithEmptyVulnerability6_1_47
41+
)
42+
expect(result.errors.length).to.eq(0)
43+
})
844
})

0 commit comments

Comments
 (0)