Serialize NordVPN bootstrap and reconciliation

This commit is contained in:
ms2k 2026-08-07 01:04:03 +09:00
commit 6b2049ccf7

View file

@ -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);
}
}