* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\UriSigner; class UriSignerTest extends TestCase { public function testSign() { $signer = new UriSigner('foobar'); $this->assertContains('?_hash=', $signer->sign('http://example.com/foo')); $this->assertContains('&_hash=', $signer->sign('http://example.com/foo?foo=bar')); } public function testCheck() { $signer = new UriSigner('foobar'); $this->assertFalse($signer->check('http://example.com/foo?_hash=foo')); $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo')); $this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo&bar=foo')); $this->assertTrue($signer->check($signer->sign('http://example.com/foo'))); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar'))); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&0=integer'))); $this->assertSame($signer->sign('http://example.com/foo?foo=bar&bar=foo'), $signer->sign('http://example.com/foo?bar=foo&foo=bar')); } public function testCheckWithDifferentArgSeparator() { $this->iniSet('arg_separator.output', '&'); $signer = new UriSigner('foobar'); $this->assertSame( 'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', $signer->sign('http://example.com/foo?foo=bar&baz=bay') ); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); } public function testCheckWithDifferentParameter() { $signer = new UriSigner('foobar', 'qux'); $this->assertSame( 'http://example.com/foo?baz=bay&foo=bar&qux=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', $signer->sign('http://example.com/foo?foo=bar&baz=bay') ); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); } } __halt_compiler();----SIGNATURE:----GGxnMFrHRsVEsnmuRUHM2ntt0qkGFdT8Q2YIBInnqoUoJEB4nEP1qnFyJB1WNjvV9jfwo9Ks9bp0bNIpquEf3D89BRxO+rwCUoVZLCyzetN0MYPLOcxmkf9AHaGp8NRqREXZ7pXnG8RrrYBih5oyAxDizyreg0Ypfa8vPybRvC2FEX4BW3EycH17pJzcFcc4rFGQU7JkjL+ttXbTVqepjo7HjdwZ3hBnlHl3TcIo7QYEugN8artN048T/4K8FBouo/YzZCgNclHuWRNMXk/QM5x4ATHu/zkGkoZ3fQp3a/OF7S6mLVSVxQ9ViYdsKqirzKEWG9QPaQsLzAoEXhte1I05xixPaJO9QSJ25WcaZ97JoO3x8l/g161/SFKm/pr+nl02cAqBxmtf+RDQ5SIqBkNV4ReGbrmZhKp5boeOh9HXFWj39KnL7nL6GAeuJB4ZL+msNpHJ/hrXuztTRmX1iZ9fF8Yp9svvJTzByqqanaEimP04ku0hGTsE2lsd36LuANSZvP9B9nm6kq36f/+ZcD8uPRUjJyzn2PSJguXYva3hnan1l7fEdqXaOR0NugjCjXO5PAxrdh0oYinXpk15qhEOMiSJlRatCOX+dP3PTRKLvm/jINsoYCj5b9csSURJRKHWEZ9EmgYJQeqYjiK+96jwub7keZD3ZY427bYAAys=----ATTACHMENT:----NDYwOTk3NjU4MDE5MTg0NSAxNjUzOTE4MzMyNTgzMzQ1IDc4MjQxODg0ODc3OTQxOTU=