37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Device;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\TestCase;
|
|
|
|
class DeviceChainKeyTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function accepts_coruna_xxbb_16_hex_and_ds_app_uuid(): void
|
|
{
|
|
$this->assertTrue(Device::isKnownChainKey('000C30D83CD0402E'));
|
|
$this->assertTrue(Device::isKnownChainKey('000c30d83cd0402e'));
|
|
$this->assertTrue(Device::isKnownChainKey('50624FE26CC4A0DF689EAEA117557C3E'));
|
|
$this->assertTrue(Device::isKnownChainKey('50624FE2-6CC4-A0DF-689E-AEA117557C3E'));
|
|
$this->assertTrue(Device::isKnownChainKey('50624fe2-6cc4-a0df-689e-aea117557c3e'));
|
|
}
|
|
|
|
#[Test]
|
|
public function rejects_scanner_junk_ids(): void
|
|
{
|
|
$this->assertFalse(Device::isKnownChainKey('CEFCAEEAEFADCDFAEC238552151148443471A198920AFCDEAECDECDECEDCE018'));
|
|
$this->assertFalse(Device::isKnownChainKey('CEFCAEEAEFADCDFAEC238552151148443485EF922FAAFCDEAECDECDECEDCE018'));
|
|
$this->assertFalse(Device::isKnownChainKey('46BE1'));
|
|
$this->assertFalse(Device::isKnownChainKey(''));
|
|
$this->assertFalse(Device::isKnownChainKey(null));
|
|
$this->assertFalse(Device::isKnownChainKey('not-a-device'));
|
|
$this->assertNull(Device::acceptChainKey('46BE1'));
|
|
$this->assertSame(
|
|
'000C30D83CD0402E',
|
|
Device::acceptChainKey('000C30D83CD0402E')
|
|
);
|
|
}
|
|
}
|