summaryrefslogtreecommitdiffstats
path: root/Core/Tests/Util
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2014-09-03 11:12:11 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2014-09-03 11:12:11 +0200
commite494f3c32878142cb811934be943e3e844e9d796 (patch)
tree01dc4046249967b68196a855c460ffc7a4de4a93 /Core/Tests/Util
parent8637c7dac164357effff563e0965a62c1e0aaa64 (diff)
parent12cf9164db2fbbcf3b918cc43810414c10f8230d (diff)
downloadsymfony-security-e494f3c32878142cb811934be943e3e844e9d796.zip
symfony-security-e494f3c32878142cb811934be943e3e844e9d796.tar.gz
symfony-security-e494f3c32878142cb811934be943e3e844e9d796.tar.bz2
Merge branch '2.5'
* 2.5: (23 commits) [HttpKernel] fixed some unit tests for 2.4 (signature now uses SHA256 instead of MD5) [HttpKernel] simplified code [HttpKernel] fixed internal fragment handling fixing yaml indentation Unexpexted ));" [WebProfiler] replaced the import/export feature from the web interface to a CLI tool Forced all fragment uris to be signed, even for ESI Add tests and more assertions [FrameworkBundle][Translator] Validate locales. [HttpFoundation] added some missing tests [HttpFoundation] Improve string values in test codes [Security] Add more tests for StringUtils::equals fix comment: not fourth but sixth argument fixing typo in a comment [FrameworkBundle] fixed CS [FrameworkBundle] PhpExtractor bugfix and improvements [Finder] Fix findertest readability [Filesystem] Add FTP stream wrapper context option to enable overwrite (override) fix parsing of Authorization header Test examples from Drupal SA-CORE-2014-003 ... Conflicts: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig src/Symfony/Component/Filesystem/Filesystem.php src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php
Diffstat (limited to 'Core/Tests/Util')
-rw-r--r--Core/Tests/Util/StringUtilsTest.php44
1 files changed, 41 insertions, 3 deletions
diff --git a/Core/Tests/Util/StringUtilsTest.php b/Core/Tests/Util/StringUtilsTest.php
index 89da98d..e0366a5 100644
--- a/Core/Tests/Util/StringUtilsTest.php
+++ b/Core/Tests/Util/StringUtilsTest.php
@@ -13,11 +13,49 @@ namespace Symfony\Component\Security\Core\Tests\Util;
use Symfony\Component\Security\Core\Util\StringUtils;
+/**
+ * Data from PHP.net's hash_equals tests
+ */
class StringUtilsTest extends \PHPUnit_Framework_TestCase
{
- public function testEquals()
+ public function dataProviderTrue()
+ {
+ return array(
+ array('same', 'same'),
+ array('', ''),
+ array(123, 123),
+ array(null, ''),
+ array(null, null),
+ );
+ }
+
+ public function dataProviderFalse()
+ {
+ return array(
+ array('not1same', 'not2same'),
+ array('short', 'longer'),
+ array('longer', 'short'),
+ array('', 'notempty'),
+ array('notempty', ''),
+ array(123, 'NaN'),
+ array('NaN', 123),
+ array(null, 123),
+ );
+ }
+
+ /**
+ * @dataProvider dataProviderTrue
+ */
+ public function testEqualsTrue($known, $user)
+ {
+ $this->assertTrue(StringUtils::equals($known, $user));
+ }
+
+ /**
+ * @dataProvider dataProviderFalse
+ */
+ public function testEqualsFalse($known, $user)
{
- $this->assertTrue(StringUtils::equals('password', 'password'));
- $this->assertFalse(StringUtils::equals('password', 'foo'));
+ $this->assertFalse(StringUtils::equals($known, $user));
}
}