Пример #1
0
 public function testProcess()
 {
     $now = explode(" ", microtime());
     $model = eve()->model('auth')->create()->process(array('auth_slug' => 'TEST AUTH ' + $now[1], 'auth_permissions' => 'test_permissions_1,test_permissions_2', 'auth_password' => '123456', 'confirm' => '123456'));
     $this->assertTrue(is_numeric($model['auth_id']));
     eve()->registry()->set('test', 'auth', $model->get());
 }
Пример #2
0
 /**
  * Executes the job
  *
  * @return void
  */
 public function run()
 {
     //if no data
     if (empty($this->data)) {
         //there should be a global catch somewhere
         throw new Exception(self::FAIL_406);
     }
     //this will be returned at the end
     $results = array();
     //see if the email exists first
     $exists = eve()->model('auth')->exists($this->data['profile_email']);
     //if it does
     if ($exists) {
         //not sure, throw an error ?
         throw new Exception('Email exists.');
     }
     //find the profile by email
     $row = eve()->model('profile')->search()->process()->filterByProfileEmail($this->data['profile_email'])->getRow();
     //if no profile
     if (empty($row)) {
         //create one
         $row = eve()->model('profile')->create()->process($this->data)->get();
     }
     //store the profile
     $results['profile'] = $row;
     //create the auth
     $results['auth'] = eve()->model('auth')->create()->process($this->data)->get();
     //link profile
     eve()->model('auth')->linkProfile($results['auth']['auth_id'], $results['profile']['profile_id']);
     return $results;
 }
Пример #3
0
 /**
  * Main route method
  *
  * @return function
  */
 public function import(array $l10n = array())
 {
     //remember this scope
     $self = $this;
     //You can add validators here
     return function ($request, $response) use($self, $l10n) {
         //before we do anything, lets's check for l10n and i18n
         $host = $request->get('server', 'HTTP_HOST');
         //if we can't find the host
         if (!isset($l10n[$host]) || $l10n[$host] === 'default') {
             //just use the default settings
             $host = 'default';
         }
         //if it's a redirect
         if (is_string($l10n[$host])) {
             eve()->redirect('http://' . $l10n[$host]);
         }
         //load the languages
         foreach ($l10n[$host]['i18n'] as $i => $i18n) {
             $translations = eve()->settings('i18n/' . $i18n);
             if ($i === 0) {
                 eve()->defaultLanguage = eve('language', $translations);
             }
             $request->set('i18n', $i18n, $translations);
         }
         //set the locale
         $request->set('l10n', $l10n[$host]);
     };
 }
Пример #4
0
 public function testRender()
 {
     $app = eve()->registry()->get('test', 'app');
     $_GET = array('client_id' => $app['app_token'], 'redirect_uri' => '/control/app/search');
     $results = BrowserTest::i()->setPath('/dialog/action/login')->setGet($_GET)->setQueryString($_GET)->setIsTriggered(true)->process();
     $this->assertTrue($results['triggered']);
 }
Пример #5
0
 public function testUnlinkProfile()
 {
     $auth = eve()->registry()->get('test', 'auth');
     $model = eve()->model('auth')->unlinkProfile($auth['auth_id'], 400);
     $this->assertEquals($auth['auth_id'], $model['auth_profile_auth']);
     $this->assertEquals(400, $model['auth_profile_profile']);
 }
Пример #6
0
 public function testImport()
 {
     $callback = Eve\Plugin\Csrf\Setup::i()->import();
     $this->assertTrue(is_callable($callback));
     $error = false;
     try {
         eve()->addCsrf(eden('registry'), eden('registry'), array('method' => 'GET', 'check_csrf' => true));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertTrue($error);
     $error = false;
     $request = eden('registry')->set('get', 'csrf', '1234567890');
     try {
         eve()->addCsrf($request, eden('registry'), array('method' => 'GET', 'check_csrf' => true, 'make_csrf' => true));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertFalse($error);
     $this->assertTrue($request->get('get', 'csrf') !== $request->get('csrf'));
     $_GET['csrf'] = $_SESSION['csrf'] = $request->get('csrf');
     $error = false;
     try {
         $callback($request, eden('registry'));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertFalse($error);
 }
Пример #7
0
 public function testRender()
 {
     $app = eve()->registry()->get('test', 'app');
     $_GET = array('access_token' => $app['app_token']);
     $results = BrowserTest::i()->setPath('/rest/action/profile/search')->setGet($_GET)->setSource($_GET)->setIsTriggered(false)->process();
     $this->assertContains('"error": false', $results['data']);
 }
Пример #8
0
 public function testProcess()
 {
     $auth = eve()->registry()->get('test', 'auth');
     $profile = eve()->registry()->get('test', 'profile');
     $row = eve()->model('session')->login()->process(array('auth_slug' => $auth['auth_slug'], 'auth_password' => '123456'));
     $this->assertEquals($profile['profile_name'], $row['profile_name']);
 }
Пример #9
0
 public function testProcess()
 {
     $now = explode(" ", microtime());
     $auth = eve()->registry()->get('test', 'auth');
     $model = eve()->model('auth')->update()->process(array('auth_id' => $auth['auth_id'], 'auth_slug' => 'TEST AUTH ' + $now[1], 'auth_permissions' => 'test_permissions_1,test_permissions_2', 'auth_password' => '123456', 'confirm' => '123456'));
     $this->assertEquals('test_permissions_1,test_permissions_2', $model['auth_permissions']);
 }
Пример #10
0
 public function testGetAppByToken()
 {
     $session = eve()->registry()->get('test', 'session');
     $app = eve()->registry()->get('test', 'app');
     $row = eve()->model('session')->getAppByToken($session['access_token']);
     $this->assertEquals($app['app_id'], $row['app_id']);
 }
Пример #11
0
 public function testProcess()
 {
     $rows = eve()->model('profile')->search()->process()->getRows();
     foreach ($rows as $row) {
         $this->assertEquals(1, $row['profile_active']);
     }
 }
Пример #12
0
 public function testValid()
 {
     $data = array('app_name' => 'Test Action App Updated', 'app_domain' => '*.test.com', 'app_permissions' => 'public_sso,user_profile,global_profile', 'profile_id' => $_SESSION['me']['profile_id']);
     $app = eve()->registry()->get('test', 'app');
     $variables = array($app['app_id']);
     $results = BrowserTest::i()->setPath('/back/action/app/update')->setPost($data)->setVariables($variables)->setIsValid(true)->setIsTriggered(true)->process();
     $this->assertTrue($results['triggered']);
 }
Пример #13
0
 public function testProcess()
 {
     $auth = eve()->registry()->get('test', 'auth');
     $app = eve()->registry()->get('test', 'app');
     $config = eve()->settings('test');
     $model = eve()->model('session')->request()->process(array('app_id' => $app['app_id'], 'auth_id' => $auth['auth_id'], 'session_permissions' => implode(',', $config['scope'])));
     $this->assertTrue(is_string($model['session_token']));
     eve()->registry()->set('test', 'session', $model->get());
 }
Пример #14
0
 public function testRender()
 {
     $app = eve()->registry()->get('test', 'app');
     $_GET = array('access_token' => $app['app_token'], 'access_secret' => $app['app_secret']);
     $_POST = array('profile_name' => 'Profile updated by REST');
     $source = array('profile_id' => 1);
     $results = BrowserTest::i()->setPath('/rest/action/profile/update')->setPost($_POST)->setSource($source)->setIsTriggered(false)->process();
     $this->assertContains('"error": false', $results['data']);
 }
Пример #15
0
 public function testValid()
 {
     $app = eve()->registry()->get('test', 'app');
     $_GET = array('client_id' => $app['app_token'], 'redirect_uri' => '/control/app/search');
     $_POST = array('profile_name' => 'Test Dialog Action Create', 'profile_email' => '*****@*****.**', 'auth_permissions' => 'user_profile,personal_profile,global_profile', 'auth_password' => '123', 'confirm' => '123');
     $app = eve()->registry()->get('test', 'app');
     $results = BrowserTest::i()->setPath('/dialog/action/update')->setGet($_GET)->setPost($_POST)->setSource($app)->setQueryString($_POST)->setIsValid(true)->setIsTriggered(true)->process();
     $this->assertTrue($results['triggered']);
 }
Пример #16
0
 public function testRender()
 {
     $app = eve()->registry()->get('test', 'app');
     $session = eve()->registry()->get('test', 'session');
     $_GET = array('access_token' => $app['app_token'], 'access_secret' => $app['app_secret']);
     $_POST = array('code' => $session['session_token']);
     $results = BrowserTest::i()->setPath('/rest/action/access')->setMethod($_GET)->setPost($_POST)->setSource($_GET)->setIsTriggered(false)->process();
     $this->assertContains('"error": false', $results['data']);
 }
Пример #17
0
 /**
  * Main action call
  *
  * @return string|null|void
  */
 public function render()
 {
     $data = $this->request->get('get');
     $data['range'] = $this->range;
     //get rows
     $rows = eve()->model('profile')->search()->process($data)->setColumns('profile_id', 'profile_name', 'profile_image', 'profile_created')->getRows();
     //success
     $this->success($rows);
 }
Пример #18
0
 /**
  * Executes the job
  *
  * @return void
  */
 public function run()
 {
     //if no data
     if (empty($this->data)) {
         //there should be a global catch somewhere
         throw new Exception(self::FAIL_406);
     }
     $results['session'] = eve()->model('session')->request()->process($this->data)->get();
     return $results;
 }
Пример #19
0
 public function testProcess()
 {
     $config = eve()->settings('test');
     $profile = eve()->registry()->get('test', 'profile');
     $session = eve()->registry()->get('test', 'session');
     $model = eve()->model('session')->access()->process(array('client_id' => $config['app_token'], 'client_secret' => $config['app_secret'], 'code' => $session['session_token']));
     $this->assertTrue(is_string($model['access_token']));
     $this->assertTrue(is_string($model['access_secret']));
     $this->assertEquals($profile['profile_name'], $model['profile_name']);
     eve()->registry()->set('test', 'session', $model);
 }
Пример #20
0
 public function testProcess()
 {
     $model = eve()->model('profile')->create()->process(array('profile_name' => 'Automated Test', 'profile_email' => '*****@*****.**'));
     $this->assertTrue(is_numeric($model['profile_id']));
     eve()->registry()->set('test', 'set', $model->get());
     $set = eve()->registry()->get('test', 'set');
     $model = eve()->model('profile')->update()->process(array('profile_id' => $set['profile_id'], 'profile_name' => 'Automated Test', 'profile_email' => '*****@*****.**'));
     $this->assertEquals($set['profile_id'], $model['profile_id']);
     $model = eve()->model('profile')->set()->process(array('profile_id' => $set['profile_id'], 'profile_name' => 'Automated Test', 'profile_email' => '*****@*****.**'));
     $this->assertEquals($set['profile_id'], $model['profile_id']);
     $this->assertEquals('*****@*****.**', $model['profile_email']);
 }
Пример #21
0
 /**
  * Processes the form
  *
  * @param array $data The item to process
  *
  * @return mixed
  */
 public function process(array $data = array())
 {
     //prevent uncatchable error
     if (count($this->errors($data))) {
         throw new Exception(self::FAIL_406);
     }
     //prepare
     $data = $this->prepare($data);
     $search = eve()->database()->search('app')->filterByAppId($data['app_id']);
     eve()->trigger('app-detail', $search);
     return $search;
 }
Пример #22
0
 public function testValid()
 {
     $app = eve()->registry()->get('test', 'app');
     $auth = eve()->registry()->get('test', 'auth');
     $_GET = array('client_id' => $app['app_token'], 'redirect_uri' => '/control/app/search');
     $config = eve()->settings('test');
     $_POST = array('session_permissions' => $config['scope'], 'action' => 'allow');
     $results = BrowserTest::i()->setPath('/dialog/action/request')->setGet($_GET)->setPost($_POST)->setSource($app)->setQueryString($_GET)->setIsTriggered(true)->process();
     $this->assertTrue($results['triggered']);
     $session = eve()->model('session')->request()->process(array('app_id' => $app['app_id'], 'auth_id' => $_SESSION['me']['auth_id'], 'session_permissions' => implode(',', $config['scope'])));
     eve()->registry()->set('test', 'session', $session);
 }
Пример #23
0
 /**
  * Processes the form
  *
  * @param array $data The item to process
  *
  * @return mixed
  */
 public function process(array $data = array())
 {
     //prevent uncatchable error
     if (count($this->errors($data))) {
         throw new Exception(self::FAIL_406);
     }
     //prepare
     $data = $this->prepare($data);
     $search = eve()->database()->search('auth')->setColumns('profile.*', 'auth.*')->innerJoinOn('auth_profile', 'auth_profile_auth = auth_id')->innerJoinOn('profile', 'auth_profile_profile = profile_id')->filterByAuthSlug($data['auth_slug'])->filterByAuthPassword(md5($data['auth_password']));
     $row = $search->getRow();
     eve()->trigger('session-login', $row);
     return $row;
 }
Пример #24
0
 /**
  * Processes the form
  *
  * @param array $data The item to process
  *
  * @return mixed
  */
 public function process(array $data = array())
 {
     //prevent uncatchable error
     if (count($this->errors($data))) {
         throw new Exception(self::FAIL_406);
     }
     //prepare
     $data = $this->prepare($data);
     $model = eve()->database()->model()->setAuthId($data['auth_id'])->setAuthActive('1');
     $model->save('auth');
     eve()->trigger('auth-restore', $model);
     return $model;
 }
Пример #25
0
 /**
  * Processes the form
  *
  * @param array $data The item to process
  *
  * @return mixed
  */
 public function process(array $data = array())
 {
     //prevent uncatchable error
     if (count($this->errors($data))) {
         throw new Exception(self::FAIL_406);
     }
     //prepare
     $data = $this->prepare($data);
     $model = eve()->database()->model()->setProfileId($data['profile_id'])->setProfileActive('0');
     $model->save('profile');
     eve()->trigger('profile-remove', $model);
     return $model;
 }
Пример #26
0
 public function testRun()
 {
     $thrown = false;
     try {
         eve()->job('session-access')->run();
     } catch (Exception $e) {
         $this->assertInstanceOf('Eve\\Framework\\Job\\Exception', $e);
         $thrown = true;
     }
     $this->assertTrue($thrown);
     $results = eve()->job('session-access')->setData(array('client_id' => eve()->registry()->get('test', 'app', 'app_token'), 'client_secret' => eve()->registry()->get('test', 'app', 'app_secret'), 'code' => eve()->registry()->get('test', 'session', 'session_token')))->run();
     $this->assertEquals(eve()->registry()->get('test', 'profile', 'profile_name'), $results['session']['profile_name']);
 }
Пример #27
0
 public function testRun()
 {
     $thrown = false;
     try {
         eve()->job('app-remove')->run();
     } catch (Exception $e) {
         $this->assertInstanceOf('Eve\\Framework\\Job\\Exception', $e);
         $thrown = true;
     }
     $this->assertTrue($thrown);
     $app = eve()->registry()->get('test', 'app');
     $results = eve()->job('app-remove')->setData(array('app_id' => $app['app_id']))->run();
     $this->assertTrue(is_numeric($results['app']['app_id']));
 }
Пример #28
0
 public function testRun()
 {
     $thrown = false;
     try {
         eve()->job('session-request')->run();
     } catch (Exception $e) {
         $this->assertInstanceOf('Eve\\Framework\\Job\\Exception', $e);
         $thrown = true;
     }
     $this->assertTrue($thrown);
     $results = eve()->job('session-request')->setData(array('app_id' => eve()->registry()->get('test', 'app', 'app_id'), 'auth_id' => eve()->registry()->get('test', 'auth', 'auth_id'), 'session_permissions' => 'public_sso,user_profile,global_profile,personal_profile'))->run();
     $this->assertTrue(is_string($results['session']['session_token']));
     eve()->registry()->set('test', 'session', $results['session']);
 }
Пример #29
0
 public function testRun()
 {
     $thrown = false;
     try {
         eve()->job('profile-update')->run();
     } catch (Exception $e) {
         $this->assertInstanceOf('Eve\\Framework\\Job\\Exception', $e);
         $thrown = true;
     }
     $this->assertTrue($thrown);
     $profile = eve()->registry()->get('test', 'profile');
     $results = eve()->job('profile-update')->setData(array('profile_id' => $profile['profile_id'], 'profile_name' => 'Test Job Profile Update'))->run();
     $this->assertTrue(is_numeric($results['profile']['profile_id']));
     $this->assertEquals('Test Job Profile Update', $results['profile']['profile_name']);
 }
Пример #30
0
 public function testRun()
 {
     $thrown = false;
     try {
         eve()->job('app-update')->run();
     } catch (Exception $e) {
         $this->assertInstanceOf('Eve\\Framework\\Job\\Exception', $e);
         $thrown = true;
     }
     $this->assertTrue($thrown);
     $app = eve()->registry()->get('test', 'app');
     $results = eve()->job('app-update')->setData(array('app_id' => $app['app_id'], 'app_name' => 'Test Job App Update', 'app_domain' => '*.test.com', 'app_permissions' => 'public_sso,user_profile,global_profile'))->run();
     $this->assertTrue(is_numeric($results['app']['app_id']));
     $this->assertEquals('Test Job App Update', $results['app']['app_name']);
 }