mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Redesign API key creation and enforce scoped abilities on the custom API routes. - ApiAbility enum and ability enforcement on the custom API routes - Redesigned API key creation: current user, all/custom permissions, and a dedicated one-time token page with a non-HTTPS clipboard fallback - Restrict custom keys to a known ability allowlist - Link global search results to the product view page rather than the edit page
27 lines
789 B
PHP
27 lines
789 B
PHP
<?php
|
|
|
|
namespace Tests\Unit\Enums;
|
|
|
|
use App\Enums\ApiAbility;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ApiAbilityTest extends TestCase
|
|
{
|
|
public function test_has_the_custom_route_abilities(): void
|
|
{
|
|
$this->assertSame('meta-extraction:extract', ApiAbility::MetaExtractionExtract->value);
|
|
$this->assertSame('user:detail', ApiAbility::UserDetail->value);
|
|
}
|
|
|
|
public function test_each_case_has_a_label_and_group(): void
|
|
{
|
|
foreach (ApiAbility::cases() as $case) {
|
|
$this->assertNotSame('', $case->label());
|
|
$this->assertNotSame('', $case->group());
|
|
}
|
|
|
|
$this->assertSame('Meta extraction', ApiAbility::MetaExtractionExtract->group());
|
|
$this->assertSame('Account', ApiAbility::UserDetail->group());
|
|
}
|
|
}
|