From 62203660c9742a648755d3d1e7c59df95458d578 Mon Sep 17 00:00:00 2001 From: lazos Date: Tue, 27 Sep 2016 18:33:29 +0200 Subject: [PATCH] complete #10 --- .../Minion/Console/Commands/RunCommand.php | 14 ++++++++++++- src/config/minion.php | 20 +++++++++++++++++++ tests/unit/MinionTest.php | 15 ++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Vinelab/Minion/Console/Commands/RunCommand.php b/src/Vinelab/Minion/Console/Commands/RunCommand.php index 346eadf..c726527 100644 --- a/src/Vinelab/Minion/Console/Commands/RunCommand.php +++ b/src/Vinelab/Minion/Console/Commands/RunCommand.php @@ -37,7 +37,7 @@ class RunCommand extends Command * * @var array * - * @since 1.3.0 + * @since 1.3.3 */ protected $options = array( 'realm', @@ -45,6 +45,8 @@ class RunCommand extends Command 'port', 'register', 'debug', + 'tls', + 'path', ); /** @@ -75,6 +77,14 @@ public function fire() $options['debug'] = true; } + if ($this->option('tls')) { + $options['tls'] = true; + } + + if ($this->option('path')) { + $options['path'] = $this->option('path'); + } + $m = new Minion(); if ($this->option('register')) { @@ -103,6 +113,8 @@ public function getOptions() ['realm', null, InputOption::VALUE_OPTIONAL, 'Specify WAMP realm to be used'], ['host', null, InputOption::VALUE_OPTIONAL, 'Specify the router host'], ['port', null, InputOption::VALUE_OPTIONAL, 'Specify the router port'], + ['tls', null, InputOption::VALUE_NONE, 'Specify the router protocol as wss'], + ['path', null, InputOption::VALUE_OPTIONAL, 'Specify the router path component'], ['register', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Register provider classes'], ['debug', null, InputOption::VALUE_NONE, 'Run in debug mode outputting all trasport messages.'], ]; diff --git a/src/config/minion.php b/src/config/minion.php index 7da31e6..5160d09 100644 --- a/src/config/minion.php +++ b/src/config/minion.php @@ -50,4 +50,24 @@ 'debug' => false, + /* + |-------------------------------------------------------------------------- + | Transport Layer Security + |-------------------------------------------------------------------------- + | + | Toggle between ws/wss protocol + | + */ + 'tls' => false, + + /* + |-------------------------------------------------------------------------- + | URL path component + |-------------------------------------------------------------------------- + | + | Will be appended to the transport URL as the path component + | + */ + 'path' => '/ws', + ]; diff --git a/tests/unit/MinionTest.php b/tests/unit/MinionTest.php index 2fc50b0..18d24ea 100644 --- a/tests/unit/MinionTest.php +++ b/tests/unit/MinionTest.php @@ -59,6 +59,21 @@ public function test_merging_config() $this->m->mergeConfig($options); $this->assertEquals($merged, $this->m->getConfig()); } + + public function test_config_tls() + { + $this->assertEquals(false, $this->m->getConfig('tls')); + $this->m->mergeConfig(['tls'=>true]); + $this->assertEquals(true, $this->m->getConfig('tls')); + } + + public function test_config_path() + { + $path = '/websocket'; + $this->assertEquals('/ws', $this->m->getConfig('path')); + $this->m->mergeConfig(['path'=>$path]); + $this->assertEquals($path, $this->m->getConfig('path')); + } } class NonProvider