1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BringYourOwnIdeas\SecurityChecker\Tests\Extensions; |
4
|
|
|
|
5
|
|
|
use BringYourOwnIdeas\Maintenance\Model\Package; |
|
|
|
|
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
7
|
|
|
use Symbiote\QueuedJobs\Services\QueuedJobService; |
8
|
|
|
|
9
|
|
|
class PackageSecurityExtensionTest extends SapphireTest |
10
|
|
|
{ |
11
|
|
|
protected static $fixture_file = 'PackageSecurityExtensionTest.yml'; |
12
|
|
|
|
13
|
|
|
protected function setUp() |
14
|
|
|
{ |
15
|
|
|
if (!class_exists(Package::class)) { |
16
|
|
|
static::$fixture_file = null; |
17
|
|
|
$this->markTestSkipped('This test class requires the maintenance module to be installed'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
QueuedJobService::config()->set('use_shutdown_function', false); |
21
|
|
|
|
22
|
|
|
parent::setUp(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testAlertsAreIncludedInDataSchema() |
26
|
|
|
{ |
27
|
|
|
/** @var Package $package */ |
28
|
|
|
$package = $this->objFromFixture(Package::class, 'package_a'); |
29
|
|
|
|
30
|
|
|
$dataSchema = $package->getDataSchema(); |
31
|
|
|
$this->assertArrayHasKey('securityAlerts', $dataSchema); |
32
|
|
|
$this->assertNotEmpty($dataSchema['securityAlerts']); |
33
|
|
|
|
34
|
|
|
$firstAlert = $dataSchema['securityAlerts'][0]; |
35
|
|
|
$this->assertEquals('SS-123-456', $firstAlert['Identifier']); |
36
|
|
|
$this->assertEquals('silverstripe.org', $firstAlert['ExternalLink']); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testListSecurityAlertIdentifiers() |
40
|
|
|
{ |
41
|
|
|
/** @var Package $package */ |
42
|
|
|
$package = $this->objFromFixture(Package::class, 'otheralerts'); |
43
|
|
|
|
44
|
|
|
$this->assertEquals('ABC-001, SPY-007', $package->listSecurityAlertIdentifiers()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetBadgesHook() |
48
|
|
|
{ |
49
|
|
|
/** @var Package $package */ |
50
|
|
|
$package = $this->objFromFixture(Package::class, 'otheralerts'); |
51
|
|
|
|
52
|
|
|
$badges = $package->getBadges(); |
53
|
|
|
$this->assertCount(1, $badges); |
54
|
|
|
$this->assertEquals('warning security-alerts__toggler', $badges->first()->Type); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths