public function testGenerate()
 {
     /* @var User $model */
     $model = $this->model->findOne(['username' => 'choateyao']);
     $this->generator->setModel($model);
     $this->generator->setModule(new Module('vsftpd', null, ['vsftpdUserConfigPath' => '/tmp']));
     $this->assertEquals(strlen($model->buildConfigBySetting()), $this->generator->generate());
     $this->assertFileExists('/tmp/choateyao');
 }
Exemple #2
0
 public function actionDelete($id)
 {
     /* @var User $model */
     $model = User::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException();
     }
     $generator = new GeneratorUserConfig(['module' => $this->module, 'model' => $model]);
     $generator->remove();
     $model->delete();
     return $this->redirect(['index']);
 }
Exemple #3
0
 public function testBuildConfigBySetting()
 {
     /* @var User $model */
     $model = $this->model->find()->andWhere(['username' => 'choateyao'])->one();
     $config = explode("\n", $model->buildConfigBySetting());
     $this->assertGreaterThanOrEqual(3, count($config));
     foreach ($config as $value) {
         list($k, $v) = explode('=', $value);
         $this->assertContains($k, ['download_enable', 'write_enable', 'local_root', 'cmds_denied']);
         switch ($k) {
             case 'download_enable':
             case 'write_enable':
                 $this->assertContains($v, ['YES', 'NO']);
                 break;
             case 'local_root':
                 $this->assertEquals('/data/data1/video', $v);
                 break;
             case 'cmds_denied':
                 $this->assertContains(explode(',', $v), $model->getFileOperationItem());
                 break;
         }
     }
 }
 public function down()
 {
     $this->dropTable('IF EXISTS ' . User::tableName());
     return true;
 }