mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 03:46:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Tests\Unit\Http\Middleware;
 | |
| 
 | |
| use Pterodactyl\Http\Middleware\Authenticate;
 | |
| 
 | |
| class AuthenticateTest extends MiddlewareTestCase
 | |
| {
 | |
|     /**
 | |
|      * Test that a logged in user validates correctly.
 | |
|      */
 | |
|     public function testLoggedInUser()
 | |
|     {
 | |
|         $this->request->shouldReceive('user')->withNoArgs()->once()->andReturn(true);
 | |
| 
 | |
|         $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Test that a logged out user results in an exception.
 | |
|      *
 | |
|      * @expectedException \Illuminate\Auth\AuthenticationException
 | |
|      */
 | |
|     public function testLoggedOutUser()
 | |
|     {
 | |
|         $this->request->shouldReceive('user')->withNoArgs()->once()->andReturnNull();
 | |
| 
 | |
|         $this->getMiddleware()->handle($this->request, $this->getClosureAssertions());
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Return an instance of the middleware using mocked dependencies.
 | |
|      *
 | |
|      * @return \Pterodactyl\Http\Middleware\Authenticate
 | |
|      */
 | |
|     private function getMiddleware(): Authenticate
 | |
|     {
 | |
|         return new Authenticate();
 | |
|     }
 | |
| }
 | 
