paddel setup new verifier
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\LicenseProduct;
|
||||
use App\Models\LicenseActivation;
|
||||
use App\Services\Licensing\LicenseIssuer;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
@@ -18,4 +19,65 @@ class LicenseActivationTest extends TestCase
|
||||
$this->postJson('/api/v1/activate',$one)->assertOk();
|
||||
$this->postJson('/api/v1/activate',array_merge($one,['installationID'=>'22222222-2222-4222-8222-222222222222']))->assertStatus(409);
|
||||
}
|
||||
public function test_validation_refreshes_an_active_installation_without_calling_paddle(): void
|
||||
{
|
||||
$product = LicenseProduct::create([
|
||||
'code' => 'validate-active',
|
||||
'name' => 'Validate Active',
|
||||
'edition' => 'Professional',
|
||||
'activation_limit' => 1,
|
||||
'max_major_version' => 1,
|
||||
'active' => true,
|
||||
]);
|
||||
[, $key] = app(LicenseIssuer::class)->issue($product, 'Test', 'test@example.com');
|
||||
$request = [
|
||||
'licenseKey' => $key,
|
||||
'installationID' => '11111111-1111-4111-8111-111111111111',
|
||||
'appVersion' => '1.0.0',
|
||||
'platform' => 'macOS',
|
||||
];
|
||||
|
||||
$token = $this->postJson('/api/v1/activate', $request)->assertOk()->json('licenseToken');
|
||||
|
||||
$this->postJson('/api/v1/validate', [
|
||||
'licenseToken' => $token,
|
||||
'installationID' => $request['installationID'],
|
||||
'appVersion' => '1.0.1',
|
||||
'platform' => 'macOS',
|
||||
])->assertOk()->assertJson([
|
||||
'active' => true,
|
||||
])->assertJsonStructure(['licenseToken']);
|
||||
}
|
||||
|
||||
public function test_validation_rejects_an_installation_deactivated_from_the_portal(): void
|
||||
{
|
||||
$product = LicenseProduct::create([
|
||||
'code' => 'validate-deactivated',
|
||||
'name' => 'Validate Deactivated',
|
||||
'edition' => 'Personal',
|
||||
'activation_limit' => 1,
|
||||
'max_major_version' => 1,
|
||||
'active' => true,
|
||||
]);
|
||||
[, $key] = app(LicenseIssuer::class)->issue($product, 'Test', 'test@example.com');
|
||||
$request = [
|
||||
'licenseKey' => $key,
|
||||
'installationID' => '22222222-2222-4222-8222-222222222222',
|
||||
'appVersion' => '1.0.0',
|
||||
'platform' => 'macOS',
|
||||
];
|
||||
|
||||
$token = $this->postJson('/api/v1/activate', $request)->assertOk()->json('licenseToken');
|
||||
LicenseActivation::query()->where('installation_id', strtolower($request['installationID']))->update(['deactivated_at' => now()]);
|
||||
|
||||
$this->postJson('/api/v1/validate', [
|
||||
'licenseToken' => $token,
|
||||
'installationID' => $request['installationID'],
|
||||
'appVersion' => '1.0.0',
|
||||
'platform' => 'macOS',
|
||||
])->assertStatus(403)->assertJson([
|
||||
'message' => 'This Mac has been deactivated from the licence portal.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user