| @@ 234-251 (lines=18) @@ | ||
| 231 | new Facebook($config); |
|
| 232 | } |
|
| 233 | ||
| 234 | public function testMcryptCsprgCanBeForced() |
|
| 235 | { |
|
| 236 | if (!function_exists('mcrypt_create_iv')) { |
|
| 237 | $this->markTestSkipped( |
|
| 238 | 'Mcrypt must be installed to test mcrypt_create_iv().' |
|
| 239 | ); |
|
| 240 | } |
|
| 241 | ||
| 242 | $config = array_merge($this->config, [ |
|
| 243 | 'persistent_data_handler' => 'memory', // To keep session errors from happening |
|
| 244 | 'pseudo_random_string_generator' => 'mcrypt' |
|
| 245 | ]); |
|
| 246 | $fb = new Facebook($config); |
|
| 247 | $this->assertInstanceOf( |
|
| 248 | 'Facebook\PseudoRandomString\McryptPseudoRandomStringGenerator', |
|
| 249 | $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator() |
|
| 250 | ); |
|
| 251 | } |
|
| 252 | ||
| 253 | public function testOpenSslCsprgCanBeForced() |
|
| 254 | { |
|
| @@ 253-270 (lines=18) @@ | ||
| 250 | ); |
|
| 251 | } |
|
| 252 | ||
| 253 | public function testOpenSslCsprgCanBeForced() |
|
| 254 | { |
|
| 255 | if (!function_exists('openssl_random_pseudo_bytes')) { |
|
| 256 | $this->markTestSkipped( |
|
| 257 | 'The OpenSSL extension must be enabled to test openssl_random_pseudo_bytes().' |
|
| 258 | ); |
|
| 259 | } |
|
| 260 | ||
| 261 | $config = array_merge($this->config, [ |
|
| 262 | 'persistent_data_handler' => 'memory', // To keep session errors from happening |
|
| 263 | 'pseudo_random_string_generator' => 'openssl' |
|
| 264 | ]); |
|
| 265 | $fb = new Facebook($config); |
|
| 266 | $this->assertInstanceOf( |
|
| 267 | 'Facebook\PseudoRandomString\OpenSslPseudoRandomStringGenerator', |
|
| 268 | $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator() |
|
| 269 | ); |
|
| 270 | } |
|
| 271 | ||
| 272 | public function testUrandomCsprgCanBeForced() |
|
| 273 | { |
|
| @@ 272-295 (lines=24) @@ | ||
| 269 | ); |
|
| 270 | } |
|
| 271 | ||
| 272 | public function testUrandomCsprgCanBeForced() |
|
| 273 | { |
|
| 274 | if (ini_get('open_basedir')) { |
|
| 275 | $this->markTestSkipped( |
|
| 276 | 'Cannot test /dev/urandom generator due to open_basedir constraint.' |
|
| 277 | ); |
|
| 278 | } |
|
| 279 | ||
| 280 | if (!is_readable('/dev/urandom')) { |
|
| 281 | $this->markTestSkipped( |
|
| 282 | '/dev/urandom not found or is not readable.' |
|
| 283 | ); |
|
| 284 | } |
|
| 285 | ||
| 286 | $config = array_merge($this->config, [ |
|
| 287 | 'persistent_data_handler' => 'memory', // To keep session errors from happening |
|
| 288 | 'pseudo_random_string_generator' => 'urandom' |
|
| 289 | ]); |
|
| 290 | $fb = new Facebook($config); |
|
| 291 | $this->assertInstanceOf( |
|
| 292 | 'Facebook\PseudoRandomString\UrandomPseudoRandomStringGenerator', |
|
| 293 | $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator() |
|
| 294 | ); |
|
| 295 | } |
|
| 296 | ||
| 297 | /** |
|
| 298 | * @expectedException \InvalidArgumentException |
|