public function testBuildConfig()
 {
     // setup param
     $clientParam = \Lib\ServiceManager::getModel('Openvpn', 'ClientParam');
     $clientParam->setAccountId($this->account);
     $clientParam->addParam('dev', 'phpunit-dev');
     $clientParam->addParam('verb', '1');
     $clientParam->addParam('proto', 'phpunit-proto');
     $clientParam->save();
     // build config
     $config = \Lib\ServiceManager::getService('Openvpn', 'ClientConfig')->getConfig($this->account, 'us1');
     $this->assertNotEmpty($config);
     // check params
     preg_match("/\r\ndev\\s(.*)/", $config, $matches);
     $paramDev = $matches[1];
     $this->assertEquals('phpunit-dev', $paramDev);
     preg_match("/\r\nverb\\s(.*)/", $config, $matches);
     $paramVerb = $matches[1];
     $this->assertEquals('1', $paramVerb);
     preg_match("/\r\nproto\\s(.*)/", $config, $matches);
     $paramProto = $matches[1];
     $this->assertEquals('phpunit-proto', $paramProto);
     // check crt & key
     preg_match("/<cert>\r\n(.*)\r\n<\\/cert>/s", $config, $matches);
     $crt = $matches[1];
     $this->assertNotEmpty($crt);
     preg_match("/<key>\r\n(.*)\r\n<\\/key>/s", $config, $matches);
     $key = $matches[1];
     $this->assertNotEmpty($key);
     // delete params
     $clientParam->delete();
 }
 /**
  * Execute process 
  *
  * Implement Singleprocess run()
  * @param array
  */
 public function run()
 {
     $this->validate();
     $serverStatus = \Lib\ServiceManager::getModel('Openvpn', 'ServerStatus')->load($this->host);
     $serverStatus->fetchServerStatus();
     $serverStatus->save();
     $this->debug($serverStatus);
 }
示例#3
0
 public function getServiceConfig()
 {
     $default = array('factories' => array('Db\\Radius' => function ($sm) {
         return $sm->get('radius_prod');
     }, 'Db\\Webservice' => function ($sm) {
         return $sm->get('webserver_prod');
     }), 'initializers' => array('ObjectHelper' => function ($service, $sm) {
         // inject service manager  only when controllerManager get call
         if ($service instanceof \Zend\Mvc\Controller\ControllerManager) {
             \Lib\ServiceManager::setServiceManager($sm);
         }
     }));
     $init = array();
     //return array_merge($default, $this->getOpenvpnConfig());
     return array_merge_recursive($default, $this->getRadiusConfig(), $this->getOpenvpnConfig());
 }
 protected function getMapper()
 {
     $mapperNameSpace = explode('\\', get_class($this));
     return \Lib\ServiceManager::getMapper($mapperNameSpace[1], $mapperNameSpace[3]);
 }