Пример #1
0
 /**
  * Handle private content version cookie
  * Set cookie if it is not set.
  * Increment version on post requests.
  * In all other cases do nothing.
  *
  * @return void
  */
 public function process()
 {
     if ($this->request->isPost()) {
         $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration(self::COOKIE_PERIOD)->setPath('/')->setSecure($this->request->isSecure())->setHttpOnly(false);
         $this->cookieManager->setPublicCookie(self::COOKIE_NAME, $this->generateValue(), $publicCookieMetadata);
     }
 }
Пример #2
0
 /**
  * @dataProvider isSecureDataProvider
  *
  * @param bool $isSecure expected output of isSecure method
  * @param string $serverHttps value of $_SERVER['HTTPS']
  * @param string $headerOffloadKey <Name-Of-Offload-Header>
  * @param string $headerOffloadValue value of $_SERVER[<Name-Of-Offload-Header>]
  * @param int $configCall number of times config->getValue is expected to be called
  */
 public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $headerOffloadValue, $configCall)
 {
     $this->_model = $this->getModel();
     $configOffloadHeader = 'Header-From-Proxy';
     $configMock = $this->getMockBuilder('Magento\\Framework\\App\\Config')->disableOriginalConstructor()->setMethods(['getValue'])->getMock();
     $configMock->expects($this->exactly($configCall))->method('getValue')->with(\Magento\Framework\App\Request\Http::XML_PATH_OFFLOADER_HEADER, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)->willReturn($configOffloadHeader);
     $this->objectManager->expects($this->exactly($configCall))->method('get')->with('Magento\\Framework\\App\\Config')->will($this->returnValue($configMock));
     $this->_model->getServer()->set($headerOffloadKey, $headerOffloadValue);
     $this->_model->getServer()->set('HTTPS', $serverHttps);
     $this->assertSame($isSecure, $this->_model->isSecure());
 }
Пример #3
0
 /**
  * @param \Magento\Framework\App\Request\Http $request
  */
 public function __construct(\Magento\Framework\App\Request\Http $request)
 {
     $data = [$request->isSecure(), $request->getRequestUri(), $request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING)];
     $this->value = md5(serialize($data));
 }
Пример #4
0
 /**
  * Return unique page identifier
  *
  * @return string
  */
 public function getValue()
 {
     $data = [$this->request->isSecure(), $this->request->getUriString(), $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING) ?: $this->context->getVaryString()];
     return md5(serialize($data));
 }