Exemplo n.º 1
0
 /**
  * testing setOpEndpoint
  *
  */
 public function testSetOpEndpoint()
 {
     $this->expectOutputRegex('/.*/');
     // Hide stdout from the component when the test run
     $storage = new Provider\Storage\File(__DIR__ . "/_files/provider");
     $provider = new ProviderHelper(null, null, $this->_user, $storage);
     $provider->setOpEndpoint("http://www.test.com/real_endpoint.php");
     // OpenID 2.0 with SHA256
     $_SERVER['SCRIPT_URI'] = "http://www.test.com/endpoint.php";
     $response = new ResponseHelper(true);
     $storage->addAssociation(self::HANDLE, "sha256", pack("H*", '0102030405060708091011121314151617181920212223242526272829303132'), time() + 3660);
     $this->assertTrue($provider->respondToConsumer(array('openid_ns' => OpenId::NS_2_0, 'openid_assoc_handle' => self::HANDLE, 'openid_return_to' => 'http://www.test.com/test.php'), null, $response));
     $headers = $response->headers();
     $this->assertTrue($headers->has('Location'));
     $url = parse_url($headers->get('Location')->getFieldValue());
     $this->assertSame('www.test.com', $url['host']);
     $this->assertSame('/test.php', $url['path']);
     $ret = array();
     foreach (explode('&', $url['query']) as $line) {
         list($key, $val) = explode('=', $line, 2);
         $ret[$key] = urldecode($val);
     }
     $this->assertSame('id_res', $ret['openid.mode']);
     $this->assertSame('http://www.test.com/test.php', $ret['openid.return_to']);
     $this->assertSame(self::HANDLE, $ret['openid.assoc_handle']);
     $this->assertTrue(isset($ret['openid.response_nonce']));
     $this->assertTrue(isset($ret['openid.signed']));
     $this->assertTrue(isset($ret['openid.sig']));
     $this->assertSame(OpenId::NS_2_0, $ret['openid.ns']);
     $this->assertSame("http://www.test.com/real_endpoint.php", $ret['openid.op_endpoint']);
     $this->assertTrue($storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires));
     $this->assertSame('sha256', $macFunc);
     $storage->delAssociation(self::HANDLE);
 }
Exemplo n.º 2
0
 /**
  * testing getAssociation
  *
  */
 public function testGetAssociationExpiratin()
 {
     $expiresIn = time() + 1;
     $storage = new Storage\File(__DIR__ . "/_files");
     $storage->delAssociation(self::HANDLE);
     $this->assertTrue($storage->addAssociation(self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn));
     sleep(2);
     $this->assertFalse($storage->getAssociation(self::HANDLE, $macFunc, $secret, $expires));
 }