/**
  * Test of prolong user action
  *
  * @magentoDbIsolation enabled
  */
 public function testProcessProlong()
 {
     $this->auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
     $sessionId = $this->authSession->getSessionId();
     $dateInPast = $this->dateTime->formatDate($this->authSession->getUpdatedAt() - 100);
     $this->adminSessionsManager->getCurrentSession()->setData('updated_at', $dateInPast)->save();
     $this->adminSessionInfo->load($sessionId, 'session_id');
     $oldUpdatedAt = $this->adminSessionInfo->getUpdatedAt();
     $this->authSession->prolong();
     $this->adminSessionInfo->load($sessionId, 'session_id');
     $updatedAt = $this->adminSessionInfo->getUpdatedAt();
     $this->assertGreaterThan($oldUpdatedAt, $updatedAt);
 }
Example #2
0
 public function testProlong()
 {
     $name = session_name();
     $cookie = 'cookie';
     $lifetime = 900;
     $path = '/';
     $domain = 'magento2';
     $secure = true;
     $httpOnly = true;
     $cookieMetadata = $this->getMock('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata');
     $cookieMetadata->expects($this->once())->method('setDuration')->with($lifetime)->will($this->returnSelf());
     $cookieMetadata->expects($this->once())->method('setPath')->with($path)->will($this->returnSelf());
     $cookieMetadata->expects($this->once())->method('setDomain')->with($domain)->will($this->returnSelf());
     $cookieMetadata->expects($this->once())->method('setSecure')->with($secure)->will($this->returnSelf());
     $cookieMetadata->expects($this->once())->method('setHttpOnly')->with($httpOnly)->will($this->returnSelf());
     $this->cookieMetadataFactory->expects($this->once())->method('createPublicCookieMetadata')->will($this->returnValue($cookieMetadata));
     $this->cookieManager->expects($this->once())->method('getCookie')->with($name)->will($this->returnValue($cookie));
     $this->cookieManager->expects($this->once())->method('setPublicCookie')->with($name, $cookie, $cookieMetadata);
     $this->config->expects($this->once())->method('getValue')->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME)->will($this->returnValue($lifetime));
     $this->sessionConfig->expects($this->once())->method('getCookiePath')->will($this->returnValue($path));
     $this->sessionConfig->expects($this->once())->method('getCookieDomain')->will($this->returnValue($domain));
     $this->sessionConfig->expects($this->once())->method('getCookieSecure')->will($this->returnValue($secure));
     $this->sessionConfig->expects($this->once())->method('getCookieHttpOnly')->will($this->returnValue($httpOnly));
     $this->session->prolong();
     $this->assertLessThanOrEqual(time(), $this->session->getUpdatedAt());
 }
 /**
  * {@inheritdoc}
  */
 public function prolong()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'prolong');
     if (!$pluginInfo) {
         return parent::prolong();
     } else {
         return $this->___callPlugins('prolong', func_get_args(), $pluginInfo);
     }
 }
Example #4
0
 public function testProlong()
 {
     $name = session_name();
     $cookie = 'cookie';
     $lifetime = 900;
     $path = '/';
     $domain = 'magento2';
     $secure = true;
     $httpOnly = true;
     $this->cookie->expects($this->once())->method('get')->with($name)->will($this->returnValue($cookie));
     $this->cookie->expects($this->once())->method('set')->with($name, $cookie, $lifetime, $path, $domain, $secure, $httpOnly);
     $this->config->expects($this->once())->method('getValue')->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME)->will($this->returnValue($lifetime));
     $this->sessionConfig->expects($this->once())->method('getCookiePath')->will($this->returnValue($path));
     $this->sessionConfig->expects($this->once())->method('getCookieDomain')->will($this->returnValue($domain));
     $this->sessionConfig->expects($this->once())->method('getCookieSecure')->will($this->returnValue($secure));
     $this->sessionConfig->expects($this->once())->method('getCookieHttpOnly')->will($this->returnValue($httpOnly));
     $this->session->prolong();
     $this->assertLessThanOrEqual(time(), $this->session->getUpdatedAt());
 }