Multi-user OSINT investigation tool with owner-controlled per-user and per-group access grants. Includes Sherlock, theHarvester, crt.sh, WHOIS, and ip-api.com collectors wired through a pluggable Runner/queue pipeline, investigation search, and printable/CSV/JSON reporting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Osint;
|
|
|
|
use App\Models\Target;
|
|
use App\Osint\Runners\CrtShRunner;
|
|
use App\Osint\RunnerException;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
class CrtShRunnerTest extends TestCase
|
|
{
|
|
public function test_parses_and_deduplicates_subdomains(): void
|
|
{
|
|
Http::fake([
|
|
'crt.sh/*' => Http::response(json_encode([
|
|
['name_value' => "www.example.com\nexample.com"],
|
|
['name_value' => "*.example.com\nwww.example.com"],
|
|
])),
|
|
]);
|
|
|
|
$target = new Target(['type' => 'domain', 'value' => 'example.com']);
|
|
|
|
$result = (new CrtShRunner)->run($target);
|
|
|
|
$this->assertSame(
|
|
['*.example.com', 'example.com', 'www.example.com'],
|
|
$result->raw['subdomains']
|
|
);
|
|
$this->assertStringContainsString('3 unique subdomains', $result->summary);
|
|
}
|
|
|
|
public function test_handles_empty_response(): void
|
|
{
|
|
Http::fake(['crt.sh/*' => Http::response('')]);
|
|
|
|
$target = new Target(['type' => 'domain', 'value' => 'nonexistent-domain-xyz.com']);
|
|
|
|
$result = (new CrtShRunner)->run($target);
|
|
|
|
$this->assertSame([], $result->raw['subdomains']);
|
|
$this->assertSame('No certificates found.', $result->summary);
|
|
}
|
|
|
|
public function test_rejects_non_domain_targets(): void
|
|
{
|
|
$target = new Target(['type' => 'ip', 'value' => '8.8.8.8']);
|
|
|
|
$this->expectException(RunnerException::class);
|
|
|
|
(new CrtShRunner)->run($target);
|
|
}
|
|
|
|
public function test_throws_on_http_failure(): void
|
|
{
|
|
Http::fake(['crt.sh/*' => Http::response('', 500)]);
|
|
|
|
$target = new Target(['type' => 'domain', 'value' => 'example.com']);
|
|
|
|
$this->expectException(RunnerException::class);
|
|
|
|
(new CrtShRunner)->run($target);
|
|
}
|
|
}
|