60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\SecurityReport;
|
|
|
|
use App\Services\SecurityReport\SecurityReportScanner;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class SecurityReportScannerTest extends TestCase
|
|
{
|
|
public function test_it_summarizes_npm_metadata_vulnerability_counts(): void
|
|
{
|
|
$scanner = new SecurityReportScanner();
|
|
|
|
$counts = $scanner->summarizeNpmAudit([
|
|
'metadata' => [
|
|
'vulnerabilities' => [
|
|
'critical' => 1,
|
|
'high' => 2,
|
|
'moderate' => 3,
|
|
'low' => 4,
|
|
'info' => 5,
|
|
],
|
|
],
|
|
]);
|
|
|
|
self::assertSame(1, $counts['critical']);
|
|
self::assertSame(2, $counts['high']);
|
|
self::assertSame(3, $counts['moderate']);
|
|
self::assertSame(4, $counts['low']);
|
|
self::assertSame(5, $counts['info']);
|
|
}
|
|
|
|
public function test_it_summarizes_composer_advisory_severity_counts(): void
|
|
{
|
|
$scanner = new SecurityReportScanner();
|
|
|
|
$counts = $scanner->summarizeComposerAudit([
|
|
'advisories' => [
|
|
'laravel/framework' => [
|
|
['severity' => 'critical'],
|
|
['severity' => 'high'],
|
|
],
|
|
'symfony/http-foundation' => [
|
|
['severity' => 'medium'],
|
|
['severity' => 'low'],
|
|
['severity' => 'unexpected'],
|
|
],
|
|
],
|
|
]);
|
|
|
|
self::assertSame(1, $counts['critical']);
|
|
self::assertSame(1, $counts['high']);
|
|
self::assertSame(1, $counts['medium']);
|
|
self::assertSame(1, $counts['low']);
|
|
self::assertSame(1, $counts['unknown']);
|
|
}
|
|
}
|