Skip to content

Commit e790d08

Browse files
committed
Cleanup code
1 parent 8537e66 commit e790d08

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Middleware/OAuthUserMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use LucaDegasperi\OAuth2Server\Authorizer;
1717

1818
/**
19-
* This is the oauth user middleware
19+
* This is the oauth user middleware class.
2020
*
2121
* @author Vincent Klaiber <[email protected]>
2222
*/
@@ -30,7 +30,7 @@ class OAuthUserMiddleware
3030
protected $authorizer;
3131

3232
/**
33-
* Create a new oauth owner middleware instance.
33+
* Create a new oauth user middleware instance.
3434
*
3535
* @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
3636
*/

tests/unit/LucaDegasperi/OAuth2Server/Middleware/OAuthUserMiddlewareSpec.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,15 @@ public function it_passes_if_resource_owners_are_allowed(Request $request, Autho
4949
$this->shouldThrow(new MiddlewareException('Called execution of $next'))
5050
->during('handle', [$request, $this->next]);
5151
}
52+
53+
public function it_blocks_if_resource_owners_are_not_allowed(Request $request, Authorizer $authorizer)
54+
{
55+
$authorizer->getResourceOwnerType()->willReturn('client')->shouldBeCalled();
56+
57+
$this->shouldThrow(new AccessDeniedException())
58+
->during('handle', [$request, $this->next]);
59+
60+
$this->shouldNotThrow(new MiddlewareException('Called execution of $next'))
61+
->during('handle', [$request, $this->next]);
62+
}
5263
}

0 commit comments

Comments
 (0)