summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2014-12-20 17:02:27 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2014-12-20 17:02:27 +0100
commitab8d1dc9a59700ebf179461b5a85e6d11e201705 (patch)
tree983ed3b9b10737597aefd362b23e06852242fde0
parent24211b9e8e8061626ef0ee0490790a99af306a45 (diff)
parent6b42215ea1e9d59e8d449b7436ec05e04cb00f5e (diff)
downloadsymfony-security-ab8d1dc9a59700ebf179461b5a85e6d11e201705.zip
symfony-security-ab8d1dc9a59700ebf179461b5a85e6d11e201705.tar.gz
symfony-security-ab8d1dc9a59700ebf179461b5a85e6d11e201705.tar.bz2
Merge branch '2.5' into 2.6
* 2.5: [Config] adds missing « use » statement for InvalidTypeException type hint in documentation. [Config] fixes broken unit test on ArrayNode class. fixed CS [Security] Delete old session on auth strategy migrate update required minimum TwigBridge version Very minor grammar fix in error message [Tests] Silenced all deprecations in tests for 2.3 BinaryFileResponse - add missing newline fixed CS add a limit and a test to FlattenExceptionTest. CS: There should be no empty lines following phpdocs [FrameworkBundle] fix cache:clear command [2.3] Docblocks should not be followed by a blank line Fix return phpdoc [PropertyAccess] Added test to verify #5775 is fixed
-rw-r--r--Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php175
-rw-r--r--Http/Session/SessionAuthenticationStrategy.php2
-rw-r--r--Http/Tests/Session/SessionAuthenticationStrategyTest.php2
-rw-r--r--phpunit.xml.dist4
4 files changed, 6 insertions, 177 deletions
diff --git a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
deleted file mode 100644
index ef93e25..0000000
--- a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ /dev/null
@@ -1,175 +0,0 @@
-<?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\Security\Core\Tests\Validator\Constraints;
-
-use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
-use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
-use Symfony\Component\Security\Core\SecurityContextInterface;
-use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
-use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
-use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
-use Symfony\Component\Validator\Validation;
-
-/**
- * @author Bernhard Schussek <bschussek@gmail.com>
- */
-class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
-{
- const PASSWORD = 's3Cr3t';
-
- const SALT = '^S4lt$';
-
- /**
- * @var SecurityContextInterface
- */
- protected $securityContext;
-
- /**
- * @var PasswordEncoderInterface
- */
- protected $encoder;
-
- /**
- * @var EncoderFactoryInterface
- */
- protected $encoderFactory;
-
- protected function getApiVersion()
- {
- return Validation::API_VERSION_2_5;
- }
-
- protected function createValidator()
- {
- return new UserPasswordValidator($this->securityContext, $this->encoderFactory);
- }
-
- protected function setUp()
- {
- $user = $this->createUser();
- $this->securityContext = $this->createSecurityContext($user);
- $this->encoder = $this->createPasswordEncoder();
- $this->encoderFactory = $this->createEncoderFactory($this->encoder);
-
- parent::setUp();
- }
-
- public function testPasswordIsValid()
- {
- $constraint = new UserPassword(array(
- 'message' => 'myMessage',
- ));
-
- $this->encoder->expects($this->once())
- ->method('isPasswordValid')
- ->with(static::PASSWORD, 'secret', static::SALT)
- ->will($this->returnValue(true));
-
- $this->validator->validate('secret', $constraint);
-
- $this->assertNoViolation();
- }
-
- public function testPasswordIsNotValid()
- {
- $constraint = new UserPassword(array(
- 'message' => 'myMessage',
- ));
-
- $this->encoder->expects($this->once())
- ->method('isPasswordValid')
- ->with(static::PASSWORD, 'secret', static::SALT)
- ->will($this->returnValue(false));
-
- $this->validator->validate('secret', $constraint);
-
- $this->buildViolation('myMessage')
- ->assertRaised();
- }
-
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
- public function testUserIsNotValid()
- {
- $user = $this->getMock('Foo\Bar\User');
-
- $this->securityContext = $this->createSecurityContext($user);
- $this->validator = $this->createValidator();
- $this->validator->initialize($this->context);
-
- $this->validator->validate('secret', new UserPassword());
- }
-
- protected function createUser()
- {
- $mock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
-
- $mock
- ->expects($this->any())
- ->method('getPassword')
- ->will($this->returnValue(static::PASSWORD))
- ;
-
- $mock
- ->expects($this->any())
- ->method('getSalt')
- ->will($this->returnValue(static::SALT))
- ;
-
- return $mock;
- }
-
- protected function createPasswordEncoder($isPasswordValid = true)
- {
- return $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
- }
-
- protected function createEncoderFactory($encoder = null)
- {
- $mock = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
-
- $mock
- ->expects($this->any())
- ->method('getEncoder')
- ->will($this->returnValue($encoder))
- ;
-
- return $mock;
- }
-
- protected function createSecurityContext($user = null)
- {
- $token = $this->createAuthenticationToken($user);
-
- $mock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
- $mock
- ->expects($this->any())
- ->method('getToken')
- ->will($this->returnValue($token))
- ;
-
- return $mock;
- }
-
- protected function createAuthenticationToken($user = null)
- {
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
- $mock
- ->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($user))
- ;
-
- return $mock;
- }
-}
diff --git a/Http/Session/SessionAuthenticationStrategy.php b/Http/Session/SessionAuthenticationStrategy.php
index 0e688c7..dd258a0 100644
--- a/Http/Session/SessionAuthenticationStrategy.php
+++ b/Http/Session/SessionAuthenticationStrategy.php
@@ -47,7 +47,7 @@ class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInte
return;
case self::MIGRATE:
- $request->getSession()->migrate();
+ $request->getSession()->migrate(true);
return;
diff --git a/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/Http/Tests/Session/SessionAuthenticationStrategyTest.php
index 7be9054..a1f960f 100644
--- a/Http/Tests/Session/SessionAuthenticationStrategyTest.php
+++ b/Http/Tests/Session/SessionAuthenticationStrategyTest.php
@@ -40,7 +40,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
public function testSessionIsMigrated()
{
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
- $session->expects($this->once())->method('migrate');
+ $session->expects($this->once())->method('migrate')->with($this->equalTo(true));
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
$strategy->onAuthentication($this->getRequest($session), $this->getToken());
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 4d167b7..f11fabe 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -6,6 +6,10 @@
colors="true"
bootstrap="vendor/autoload.php"
>
+ <php>
+ <!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
+ <ini name="error_reporting" value="-16385"/>
+ </php>
<testsuites>
<testsuite name="Symfony Security Component Test Suite">
<directory>./Acl/Tests/</directory>