Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2.8: [HttpKernel] fixed internal subrequests having an if-modified-since-header [Security] Fix deprecated usage of DigestAuthenticationEntryPoint::getKey() in DigestAuthenticationListener [Validator] Added additional MasterCard range to the CardSchemeValidator Make the exception message more clear. [Form] fixed bug - name in ButtonBuilder [DoctrineBridge] added missing error code for constraint. [ClassLoader] Fix declared classes being computed when not needed [varDumper] Fix missing usage of ExceptionCaster::$traceArgs Conflicts: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
- Loading branch information
Showing
13 changed files
with
188 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Form\Tests; | ||
|
||
use Symfony\Component\Form\ButtonBuilder; | ||
|
||
/** | ||
* @author Alexander Cheprasov <cheprasov.84@ya.ru> | ||
*/ | ||
class ButtonBuilderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function getValidNames() | ||
{ | ||
return array( | ||
array('reset'), | ||
array('submit'), | ||
array('foo'), | ||
array('0'), | ||
array(0), | ||
array('button[]'), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider getValidNames | ||
*/ | ||
public function testValidNames($name) | ||
{ | ||
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name)); | ||
} | ||
|
||
public function getInvalidNames() | ||
{ | ||
return array( | ||
array(''), | ||
array(false), | ||
array(null), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider getInvalidNames | ||
*/ | ||
public function testInvalidNames($name) | ||
{ | ||
$this->setExpectedException( | ||
'\Symfony\Component\Form\Exception\InvalidArgumentException', | ||
'Buttons cannot have empty names.' | ||
); | ||
new ButtonBuilder($name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Security\Http\Tests\Firewall; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; | ||
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint; | ||
use Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener; | ||
|
||
class DigestAuthenticationListenerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testHandleWithValidDigest() | ||
{ | ||
$time = microtime(true) + 1000; | ||
$secret = 'ThisIsASecret'; | ||
$nonce = base64_encode($time.':'.md5($time.':'.$secret)); | ||
$username = 'user'; | ||
$password = 'password'; | ||
$realm = 'Welcome, robot!'; | ||
$cnonce = 'MDIwODkz'; | ||
$nc = '00000001'; | ||
$qop = 'auth'; | ||
$uri = '/path/info?p1=5&p2=5'; | ||
|
||
$serverDigest = $this->calculateServerDigest($username, $realm, $password, $nc, $nonce, $cnonce, $qop, 'GET', $uri); | ||
|
||
$digestData = | ||
'username="'.$username.'", realm="'.$realm.'", nonce="'.$nonce.'", '. | ||
'uri="'.$uri.'", cnonce="'.$cnonce.'", nc='.$nc.', qop="'.$qop.'", '. | ||
'response="'.$serverDigest.'"' | ||
; | ||
|
||
$request = new Request(array(), array(), array(), array(), array(), array('PHP_AUTH_DIGEST' => $digestData)); | ||
|
||
$entryPoint = new DigestAuthenticationEntryPoint($realm, $secret); | ||
|
||
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); | ||
$user->method('getPassword')->willReturn($password); | ||
|
||
$providerKey = 'TheProviderKey'; | ||
|
||
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); | ||
$tokenStorage | ||
->expects($this->once()) | ||
->method('getToken') | ||
->will($this->returnValue(null)) | ||
; | ||
$tokenStorage | ||
->expects($this->once()) | ||
->method('setToken') | ||
->with($this->equalTo(new UsernamePasswordToken($user, $password, $providerKey))) | ||
; | ||
|
||
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); | ||
$userProvider->method('loadUserByUsername')->willReturn($user); | ||
|
||
$listener = new DigestAuthenticationListener($tokenStorage, $userProvider, $providerKey, $entryPoint); | ||
|
||
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); | ||
$event | ||
->expects($this->any()) | ||
->method('getRequest') | ||
->will($this->returnValue($request)) | ||
; | ||
|
||
$listener->handle($event); | ||
} | ||
|
||
private function calculateServerDigest($username, $realm, $password, $nc, $nonce, $cnonce, $qop, $method, $uri) | ||
{ | ||
$response = md5( | ||
md5($username.':'.$realm.':'.$password).':'.$nonce.':'.$nc.':'.$cnonce.':'.$qop.':'.md5($method.':'.$uri) | ||
); | ||
|
||
return sprintf('username="%s", realm="%s", nonce="%s", uri="%s", cnonce="%s", nc=%s, qop="%s", response="%s"', | ||
$username, $realm, $nonce, $uri, $cnonce, $nc, $qop, $response | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters