/** * @param $ip * @param $username * @param $userid * @param $display * @param $exception * @param $corruptRequest * * @throws \Exception * * @dataProvider ipOptions */ public function testRetrieve($ip, $username, $userid, $display, $exception = null, $corruptRequest = false) { if ($exception !== null) { $this->setExpectedException('\\Exception', $exception); } $cnf = []; $cnf['192.168.0.10'] = ['username' => 'bob', 'userid' => 3, 'display' => 'Bobby']; $cnf['192.168.0.11'] = ['userid' => 3, 'display' => 'Bobby']; $cnf['192.168.0.12'] = ['username' => 'bob', 'display' => 'Bobby']; $cnf['tester'] = ['username' => 'pet', 'userid' => 2, 'display' => 'Dog']; $cnf['192.168.0.20'] = ['alias' => 'tester']; $configProvider = new TestConfigProvider(); $authSection = new ConfigSection('ipauth', $cnf); $configProvider->addSection($authSection); $cubex = new Cubex(); $cubex->configure($configProvider); $request = new Request(); $request->server->set('REMOTE_ADDR', $ip); if ($corruptRequest) { $cubex->instance('request', 'invalid'); } else { $cubex->instance('request', $request); } $auth = new IPAuthProvider(); $auth->setCubex($cubex); $user = $auth->login('test', 'test'); if ($username === null) { $this->assertNull($user); } else { $this->assertEquals($username, $user->getUsername()); $this->assertEquals($userid, $user->getUserId()); $this->assertEquals($display, $user->getProperty('display')); } }
public function testAuthFacade() { $provider = new TestAuthProvider(); $authy = new AuthedUser('brooke', 1); $provider->setRetrieve($authy); $cubex = new Cubex(); $cubex->configure(new TestConfigProvider()); $cubex->processConfiguration($cubex->getConfiguration()); $cubex->instance('request', Request::createFromGlobals()); $cubex->instance('\\Cubex\\Auth\\IAuthProvider', $provider); $sm = new ServiceManager(); $sm->setCubex($cubex); $sm->boot(); Auth::setFacadeApplication($cubex); $username = '******'; $this->assertTrue(Auth::forgottenPassword($username)); $authUser = Auth::login($username, 'password'); $this->assertEquals("brooke", $authUser->getUsername()); $autho = Auth::getAuthedUser(); $this->assertEquals("brooke", $autho->getUsername()); Auth::updateAuthedUser($autho); $this->assertTrue(Auth::isLoggedIn()); $this->assertTrue(Auth::logout()); $this->assertFalse(Auth::isLoggedIn()); }
public function testServiceAliases() { $cubex = new Cubex(); $cubex->configure(new TestConfigProvider()); $manager = new ServiceManager(); $manager->setCubex($cubex); $manager->boot(); $encrypter = $cubex->make('encrypter'); $this->assertInstanceOf('\\Illuminate\\Encryption\\Encrypter', $encrypter); }
public function testRegisterCreatesEncrypter() { $cubex = new Cubex(); $cubex->configure(new TestConfigProvider()); $encryptionService = new EncryptionService(); $this->assertInstanceOf('\\Cubex\\ServiceManager\\IServiceProvider', $encryptionService); $encryptionService->boot($cubex, new ConfigSection()); $encryptionService->register(); $encrypter = $cubex->make('encrypter'); $this->assertInstanceOf('\\Illuminate\\Encryption\\Encrypter', $encrypter); }
public function testConfiguration() { $kernel = $this->getMockForAbstractClass('\\Cubex\\Kernel\\CubexKernel'); /** * @var $kernel CubexKernel */ $config = new TestConfigProvider(); $config->addItem('test', 'entry', 'cube'); $cubex = new Cubex(); $cubex->configure($config); $kernel->setCubex($cubex); $this->assertEquals('cube', $kernel->getConfigItem('test', 'entry', false)); $this->assertEquals(false, $kernel->getConfigItem('test', 'ab', false)); }
public function testConfigure() { $config = new TestConfigProvider(); $config->addItem("kernel", "project", 'Project'); $cubex = new Cubex(); $cubex->configure($config); $this->assertSame($config, $cubex->getConfiguration()); }