|
4 | 4 |
|
5 | 5 | use Illuminate\Contracts\Routing\Registrar;
|
6 | 6 | use Illuminate\Foundation\Auth\User;
|
| 7 | +use Illuminate\Support\Facades\Route; |
7 | 8 | use Laravel\Passport\HasApiTokens;
|
8 | 9 | use Laravel\Passport\Http\Middleware\CheckForAnyScope;
|
9 | 10 | use Laravel\Passport\Http\Middleware\CheckScopes;
|
@@ -64,6 +65,40 @@ public function testActingAsWhenTheRouteIsProtectedByCheckForAnyScopeMiddleware(
|
64 | 65 | $response->assertSuccessful();
|
65 | 66 | $response->assertSee('bar');
|
66 | 67 | }
|
| 68 | + |
| 69 | + public function testActingAsWhenTheRouteIsProtectedByCheckScopesMiddlewareWithInheritance() |
| 70 | + { |
| 71 | + Passport::$withInheritedScopes = true; |
| 72 | + |
| 73 | + $this->withoutExceptionHandling(); |
| 74 | + |
| 75 | + Route::middleware(CheckScopes::class.':foo:bar,baz:qux')->get('/foo', function () { |
| 76 | + return 'bar'; |
| 77 | + }); |
| 78 | + |
| 79 | + Passport::actingAs(new PassportUser(), ['foo', 'baz']); |
| 80 | + |
| 81 | + $response = $this->get('/foo'); |
| 82 | + $response->assertSuccessful(); |
| 83 | + $response->assertSee('bar'); |
| 84 | + } |
| 85 | + |
| 86 | + public function testActingAsWhenTheRouteIsProtectedByCheckForAnyScopeMiddlewareWithInheritance() |
| 87 | + { |
| 88 | + Passport::$withInheritedScopes = true; |
| 89 | + |
| 90 | + $this->withoutExceptionHandling(); |
| 91 | + |
| 92 | + Route::middleware(CheckForAnyScope::class.':foo:baz,baz:qux')->get('/foo', function () { |
| 93 | + return 'bar'; |
| 94 | + }); |
| 95 | + |
| 96 | + Passport::actingAs(new PassportUser(), ['foo']); |
| 97 | + |
| 98 | + $response = $this->get('/foo'); |
| 99 | + $response->assertSuccessful(); |
| 100 | + $response->assertSee('bar'); |
| 101 | + } |
67 | 102 | }
|
68 | 103 |
|
69 | 104 | class PassportUser extends User
|
|
0 commit comments