Ejemplo n.º 1
0
 public function testOpenidWrapperRunModeIdResSmartModeDbStoreExistent()
 {
     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']);
     $_GET = self::$requestCheckAuthenticationGet;
     $_GET['openid_mode'] = 'id_res';
     $credentials = new ezcAuthenticationIdCredentials(self::$url);
     $options = new ezcAuthenticationOpenidOptions();
     $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART;
     $options->store = new ezcAuthenticationOpenidDbStore($this->db);
     $options->store->storeAssociation(self::$provider, $association);
     $filter = new ezcAuthenticationOpenidWrapper($options);
     $result = $filter->run($credentials);
     $this->assertEquals(ezcAuthenticationOpenidFilter::STATUS_SIGNATURE_INCORRECT, $result);
 }
Ejemplo n.º 2
0
 public function testOpenidWrapperAssociateDhSha1Gmp()
 {
     if (!ezcBaseFeatures::hasExtensionSupport('openssl')) {
         $this->markTestSkipped('PHP must be compiled with --with-openssl.');
     }
     if (!ezcBaseFeatures::hasExtensionSupport('gmp')) {
         $this->markTestSkipped('PHP must be compiled with --with-gmp.');
     }
     $lib = ezcAuthenticationMath::createBignumLibrary('gmp');
     $private = $lib->rand(self::$p);
     $private = $lib->add($private, 1);
     $public = $lib->powmod(self::$q, $private, self::$p);
     $params = array('openid.mode' => 'associate', 'openid.assoc_type' => 'HMAC-SHA1', 'openid.dh_modulus' => urlencode(base64_encode($lib->btwoc(self::$p))), 'openid.dh_gen' => 2, urlencode(base64_encode($lib->btwoc(self::$q))), 'openid.dh_consumer_public' => urlencode(base64_encode($lib->btwoc($public))));
     $filter = new ezcAuthenticationOpenidWrapper();
     $result = $filter->associate(self::$provider, $params);
     $this->assertNotEquals(false, $result);
     $this->assertEquals(true, isset($result['assoc_handle']));
     $this->assertEquals(true, isset($result['mac_key']));
 }