Serialize NordVPN bootstrap and reconciliation
This commit is contained in:
parent
0e3c367bb7
commit
6b2049ccf7
1 changed files with 74 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
use OPNsense\NordVPN\EndpointStore;
|
||||
use OPNsense\NordVPN\EnrollmentInspector;
|
||||
use OPNsense\NordVPN\NordApi;
|
||||
use OPNsense\NordVPN\ReconciliationLock;
|
||||
use OPNsense\NordVPN\StatusStore;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
@ -58,4 +59,25 @@ final class StoreAndInspectorTest extends TestCase
|
|||
|
||||
unlink($path);
|
||||
}
|
||||
|
||||
public function testReconciliationLockRejectsConcurrentOperations(): void
|
||||
{
|
||||
$path = sys_get_temp_dir() . '/nordvpn-lock-' . bin2hex(random_bytes(8));
|
||||
$first = new ReconciliationLock($path);
|
||||
$second = new ReconciliationLock($path);
|
||||
|
||||
$first->acquire();
|
||||
try {
|
||||
$second->acquire();
|
||||
$this->fail('A concurrent operation acquired the lock.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('A NordVPN operation is already running.', $exception->getMessage());
|
||||
} finally {
|
||||
$first->release();
|
||||
}
|
||||
|
||||
$second->acquire();
|
||||
$second->release();
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue