- Add Metered and ConvexSol (CoTURN) provider drivers with response validation and caching - Add IceCandidateManager with automatic failover and structured logging - Add IceCandidateProviderInterface and DTOs conforming to RTCIceServer format
53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\IceCandidate\Providers\ConvexSolIceCandidateProvider;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Tests\TestCase;
|
|
|
|
class ConvexSolIceCandidateProviderTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Cache::flush();
|
|
}
|
|
|
|
public function test_builds_ice_servers_from_coturn_credentials(): void
|
|
{
|
|
$provider = new ConvexSolIceCandidateProvider([
|
|
'username' => 'convex_admin',
|
|
'password' => 'super_secret_password',
|
|
'turn_urls' => ['turn:turn.convexsol.com:3478', 'turns:turn.convexsol.com:5349'],
|
|
'stun_urls' => ['stun:turn.convexsol.com:3478', 'stun:stun.l.google.com:19302'],
|
|
]);
|
|
|
|
$candidates = $provider->getIceCandidates();
|
|
|
|
$this->assertCount(2, $candidates);
|
|
$array = $candidates->toArray();
|
|
|
|
$this->assertEquals(['stun:turn.convexsol.com:3478', 'stun:stun.l.google.com:19302'], $array[0]['urls']);
|
|
$this->assertEquals(['turn:turn.convexsol.com:3478', 'turns:turn.convexsol.com:5349'], $array[1]['urls']);
|
|
$this->assertEquals('convex_admin', $array[1]['username']);
|
|
$this->assertEquals('super_secret_password', $array[1]['credential']);
|
|
}
|
|
|
|
public function test_caches_coturn_credentials(): void
|
|
{
|
|
$provider = new ConvexSolIceCandidateProvider([
|
|
'username' => 'cached_user',
|
|
'password' => 'cached_pass',
|
|
'turn_urls' => 'turn:turn.convexsol.com:3478',
|
|
'stun_urls' => 'stun:turn.convexsol.com:3478',
|
|
]);
|
|
|
|
$candidates1 = $provider->getIceCandidates();
|
|
$candidates2 = $provider->getIceCandidates();
|
|
|
|
$this->assertCount(2, $candidates1);
|
|
$this->assertEquals($candidates1->toArray(), $candidates2->toArray());
|
|
}
|
|
}
|