Ejemplo n.º 1
0
 public function __construct(Storage\AbstractStorage $storage = null, $dumbMode = false)
 {
     $container = new SessionContainer('Default', new SessionManager());
     $this->setSession($container);
     parent::__construct($storage, $dumbMode);
 }
Ejemplo n.º 2
0
 /**
  * testing check
  *
  */
 public function testCheck()
 {
     $expiresIn = time() + 600;
     $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php";
     $storage = new Storage\File(__DIR__ . "/_files/consumer");
     $storage->delDiscoveryInfo(self::ID);
     $this->assertTrue($storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn));
     $storage->delAssociation(self::SERVER);
     $this->assertTrue($storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn));
     $response = new OpenIDTest\ResponseHelper(true);
     $consumer = new Consumer($storage);
     $this->assertTrue($consumer->check(self::ID, null, null, null, $response));
     $headers = $response->getHeaders();
     $this->assertSame('', $response->getBody());
     $this->assertTrue(is_array($headers));
     $this->assertSame(1, count($headers));
     $this->assertTrue(is_array($headers[0]));
     $this->assertSame(3, count($headers[0]));
     $this->assertSame('Location', $headers[0]['name']);
     $this->assertSame(true, $headers[0]['replace']);
     $url = $headers[0]['value'];
     $url = parse_url($url);
     $this->assertSame("http", $url['scheme']);
     $this->assertSame("www.myopenid.com", $url['host']);
     $this->assertSame("/", $url['path']);
     $q = explode("&", $url['query']);
     $query = array();
     foreach ($q as $var) {
         if (list($key, $val) = explode("=", $var, 2)) {
             $query[$key] = $val;
         }
     }
     $this->assertTrue(is_array($query));
     $this->assertSame(6, count($query));
     $this->assertSame('checkid_immediate', $query['openid.mode']);
     $this->assertSame('http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity']);
     $this->assertSame('http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id']);
     $this->assertSame(self::HANDLE, $query['openid.assoc_handle']);
     $this->assertSame('http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to']);
     $this->assertSame('http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root']);
     $storage->delDiscoveryInfo(self::ID);
     $storage->delAssociation(self::SERVER);
 }