public function testCanValidateAcrossMultipleSession() { $signed_url = $this->service->sign($this->url, '+1 day'); $this->assertTrue($this->service->isValid($signed_url)); _elgg_services()->session->invalidate(); _elgg_services()->session->start(); $this->assertTrue($this->service->isValid($signed_url)); }
/** @test */ public function signedRouteIsAccepted() { $urlSigner = new UrlSigner(); // Define mock and set expectations on it $response = $this->getMockBuilder('MockResponse')->disableOriginalConstructor()->getMock(); $response->expects($this->never())->method('setStatusCode'); $response->expects($this->never())->method('setHeaderOnly'); $response->expects($this->never())->method('send'); // load mock $this->context->setResponse($response); // call method under test $secretKey = "abcdef"; $parameters = array("lang" => "fr", "query" => "htc", "signature_timestamp" => "123456", "signature_value" => sha1("fr" . "htc" . "123456" . "@" . $secretKey)); $urlSigner->redirectIfUrlIsNotSigned($parameters, $this->context, $secretKey); }
public function matchesUrl($url, $context = array()) { $parameters = parent::matchesUrl($url, $context); if (!$parameters) { return false; } $queryParameters = $this->getQueryParameters($context); $sfContext = sfContext::getInstance(); if ($this->shouldThisRouteBeSigned()) { $urlSigner = new UrlSigner(); $urlSigner->redirectIfUrlIsNotSigned($queryParameters, $sfContext, $this->getSecretKey()); return $parameters; } return $parameters; }