public function testSettingNewSessionContainerSetsHashInNewContainer() { $hash = $this->validator->getHash(); $container = new Container('foo', $this->sessionManager); $this->validator->setSession($container); $test = $container->hash; // Doing this, as expiration hops are 1; have to grab on first access $this->assertEquals($hash, $test); }
public function testValueAttributeIsSetToValidatorHash() { $element = new CsrfElement('foo'); $validator = $element->getValidator(); $value = $element->getAttribute('value'); $this->assertSame($validator->getHash(), $value); $validator = new CsrfValidator(array( 'salt' => 'foobar', 'name' => $element->getName(), )); $validator->setSalt('foobarbaz'); $element->setValidator($validator); $value2 = $element->getAttribute('value'); $this->assertSame($validator->getHash(), $value2); $this->assertNotSame($value, $value2, "$value == $value2"); }
public function testCanValidateHasheWithoutId() { $method = new \ReflectionMethod(get_class($this->validator), 'getTokenFromHash'); $method->setAccessible(true); $hash = $this->validator->getHash(); $bareToken = $method->invoke($this->validator, $hash); $this->assertTrue($this->validator->isValid($bareToken)); }
public function getCsrfValidator() { if ($this->csrfValidator === NULL) { $validator = new Csrf(); $validator->setOptions($this->getCsrfConfig())->setMessages(array(Csrf::NOT_SAME => $this->getErrorMessage('CSRF::NOT_SAME'))); $this->setCsrfValidator($validator); } return $this->csrfValidator; }