encodeToURL() public method

Encodes this error's response as a URL suitable for redirection. If the response has no return_to, another Auth_OpenID_ServerError is returned.
public encodeToURL ( )
Ejemplo n.º 1
0
 function test_browserWithReturnTo()
 {
     $return_to = "http://rp.unittest/consumer";
     // will be a ProtocolError raised by Decode or CheckIDRequest.answer
     $args = array('openid.mode' => 'monkeydance', 'openid.identity' => 'http://wagu.unittest/', 'openid.return_to' => $return_to);
     $e = new Auth_OpenID_ServerError($args, "plucky");
     $this->assertTrue($e->hasReturnTo());
     $expected_args = array('openid.mode' => 'error', 'openid.error' => 'plucky');
     $encoded = $e->encodeToURL();
     if (_isError($encoded)) {
         $this->fail($encoded->toString());
         return;
     }
     list($rt_base, $_result_args) = explode("?", $e->encodeToURL(), 2);
     $result_args = array();
     parse_str($_result_args, $result_args);
     $result_args = Auth_OpenID::fixArgs($result_args);
     $this->assertEquals($result_args, $expected_args);
 }
Ejemplo n.º 2
0
 function test_browserWithReturnTo_OpenID1_exceeds_limit()
 {
     $return_to = "http://rp.unittest/consumer" . str_repeat('x', Auth_OpenID_OPENID1_URL_LIMIT);
     // will be a ProtocolError raised by Decode or
     // CheckIDRequest.answer
     $args = Auth_OpenID_Message::fromPostArgs(array('openid.mode' => 'monkeydance', 'openid.identity' => 'http://wagu.unittest/', 'openid.return_to' => $return_to));
     $this->assertTrue($args->isOpenID1());
     $e = new Auth_OpenID_ServerError($args, "plucky");
     $this->assertTrue($e->hasReturnTo());
     $expected_args = array('openid.mode' => 'error', 'openid.error' => 'plucky');
     $this->assertTrue($e->whichEncoding() == Auth_OpenID_ENCODE_URL);
     list($rt_base, $result_args_s) = explode('?', $e->encodeToURL(), 2);
     $result_args = Auth_OpenID::parse_str($result_args_s);
     $this->assertEquals($result_args, $expected_args);
 }