diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-06-29 15:01:44 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-06-29 16:08:57 +0200 |
commit | b00cf0e38ce18e5aed46919f0bf3cee04f6e585e (patch) | |
tree | e48cf3ffdb591658da1f20a88efbd38ef50b2bdc /tests/php | |
parent | 4d3dcf866d44a4f5b5a5ee072bb2bda5f58785a8 (diff) |
Add schemes to turn:delete OCC command
As no scheme could be set when deleting a TURN server all TURN servers
matching the server and protocols were deleted regardless of their
scheme.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/Command/Turn/DeleteTest.php | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/tests/php/Command/Turn/DeleteTest.php b/tests/php/Command/Turn/DeleteTest.php index 3617e3341..d57d6d1d3 100644 --- a/tests/php/Command/Turn/DeleteTest.php +++ b/tests/php/Command/Turn/DeleteTest.php @@ -56,7 +56,9 @@ class DeleteTest extends TestCase { public function testDeleteIfEmpty() { $this->input->method('getArgument') ->willReturnCallback(function ($arg) { - if ($arg === 'server') { + if ($arg === 'schemes') { + return 'turn,turns'; + } elseif ($arg === 'server') { return 'turn.example.com'; } elseif ($arg === 'protocols') { return 'udp,tcp'; @@ -84,7 +86,9 @@ class DeleteTest extends TestCase { public function testDelete() { $this->input->method('getArgument') ->willReturnCallback(function ($arg) { - if ($arg === 'server') { + if ($arg === 'schemes') { + return 'turn,turns'; + } elseif ($arg === 'server') { return 'turn2.example.com'; } elseif ($arg === 'protocols') { return 'udp,tcp'; @@ -96,6 +100,7 @@ class DeleteTest extends TestCase { ->with('spreed', 'turn_servers') ->willReturn(json_encode([ [ + 'schemes' => 'turn,turns', 'server' => 'turn1.example.com', 'secret' => 'my-test-secret-1', 'protocols' => 'udp,tcp' @@ -108,6 +113,7 @@ class DeleteTest extends TestCase { $this->equalTo('turn_servers'), $this->equalTo(json_encode([ [ + 'schemes' => 'turn,turns', 'server' => 'turn1.example.com', 'secret' => 'my-test-secret-1', 'protocols' => 'udp,tcp' @@ -124,7 +130,9 @@ class DeleteTest extends TestCase { public function testNothingToDelete() { $this->input->method('getArgument') ->willReturnCallback(function ($arg) { - if ($arg === 'server') { + if ($arg === 'schemes') { + return 'turn,turns'; + } elseif ($arg === 'server') { return 'turn4.example.com'; } elseif ($arg === 'protocols') { return 'udp,tcp'; @@ -136,16 +144,19 @@ class DeleteTest extends TestCase { ->with('spreed', 'turn_servers') ->willReturn(json_encode([ [ + 'schemes' => 'turn,turns', 'server' => 'turn1.example.com', 'secret' => 'my-test-secret-1', 'protocols' => 'udp,tcp' ], [ + 'schemes' => 'turn,turns', 'server' => 'turn2.example.com', 'secret' => 'my-test-secret-2', 'protocols' => 'udp,tcp' ], [ + 'schemes' => 'turn,turns', 'server' => 'turn3.example.com', 'secret' => 'my-test-secret-3', 'protocols' => 'udp,tcp' @@ -158,16 +169,19 @@ class DeleteTest extends TestCase { $this->equalTo('turn_servers'), $this->equalTo(json_encode([ [ + 'schemes' => 'turn,turns', 'server' => 'turn1.example.com', 'secret' => 'my-test-secret-1', 'protocols' => 'udp,tcp' ], [ + 'schemes' => 'turn,turns', 'server' => 'turn2.example.com', 'secret' => 'my-test-secret-2', 'protocols' => 'udp,tcp' ], [ + 'schemes' => 'turn,turns', 'server' => 'turn3.example.com', 'secret' => 'my-test-secret-3', 'protocols' => 'udp,tcp' @@ -180,4 +194,54 @@ class DeleteTest extends TestCase { $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); } + + public function testDeleteMatchingSchemes() { + $this->input->method('getArgument') + ->willReturnCallback(function ($arg) { + if ($arg === 'schemes') { + return 'turn,turns'; + } elseif ($arg === 'server') { + return 'turn.example.com'; + } elseif ($arg === 'protocols') { + return 'udp,tcp'; + } + throw new \Exception(); + }); + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('spreed', 'turn_servers') + ->willReturn(json_encode([ + [ + 'schemes' => 'turn,turns', + 'server' => 'turn.example.com', + 'secret' => 'my-test-secret-1', + 'protocols' => 'udp,tcp' + ], + [ + 'schemes' => 'turn', + 'server' => 'turn.example.com', + 'secret' => 'my-test-secret-1', + 'protocols' => 'udp,tcp' + ] + ])); + $this->config->expects($this->once()) + ->method('setAppValue') + ->with( + $this->equalTo('spreed'), + $this->equalTo('turn_servers'), + $this->equalTo(json_encode([ + [ + 'schemes' => 'turn', + 'server' => 'turn.example.com', + 'secret' => 'my-test-secret-1', + 'protocols' => 'udp,tcp' + ] + ])) + ); + $this->output->expects($this->once()) + ->method('writeln') + ->with($this->equalTo('<info>Deleted turn.example.com.</info>')); + + $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]); + } } |