31 lines
1.2 KiB
PHP
31 lines
1.2 KiB
PHP
<?php
|
|
namespace Tests\Feature;
|
|
|
|
use Tests\TestCase;
|
|
|
|
final class SonarDeskCheckoutHandoffTest extends TestCase
|
|
{
|
|
public function test_checkout_is_disabled_by_default(): void
|
|
{
|
|
config()->set('sonardesk-integration.checkout_enabled', false);
|
|
$this->get('/sonardesk/buy')->assertOk()->assertSee('not yet enabled');
|
|
$this->get('/sonardesk/checkout')->assertStatus(503);
|
|
}
|
|
|
|
public function test_checkout_rejects_unlisted_host(): void
|
|
{
|
|
config()->set('sonardesk-integration.checkout_enabled', true);
|
|
config()->set('sonardesk-integration.checkout_url', 'https://evil.example/buy');
|
|
config()->set('sonardesk-integration.allowed_checkout_hosts', ['sonardesk.example']);
|
|
$this->get('/sonardesk/checkout')->assertStatus(503);
|
|
}
|
|
|
|
public function test_checkout_redirects_only_to_approved_https_host(): void
|
|
{
|
|
config()->set('sonardesk-integration.checkout_enabled', true);
|
|
config()->set('sonardesk-integration.checkout_url', 'https://sonardesk.example/buy');
|
|
config()->set('sonardesk-integration.allowed_checkout_hosts', ['sonardesk.example']);
|
|
$this->get('/sonardesk/checkout')->assertRedirect('https://sonardesk.example/buy');
|
|
}
|
|
}
|