ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
AbstractBearerTest.php
Go to the documentation of this file.
1
<?
php
2
3
namespace
Sabre\DAV\Auth\Backend
;
4
5
use
Sabre\HTTP
;
6
7
require_once
'Sabre/HTTP/ResponseMock.php'
;
8
9
class
AbstractBearerTest
extends
\PHPUnit_Framework_TestCase
{
10
11
function
testCheckNoHeaders
() {
12
13
$request
=
new
HTTP\Request();
14
$response
=
new
HTTP\Response();
15
16
$backend =
new
AbstractBearerMock
();
17
18
$this->assertFalse(
19
$backend->check(
$request
,
$response
)[0]
20
);
21
22
}
23
24
function
testCheckInvalidToken
() {
25
26
$request
=
HTTP\Sapi::createFromServerArray
([
27
'HTTP_AUTHORIZATION'
=>
'Bearer foo'
,
28
]);
29
$response
=
new
HTTP\Response();
30
31
$backend =
new
AbstractBearerMock
();
32
33
$this->assertFalse(
34
$backend->check(
$request
,
$response
)[0]
35
);
36
37
}
38
39
function
testCheckSuccess
() {
40
41
$request
=
HTTP\Sapi::createFromServerArray
([
42
'HTTP_AUTHORIZATION'
=>
'Bearer valid'
,
43
]);
44
$response
=
new
HTTP\Response();
45
46
$backend =
new
AbstractBearerMock
();
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
AbstractBearerMock
();
60
$backend->setRealm(
'writing unittests on a saturday night'
);
61
$backend->challenge(
$request
,
$response
);
62
63
$this->assertEquals(
64
'Bearer realm="writing unittests on a saturday night"'
,
65
$response
->getHeader(
'WWW-Authenticate'
)
66
);
67
68
}
69
70
}
71
72
73
class
AbstractBearerMock
extends
AbstractBearer
{
74
84
function
validateBearerToken
($bearerToken) {
85
86
return
'valid'
=== $bearerToken ?
'principals/username'
:
false
;
87
88
}
89
90
}
Sabre\DAV\Auth\Backend\AbstractBearerTest\testCheckInvalidToken
testCheckInvalidToken()
Definition:
AbstractBearerTest.php:24
$request
foreach($paths as $path) $request
Definition:
asyncclient.php:32
Sabre\DAV\Auth\Backend\AbstractBearerMock\validateBearerToken
validateBearerToken($bearerToken)
Validates a bearer token.
Definition:
AbstractBearerTest.php:84
Sabre\HTTP
Definition:
ResponseMock.php:3
PHPUnit_Framework_TestCase
Sabre\DAV\Auth\Backend\AbstractBearerTest\testCheckNoHeaders
testCheckNoHeaders()
Definition:
AbstractBearerTest.php:11
Sabre\DAV\Auth\Backend\AbstractBearerTest
Definition:
AbstractBearerTest.php:9
Sabre\DAV\Auth\Backend
Definition:
AbstractBasic.php:3
Sabre\DAV\Auth\Backend\AbstractBearerTest\testRequireAuth
testRequireAuth()
Definition:
AbstractBearerTest.php:54
Sabre\DAV\Auth\Backend\AbstractBearerMock
Definition:
AbstractBearerTest.php:73
Sabre\DAV\Auth\Backend\AbstractBearer
HTTP Bearer authentication backend class.
Definition:
AbstractBearer.php:23
php
Sabre\HTTP\Sapi\createFromServerArray
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition:
Sapi.php:107
$response
$response
Definition:
proxy_ylocal.php:39
Sabre\DAV\Auth\Backend\AbstractBearerTest\testCheckSuccess
testCheckSuccess()
Definition:
AbstractBearerTest.php:39
libs
composer
vendor
sabre
dav
tests
Sabre
DAV
Auth
Backend
AbstractBearerTest.php
Generated on Thu Jan 30 2025 19:01:29 for ILIAS by
1.8.13 (using
Doxyfile
)