server = Mockery::mock(Server::class)->makePartial(); $this->server->shouldReceive('getAttribute')->with('user')->andReturn('ubuntu'); $this->server->shouldReceive('setAttribute')->andReturnSelf(); $this->server->user = 'ubuntu'; $this->commands = new ScannerCommands($this->server, SCANNER_TEST_RUN_ID); }); afterEach(function () { Mockery::close(); }); /** * @return array> */ function scannerCommandLists(ScannerCommands $commands): array { $auth = base64_encode(json_encode(['auths' => ['ghcr.io' => ['auth' => base64_encode('user:token')]]])); return [ 'prepare' => $commands->prepare(), 'dbUpdate' => $commands->dbUpdate(null), 'dbUpdate with url' => $commands->dbUpdate('https://mirror.example.com/grype/databases'), 'dbStatus' => $commands->dbStatus(), 'inspect' => $commands->inspect('localhost:5000/team/app:1.2'), 'pull' => $commands->pull('localhost:5000/team/app:1.2'), 'diskFree' => $commands->diskFree(), 'diskUsage' => $commands->diskUsage(), 'sbomFromLocal' => $commands->sbomFromLocal('nginx', SCANNER_TEST_HEX), 'sbomFromRegistry' => $commands->sbomFromRegistry('ghcr.io/a/b@sha256:'.str_repeat('ab', 32), 'linux/amd64', 'cand-'.SCANNER_TEST_HEX, null), 'sbomFromRegistry with auth' => $commands->sbomFromRegistry('ghcr.io/a/b:1', 'linux/arm64/v8', 'cand-1', $auth), 'grype' => $commands->grype(SCANNER_TEST_HEX), 'packages' => $commands->packages(SCANNER_TEST_HEX), 'tags' => $commands->tags('nginx', null), 'tags with auth' => $commands->tags('ghcr.io/a/b', $auth), 'digest' => $commands->digest('nginx:1.27', null, null), 'digest with platform and auth' => $commands->digest('ghcr.io/a/b:1', 'linux/amd64', $auth), 'cleanup' => $commands->cleanup(), 'deleteScannerData' => $commands->deleteScannerData(), 'runningContainers' => $commands->runningContainers(), 'deleteSboms' => $commands->deleteSboms(['sha256:'.SCANNER_TEST_HEX]), ]; } /** * Unwraps `sh -c '