From 4b8a9a5189a625bf99fedec7fd31f6e146410a14 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 26 Apr 2018 01:00:12 +0200 Subject: Update FB API library --- .../McryptPseudoRandomStringGeneratorTest.php | 6 +- .../OpenSslPseudoRandomStringGeneratorTest.php | 2 +- .../PseudoRandomStringFactoryTest.php | 71 ++++++++++++++++++++++ .../PseudoRandomStringGeneratorTraitTest.php | 9 +-- .../RandomBytesPseudoRandomStringGeneratorTest.php | 44 ++++++++++++++ .../UrandomPseudoRandomStringGeneratorTest.php | 2 +- 6 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 lib/facebook-graph-sdk/tests/PseudoRandomString/PseudoRandomStringFactoryTest.php create mode 100644 lib/facebook-graph-sdk/tests/PseudoRandomString/RandomBytesPseudoRandomStringGeneratorTest.php (limited to 'lib/facebook-graph-sdk/tests/PseudoRandomString') diff --git a/lib/facebook-graph-sdk/tests/PseudoRandomString/McryptPseudoRandomStringGeneratorTest.php b/lib/facebook-graph-sdk/tests/PseudoRandomString/McryptPseudoRandomStringGeneratorTest.php index a45a3cf..f5e0336 100644 --- a/lib/facebook-graph-sdk/tests/PseudoRandomString/McryptPseudoRandomStringGeneratorTest.php +++ b/lib/facebook-graph-sdk/tests/PseudoRandomString/McryptPseudoRandomStringGeneratorTest.php @@ -1,6 +1,6 @@ =')) { + $this->markTestSkipped('Skipping test mcrypt is deprecated from 7.1'); + } + if (!function_exists('mcrypt_create_iv')) { $this->markTestSkipped( 'Mcrypt must be installed to test mcrypt_create_iv().' diff --git a/lib/facebook-graph-sdk/tests/PseudoRandomString/OpenSslPseudoRandomStringGeneratorTest.php b/lib/facebook-graph-sdk/tests/PseudoRandomString/OpenSslPseudoRandomStringGeneratorTest.php index c740d0b..3ab4edc 100644 --- a/lib/facebook-graph-sdk/tests/PseudoRandomString/OpenSslPseudoRandomStringGeneratorTest.php +++ b/lib/facebook-graph-sdk/tests/PseudoRandomString/OpenSslPseudoRandomStringGeneratorTest.php @@ -1,6 +1,6 @@ assertInstanceOf(self::COMMON_INTERFACE, $pseudoRandomStringGenerator); + $this->assertInstanceOf($expected, $pseudoRandomStringGenerator); + } + + /** + * @return array + */ + public function csprngProvider() + { + $providers = [ + [null, self::COMMON_INTERFACE], + ]; + if (function_exists('random_bytes')) { + $providers[] = ['random_bytes', self::COMMON_NAMESPACE . 'RandomBytesPseudoRandomStringGenerator']; + } + if (function_exists('mcrypt_create_iv')) { + $providers[] = ['mcrypt', self::COMMON_NAMESPACE . 'McryptPseudoRandomStringGenerator']; + } + if (function_exists('openssl_random_pseudo_bytes')) { + $providers[] = ['openssl', self::COMMON_NAMESPACE . 'OpenSslPseudoRandomStringGenerator']; + } + if (!ini_get('open_basedir') && is_readable('/dev/urandom')) { + $providers[] = ['urandom', self::COMMON_NAMESPACE . 'UrandomPseudoRandomStringGenerator']; + } + + return $providers; + } +} diff --git a/lib/facebook-graph-sdk/tests/PseudoRandomString/PseudoRandomStringGeneratorTraitTest.php b/lib/facebook-graph-sdk/tests/PseudoRandomString/PseudoRandomStringGeneratorTraitTest.php index ea3a1f8..16165d9 100644 --- a/lib/facebook-graph-sdk/tests/PseudoRandomString/PseudoRandomStringGeneratorTraitTest.php +++ b/lib/facebook-graph-sdk/tests/PseudoRandomString/PseudoRandomStringGeneratorTraitTest.php @@ -1,6 +1,6 @@ markTestSkipped( + 'Must have PHP 7 or paragonie/random_compat installed to test random_bytes().' + ); + } + + $csprng = new RandomBytesPseudoRandomStringGenerator; + $randomString = $csprng->getPseudoRandomString(10); + + $this->assertEquals(1, preg_match('/^([0-9a-f]+)$/', $randomString)); + $this->assertEquals(10, strlen($randomString)); + } +} diff --git a/lib/facebook-graph-sdk/tests/PseudoRandomString/UrandomPseudoRandomStringGeneratorTest.php b/lib/facebook-graph-sdk/tests/PseudoRandomString/UrandomPseudoRandomStringGeneratorTest.php index 9e12a58..e67136f 100644 --- a/lib/facebook-graph-sdk/tests/PseudoRandomString/UrandomPseudoRandomStringGeneratorTest.php +++ b/lib/facebook-graph-sdk/tests/PseudoRandomString/UrandomPseudoRandomStringGeneratorTest.php @@ -1,6 +1,6 @@