3 namespace MediaWiki\Tests\Session
;
6 use InvalidArgumentException
;
7 use MediaWiki\Config\HashConfig
;
8 use MediaWiki\MainConfigNames
;
9 use MediaWiki\Message\Message
;
10 use MediaWiki\Request\FauxRequest
;
11 use MediaWiki\Request\FauxResponse
;
12 use MediaWiki\Session\CookieSessionProvider
;
13 use MediaWiki\Session\SessionBackend
;
14 use MediaWiki\Session\SessionId
;
15 use MediaWiki\Session\SessionInfo
;
16 use MediaWiki\Session\SessionManager
;
17 use MediaWiki\User\User
;
18 use MediaWikiIntegrationTestCase
;
20 use Psr\Log\NullLogger
;
22 use Wikimedia\TestingAccessWrapper
;
27 * @covers \MediaWiki\Session\CookieSessionProvider
29 class CookieSessionProviderTest
extends MediaWikiIntegrationTestCase
{
30 use SessionProviderTestTrait
;
32 private function getConfig() {
33 return new HashConfig( [
34 MainConfigNames
::CookiePrefix
=> 'CookiePrefix',
35 MainConfigNames
::CookiePath
=> 'CookiePath',
36 MainConfigNames
::CookieDomain
=> 'CookieDomain',
37 MainConfigNames
::CookieSecure
=> true,
38 MainConfigNames
::CookieHttpOnly
=> true,
39 MainConfigNames
::CookieSameSite
=> '',
40 MainConfigNames
::SessionName
=> false,
41 MainConfigNames
::CookieExpiration
=> 100,
42 MainConfigNames
::ExtendedLoginCookieExpiration
=> 200,
43 MainConfigNames
::ForceHTTPS
=> false,
48 * Provider for testing both values of $wgForceHTTPS
50 public static function provideForceHTTPS() {
57 public function testConstructor() {
59 new CookieSessionProvider();
60 $this->fail( 'Expected exception not thrown' );
61 } catch ( InvalidArgumentException
$ex ) {
63 'MediaWiki\\Session\\CookieSessionProvider::__construct: priority must be specified',
69 new CookieSessionProvider( [ 'priority' => 'foo' ] );
70 $this->fail( 'Expected exception not thrown' );
71 } catch ( InvalidArgumentException
$ex ) {
73 'MediaWiki\\Session\\CookieSessionProvider::__construct: Invalid priority',
78 new CookieSessionProvider( [ 'priority' => SessionInfo
::MIN_PRIORITY
- 1 ] );
79 $this->fail( 'Expected exception not thrown' );
80 } catch ( InvalidArgumentException
$ex ) {
82 'MediaWiki\\Session\\CookieSessionProvider::__construct: Invalid priority',
87 new CookieSessionProvider( [ 'priority' => SessionInfo
::MAX_PRIORITY +
1 ] );
88 $this->fail( 'Expected exception not thrown' );
89 } catch ( InvalidArgumentException
$ex ) {
91 'MediaWiki\\Session\\CookieSessionProvider::__construct: Invalid priority',
97 new CookieSessionProvider( [ 'priority' => 1, 'cookieOptions' => null ] );
98 $this->fail( 'Expected exception not thrown' );
99 } catch ( InvalidArgumentException
$ex ) {
101 'MediaWiki\\Session\\CookieSessionProvider::__construct: cookieOptions must be an array',
106 $config = $this->getConfig();
107 $provider = new CookieSessionProvider( [ 'priority' => 1 ] );
108 $providerPriv = TestingAccessWrapper
::newFromObject( $provider );
109 $this->initProvider( $provider, new TestLogger(), $config );
110 $this->assertSame( 1, $providerPriv->priority
);
111 $this->assertEquals( [
112 'sessionName' => 'CookiePrefix_session',
113 ], $providerPriv->params
);
114 $this->assertEquals( [
115 'prefix' => 'CookiePrefix',
116 'path' => 'CookiePath',
117 'domain' => 'CookieDomain',
121 ], $providerPriv->cookieOptions
);
123 $config->set( MainConfigNames
::SessionName
, 'SessionName' );
124 $provider = new CookieSessionProvider( [ 'priority' => 3 ] );
125 $providerPriv = TestingAccessWrapper
::newFromObject( $provider );
126 $this->initProvider( $provider, new TestLogger(), $config );
127 $this->assertEquals( 3, $providerPriv->priority
);
128 $this->assertEquals( [
129 'sessionName' => 'SessionName',
130 ], $providerPriv->params
);
131 $this->assertEquals( [
132 'prefix' => 'CookiePrefix',
133 'path' => 'CookiePath',
134 'domain' => 'CookieDomain',
138 ], $providerPriv->cookieOptions
);
140 $provider = new CookieSessionProvider( [
143 'prefix' => 'XPrefix',
145 'domain' => 'XDomain',
146 'secure' => 'XSecure',
147 'httpOnly' => 'XHttpOnly',
148 'sameSite' => 'XSameSite',
150 'sessionName' => 'XSession',
152 $providerPriv = TestingAccessWrapper
::newFromObject( $provider );
153 $this->initProvider( $provider, new TestLogger(), $config );
154 $this->assertEquals( 10, $providerPriv->priority
);
155 $this->assertEquals( [
156 'sessionName' => 'XSession',
157 ], $providerPriv->params
);
158 $this->assertEquals( [
159 'prefix' => 'XPrefix',
161 'domain' => 'XDomain',
162 'secure' => 'XSecure',
163 'httpOnly' => 'XHttpOnly',
164 'sameSite' => 'XSameSite',
165 ], $providerPriv->cookieOptions
);
168 public function testBasics() {
169 $provider = new CookieSessionProvider( [ 'priority' => 10 ] );
171 $this->assertTrue( $provider->persistsSessionId() );
172 $this->assertTrue( $provider->canChangeUser() );
174 $extendedCookies = [ 'UserID', 'UserName', 'Token' ];
178 TestingAccessWrapper
::newFromObject( $provider )->getExtendedLoginCookies(),
179 'List of extended cookies (subclasses can add values, but we\'re calling the core one here)'
182 $msg = $provider->whyNoSession();
183 $this->assertInstanceOf( Message
::class, $msg );
184 $this->assertSame( 'sessionprovider-nocookies', $msg->getKey() );
187 public function testProvideSessionInfo() {
190 'sessionName' => 'session',
191 'cookieOptions' => [ 'prefix' => 'x' ],
193 $provider = new CookieSessionProvider( $params );
194 $logger = new TestLogger( true );
195 $this->initProvider( $provider, $logger, $this->getConfig(), new SessionManager() );
197 $user = static::getTestSysop()->getUser();
198 $id = $user->getId();
199 $name = $user->getName();
200 $token = $user->getToken( true );
201 $sessionId = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
204 $request = new FauxRequest();
205 $info = $provider->provideSessionInfo( $request );
206 $this->assertNull( $info );
207 $this->assertSame( [], $logger->getBuffer() );
208 $logger->clearBuffer();
211 $request = new FauxRequest();
212 $request->setCookies( [
213 'session' => $sessionId,
215 $info = $provider->provideSessionInfo( $request );
216 $this->assertNotNull( $info );
217 $this->assertSame( $params['priority'], $info->getPriority() );
218 $this->assertSame( $sessionId, $info->getId() );
219 $this->assertNotNull( $info->getUserInfo() );
220 $this->assertSame( 0, $info->getUserInfo()->getId() );
221 $this->assertNull( $info->getUserInfo()->getName() );
222 $this->assertFalse( $info->forceHTTPS() );
226 'Session "{session}" requested without UserID cookie',
228 ], $logger->getBuffer() );
229 $logger->clearBuffer();
231 // User, no session key
232 $request = new FauxRequest();
233 $request->setCookies( [
237 $info = $provider->provideSessionInfo( $request );
238 $this->assertNotNull( $info );
239 $this->assertSame( $params['priority'], $info->getPriority() );
240 $this->assertNotSame( $sessionId, $info->getId() );
241 $this->assertNotNull( $info->getUserInfo() );
242 $this->assertSame( $id, $info->getUserInfo()->getId() );
243 $this->assertSame( $name, $info->getUserInfo()->getName() );
244 $this->assertFalse( $info->forceHTTPS() );
245 $this->assertSame( [], $logger->getBuffer() );
246 $logger->clearBuffer();
248 // User and session key
249 $request = new FauxRequest();
250 $request->setCookies( [
251 'session' => $sessionId,
255 $info = $provider->provideSessionInfo( $request );
256 $this->assertNotNull( $info );
257 $this->assertSame( $params['priority'], $info->getPriority() );
258 $this->assertSame( $sessionId, $info->getId() );
259 $this->assertNotNull( $info->getUserInfo() );
260 $this->assertSame( $id, $info->getUserInfo()->getId() );
261 $this->assertSame( $name, $info->getUserInfo()->getName() );
262 $this->assertFalse( $info->forceHTTPS() );
263 $this->assertSame( [], $logger->getBuffer() );
264 $logger->clearBuffer();
266 // User with bad token
267 $request = new FauxRequest();
268 $request->setCookies( [
269 'session' => $sessionId,
271 'xToken' => 'BADTOKEN',
273 $info = $provider->provideSessionInfo( $request );
274 $this->assertNull( $info );
278 'Session "{session}" requested with invalid Token cookie.'
280 ], $logger->getBuffer() );
281 $logger->clearBuffer();
283 // User id with no token
284 $request = new FauxRequest();
285 $request->setCookies( [
286 'session' => $sessionId,
289 $info = $provider->provideSessionInfo( $request );
290 $this->assertNotNull( $info );
291 $this->assertSame( $params['priority'], $info->getPriority() );
292 $this->assertSame( $sessionId, $info->getId() );
293 $this->assertNotNull( $info->getUserInfo() );
294 $this->assertFalse( $info->getUserInfo()->isVerified() );
295 $this->assertSame( $id, $info->getUserInfo()->getId() );
296 $this->assertSame( $name, $info->getUserInfo()->getName() );
297 $this->assertFalse( $info->forceHTTPS() );
298 $this->assertSame( [], $logger->getBuffer() );
299 $logger->clearBuffer();
301 $request = new FauxRequest();
302 $request->setCookies( [
305 $info = $provider->provideSessionInfo( $request );
306 $this->assertNull( $info );
307 $this->assertSame( [], $logger->getBuffer() );
308 $logger->clearBuffer();
310 // User and session key, with forceHTTPS flag
311 $request = new FauxRequest();
312 $request->setCookies( [
313 'session' => $sessionId,
316 'forceHTTPS' => true,
318 $info = $provider->provideSessionInfo( $request );
319 $this->assertNotNull( $info );
320 $this->assertSame( $params['priority'], $info->getPriority() );
321 $this->assertSame( $sessionId, $info->getId() );
322 $this->assertNotNull( $info->getUserInfo() );
323 $this->assertSame( $id, $info->getUserInfo()->getId() );
324 $this->assertSame( $name, $info->getUserInfo()->getName() );
325 $this->assertTrue( $info->forceHTTPS() );
326 $this->assertSame( [], $logger->getBuffer() );
327 $logger->clearBuffer();
330 $request = new FauxRequest();
331 $request->setCookies( [
332 'session' => $sessionId,
335 $info = $provider->provideSessionInfo( $request );
336 $this->assertNull( $info );
337 $this->assertSame( [], $logger->getBuffer() );
338 $logger->clearBuffer();
340 // User id with matching name
341 $request = new FauxRequest();
342 $request->setCookies( [
343 'session' => $sessionId,
345 'xUserName' => $name,
347 $info = $provider->provideSessionInfo( $request );
348 $this->assertNotNull( $info );
349 $this->assertSame( $params['priority'], $info->getPriority() );
350 $this->assertSame( $sessionId, $info->getId() );
351 $this->assertNotNull( $info->getUserInfo() );
352 $this->assertFalse( $info->getUserInfo()->isVerified() );
353 $this->assertSame( $id, $info->getUserInfo()->getId() );
354 $this->assertSame( $name, $info->getUserInfo()->getName() );
355 $this->assertFalse( $info->forceHTTPS() );
356 $this->assertSame( [], $logger->getBuffer() );
357 $logger->clearBuffer();
359 // User id with wrong name
360 $request = new FauxRequest();
361 $request->setCookies( [
362 'session' => $sessionId,
364 'xUserName' => 'Wrong',
366 $info = $provider->provideSessionInfo( $request );
367 $this->assertNull( $info );
371 'Session "{session}" requested with mismatched UserID and UserName cookies.',
373 ], $logger->getBuffer() );
374 $logger->clearBuffer();
377 public function testGetVaryCookies() {
378 $provider = new CookieSessionProvider( [
380 'sessionName' => 'MySessionName',
381 'cookieOptions' => [ 'prefix' => 'MyCookiePrefix' ],
383 $this->assertArrayEquals( [
384 'MyCookiePrefixToken',
385 'MyCookiePrefixLoggedOut',
388 ], $provider->getVaryCookies() );
391 public function testSuggestLoginUsername() {
392 $provider = new CookieSessionProvider( [
394 'sessionName' => 'MySessionName',
395 'cookieOptions' => [ 'prefix' => 'x' ],
398 $provider, null, $this->getConfig(), null, null, $this->getServiceContainer()->getUserNameUtils()
401 $request = new FauxRequest();
402 $this->assertNull( $provider->suggestLoginUsername( $request ) );
404 $request->setCookies( [
405 'xUserName' => 'Example',
407 $this->assertEquals( 'Example', $provider->suggestLoginUsername( $request ) );
410 /** @dataProvider provideForceHTTPS */
411 public function testPersistSession( $forceHTTPS ) {
412 $provider = new CookieSessionProvider( [
414 'sessionName' => 'MySessionName',
415 'cookieOptions' => [ 'prefix' => 'x' ],
417 $config = $this->getConfig();
418 $config->set( MainConfigNames
::ForceHTTPS
, $forceHTTPS );
419 $hookContainer = $this->createHookContainer();
420 $this->initProvider( $provider, new TestLogger(), $config, SessionManager
::singleton(), $hookContainer );
422 $sessionId = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
423 $store = new TestBagOStuff();
425 // For User::requiresHTTPS
426 $this->overrideConfigValue( MainConfigNames
::ForceHTTPS
, $forceHTTPS );
428 $user = static::getTestSysop()->getUser();
431 $backend = new SessionBackend(
432 new SessionId( $sessionId ),
433 new SessionInfo( SessionInfo
::MIN_PRIORITY
, [
434 'provider' => $provider,
444 TestingAccessWrapper
::newFromObject( $backend )->usePhpSessionHandling
= false;
447 $backend->setUser( $anon );
448 $backend->setRememberUser( true );
449 $backend->setForceHTTPS( false );
450 $request = new FauxRequest();
451 $provider->persistSession( $backend, $request );
452 $this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
453 $this->assertSame( '', $request->response()->getCookie( 'xUserID' ) );
454 $this->assertSame( null, $request->response()->getCookie( 'xUserName' ) );
455 $this->assertSame( '', $request->response()->getCookie( 'xToken' ) );
457 $this->assertSame( null, $request->response()->getCookie( 'forceHTTPS' ) );
459 $this->assertSame( '', $request->response()->getCookie( 'forceHTTPS' ) );
461 $this->assertSame( [], $backend->getData() );
463 // Logged-in user, no remember
464 $backend->setUser( $user );
465 $backend->setRememberUser( false );
466 $backend->setForceHTTPS( false );
467 $request = new FauxRequest();
468 $provider->persistSession( $backend, $request );
469 $this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
470 $this->assertSame( (string)$user->getId(), $request->response()->getCookie( 'xUserID' ) );
471 $this->assertSame( $user->getName(), $request->response()->getCookie( 'xUserName' ) );
472 $this->assertSame( '', $request->response()->getCookie( 'xToken' ) );
474 $this->assertSame( null, $request->response()->getCookie( 'forceHTTPS' ) );
476 $this->assertSame( '', $request->response()->getCookie( 'forceHTTPS' ) );
478 $this->assertSame( [], $backend->getData() );
480 // Logged-in user, remember
481 $backend->setUser( $user );
482 $backend->setRememberUser( true );
483 $backend->setForceHTTPS( true );
484 $request = new FauxRequest();
485 $provider->persistSession( $backend, $request );
486 $this->assertSame( $sessionId, $request->response()->getCookie( 'MySessionName' ) );
487 $this->assertSame( (string)$user->getId(), $request->response()->getCookie( 'xUserID' ) );
488 $this->assertSame( $user->getName(), $request->response()->getCookie( 'xUserName' ) );
489 $this->assertSame( $user->getToken(), $request->response()->getCookie( 'xToken' ) );
491 $this->assertSame( null, $request->response()->getCookie( 'forceHTTPS' ) );
493 $this->assertSame( 'true', $request->response()->getCookie( 'forceHTTPS' ) );
495 $this->assertSame( [], $backend->getData() );
499 * @dataProvider provideCookieData
500 * @param bool $secure
501 * @param bool $remember
502 * @param bool $forceHTTPS
504 public function testCookieData( $secure, $remember, $forceHTTPS ) {
505 $this->overrideConfigValues( [
506 MainConfigNames
::SecureLogin
=> false,
507 MainConfigNames
::ForceHTTPS
=> $forceHTTPS,
510 $provider = new CookieSessionProvider( [
512 'sessionName' => 'MySessionName',
513 'cookieOptions' => [ 'prefix' => 'x' ],
515 $config = $this->getConfig();
516 $config->set( MainConfigNames
::CookieSecure
, $secure );
517 $config->set( MainConfigNames
::ForceHTTPS
, $forceHTTPS );
518 $hookContainer = $this->createHookContainer();
519 $this->initProvider( $provider, new TestLogger(), $config, SessionManager
::singleton(), $hookContainer );
521 $sessionId = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
522 $user = static::getTestSysop()->getUser();
523 $this->assertSame( $user->requiresHTTPS(), $forceHTTPS );
525 $backend = new SessionBackend(
526 new SessionId( $sessionId ),
527 new SessionInfo( SessionInfo
::MIN_PRIORITY
, [
528 'provider' => $provider,
538 TestingAccessWrapper
::newFromObject( $backend )->usePhpSessionHandling
= false;
539 $backend->setUser( $user );
540 $backend->setRememberUser( $remember );
541 $backend->setForceHTTPS( $secure );
542 $request = new FauxRequest();
544 $provider->persistSession( $backend, $request );
547 'expire' => (int)100,
548 'path' => $config->get( MainConfigNames
::CookiePath
),
549 'domain' => $config->get( MainConfigNames
::CookieDomain
),
550 'secure' => $secure ||
$forceHTTPS,
551 'httpOnly' => $config->get( MainConfigNames
::CookieHttpOnly
),
555 $normalExpiry = $config->get( MainConfigNames
::CookieExpiration
);
556 $extendedExpiry = $config->get( MainConfigNames
::ExtendedLoginCookieExpiration
);
557 $extendedExpiry = (int)( $extendedExpiry ??
0 );
560 'value' => (string)$sessionId,
564 'value' => (string)$user->getId(),
565 'expire' => $remember ?
$extendedExpiry : $normalExpiry,
568 'value' => $user->getName(),
569 'expire' => $remember ?
$extendedExpiry : $normalExpiry
572 'value' => $remember ?
$user->getToken() : '',
573 'expire' => $remember ?
$extendedExpiry : -31536000,
576 if ( !$forceHTTPS ) {
577 $expect['forceHTTPS'] = [
578 'value' => $secure ?
'true' : '',
580 'expire' => $secure ?
( $remember ?
$defaults['expire'] : 0 ) : -31536000,
583 foreach ( $expect as $key => $value ) {
584 $actual = $request->response()->getCookieData( $key );
585 if ( $actual && $actual['expire'] > 0 ) {
586 // Round expiry so we don't randomly fail if the seconds ticked during the test.
587 $actual['expire'] = round( $actual['expire'] - $time, -2 );
589 $this->assertEquals( $value, $actual, "Cookie $key" );
593 public static function provideCookieData() {
594 return ArrayUtils
::cartesianProduct(
595 [ false, true ], // $secure
596 [ false, true ], // $remember
597 [ false, true ] // $forceHTTPS
601 protected function getSentRequest() {
602 $sentResponse = $this->getMockBuilder( FauxResponse
::class )
603 ->onlyMethods( [ 'headersSent', 'setCookie', 'header' ] )->getMock();
604 $sentResponse->method( 'headersSent' )
605 ->willReturn( true );
606 $sentResponse->expects( $this->never() )->method( 'setCookie' );
607 $sentResponse->expects( $this->never() )->method( 'header' );
609 $sentRequest = $this->getMockBuilder( FauxRequest
::class )
610 ->onlyMethods( [ 'response' ] )->getMock();
611 $sentRequest->method( 'response' )
612 ->willReturn( $sentResponse );
616 public function testUnpersistSession() {
617 $provider = new CookieSessionProvider( [
619 'sessionName' => 'MySessionName',
620 'cookieOptions' => [ 'prefix' => 'x' ],
623 $provider, null, $this->getConfig(), SessionManager
::singleton(), $this->createHookContainer()
626 $request = new FauxRequest();
627 $provider->unpersistSession( $request );
628 $this->assertSame( '', $request->response()->getCookie( 'MySessionName' ) );
629 $this->assertSame( '', $request->response()->getCookie( 'xUserID' ) );
630 $this->assertSame( null, $request->response()->getCookie( 'xUserName' ) );
631 $this->assertSame( '', $request->response()->getCookie( 'xToken' ) );
632 $this->assertSame( '', $request->response()->getCookie( 'forceHTTPS' ) );
634 $provider->unpersistSession( $this->getSentRequest() );
637 public function testSetLoggedOutCookie() {
638 $provider = new CookieSessionProvider( [
640 'sessionName' => 'MySessionName',
641 'cookieOptions' => [ 'prefix' => 'x' ],
643 $providerPriv = TestingAccessWrapper
::newFromObject( $provider );
645 $provider, null, $this->getConfig(), SessionManager
::singleton(), $this->createHookContainer()
649 $t2 = time() - 86400 * 2;
652 $request = new FauxRequest();
653 $providerPriv->setLoggedOutCookie( $t1, $request );
654 $this->assertSame( (string)$t1, $request->response()->getCookie( 'xLoggedOut' ) );
657 $request = new FauxRequest();
658 $providerPriv->setLoggedOutCookie( $t2, $request );
659 $this->assertSame( null, $request->response()->getCookie( 'xLoggedOut' ) );
661 // Don't reset if it's already set
662 $request = new FauxRequest();
663 $request->setCookies( [
666 $providerPriv->setLoggedOutCookie( $t1, $request );
667 $this->assertSame( null, $request->response()->getCookie( 'xLoggedOut' ) );
670 public function testGetCookie() {
671 $provider = new CookieSessionProvider( [
673 'sessionName' => 'MySessionName',
674 'cookieOptions' => [ 'prefix' => 'x' ],
677 $provider, null, $this->getConfig(), SessionManager
::singleton(), $this->createHookContainer()
679 $provider = TestingAccessWrapper
::newFromObject( $provider );
681 $request = new FauxRequest();
682 $request->setCookies( [
686 $this->assertSame( 'foo!', $provider->getCookie( $request, 'Foo', 'x' ) );
687 $this->assertNull( $provider->getCookie( $request, 'Bar', 'x' ) );
688 $this->assertNull( $provider->getCookie( $request, 'Baz', 'x' ) );
691 public function testGetRememberUserDuration() {
692 $config = $this->getConfig();
693 $provider = new CookieSessionProvider( [ 'priority' => 10 ] );
694 $this->initProvider( $provider, null, $config, SessionManager
::singleton(), $this->createHookContainer() );
696 $this->assertSame( 200, $provider->getRememberUserDuration() );
698 $config->set( MainConfigNames
::ExtendedLoginCookieExpiration
, null );
700 $this->assertSame( 100, $provider->getRememberUserDuration() );
702 $config->set( MainConfigNames
::ExtendedLoginCookieExpiration
, 0 );
704 $this->assertSame( null, $provider->getRememberUserDuration() );
707 public function testGetLoginCookieExpiration() {
708 $config = $this->getConfig();
709 $provider = new CookieSessionProvider( [
712 $providerPriv = TestingAccessWrapper
::newFromObject( $provider );
713 $this->initProvider( $provider, null, $config, SessionManager
::singleton(), $this->createHookContainer() );
715 // First cookie is an extended cookie, remember me true
716 $this->assertSame( 200, $providerPriv->getLoginCookieExpiration( 'Token', true ) );
717 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'User', true ) );
719 // First cookie is an extended cookie, remember me false
720 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'UserID', false ) );
721 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'User', false ) );
723 $config->set( MainConfigNames
::ExtendedLoginCookieExpiration
, null );
725 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'Token', true ) );
726 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'User', true ) );
728 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'Token', false ) );
729 $this->assertSame( 100, $providerPriv->getLoginCookieExpiration( 'User', false ) );