Skip to content

Commit 9e49162

Browse files
feat: add test for input schema
1 parent 9625f45 commit 9e49162

File tree

1 file changed

+35
-0
lines changed

1 file changed

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

433
describe('mandatoryTest_6_1_46', function () {
534
it('only runs on relevant documents', function () {
635
assert.equal(mandatoryTest_6_1_46({ document: 'mydoc' }).isValid, true)
736
})
37+
it('test input schema with empty json object in vulnerabilities', async function () {
38+
const result = mandatoryTest_6_1_46(
39+
validInputSchemaTestWithEmptyVulnerability6_1_46
40+
)
41+
expect(result.errors.length).to.eq(0)
42+
})
843
})

0 commit comments

Comments
 (0)