Skip to content

Commit bedf716

Browse files
committed
Merge branch '10.x'
# Conflicts: # CHANGELOG.md # tests/Feature/PassportTestCase.php
2 parents 187580a + a263428 commit bedf716

File tree

6 files changed

+46
-85
lines changed

6 files changed

+46
-85
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/laravel/passport/compare/v10.2.0...master)
3+
## [Unreleased](https://github.com/laravel/passport/compare/v10.2.1...master)
4+
5+
6+
## [v10.2.1 (2021-12-07)](https://github.com/laravel/passport/compare/v10.2.0...v10.2.1)
7+
8+
### Fixed
9+
- Fix `str_replace` error when third parameter ($subject) is null ([#1511](https://github.com/laravel/passport/pull/1511))
410

511

612
## [v10.2.0 (2021-11-02)](https://github.com/laravel/passport/compare/v10.1.4...v10.2.0)

src/Console/KeysCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class KeysCommand extends Command
2929
/**
3030
* Execute the console command.
3131
*
32-
* @return void
32+
* @return int
3333
*/
3434
public function handle()
3535
{
@@ -40,6 +40,8 @@ public function handle()
4040

4141
if ((file_exists($publicKey) || file_exists($privateKey)) && ! $this->option('force')) {
4242
$this->error('Encryption keys already exist. Use the --force option to overwrite them.');
43+
44+
return 1;
4345
} else {
4446
if (class_exists(LegacyRSA::class)) {
4547
$keys = (new LegacyRSA)->createKey($this->input ? (int) $this->option('length') : 4096);
@@ -55,5 +57,7 @@ public function handle()
5557

5658
$this->info('Encryption keys generated successfully.');
5759
}
60+
61+
return 0;
5862
}
5963
}

src/PassportServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ protected function registerResourceServer()
311311
*/
312312
protected function makeCryptKey($type)
313313
{
314-
$key = str_replace('\\n', "\n", $this->app->make(Config::class)->get('passport.'.$type.'_key'));
314+
$key = str_replace('\\n', "\n", $this->app->make(Config::class)->get('passport.'.$type.'_key') ?? '');
315315

316316
if (! $key) {
317317
$key = 'file://'.Passport::keyPath('oauth-'.$type.'.key');

tests/Feature/KeysCommandTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Laravel\Passport\Tests\Feature;
4+
5+
use Mockery as m;
6+
7+
class KeysCommandTest extends PassportTestCase
8+
{
9+
protected function tearDown(): void
10+
{
11+
m::close();
12+
13+
@unlink(self::PUBLIC_KEY);
14+
@unlink(self::PRIVATE_KEY);
15+
}
16+
17+
public function testPrivateAndPublicKeysAreGenerated()
18+
{
19+
$this->assertFileExists(self::PUBLIC_KEY);
20+
$this->assertFileExists(self::PRIVATE_KEY);
21+
}
22+
23+
public function testPrivateAndPublicKeysShouldNotBeGeneratedTwice()
24+
{
25+
$this->artisan('passport:keys')
26+
->assertFailed()
27+
->expectsOutput('Encryption keys already exist. Use the --force option to overwrite them.');
28+
}
29+
}

tests/Feature/PassportTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
use Illuminate\Contracts\Config\Repository;
66
use Illuminate\Foundation\Testing\RefreshDatabase;
77
use Laravel\Passport\PassportServiceProvider;
8+
use Laravel\Passport\Passport;
89
use Orchestra\Testbench\TestCase;
910

1011
abstract class PassportTestCase extends TestCase
1112
{
1213
use RefreshDatabase;
1314

14-
const KEYS = __DIR__.'/keys';
15+
const KEYS = __DIR__.'/../keys';
1516
const PUBLIC_KEY = self::KEYS.'/oauth-public.key';
1617
const PRIVATE_KEY = self::KEYS.'/oauth-private.key';
1718

@@ -21,6 +22,8 @@ protected function setUp(): void
2122

2223
$this->artisan('migrate:fresh');
2324

25+
Passport::loadKeysFrom(self::KEYS);
26+
2427
@unlink(self::PUBLIC_KEY);
2528
@unlink(self::PRIVATE_KEY);
2629

tests/Unit/KeysCommandTest.php

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)