Skip to content

Commit

Permalink
Update OauthMiddlewareTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
salkhwlani authored Jul 22, 2024
1 parent 6eb73e6 commit ce67e19
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/OauthMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ protected function getEnvironmentSetUp($app)
return 'hello '. auth()->guard('salla-oauth')->user()->getAuthIdentifier();
})->middleware(OauthMiddleware::class);

$app['router']->get('hello/user_allowed_scope')->uses(function () {
$app['router']->get('hello/user-order-read-scope')->uses(function () {

Check notice on line 18 in test/OauthMiddlewareTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/OauthMiddlewareTest.php#L18

Opening parenthesis of a multi-line function call must be the last content on the line
return 'hello '. auth()->guard('salla-oauth')->user()->getAuthIdentifier();
})->middleware('salla.oauth:orders.read');

Check notice on line 20 in test/OauthMiddlewareTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/OauthMiddlewareTest.php#L20

Closing parenthesis of a multi-line function call must be on a line by itself

$app['router']->get('hello/user_not_allowed_scope')->uses(function () {
return 'hello '. auth()->guard('salla-oauth')->user()->getAuthIdentifier();
})->middleware('salla.oauth:orders.write');

$app['router']->get('hello/guest')->name('auth.guest')->uses(function () {
return 'hello guest';
});
Expand Down Expand Up @@ -146,7 +142,7 @@ public function testCheckAllowedUserScope()
->with($this->equalTo($token))
->willReturn($user);

$response = $this->get('hello/user_allowed_scope', [
$response = $this->get('hello/user-order-read-scope', [
'Authorization' => 'Bearer foobar'
]);
$response->assertStatus(200)->assertSeeText('hello 12345');
Expand Down Expand Up @@ -184,7 +180,7 @@ public function testCheckNotAllowedUserScope()
],
'context' => [
'app' => '123',
'scope' => 'orders.read products.read',
'scope' => 'customers.read products.read',
'exp' => 1721326955
]
]
Expand All @@ -200,7 +196,7 @@ public function testCheckNotAllowedUserScope()
->with($this->equalTo($token))
->willReturn($user);

$response = $this->get('hello/user_not_allowed_scope', [
$response = $this->get('hello/user-order-read-scope', [
'Authorization' => 'Bearer foobar'
]);
$response->assertStatus(401)->assertSeeText('Unauthorized');
Expand Down

0 comments on commit ce67e19

Please sign in to comment.