1<?php 2 3namespace Sabre\DAV\Auth\Backend; 4 5use Sabre\DAV; 6use Sabre\HTTP; 7 8class ApacheTest extends \PHPUnit_Framework_TestCase { 9 10 function testConstruct() { 11 12 $backend = new Apache(); 13 $this->assertInstanceOf('Sabre\DAV\Auth\Backend\Apache', $backend); 14 15 } 16 17 function testNoHeader() { 18 19 $request = new HTTP\Request(); 20 $response = new HTTP\Response(); 21 $backend = new Apache(); 22 23 $this->assertFalse( 24 $backend->check($request, $response)[0] 25 ); 26 27 } 28 29 function testRemoteUser() { 30 31 $request = HTTP\Sapi::createFromServerArray([ 32 'REMOTE_USER' => 'username', 33 ]); 34 $response = new HTTP\Response(); 35 $backend = new Apache(); 36 37 $this->assertEquals( 38 [true, 'principals/username'], 39 $backend->check($request, $response) 40 ); 41 42 } 43 44 function testRedirectRemoteUser() { 45 46 $request = HTTP\Sapi::createFromServerArray([ 47 'REDIRECT_REMOTE_USER' => 'username', 48 ]); 49 $response = new HTTP\Response(); 50 $backend = new Apache(); 51 52 $this->assertEquals( 53 [true, 'principals/username'], 54 $backend->check($request, $response) 55 ); 56 57 } 58 59 function testRequireAuth() { 60 61 $request = new HTTP\Request(); 62 $response = new HTTP\Response(); 63 64 $backend = new Apache(); 65 $backend->challenge($request, $response); 66 67 $this->assertNull( 68 $response->getHeader('WWW-Authenticate') 69 ); 70 71 } 72} 73