ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BearerTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\HTTP\Auth;
4 
7 
9 
10  function testGetToken() {
11 
12  $request = new Request('GET', '/', [
13  'Authorization' => 'Bearer 12345'
14  ]);
15 
16  $bearer = new Bearer('Dagger', $request, new Response());
17 
18  $this->assertEquals(
19  '12345',
20  $bearer->getToken()
21  );
22 
23  }
24 
26 
27  $request = new Request('GET', '/', []);
28  $bearer = new Bearer('Dagger', $request, new Response());
29 
30  $this->assertNull($bearer->getToken());
31 
32  }
33 
35 
36  $request = new Request('GET', '/', [
37  'Authorization' => 'QBearer 12345'
38  ]);
39  $bearer = new Bearer('Dagger', $request, new Response());
40 
41  $this->assertNull($bearer->getToken());
42 
43  }
44 
45  function testRequireLogin() {
46 
47  $response = new Response();
48  $bearer = new Bearer('Dagger', new Request(), $response);
49 
50  $bearer->requireLogin();
51 
52  $this->assertEquals('Bearer realm="Dagger"', $response->getHeader('WWW-Authenticate'));
53  $this->assertEquals(401, $response->getStatus());
54 
55  }
56 
57 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
The Request class represents a single HTTP request.
Definition: Request.php:18
HTTP Bearer authentication utility.
Definition: Bearer.php:18
This class represents a single HTTP response.
Definition: Response.php:12
$response