|
7 | 7 | use Illuminate\Database\Schema\Blueprint; |
8 | 8 | use Illuminate\Support\Facades\Schema; |
9 | 9 | use Laravel\Passport\Client; |
10 | | -use Laravel\Passport\ClientRepository; |
11 | 10 | use Laravel\Passport\Database\Factories\ClientFactory; |
12 | 11 | use Laravel\Passport\HasApiTokens; |
13 | 12 | use Laravel\Passport\Passport; |
| 13 | +use Laravel\Passport\PersonalAccessTokenFactory; |
14 | 14 | use Laravel\Passport\Token; |
15 | | -use Laravel\Passport\TokenRepository; |
16 | | -use Lcobucci\JWT\Configuration; |
17 | 15 |
|
18 | 16 | class AccessTokenControllerTest extends PassportTestCase |
19 | 17 | { |
@@ -78,10 +76,7 @@ public function testGettingAccessTokenWithClientCredentialsGrant() |
78 | 76 | $expiresInSeconds = 31536000; |
79 | 77 | $this->assertEqualsWithDelta($expiresInSeconds, $decodedResponse['expires_in'], 5); |
80 | 78 |
|
81 | | - $jwtAccessToken = Configuration::forUnsecuredSigner()->parser()->parse($decodedResponse['access_token']); |
82 | | - $this->assertTrue($this->app->make(ClientRepository::class)->findActive($jwtAccessToken->claims()->get('aud'))->is($client)); |
83 | | - |
84 | | - $token = $this->app->make(TokenRepository::class)->find($jwtAccessToken->claims()->get('jti')); |
| 79 | + $token = $this->app->make(PersonalAccessTokenFactory::class)->findAccessToken($decodedResponse); |
85 | 80 | $this->assertInstanceOf(Token::class, $token); |
86 | 81 | $this->assertTrue($token->client->is($client)); |
87 | 82 | $this->assertFalse($token->revoked); |
@@ -171,11 +166,7 @@ public function testGettingAccessTokenWithPasswordGrant() |
171 | 166 | $expiresInSeconds = 31536000; |
172 | 167 | $this->assertEqualsWithDelta($expiresInSeconds, $decodedResponse['expires_in'], 5); |
173 | 168 |
|
174 | | - $jwtAccessToken = Configuration::forUnsecuredSigner()->parser()->parse($decodedResponse['access_token']); |
175 | | - $this->assertTrue($this->app->make(ClientRepository::class)->findActive($jwtAccessToken->claims()->get('aud'))->is($client)); |
176 | | - $this->assertTrue($this->app->make('auth')->createUserProvider()->retrieveById($jwtAccessToken->claims()->get('sub'))->is($user)); |
177 | | - |
178 | | - $token = $this->app->make(TokenRepository::class)->find($jwtAccessToken->claims()->get('jti')); |
| 169 | + $token = $this->app->make(PersonalAccessTokenFactory::class)->findAccessToken($decodedResponse); |
179 | 170 | $this->assertInstanceOf(Token::class, $token); |
180 | 171 | $this->assertFalse($token->revoked); |
181 | 172 | $this->assertTrue($token->user->is($user)); |
|
0 commit comments