コード例 #1
0
 /**
  * @param string $email
  * @param string $firstName
  * @param string $lastName
  * @return bool
  * @throws \TYPO3\Flow\Http\Client\InfiniteRedirectionException
  */
 protected function sendApiRequest($email, $firstName, $lastName)
 {
     $browser = new Browser();
     $engine = new CurlEngine();
     $browser->setRequestEngine($engine);
     $jsonString = 'email=' . urlencode($email) . '&first_name=' . urlencode($firstName) . '&last_name=' . urlencode($lastName) . '&token=' . $this->settings['Slack']['token'] . '&set_active=true';
     return $browser->request($this->settings['Slack']['TeamUrl'] . '/api/users.admin.invite?t=' . time(), 'POST', [], [], [], $jsonString);
 }
コード例 #2
0
 /**
  * Sets up a virtual browser and web environment for seamless HTTP and MVC
  * related tests.
  *
  * @return void
  */
 protected function setupHttp()
 {
     $this->browser = new \TYPO3\Flow\Http\Client\Browser();
     $this->browser->setRequestEngine(new \TYPO3\Flow\Http\Client\InternalRequestEngine());
     $this->router = $this->browser->getRequestEngine()->getRouter();
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $requestHandler->setHttpRequest(Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/typo3/flow/test')));
     $requestHandler->setHttpResponse(new \TYPO3\Flow\Http\Response());
 }
コード例 #3
0
 /**
  * @test
  * @expectedException \TYPO3\Flow\Http\Client\InfiniteRedirectionException
  */
 public function browserHaltsOnExceedingMaximumRedirections()
 {
     $requestEngine = $this->getMock(\TYPO3\Flow\Http\Client\RequestEngineInterface::class);
     for ($i = 0; $i <= 10; $i++) {
         $response = new Response();
         $response->setHeader('Location', 'http://localhost/this/willLead/you/knowhere/' . $i);
         $response->setStatus(301);
         $requestEngine->expects($this->at($i))->method('sendRequest')->will($this->returnValue($response));
     }
     $this->browser->setRequestEngine($requestEngine);
     $this->browser->request('http://localhost/some/initialRequest');
 }
コード例 #4
0
 /**
  * Sets up a virtual browser and web environment for seamless HTTP and MVC
  * related tests.
  *
  * @return void
  */
 protected function setupHttp()
 {
     $_GET = array();
     $_POST = array();
     $_COOKIE = array();
     $_FILES = array();
     $_SERVER = array('REDIRECT_FLOW_CONTEXT' => 'Development', 'REDIRECT_FLOW_REWRITEURLS' => '1', 'REDIRECT_STATUS' => '200', 'FLOW_CONTEXT' => 'Testing', 'FLOW_REWRITEURLS' => '1', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin', 'SERVER_SIGNATURE' => '', 'SERVER_SOFTWARE' => 'Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/1.0.0e DAV/2 PHP/5.3.8', 'SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/opt/local/apache2/htdocs/', 'SERVER_ADMIN' => 'george@localhost', 'SCRIPT_FILENAME' => '/opt/local/apache2/htdocs/Web/index.php', 'REMOTE_PORT' => '51439', 'REDIRECT_QUERY_STRING' => '', 'REDIRECT_URL' => '', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'REQUEST_TIME' => 1326472534);
     $this->browser = new \TYPO3\Flow\Http\Client\Browser();
     $this->browser->setRequestEngine(new \TYPO3\Flow\Http\Client\InternalRequestEngine());
     $this->router = $this->browser->getRequestEngine()->getRouter();
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $requestHandler->setHttpRequest(\TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/typo3/flow/test')));
     $requestHandler->setHttpResponse(new \TYPO3\Flow\Http\Response());
 }
コード例 #5
0
ファイル: Reporting.php プロジェクト: portachtzig/neos-piwik
 /**
  * Call the Piwik Reporting API for node specific statistics
  * @todo make this protected for security !!!
  * @param $node NodeInterface
  * @param $controllerContext ControllerContext
  * @param $arguments array
  * @return DataResult
  */
 public function getNodeStatistics($node = NULL, $controllerContext = NULL, $arguments = array())
 {
     if (!empty($this->settings['host']) && !empty($this->settings['token_auth'] && !empty($this->settings['token_auth']))) {
         $params = '';
         foreach ($arguments as $key => $value) {
             if (!empty($value) && $key != 'view' && $key != 'device' && $key != 'type') {
                 $params .= '&' . $key . '=' . rawurlencode($value);
             }
         }
         try {
             $pageUrl = urlencode($this->getLiveNodeUri($node, $controllerContext)->__toString());
         } catch (StatisticsNotAvailableException $err) {
             return;
         }
         $apiCallUrl = $this->settings['protocol'] . '://' . $this->settings['host'] . '/index.php?module=API&format=json' . $params;
         $apiCallUrl .= '&pageUrl=' . $pageUrl;
         $apiCallUrl .= '&idSite=' . $this->settings['idSite'] . '&token_auth=' . $this->settings['token_auth'];
         $this->browser->setRequestEngine($this->browserRequestEngine);
         if ($arguments['view'] == 'TimeSeriesView') {
             $response = $this->browser->request($apiCallUrl);
             return new TimeSeriesDataResult($response);
         }
         if ($arguments['view'] == 'ColumnView') {
             $response = $this->browser->request($apiCallUrl);
             return new ColumnDataResult($response);
         }
         if ($arguments['type'] == 'device') {
             $apiCallUrl .= '&segment=pageUrl==' . $pageUrl;
             $response = $this->browser->request($apiCallUrl);
             return new DeviceDataResult($response);
         }
         if ($arguments['type'] == 'osFamilies') {
             $apiCallUrl .= '&segment=pageUrl==' . $pageUrl;
             $response = $this->browser->request($apiCallUrl);
             return new OperatingSystemDataResult($response);
         }
         if ($arguments['type'] == 'browsers') {
             $apiCallUrl .= '&segment=pageUrl==' . $pageUrl;
             $response = $this->browser->request($apiCallUrl);
             return new BrowserDataResult($response);
         }
         if ($arguments['type'] == 'outlinks') {
             $apiCallUrl .= '&segment=pageUrl==' . $pageUrl;
             $response = $this->browser->request($apiCallUrl);
             return new OutlinkDataResult($response);
         }
     }
 }
コード例 #6
0
 /**
  * @param string $changeId
  * @param string $topic
  */
 private function setTopic($changeId, $topic)
 {
     $user = $this->settings['Gerrit']['username'];
     $pass = $this->settings['Gerrit']['password'];
     $browser = new Client\Browser();
     $engine = new Client\CurlEngine();
     $browser->setRequestEngine($engine);
     $browser->request('https://' . $user . ':' . $pass . '@review.typo3.org/a/changes/' . $changeId . '/topic', 'PUT', array(), array(), array('PHP_AUTH_USER' => $user, 'PHP_AUTH_PW' => $pass, 'HTTP_CONTENT_TYPE' => 'application/json'), json_encode(array('topic' => $topic)));
     $this->counter['canSet']++;
 }
コード例 #7
0
 /**
  * Returns a browser instance with curlengine and authentication parameters set
  *
  * @return Browser
  */
 protected function getBrowser()
 {
     $browser = new Browser();
     $browser->setRequestEngine(new CurlEngine());
     if (array_key_exists('username', $this->apiSettings) && !empty($this->apiSettings['username']) && array_key_exists('password', $this->apiSettings) && !empty($this->apiSettings['password'])) {
         $browser->addAutomaticRequestHeader('Authorization', 'Basic ' . base64_encode($this->apiSettings['username'] . ':' . $this->apiSettings['password']));
     }
     return $browser;
 }
コード例 #8
0
 /**
  * @return void
  */
 public function initializeObject()
 {
     $requestEngine = new CurlEngine();
     $requestEngine->setOption(CURLOPT_TIMEOUT, $this->settings['transfer']['connectionTimeout']);
     $this->browser->setRequestEngine($requestEngine);
 }
コード例 #9
0
 /**
  * Update the page https://forge.typo3.org/projects/typo3cms-core/wiki/Forgertest
  * @deprecated Not usable because our redmine is too old
  * @param string $content
  * @param string $project
  * @param string $page
  */
 protected function updateWikiPage($content, $project = 'typo3cms-core', $page = 'Mergedorphans')
 {
     //content[text]
     //content[comments]
     $user = $this->settings['Gerrit']['username'];
     $pass = $this->settings['Gerrit']['password'];
     $browser = new Client\Browser();
     $engine = new Client\CurlEngine();
     $browser->setRequestEngine($engine);
     $res = $browser->request('https://' . $user . ':' . $pass . '@forge.typo3.org/projects/' . $project . '/wiki/' . $page . '/', 'PUT', array(), array(), array('PHP_AUTH_USER' => $user, 'PHP_AUTH_PW' => $pass), 'content[text]=' . rawurlencode($content) . '&commit=Save');
     \TYPO3\Flow\var_dump($res);
 }
コード例 #10
0
 /**
  * @return void
  */
 protected function initializeObject()
 {
     $this->browser->setRequestEngine(new \TYPO3\Flow\Http\Client\CurlEngine());
 }
コード例 #11
0
 /**
  * @return void
  */
 public function initializeObject()
 {
     $this->browserRequestEngine->setOption(CURLOPT_SSL_VERIFYPEER, FALSE);
     $this->browserRequestEngine->setOption(CURLOPT_SSL_VERIFYHOST, FALSE);
     $this->browser->setRequestEngine($this->browserRequestEngine);
 }
コード例 #12
0
 /**
  * Initializes defaults
  */
 public function initializeAction()
 {
     parent::initializeAction();
     $this->browser->setRequestEngine($this->browserRequestEngine);
 }
コード例 #13
0
 /**
  *
  */
 public function __construct()
 {
     $browser = new Browser();
     $browser->setRequestEngine(new CurlEngine());
     $this->browser = $browser;
 }
コード例 #14
0
 /**
  * @return void
  */
 protected function initializeObject()
 {
     $this->browser->setRequestEngine(new CurlEngine());
 }