/** * testNonce * * @return void */ public function testNonce() { $uri = 'http://exampleop.com'; $object = new OpenID_Nonce($uri); $nonce = $object->createNonce(); $this->cache->deleteNonce($nonce, $uri); $this->assertFalse($this->cache->getNonce($nonce, $uri)); $this->cache->setNonce($nonce, $uri); $this->assertSame($nonce, $this->cache->getNonce($nonce, $uri)); $this->cache->deleteNonce($nonce, $uri); $this->assertFalse($this->cache->getNonce($nonce, $uri)); }
/** * testValidateReturnToNonceFailInvalid * * @expectedException OpenID_Assertion_Exception * @return void */ public function testValidateReturnToNonceFailInvalid() { $nonce = new OpenID_Nonce($this->opEndpointURL); $nonceValue = $nonce->createNonce(); $this->message->delete('openid.ns'); $this->message->delete('openid.claimed_id'); $this->message->set('openid.identity', $this->claimedID); $rtnonce = $this->requestedURL . '?' . OpenID_Nonce::RETURN_TO_NONCE . '=' . urlencode($nonceValue); $this->message->set('openid.return_to', $rtnonce); $this->requestedURL = $rtnonce; $this->discover = $this->getMock('OpenID_Discover', array('__get'), array($this->claimedID)); $opEndpoint = new OpenID_ServiceEndpoint(); $opEndpoint->setURIs(array($this->opEndpointURL)); $opEndpoints = new OpenID_ServiceEndpoints($this->claimedID, $opEndpoint); $this->discover->expects($this->once())->method('__get')->will($this->returnValue($opEndpoints)); $this->store->expects($this->once())->method('getDiscover')->will($this->returnValue($this->discover)); $this->store->expects($this->any())->method('getNonce')->will($this->returnValue(false)); $this->createObjects(); }
/** * Validates the openid.response_nonce parameter. * * @return void * @throws OpenID_Assertion_Exception on invalid or existing nonce */ protected function validateNonce() { $opURL = $this->message->get('openid.op_endpoint'); $responseNonce = $this->message->get('openid.response_nonce'); $nonce = new OpenID_Nonce($opURL, $this->clockSkew); if (!$nonce->verifyResponseNonce($responseNonce)) { throw new OpenID_Assertion_Exception('Invalid or already existing response_nonce'); } }
/** * testGetAssertionObject * * @return void */ public function testGetAssertionObject() { $this->store->expects($this->any())->method('getDiscover')->will($this->returnValue($this->discover)); $this->store->expects($this->once())->method('getNonce')->will($this->returnValue(false)); $nonceObj = new OpenID_Nonce($this->opEndpointURL); $nonce = $nonceObj->createNonce(); $message = new OpenID_Message(); $message->set('openid.mode', 'id_res'); $message->set('openid.ns', OpenID::NS_2_0); $message->set('openid.return_to', $this->returnTo); $message->set('openid.claimed_id', $this->id); $message->set('openid.identity', $this->id); $message->set('openid.op_endpoint', $this->opEndpointURL); $message->set('openid.invalidate_handle', '12345qwerty'); $message->set('openid.response_nonce', $nonce); $rp = new OpenID_RelyingParty_Mock($this->id, $this->returnTo, $this->realm); $this->assertInstanceOf('OpenID_Assertion', $rp->returnGetAssertionObject($message, new Net_URL2($this->returnTo))); }