FOSSology  4.7.1
Open Source License Compliance by Open Source Software
test_report_output.php File Reference

Unit tests for BomReportGenerator CycloneDX output. More...

Go to the source code of this file.

Classes

class  Fossology\Lib\Data\LicenseRef
 

Functions

 assert_test ($name, $condition, $detail='')
 

Variables

 if (!function_exists( 'uuid_create'))
 
 $generator = new BomReportGenerator()
 
 $passed = 0
 
 $failed = 0
 
 $licenseData
 
 $result = $generator->createLicense($licenseData)
 
 $licenseDataNoText
 
 $result2 = $generator->createLicense($licenseDataNoText)
 
 $licenseRef
 
 $result3 = $generator->createLicense($licenseRef)
 
 $componentData
 
 $comp = $generator->createComponent($componentData)
 
 $compNoCopyright
 
 $fileComponent
 
 $report
 
 $json = json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
 
 $decoded = json_decode($json, true)
 
 $compWithVersion
 
 $compNoVersion
 
 $compWithPurl
 
 $compNoPurl
 
 $compWithDesc
 
 $compNoDesc
 
 $compWithProps
 
 $compOnlyAck
 
 $compNoProps
 
 $compWithExtRef
 
 $compNoExtRef
 
 $reportWithExtRef
 
 $fullComp
 
if($failed > 0) else
 

Detailed Description

Unit tests for BomReportGenerator CycloneDX output.

Definition in file test_report_output.php.

Variable Documentation

◆ $compNoCopyright

$compNoCopyright
Initial value:
= $generator->createComponent(array(
'type' => 'file',
'name' => 'README.md'
))

Definition at line 135 of file test_report_output.php.

◆ $compNoDesc

$compNoDesc
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'openssl',
'description' => ''
))

Definition at line 237 of file test_report_output.php.

◆ $compNoExtRef

$compNoExtRef
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'openssl',
'externalReferences' => []
))

Definition at line 302 of file test_report_output.php.

◆ $compNoProps

$compNoProps
Initial value:
= $generator->createComponent(array(
'type' => 'file',
'name' => 'src/test.c',
'acknowledgements' => '',
'comments' => ''
))

Definition at line 275 of file test_report_output.php.

◆ $compNoPurl

$compNoPurl
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'busybox',
'purl' => ''
))

Definition at line 218 of file test_report_output.php.

◆ $compNoVersion

$compNoVersion
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'busybox',
'version' => ''
))

Definition at line 199 of file test_report_output.php.

◆ $componentData

$componentData
Initial value:
= array(
'type' => 'library',
'name' => 'openssl-3.0.12.tar.gz',
'bomref' => '42',
'scope' => 'required',
'mimeType' => 'application/gzip',
'copyright' => "Copyright 2000-2023 The OpenSSL Project Authors\nCopyright 1995-2023 Eric A. Young, Tim J. Hudson",
'hashes' => array(
$generator->createHash('SHA-1', 'abc123'),
$generator->createHash('MD5', 'def456')
),
'licenses' => array($result)
)

Definition at line 108 of file test_report_output.php.

◆ $compOnlyAck

$compOnlyAck
Initial value:
= $generator->createComponent(array(
'type' => 'file',
'name' => 'src/util.c',
'acknowledgements' => 'Thanks to maintainers',
'comments' => ''
))

Definition at line 265 of file test_report_output.php.

◆ $compWithDesc

$compWithDesc
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'openssl',
'description' => 'Open source SSL/TLS toolkit'
))

Definition at line 228 of file test_report_output.php.

◆ $compWithExtRef

$compWithExtRef
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'openssl',
'externalReferences' => [
['type' => 'distribution', 'url' => 'https://www.openssl.org/source/openssl-3.0.12.tar.gz'],
['type' => 'vcs', 'url' => 'https://github.com/openssl/openssl']
]
))

Definition at line 286 of file test_report_output.php.

◆ $compWithProps

$compWithProps
Initial value:
= $generator->createComponent(array(
'type' => 'file',
'name' => 'src/main.c',
'acknowledgements' => "Thanks to the OpenSSL team\nThanks to contributors",
'comments' => 'Reviewed and approved by legal team'
))

Definition at line 247 of file test_report_output.php.

◆ $compWithPurl

$compWithPurl
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'busybox',
'purl' => 'pkg:deb/debian/busybox@1.36.1'
))

Definition at line 209 of file test_report_output.php.

◆ $compWithVersion

$compWithVersion
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'busybox',
'version' => '1.36.1'
))

Definition at line 190 of file test_report_output.php.

◆ $fileComponent

$fileComponent
Initial value:
= $generator->createComponent(array(
'type' => 'file',
'name' => 'src/main.c',
'bomref' => '42-100',
'copyright' => 'Copyright 2023 Test Author',
'hashes' => array($generator->createHash('SHA-1', 'aaa')),
'licenses' => array($result)
))

Definition at line 145 of file test_report_output.php.

◆ $fullComp

$fullComp
Initial value:
= $generator->createComponent(array(
'type' => 'library',
'name' => 'busybox',
'version' => '1.36.1',
'bomref' => '99',
'scope' => 'required',
'mimeType' => 'application/x-tar',
'copyright' => 'Copyright 2023 BusyBox Authors',
'description' => 'Tiny utilities for small and embedded systems',
'purl' => 'pkg:generic/busybox@1.36.1',
'hashes' => array($generator->createHash('SHA-256', 'abc123def456')),
'licenses' => array($result),
'externalReferences' => [
['type' => 'vcs', 'url' => 'https://git.busybox.net/busybox/']
],
'acknowledgements' => 'Thanks to Denys Vlasenko',
'comments' => 'Primary build dependency'
))

Definition at line 329 of file test_report_output.php.

◆ $licenseData

$licenseData
Initial value:
= array(
'id' => 'MIT',
'name' => 'MIT License',
'url' => 'https://opensource.org/licenses/MIT',
'textContent' => base64_encode('Permission is hereby granted, free of charge...'),
'textContentType' => 'text/plain'
)

Definition at line 59 of file test_report_output.php.

◆ $licenseDataNoText

$licenseDataNoText
Initial value:
= array(
'id' => 'Apache-2.0',
'name' => 'Apache License 2.0',
'url' => 'https://www.apache.org/licenses/LICENSE-2.0'
)

Definition at line 81 of file test_report_output.php.

◆ $licenseRef

$licenseRef
Initial value:
= array(
'id' => 'LicenseRef-fossology-custom',
'name' => 'Custom License'
)

Definition at line 95 of file test_report_output.php.

◆ $report

$report
Initial value:
= $generator->generateReport(array(
'tool-version' => '4.5.0',
'maincomponent' => $comp,
'components' => array($fileComponent)
))

Definition at line 154 of file test_report_output.php.

◆ $reportWithExtRef

$reportWithExtRef
Initial value:
= $generator->generateReport(array(
'tool-version' => '4.5.0',
'maincomponent' => $comp,
'components' => array($fileComponent),
'externalReferences' => [
['type' => 'website', 'url' => 'https://www.fossology.org']
]
))

Definition at line 312 of file test_report_output.php.

◆ else

if ( $failed > 0) else
Initial value:
{
echo "\nAll tests passed!\n"

Definition at line 369 of file test_report_output.php.