8000 Duplicate UriSignerTest, add CHANGELOG and UPGRADE changes · symfony/symfony@aa2e016 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa2e016

Browse files
Duplicate UriSignerTest, add CHANGELOG and UPGRADE changes
1 parent 62d1d7a commit aa2e016

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

UPGRADE-6.4.md

+3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ HttpFoundation
8989
HttpKernel
9090
----------
9191

92+
* Deprecate `UriSigner`, use `HttpFoundation` `UriSigner` instead
9293
* [BC break] `BundleInterface` no longer extends `ContainerAwareInterface`
9394
* [BC break] Add native return types to `TraceableEventDispatcher` and to `MergeExtensionConfigurationPass`
95+
* `BundleInterface` no longer extends `ContainerAwareInterface`
96+
* Add native return types to `TraceableEventDispatcher` and to `MergeExtensionConfigurationPass`
9497

9598
Messenger
9699
---------

src/Symfony/Component/HttpFoundation/Tests/UriSignerTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\UriSigner;
1717

18-
/**
19-
* @group legacy
20-
*/
2118
class UriSignerTest extends TestCase
2219
{
2320
public function testSign()

src/Symfony/Component/HttpKernel/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
6.4
55
---
66

7+
* Deprecate `UriSigner`, use `HttpFoundation` `UriSigner` instead
78
* Support backed enums in #[MapQueryParameter]
89
* `BundleInterface` no longer extends `ContainerAwareInterface`
910
* Add optional `$className` parameter to `ControllerEvent::getAttributes()`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\UriSigner;
17+
18+
/**
19+
* @group legacy
20+
*/
21+
class UriSignerTest extends TestCase
22+
{
23+
public function testSign()
24+
{
25+
$signer = new UriSigner('foobar');
26+
27+
$this->assertStringContainsString('?_hash=', $signer->sign('http://example.com/foo'));
28+
$this->assertStringContainsString('?_hash=', $signer->sign('http://example.com/foo?foo=bar'));
29+
$this->assertStringContainsString('&foo=', $signer->sign('http://example.com/foo?foo=bar'));
30+
}
31+
32+
public function testCheck()
33+
{
34+
$signer = new UriSigner('foobar');
35+
36+
$this->assertFalse($signer->check('http://example.com/foo?_hash=foo'));
37+
$this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo'));
38+
$this->assertFalse($signer->check('http://example.com/foo?foo=bar&_hash=foo&bar=foo'));
39+
40+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo')));
41+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar')));
42+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&0=integer')));
43+
44+
$this->assertSame($signer->sign('http://example.com/foo?foo=bar&bar=foo'), $signer->sign('http://example.com/foo?bar=foo&foo=bar'));
45+
}
46+
47+
public function testCheckWithDifferentArgSeparator()
48+
{
49+
$this->iniSet('arg_separator.output', '&amp;');
50+
$signer = new UriSigner('foobar');
51+
52+
$this->assertSame(
53+
'http://example.com/foo?_hash=rIOcC%2FF3DoEGo%2FvnESjSp A3E2 7uU9zA9S%2F%2BOLhxgMexoPUM%3D&baz=bay&foo=bar',
54+
$signer->sign('http://example.com/foo?foo=bar&baz=bay')
55+
);
56+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
57+
}
58+
59+
public function testCheckWithRequest()
60+
{
61+
$signer = new UriSigner('foobar');
62+
63+
$this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo'))));
64+
$this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo?foo=bar'))));
65+
$this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo?foo=bar&0=integer'))));
66+
}
67+
68+
public function testCheckWithDifferentParameter()
69+
{
70+
$signer = new UriSigner('foobar', 'qux');
71+
72+
$this->assertSame(
73+
'http://example.com/foo?baz=bay&foo=bar&qux=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D',
74+
$signer->sign('http://example.com/foo?foo=bar&baz=bay')
75+
);
76+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay')));
77+
}
78+
79+
public function testSignerWorksWithFragments()
80+
{
81+
$signer = new UriSigner('foobar');
82+
83+
$this->assertSame(
84+
'http://example.com/foo?_hash=EhpAUyEobiM3QTrKxoLOtQq5IsWyWedoXDPqIjzNj5o%3D&bar=foo&foo=bar#foobar',
85+
$signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar')
86+
);
87+
$this->assertTrue($signer->check($signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar')));
88+
}
89+
}

0 commit comments

Comments
 (0)
0