diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2021-05-10 21:49:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-10 21:49:17 +0200 |
commit | d1b6143b6bbd0b7c33fe298b63d2a74c06b012e6 (patch) | |
tree | 235c51ca45fb6b8ad7fa531da9f1124e88e22563 /tests/php | |
parent | 6168e9fe29464e14c9b0697e151ef8e1f76f76b0 (diff) | |
parent | 74baa14c5c6d99cf1d49db7bf88b3ea884345f8a (diff) |
Merge pull request #5491 from brknkfr/multiple_turnservers
Provide multiple TURN servers to webrtc client
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/ConfigTest.php | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/tests/php/ConfigTest.php b/tests/php/ConfigTest.php index 0cb2d9d95..3bcff2e12 100644 --- a/tests/php/ConfigTest.php +++ b/tests/php/ConfigTest.php @@ -117,13 +117,19 @@ class ConfigTest extends TestCase { ->willReturn(json_encode([ [ // No scheme explicitly given - 'server' => 'turn.example.org', + 'server' => 'turn.example.org:3478', 'secret' => 'thisisasupersecretsecret', 'protocols' => 'udp,tcp', ], [ 'schemes' => 'turn,turns', - 'server' => 'turn2.example.com', + 'server' => 'turn2.example.com:5349', + 'secret' => 'ThisIsAlsoSuperSecret', + 'protocols' => 'udp', + ], + [ + 'schemes' => 'turns', + 'server' => 'turn-tls.example.com:443', 'secret' => 'ThisIsAlsoSuperSecret', 'protocols' => 'tcp', ], @@ -149,24 +155,53 @@ class ConfigTest extends TestCase { $helper = new Config($config, $secureRandom, $groupManager, $timeFactory); // - $server = $helper->getTurnSettings(); - if ($server['server'] === 'turn.example.org') { - $this->assertSame([ - 'schemes' => 'turn', - 'server' => 'turn.example.org', - 'username' => '1479829425:abcdefghijklmnop', - 'password' => '4VJLVbihLzuxgMfDrm5C3zy8kLQ=', - 'protocols' => 'udp,tcp', - ], $server); - } else { - $this->assertSame([ - 'schemes' => 'turn,turns', - 'server' => 'turn2.example.com', - 'username' => '1479829425:abcdefghijklmnop', - 'password' => 'Ol9DEqnvyN4g+IAM+vFnqhfWUTE=', - 'protocols' => 'tcp', - ], $server); - } + $settings = $helper->getTurnSettings(); + $this->assertEquals(3, count($settings)); + $this->assertSame([ + 'schemes' => 'turn', + 'server' => 'turn.example.org:3478', + 'username' => '1479829425:abcdefghijklmnop', + 'password' => '4VJLVbihLzuxgMfDrm5C3zy8kLQ=', + 'protocols' => 'udp,tcp', + ], $settings[0]); + $this->assertSame([ + 'schemes' => 'turn,turns', + 'server' => 'turn2.example.com:5349', + 'username' => '1479829425:abcdefghijklmnop', + 'password' => 'Ol9DEqnvyN4g+IAM+vFnqhfWUTE=', + 'protocols' => 'udp', + ], $settings[1]); + $this->assertSame([ + 'schemes' => 'turns', + 'server' => 'turn-tls.example.com:443', + 'username' => '1479829425:abcdefghijklmnop', + 'password' => 'Ol9DEqnvyN4g+IAM+vFnqhfWUTE=', + 'protocols' => 'tcp', + ], $settings[2]); + } + + public function testGenerateTurnSettingsEmpty() { + /** @var MockObject|IConfig $config */ + $config = $this->createMock(IConfig::class); + $config + ->expects($this->once()) + ->method('getAppValue') + ->with('spreed', 'turn_servers', '') + ->willReturn(json_encode([])); + + /** @var MockObject|ITimeFactory $timeFactory */ + $timeFactory = $this->createMock(ITimeFactory::class); + + /** @var MockObject|IGroupManager $secureRandom */ + $groupManager = $this->createMock(IGroupManager::class); + + /** @var MockObject|ISecureRandom $secureRandom */ + $secureRandom = $this->createMock(ISecureRandom::class); + + $helper = new Config($config, $secureRandom, $groupManager, $timeFactory); + + $settings = $helper->getTurnSettings(); + $this->assertEquals(0, count($settings)); } public function dataGetWebSocketDomainForSignalingServer() { |