clusev/tests/Feature/WebauthnAvailableTest.php

37 lines
1.0 KiB
PHP

<?php
namespace Tests\Feature;
use App\Services\DeploymentService;
use App\Services\WebauthnService;
use Tests\TestCase;
class WebauthnAvailableTest extends TestCase
{
private function service(?string $domain): WebauthnService
{
$deployment = $this->mock(DeploymentService::class);
$deployment->shouldReceive('domain')->andReturn($domain);
return app(WebauthnService::class);
}
public function test_available_only_with_domain_and_https(): void
{
$this->app['request']->server->set('HTTPS', 'on');
$this->assertTrue($this->service('panel.example.com')->available());
}
public function test_unavailable_without_domain(): void
{
$this->app['request']->server->set('HTTPS', 'on');
$this->assertFalse($this->service(null)->available());
}
public function test_unavailable_without_https(): void
{
$this->app['request']->server->remove('HTTPS');
$this->assertFalse($this->service('panel.example.com')->available());
}
}