Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4134970
CentralAuthSessionProviderTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
CentralAuthSessionProviderTest.php
View Options
<?php
use
MediaWiki\Config\HashConfig
;
use
MediaWiki\MainConfigNames
;
use
MediaWiki\Request\FauxRequest
;
use
MediaWiki\Tests\Session\SessionProviderTestTrait
;
/**
* @covers CentralAuthSessionProvider
*/
class
CentralAuthSessionProviderTest
extends
MediaWikiIntegrationTestCase
{
use
SessionProviderTestTrait
;
private
function
getConfig
()
{
return
new
HashConfig
(
[
'CentralAuthCookies'
=>
true
,
'CentralAuthCookiePrefix'
=>
'central_'
,
'CentralAuthCookiePath'
=>
'/'
,
'CentralAuthCookieDomain'
=>
''
,
MainConfigNames
::
CookieExpiration
=>
100
,
MainConfigNames
::
ExtendedLoginCookieExpiration
=>
200
,
// these are needed by CookieSessionProvider::getConfig
MainConfigNames
::
SessionName
=>
null
,
MainConfigNames
::
CookiePrefix
=>
''
,
MainConfigNames
::
CookiePath
=>
''
,
MainConfigNames
::
CookieDomain
=>
'example.com'
,
MainConfigNames
::
CookieSecure
=>
true
,
MainConfigNames
::
CookieHttpOnly
=>
true
,
MainConfigNames
::
CookieSameSite
=>
''
,
]
);
}
/**
* @dataProvider provideSuggestLoginUsername
*/
public
function
testSuggestLoginUsername
(
$cookies
,
$expectedUsername
)
{
$services
=
$this
->
getServiceContainer
();
$provider
=
new
CentralAuthSessionProvider
(
$services
->
getTempUserConfig
(),
$services
->
getUserIdentityLookup
(),
$services
->
get
(
'CentralAuth.CentralAuthSessionManager'
),
[
'priority'
=>
42
,
'cookieOptions'
=>
[
'prefix'
=>
''
],
'centralCookieOptions'
=>
[
'prefix'
=>
''
],
]
);
$this
->
initProvider
(
$provider
,
null
,
$this
->
getConfig
(),
null
,
null
,
$services
->
getUserNameUtils
()
);
$request
=
new
FauxRequest
();
$request
->
setCookies
(
$cookies
,
''
);
$this
->
assertSame
(
$expectedUsername
,
$provider
->
suggestLoginUsername
(
$request
)
);
}
public
static
function
provideSuggestLoginUsername
()
{
return
[
[
[
'Foo'
=>
'bar'
],
null
],
[
[
'User'
=>
'Foo'
],
'Foo'
],
[
[
'User'
=>
'foo'
],
'Foo'
],
[
[
'User'
=>
'#&@!'
],
null
],
[
[
'UserName'
=>
'Foo'
],
'Foo'
],
[
[
'UserName'
=>
'foo'
],
'Foo'
],
[
[
'UserName'
=>
'#&@!'
],
null
],
[
[
'User'
=>
'Foo'
,
'UserName'
=>
'Bar'
],
'Foo'
],
[
[
'User'
=>
'0'
],
'0'
],
[
[
'UserName'
=>
'0'
],
'0'
],
];
}
public
function
testGetRememberUserDuration
()
{
$services
=
$this
->
getServiceContainer
();
$provider
=
new
CentralAuthSessionProvider
(
$services
->
getTempUserConfig
(),
$services
->
getUserIdentityLookup
(),
$services
->
get
(
'CentralAuth.CentralAuthSessionManager'
),
[
'priority'
=>
42
]
);
$this
->
initProvider
(
$provider
,
null
,
$this
->
getConfig
()
);
$this
->
assertSame
(
200
,
$provider
->
getRememberUserDuration
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 12:55 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
14/70/dd8249a23baee39e7428219c2d1f
Default Alt Text
CentralAuthSessionProviderTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment