function test_fromSuccessResponse() { $name = "ziggy"; $value = "stardust"; $uri = "http://david.bowie.name/"; $args = array('mode' => 'id_res', 'ns' => Auth_OpenID_OPENID2_NS, 'ns.ax' => Auth_OpenID_AX_NS_URI, 'ax.mode' => 'fetch_response', 'ax.update_url' => 'http://example.com/realm/update_path', 'ax.type.' . $name => $uri, 'ax.count.' . $name => '1', 'ax.value.' . $name . '.1' => $value); $sf = array(); foreach (array_keys($args) as $k) { array_push($sf, $k); } $msg = Auth_OpenID_Message::fromOpenIDArgs($args); $e = new FauxEndpoint(); $resp = new Auth_OpenID_SuccessResponse($e, $msg, $sf); $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($resp, false); $this->assertFalse($ax_resp === null); $this->assertTrue(is_a($ax_resp, 'Auth_OpenID_AX_FetchResponse')); $values = $ax_resp->get($uri); $this->assertEquals(array($value), $values); }
function fromKVForm($kvform_string) { // Create a Message from a KVForm string return Auth_OpenID_Message::fromOpenIDArgs(Auth_OpenID_KVForm::toArray($kvform_string)); }
/** * @access private */ function _createAssociateRequest($endpoint, $assoc_type, $session_type) { if (array_key_exists($session_type, $this->session_types)) { $session_type_class = $this->session_types[$session_type]; if (is_callable($session_type_class)) { $assoc_session = $session_type_class(); } else { $assoc_session = new $session_type_class(); } } else { return null; } $args = array('mode' => 'associate', 'assoc_type' => $assoc_type); if (!$endpoint->compatibilityMode()) { $args['ns'] = Auth_OpenID_OPENID2_NS; } // Leave out the session type if we're in compatibility mode // *and* it's no-encryption. if (!$endpoint->compatibilityMode() || $assoc_session->session_type != 'no-encryption') { $args['session_type'] = $assoc_session->session_type; } $args = array_merge($args, $assoc_session->getRequest()); $message = Auth_OpenID_Message::fromOpenIDArgs($args); return array($assoc_session, $message); }
function test_openID2MismatchedDoesDisco_failure() { $mismatched = new Auth_OpenID_ServiceEndpoint(); $mismatched->identity = 'nothing special, but different'; $mismatched->local_id = 'green cheese'; $op_endpoint = 'Phone Home'; $msg = Auth_OpenID_Message::fromOpenIDArgs(array('ns' => Auth_OpenID_OPENID2_NS, 'identity' => 'sour grapes', 'claimed_id' => 'monkeysoft', 'op_endpoint' => $op_endpoint)); $result = $this->consumer->_verifyDiscoveryResults($msg, $mismatched); $this->assertTrue(Auth_OpenID::isFailure($result)); }
function test_200() { $response = new Auth_Yadis_HTTPResponse(); $response->status = 200; $response->body = "foo:bar\nbaz:quux\n"; $r = Auth_OpenID_GenericConsumer::_httpResponseToMessage($response, $this->server_url); $expected_msg = Auth_OpenID_Message::fromOpenIDArgs(array('foo' => 'bar', 'baz' => 'quux')); $this->assertEquals($expected_msg, $r); }
function _setUpDH() { list($sess, $message) = $this->consumer->_createAssociateRequest($this->endpoint, 'HMAC-SHA1', 'DH-SHA1'); // XXX: this is testing _createAssociateRequest $this->assertEquals($this->endpoint->compatibilityMode(), $message->isOpenID1()); $server_sess = Auth_OpenID_DiffieHellmanSHA1ServerSession::fromMessage($message); $server_resp = $server_sess->answer($this->secret); $server_resp['assoc_type'] = 'HMAC-SHA1'; $server_resp['assoc_handle'] = 'handle'; $server_resp['expires_in'] = '1000'; $server_resp['session_type'] = 'DH-SHA1'; return array($sess, Auth_OpenID_Message::fromOpenIDArgs($server_resp)); }
function test_fromSuccessResponse() { $openid_req_msg = Auth_OpenID_Message::fromOpenIDArgs(array('mode' => 'id_res', 'ns' => Auth_OpenID_OPENID2_NS, 'ns.pape' => Auth_OpenID_PAPE_NS_URI, 'auth_policies' => implode(' ', array(PAPE_AUTH_MULTI_FACTOR, PAPE_AUTH_PHISHING_RESISTANT)), 'auth_time' => '2008-03-02T12:34:56Z')); $signed_stuff = array('auth_policies' => implode(' ', array(PAPE_AUTH_MULTI_FACTOR, PAPE_AUTH_PHISHING_RESISTANT)), 'auth_time' => '2008-03-02T12:34:56Z'); $oid_req = new PAPE_DummySuccessResponse($openid_req_msg, $signed_stuff); $req = Auth_OpenID_PAPE_Response::fromSuccessResponse($oid_req); $this->assertEquals(array(PAPE_AUTH_MULTI_FACTOR, PAPE_AUTH_PHISHING_RESISTANT), $req->auth_policies); $this->assertEquals('2008-03-02T12:34:56Z', $req->auth_time); }
function test_openidUpdateURLVerificationSuccessReturnTo() { $openid_req_msg = Auth_OpenID_Message::fromOpenIDArgs(array('mode' => 'checkid_setup', 'ns' => Auth_OpenID_OPENID2_NS, 'return_to' => 'http://example.com/realm', 'ns.ax' => Auth_OpenID_AX_NS_URI, 'ax.update_url' => 'http://example.com/realm/update_path', 'ax.mode' => 'fetch_request')); $fr = Auth_OpenID_AX_FetchRequest::fromOpenIDRequest($openid_req_msg); $this->assertFalse(Auth_OpenID_AX::isError($fr)); }
function test_signInvalidHandle() { $request = new Auth_OpenID_ServerRequest(); $assoc_handle = '{bogus-assoc}{notvalid}'; $request->assoc_handle = $assoc_handle; $request->namespace = Auth_OpenID_OPENID1_NS; $response = new Auth_OpenID_ServerResponse($request); $response->fields = Auth_OpenID_Message::fromOpenIDArgs(array('foo' => 'amsigned', 'bar' => 'notsigned', 'azu' => 'alsosigned')); $response->signed = array('foo', 'azu'); $sresponse = $this->signatory->sign($response); $new_assoc_handle = $sresponse->fields->getArg(Auth_OpenID_OPENID_NS, 'assoc_handle'); $this->assertTrue($new_assoc_handle); $this->assertFalse($new_assoc_handle == $assoc_handle); $this->assertEquals($sresponse->fields->getArg(Auth_OpenID_OPENID_NS, 'invalidate_handle'), $assoc_handle); $this->assertEquals($sresponse->fields->getArg(Auth_OpenID_OPENID_NS, 'signed'), 'assoc_handle,azu,bar,foo,invalidate_handle,signed'); $this->assertTrue($sresponse->fields->hasKey(Auth_OpenID_OPENID_NS, 'sig')); // make sure the new key is a dumb mode association $this->assertTrue($this->store->getAssociation($this->dumb_key, $new_assoc_handle)); $this->assertFalse($this->store->getAssociation($this->normal_key, $new_assoc_handle)); }
function test_fromSuccessResponse_unsigned() { $message = Auth_OpenID_Message::fromOpenIDArgs(array('sreg.nickname' => 'The Mad Stork')); $success_resp = new DummySuccessResponse($message, array()); $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($success_resp, false); $this->assertEquals(array('nickname' => 'The Mad Stork'), $sreg_resp->contents()); }