Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari committed Sep 19, 2024
1 parent 1117607 commit 662c50c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/Feature/DeviceAuthorizationGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Laravel\Passport\Tests\Feature;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Database\Factories\ClientFactory;
use Laravel\Passport\Passport;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
Expand Down Expand Up @@ -160,6 +162,14 @@ public function testRequestAccessToken()
$this->assertArrayHasKey('refresh_token', $json);
$this->assertSame('Bearer', $json['token_type']);
$this->assertSame(31536000, $json['expires_in']);

Route::get('/foo', fn (Request $request) => $request->user()->token()->toJson())->middleware('auth:api');

$json = $this->withToken($json['access_token'], $json['token_type'])->get('/foo')->json();

$this->assertSame($client->getKey(), $json['oauth_client_id']);
$this->assertEquals($user->getAuthIdentifier(), $json['oauth_user_id']);
// $this->assertSame(['create', 'read'], $json['oauth_scopes']); TODO: https://github.com/thephpleague/oauth2-server/pull/1412
}

public function testDenyAuthorization()
Expand Down

0 comments on commit 662c50c

Please sign in to comment.