@@ -13,10 +13,14 @@ class PassportServiceProviderTest extends TestCase
1313{
1414 public function test_can_use_crypto_keys_from_config ()
1515 {
16- $ config = m::mock (Config::class, function ($ config ) {
16+ $ privateKey = openssl_pkey_new ();
17+
18+ openssl_pkey_export ($ privateKey , $ privateKeyString );
19+
20+ $ config = m::mock (Config::class, function ($ config ) use ($ privateKeyString ) {
1721 $ config ->shouldReceive ('get ' )
1822 ->with ('passport.private_key ' )
19- ->andReturn (' -----BEGIN RSA PRIVATE KEY-----\nconfig\n-----END RSA PRIVATE KEY----- ' );
23+ ->andReturn ($ privateKeyString );
2024 });
2125
2226 $ provider = new PassportServiceProvider (
@@ -29,7 +33,7 @@ public function test_can_use_crypto_keys_from_config()
2933 })->call ($ provider );
3034
3135 $ this ->assertSame (
32- " -----BEGIN RSA PRIVATE KEY----- \n config \n -----END RSA PRIVATE KEY----- " ,
36+ $ privateKeyString ,
3337 file_get_contents ($ cryptKey ->getKeyPath ())
3438 );
3539 }
@@ -38,10 +42,10 @@ public function test_can_use_crypto_keys_from_local_disk()
3842 {
3943 Passport::loadKeysFrom (__DIR__ .'/../keys ' );
4044
41- file_put_contents (
42- __DIR__ . ' /../keys/oauth-private.key ' ,
43- " -----BEGIN RSA PRIVATE KEY----- \n disk \n -----END RSA PRIVATE KEY----- "
44- );
45+ $ privateKey = openssl_pkey_new ();
46+
47+ openssl_pkey_export_to_file ( $ privateKey , __DIR__ . ' /../keys/oauth-private.key ' );
48+ openssl_pkey_export ( $ privateKey , $ privateKeyString );
4549
4650 $ config = m::mock (Config::class, function ($ config ) {
4751 $ config ->shouldReceive ('get ' )->with ('passport.private_key ' )->andReturn (null );
@@ -57,7 +61,7 @@ public function test_can_use_crypto_keys_from_local_disk()
5761 })->call ($ provider );
5862
5963 $ this ->assertSame (
60- " -----BEGIN RSA PRIVATE KEY----- \n disk \n -----END RSA PRIVATE KEY----- " ,
64+ $ privateKeyString ,
6165 file_get_contents ($ cryptKey ->getKeyPath ())
6266 );
6367
0 commit comments