mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 04:26:52 +01:00 
			
		
		
		
	 3d764a89f7
			
		
	
	
		3d764a89f7
		
			
		
	
	
	
	
		
			
			* chore: yarn upgrade * chore: composer upgrade * chore: php artisan filament:upgrade * chore: update filament-monaco-editor-views * chore: update filament-monaco-editor-configs * chore: move turnstile-views to plugins * fix monaco-editor loader & css
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Tests\Unit\Http\Middleware\Api\Application;
 | |
| 
 | |
| use App\Tests\Unit\Http\Middleware\MiddlewareTestCase;
 | |
| use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
 | |
| use App\Http\Middleware\Api\Application\AuthenticateApplicationUser;
 | |
| 
 | |
| class AuthenticateUserTest extends MiddlewareTestCase
 | |
| {
 | |
|     /**
 | |
|      * Test that no user defined results in an access denied exception.
 | |
|      */
 | |
|     public function test_no_user_defined(): void
 | |
|     {
 | |
|         $this->expectException(AccessDeniedHttpException::class);
 | |
| 
 | |
|         $this->setRequestUserModel(null);
 | |
| 
 | |
|         $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Test that a non-admin user results in an exception.
 | |
|      */
 | |
|     public function test_non_admin_user(): void
 | |
|     {
 | |
|         $this->expectException(AccessDeniedHttpException::class);
 | |
| 
 | |
|         $this->generateRequestUserModel(false);
 | |
| 
 | |
|         $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Test that an admin user continues though the middleware.
 | |
|      */
 | |
|     public function test_admin_user(): void
 | |
|     {
 | |
|         $this->generateRequestUserModel(true);
 | |
| 
 | |
|         $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Return an instance of the middleware for testing.
 | |
|      */
 | |
|     private function getMiddleware(): AuthenticateApplicationUser
 | |
|     {
 | |
|         return new AuthenticateApplicationUser();
 | |
|     }
 | |
| }
 |