Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1820982
BasicTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
1 KB
Subscribers
None
BasicTest.php
View Options
<?php
namespace
Sabre\HTTP\Auth
;
use
Sabre\HTTP\Request
;
use
Sabre\HTTP\Response
;
class
BasicTest
extends
\PHPUnit_Framework_TestCase
{
function
testGetCredentials
()
{
$request
=
new
Request
(
'GET'
,
'/'
,
[
'Authorization'
=>
'Basic '
.
base64_encode
(
'user:pass:bla'
)
]);
$basic
=
new
Basic
(
'Dagger'
,
$request
,
new
Response
());
$this
->
assertEquals
([
'user'
,
'pass:bla'
,
],
$basic
->
getCredentials
(
$request
));
}
function
testGetInvalidCredentialsColonMissing
()
{
$request
=
new
Request
(
'GET'
,
'/'
,
[
'Authorization'
=>
'Basic '
.
base64_encode
(
'userpass'
)
]);
$basic
=
new
Basic
(
'Dagger'
,
$request
,
new
Response
());
$this
->
assertNull
(
$basic
->
getCredentials
(
$request
));
}
function
testGetCredentialsNoheader
()
{
$request
=
new
Request
(
'GET'
,
'/'
,
[]);
$basic
=
new
Basic
(
'Dagger'
,
$request
,
new
Response
());
$this
->
assertNull
(
$basic
->
getCredentials
(
$request
));
}
function
testGetCredentialsNotBasic
()
{
$request
=
new
Request
(
'GET'
,
'/'
,
[
'Authorization'
=>
'QBasic '
.
base64_encode
(
'user:pass:bla'
)
]);
$basic
=
new
Basic
(
'Dagger'
,
$request
,
new
Response
());
$this
->
assertNull
(
$basic
->
getCredentials
(
$request
));
}
function
testRequireLogin
()
{
$response
=
new
Response
();
$basic
=
new
Basic
(
'Dagger'
,
new
Request
(),
$response
);
$basic
->
requireLogin
();
$this
->
assertEquals
(
'Basic realm="Dagger"'
,
$response
->
getHeader
(
'WWW-Authenticate'
));
$this
->
assertEquals
(
401
,
$response
->
getStatus
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Dec 23, 12:25 AM (1 d, 18 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
916522
Default Alt Text
BasicTest.php (1 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment