summaryrefslogtreecommitdiffstats
path: root/Core/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Tests')
-rw-r--r--Core/Tests/Encoder/BCryptPasswordEncoderTest.php20
-rw-r--r--Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php20
-rw-r--r--Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php20
-rw-r--r--Core/Tests/Encoder/PlaintextPasswordEncoderTest.php20
4 files changed, 80 insertions, 0 deletions
diff --git a/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/Core/Tests/Encoder/BCryptPasswordEncoderTest.php
index 4780411..99f03a3 100644
--- a/Core/Tests/Encoder/BCryptPasswordEncoderTest.php
+++ b/Core/Tests/Encoder/BCryptPasswordEncoderTest.php
@@ -64,6 +64,26 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
}
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testEncodePasswordLength()
+ {
+ $encoder = new BCryptPasswordEncoder(4);
+
+ $encoder->encodePassword(str_repeat('a', 5000), 'salt');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testCheckPasswordLength()
+ {
+ $encoder = new BCryptPasswordEncoder(4);
+
+ $encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt');
+ }
+
private function skipIfPhpVersionIsNotSupported()
{
if (version_compare(phpversion(), '5.3.7', '<')) {
diff --git a/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php b/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
index 550d08e..1e8faaf 100644
--- a/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
+++ b/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
@@ -42,4 +42,24 @@ class MessageDigestPasswordEncoderTest extends \PHPUnit_Framework_TestCase
$encoder = new MessageDigestPasswordEncoder('foobar');
$encoder->encodePassword('password', '');
}
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testEncodePasswordLength()
+ {
+ $encoder = new MessageDigestPasswordEncoder();
+
+ $encoder->encodePassword(str_repeat('a', 5000), 'salt');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testCheckPasswordLength()
+ {
+ $encoder = new MessageDigestPasswordEncoder();
+
+ $encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt');
+ }
}
diff --git a/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php b/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
index ba5c4d5..4991330 100644
--- a/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
+++ b/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
@@ -42,4 +42,24 @@ class Pbkdf2PasswordEncoderTest extends \PHPUnit_Framework_TestCase
$encoder = new Pbkdf2PasswordEncoder('foobar');
$encoder->encodePassword('password', '');
}
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testEncodePasswordLength()
+ {
+ $encoder = new Pbkdf2PasswordEncoder();
+
+ $encoder->encodePassword(str_repeat('a', 5000), 'salt');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testCheckPasswordLength()
+ {
+ $encoder = new Pbkdf2PasswordEncoder();
+
+ $encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt');
+ }
}
diff --git a/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php b/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
index 513a94a..763aae1 100644
--- a/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
+++ b/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
@@ -36,4 +36,24 @@ class PlaintextPasswordEncoderTest extends \PHPUnit_Framework_TestCase
$this->assertSame('foo', $encoder->encodePassword('foo', ''));
}
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testEncodePasswordLength()
+ {
+ $encoder = new PlaintextPasswordEncoder();
+
+ $encoder->encodePassword(str_repeat('a', 5000), 'salt');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
+ */
+ public function testCheckPasswordLength()
+ {
+ $encoder = new PlaintextPasswordEncoder();
+
+ $encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt');
+ }
}