Ejemplo n.º 1
0
 /**
  * @param array $authToken
  * @return CookieJar
  */
 private function buildAuthCookie(array $authToken)
 {
     $cookie = new SetCookie();
     $cookie->setDomain($authToken['cookieDomain']);
     $cookie->setName($authToken['cookieName']);
     $cookie->setValue($authToken['cookieValue']);
     return new CookieJar(false, [$cookie]);
 }
Ejemplo n.º 2
0
 public function testMatchesDomain()
 {
     $cookie = new SetCookie();
     $this->assertTrue($cookie->matchesDomain('baz.com'));
     $cookie->setDomain('baz.com');
     $this->assertTrue($cookie->matchesDomain('baz.com'));
     $this->assertFalse($cookie->matchesDomain('bar.com'));
     $cookie->setDomain('.baz.com');
     $this->assertTrue($cookie->matchesDomain('.baz.com'));
     $this->assertTrue($cookie->matchesDomain('foo.baz.com'));
     $this->assertFalse($cookie->matchesDomain('baz.bar.com'));
     $this->assertTrue($cookie->matchesDomain('baz.com'));
     $cookie->setDomain('.127.0.0.1');
     $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
     $cookie->setDomain('127.0.0.1');
     $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
     $cookie->setDomain('.com.');
     $this->assertFalse($cookie->matchesDomain('baz.com'));
     $cookie->setDomain('.local');
     $this->assertTrue($cookie->matchesDomain('example.local'));
 }
Ejemplo n.º 3
0
 public function setColor($color = '2F2F2F')
 {
     if (!preg_match("/[0-9a-f]{6}/i", $color)) {
         throw new InvalidArgumentException('Invalid color ' . $color . '.');
     }
     $color = strtoupper($color);
     if (isset($this->colorCookie)) {
         $this->colorCookie->setValue($color);
         return $this;
     }
     $colorCookie = new SetCookie();
     $colorCookie->setName('l_chatroomcolor');
     $colorCookie->setValue($color);
     $colorCookie->setDomain('.erepublik.com');
     $this->getSession()->getCookieJar()->setCookie($colorCookie);
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Check if the cookie domain matches the config URL.
  *
  * @param array $cookie
  * @return bool
  */
 private function cookieDomainMatchesConfigUrl(array $cookie)
 {
     if (!array_key_exists('domain', $cookie)) {
         return true;
     }
     $setCookie = new SetCookie();
     $setCookie->setDomain($cookie['domain']);
     return $setCookie->matchesDomain(parse_url($this->config['url'], PHP_URL_HOST));
 }
Ejemplo n.º 5
0
 /**
  * @param array $config
  *
  * @return array
  */
 protected function addCookiesToForwardDebugSession(array $config)
 {
     if (!Config::get(ZedRequestConstants::TRANSFER_DEBUG_SESSION_FORWARD_ENABLED)) {
         return $config;
     }
     if (!isset($_COOKIE[Config::get(ZedRequestConstants::TRANSFER_DEBUG_SESSION_NAME)])) {
         return $config;
     }
     $cookie = new SetCookie();
     $cookie->setName(trim(Config::get(ZedRequestConstants::TRANSFER_DEBUG_SESSION_NAME)));
     $cookie->setValue($_COOKIE[Config::get(ZedRequestConstants::TRANSFER_DEBUG_SESSION_NAME)]);
     $cookie->setDomain(Config::get(ZedRequestConstants::HOST_ZED_API));
     $cookieJar = new CookieJar();
     $cookieJar->setCookie($cookie);
     $config['cookies'] = $cookieJar;
     return $config;
 }