Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821237
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, 10:45 AM (10 h, 18 m 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