Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions csaf_2_1/mandatoryTests/mandatoryTest_6_1_44.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const inputSchema = /** @type {const} */ ({
full_product_names: {
elements: fullProductNameSchema,
},
relationships: {
product_paths: {
elements: {
additionalProperties: true,
optionalProperties: {
Expand Down Expand Up @@ -136,11 +136,11 @@ export function mandatoryTest_6_1_44(doc) {
)
})

doc.product_tree?.relationships?.forEach((relationship, index) => {
const fullProductName = relationship.full_product_name
doc.product_tree?.product_paths?.forEach((productPath, index) => {
const fullProductName = productPath.full_product_name
if (fullProductName) {
checkFullProductName(
`/product_tree/relationships/${index}/full_product_name`,
`/product_tree/product_paths/${index}/full_product_name`,
fullProductName
)
}
Expand Down
83 changes: 83 additions & 0 deletions tests/csaf_2_1/mandatoryTest_6_1_44.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,87 @@ describe('mandatoryTest_6_1_44', function () {
it('only runs on relevant documents', function () {
assert.equal(mandatoryTest_6_1_44({ product_tree: 'mydoc' }).isValid, true)
})

it('validates branches and skips invalid ones', function () {
assert.equal(
mandatoryTest_6_1_44({
product_tree: {
branches: [
{
product: {
product_identification_helper: {
serial_numbers: ['*P\\*\\*?\\*'],
},
},
branches: [
{
product: 'invalid',
},
{
branches: [{}],
},
],
},
],
},
}).isValid,
true
)
})

it('validates product_paths and skips invalid ones', function () {
assert.equal(
mandatoryTest_6_1_44({
product_tree: {
product_paths: [
{
full_product_name: {
serial_numbers: ['*P\\*\\*?\\*'],
},
},
{},
],
},
}).isValid,
true
)
})

it('detects invalid serial numbers in branches', function () {
assert.equal(
mandatoryTest_6_1_44({
product_tree: {
branches: [
{
product: {
product_identification_helper: {
serial_numbers: ['P*A*'],
},
},
},
],
},
}).isValid,
false
)
})

it('detects invalid serial numbers in product_paths', function () {
assert.equal(
mandatoryTest_6_1_44({
product_tree: {
product_paths: [
{
full_product_name: {
product_identification_helper: {
serial_numbers: ['P*A*'],
},
},
},
],
},
}).isValid,
false
)
})
})
Loading