22 lines
1.0 KiB
PHP
22 lines
1.0 KiB
PHP
<?php
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\LicenseProduct;
|
|
use App\Services\Licensing\LicenseIssuer;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class LicenseActivationTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
public function test_activation_is_idempotent_and_enforces_machine_limit(): void
|
|
{
|
|
$product=LicenseProduct::create(['code'=>'test','name'=>'Test','edition'=>'Professional','activation_limit'=>1,'max_major_version'=>1,'active'=>true]);
|
|
[, $key]=app(LicenseIssuer::class)->issue($product,'Test','test@example.com');
|
|
$one=['licenseKey'=>$key,'installationID'=>'11111111-1111-4111-8111-111111111111','appVersion'=>'1.0.0','platform'=>'macOS'];
|
|
$this->postJson('/api/v1/activate',$one)->assertOk()->assertJsonStructure(['licenseToken']);
|
|
$this->postJson('/api/v1/activate',$one)->assertOk();
|
|
$this->postJson('/api/v1/activate',array_merge($one,['installationID'=>'22222222-2222-4222-8222-222222222222']))->assertStatus(409);
|
|
}
|
|
}
|