public function testOpenidFileStoreRemoveAssociationNormal()
 {
     $path = $this->path;
     $store = new ezcAuthenticationOpenidFileStore($path);
     $association = ezcAuthenticationOpenidAssociation::__set_state(self::$association);
     $url = self::$url;
     $store->storeAssociation($url, $association);
     $files = ezcAuthenticationOpenidFileStoreHelper::getFiles($path);
     foreach ($files as $file) {
         if ($file !== '.' && $file !== '..') {
             break;
         }
     }
     $data = file_get_contents($path . DIRECTORY_SEPARATOR . $file);
     $this->assertEquals(unserialize($data), $store->getAssociation($url));
     $this->assertEquals(true, $store->removeAssociation($url));
     $this->assertEquals(false, $store->getAssociation($url));
 }
 public function testOpenidCaseNullSmartModeFileStoreExistent()
 {
     if (!(ezcBaseFeatures::hasExtensionSupport('bcmath') || ezcBaseFeatures::hasExtensionSupport('gmp'))) {
         $this->markTestSkipped('PHP must be compiled with --with-bcmath or --with-gmp.');
     }
     if (!ezcBaseFeatures::hasExtensionSupport('openssl')) {
         $this->markTestSkipped('PHP must be compiled with --with-openssl.');
     }
     $params = array('openid.mode' => 'associate', 'openid.assoc_type' => 'HMAC-SHA1');
     $filter = new ezcAuthenticationOpenidWrapper();
     $res = $filter->associate(self::$provider, $params);
     $secret = isset($res['enc_mac_key']) ? $res['enc_mac_key'] : $res['mac_key'];
     $association = new ezcAuthenticationOpenidAssociation($res['assoc_handle'], $secret, time(), $res['expires_in'], $res['assoc_type']);
     $credentials = new ezcAuthenticationIdCredentials(self::$url);
     $authentication = new ezcAuthentication($credentials);
     $options = new ezcAuthenticationOpenidOptions();
     $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART;
     $path = $this->createTempDir(get_class($this));
     $options->store = new ezcAuthenticationOpenidFileStore($path);
     $options->store->storeAssociation(self::$provider, $association);
     $filter = new ezcAuthenticationOpenidFilter($options);
     $authentication->addFilter($filter);
     try {
         $authentication->run();
         $this->removeTempDir();
         $this->fail("Expected exception was not thrown.");
     } catch (ezcAuthenticationOpenidException $e) {
         $result = $e->getMessage();
         $expected = "Could not redirect to 'http://www.myopenid.com/server?openid.return_to=http%3A%2F%2Flocalhost%2Fopenid.php%3Faction%3Dlogin%26openid_identifier%3Dhttp%253A%252F%252Fezc.myopenid.com%26nonce%3D859610&openid.trust_root=http%3A%2F%2Flocalhost&openid.identity=http%3A%2F%2Fezc.myopenid.com%2F&openid.mode=checkid_setup'. Most probably your browser does not support redirection or JavaScript.";
         $this->assertEquals(substr($expected, 0, 192), substr($result, 0, 192));
         $files = ezcAuthenticationOpenidFileStoreHelper::getFiles($path);
         foreach ($files as $file) {
             if ($file !== '.' && $file !== '..') {
                 break;
             }
         }
         $data = unserialize(file_get_contents($path . DIRECTORY_SEPARATOR . $file));
         $this->assertEquals('HMAC-SHA1', $data->type);
     }
     $this->removeTempDir();
 }