/** * Provides test instances for all tests. * * @return array the test data */ public function instancesProvider() { $res = array(); $cryptoFactory = new CryptoFactory(); // Session login method (duration: 2 seconds) $storage = new DefaultStorage(new JsonStorageEngine(true, __DIR__ . DIRECTORY_SEPARATOR . 'test.json')); $session = new Session($storage, 'session', '/', null, false, new DefaultCookieTransceiver(), new DefaultCookieTransceiver()); $session->setDuration(2); $sessionLoginMethod = new SessionLoginMethod($session); // Default persistence login method (duration: 5 seconds) $storage = new JsonLoginStorage(__DIR__ . DIRECTORY_SEPARATOR . 'login.json', new Md5HashFunction(), 100, 'mykey'); $transceiver = new DefaultCookieTransceiver(); $defaultPersistenceLoginMethod = new DefaultPersistentLoginMethod($storage, $transceiver); $defaultPersistenceLoginMethod->setDuration(5); // Secure persistence login method (duration: 5 seconds) $storage = new JsonLoginStorage(__DIR__ . DIRECTORY_SEPARATOR . 'login.json', new Md5HashFunction(), 100, 'mykey'); $transceiver = new SecureCookieTransceiver($cryptoFactory->getHashFunction('Sha256'), $cryptoFactory->getHashFunction('Sha256'), $cryptoFactory->getSymmetricCypher('Aes256'), 'secret key', new GID(), 'session id'); $securePersistenceLoginMethod = new SecurePersistentLoginMethod($storage, $transceiver); $securePersistenceLoginMethod->setDuration(5); // User storage $userStorageMock = new MockUserStorage(self::GID); $res[] = array(new Login($sessionLoginMethod, $defaultPersistenceLoginMethod, $userStorageMock)); $res[] = array(new Login($sessionLoginMethod, $securePersistenceLoginMethod, $userStorageMock)); return $res; }
public function logout() { $this->session->destroy(); }
/** * Tests logout. * * @covers empire\framework\login\SessionLoginMethod::logout */ public function testLogout() { $gid = '58d93d649ffffffff5331ad0219ea200'; $storage = new DefaultStorage(new JsonStorageEngine(true, __DIR__ . DIRECTORY_SEPARATOR . 'test.json')); $session = new Session($storage, 'session', '/', null, false, new DefaultCookieTransceiver(), new DefaultCookieTransceiver()); $session->setDuration(200); $method = new SessionLoginMethod($session); $this->remoteCall('login', $method, $gid); $this->remoteCall('logout', $method); $this->assertNull($this->remoteCall('authenticate', $method)); }
function sessionDelete(Session $session, $index) { $res = $session->delete($index); echo base64_encode(serialize($res)); }