ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractBasicTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Auth\Backend;
4 
5 use Sabre\HTTP;
6 
8 
9  function testCheckNoHeaders() {
10 
11  $request = new HTTP\Request();
12  $response = new HTTP\Response();
13 
14  $backend = new AbstractBasicMock();
15 
16  $this->assertFalse(
17  $backend->check($request, $response)[0]
18  );
19 
20  }
21 
22  function testCheckUnknownUser() {
23 
25  'PHP_AUTH_USER' => 'username',
26  'PHP_AUTH_PW' => 'wrongpassword',
27  ]);
28  $response = new HTTP\Response();
29 
30  $backend = new AbstractBasicMock();
31 
32  $this->assertFalse(
33  $backend->check($request, $response)[0]
34  );
35 
36  }
37 
38  function testCheckSuccess() {
39 
41  'PHP_AUTH_USER' => 'username',
42  'PHP_AUTH_PW' => 'password',
43  ]);
44  $response = new HTTP\Response();
45 
46  $backend = new AbstractBasicMock();
47  $this->assertEquals(
48  [true, 'principals/username'],
49  $backend->check($request, $response)
50  );
51 
52  }
53 
54  function testRequireAuth() {
55 
56  $request = new HTTP\Request();
57  $response = new HTTP\Response();
58 
59  $backend = new AbstractBasicMock();
60  $backend->setRealm('writing unittests on a saturday night');
61  $backend->challenge($request, $response);
62 
63  $this->assertEquals(
64  'Basic realm="writing unittests on a saturday night"',
65  $response->getHeader('WWW-Authenticate')
66  );
67 
68  }
69 
70 }
71 
72 
74 
85  function validateUserPass($username, $password) {
86 
87  return ($username == 'username' && $password == 'password');
88 
89  }
90 
91 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
HTTP Basic authentication backend class.
$password
Definition: cron.php:14
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
validateUserPass($username, $password)
Validates a username and password.
$response