ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BasicTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\HTTP\Auth;
4 
7 
9 
10  function testGetCredentials() {
11 
12  $request = new Request('GET', '/', [
13  'Authorization' => 'Basic ' . base64_encode('user:pass:bla')
14  ]);
15 
16  $basic = new Basic('Dagger', $request, new Response());
17 
18  $this->assertEquals([
19  'user',
20  'pass:bla',
21  ], $basic->getCredentials());
22 
23  }
24 
26 
27  $request = new Request('GET', '/', [
28  'Authorization' => 'Basic ' . base64_encode('userpass')
29  ]);
30 
31  $basic = new Basic('Dagger', $request, new Response());
32 
33  $this->assertNull($basic->getCredentials());
34 
35  }
36 
38 
39  $request = new Request('GET', '/', []);
40  $basic = new Basic('Dagger', $request, new Response());
41 
42  $this->assertNull($basic->getCredentials());
43 
44  }
45 
47 
48  $request = new Request('GET', '/', [
49  'Authorization' => 'QBasic ' . base64_encode('user:pass:bla')
50  ]);
51  $basic = new Basic('Dagger', $request, new Response());
52 
53  $this->assertNull($basic->getCredentials());
54 
55  }
56 
57  function testRequireLogin() {
58 
59  $response = new Response();
60  $basic = new Basic('Dagger', new Request(), $response);
61 
62  $basic->requireLogin();
63 
64  $this->assertEquals('Basic realm="Dagger", charset="UTF-8"', $response->getHeader('WWW-Authenticate'));
65  $this->assertEquals(401, $response->getStatus());
66 
67  }
68 
69 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
The Request class represents a single HTTP request.
Definition: Request.php:18
This class represents a single HTTP response.
Definition: Response.php:12
$response
HTTP Basic authentication utility.
Definition: Basic.php:18