Exemplo n.º 1
0
 public function setUp()
 {
     self::$client = static::createClient();
     $container = static::$client->getContainer();
     $request = Request::create('/syrup/run', 'POST');
     $container->get('request_stack')->push($request);
     $this->controller = new ApiController();
     $this->controller->setContainer($container);
     $this->container = $container;
 }
Exemplo n.º 2
0
 public function setUp()
 {
     self::$client = static::createClient();
     $container = static::$client->getContainer();
     $request = Request::create('/syrup/run', 'POST');
     $request->headers->set('X-StorageApi-Token', $container->getParameter('storage_api.test.token'));
     $container->get('request_stack')->push($request);
     $this->controller = new ApiController();
     $this->controller->setContainer($container);
     $this->container = $container;
 }
 /**
  * @covers \Keboola\Syrup\Listener\SyrupControllerListener::onKernelController
  */
 public function testListener()
 {
     $client = static::createClient();
     $request = Request::create('/syrup/run', 'POST');
     $request->headers->set('X-StorageApi-Token', SYRUP_SAPI_TEST_TOKEN);
     /** @var RequestStack $requestStack */
     $requestStack = $client->getContainer()->get('request_stack');
     $requestStack->push($request);
     $controller = new ApiController();
     $controller->setContainer($client->getContainer());
     $event = new FilterControllerEvent(self::$kernel, [$controller, 'runAction'], $request, HttpKernelInterface::MASTER_REQUEST);
     $this->assertEmpty(\PHPUnit_Framework_Assert::readAttribute($controller, 'componentName'));
     $listener = new SyrupControllerListener();
     $listener->onKernelController($event);
     $this->assertNotEmpty(\PHPUnit_Framework_Assert::readAttribute($controller, 'componentName'));
 }
 /**
  *
  * Init backend class and storage API
  *
  * @param Request $request
  */
 public function preExecute(Request $request)
 {
     parent::preExecute($request);
     $logProcessor = $this->container->get('syrup.monolog.syslog_processor');
     $logProcessor->setRunId($this->storageApi->getRunId());
     // Init backend class
     $backend = $request->get("backend");
     switch ($backend) {
         case 'mysql':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Database\\Mysql";
             break;
         case 'wrdb':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Database\\Wrdb";
             break;
         case 'redshift':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Database\\Redshift";
             break;
         case 'redshift-workspace':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Workspace\\Redshift";
             break;
         case 'snowflake':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Workspace\\Snowflake";
             break;
         case 'docker':
             $className = "\\Keboola\\ProvisioningBundle\\Provisioning\\Manager\\Servers\\Docker";
             break;
         default:
             throw new UserException("Class '{$backend}' not found. Possible typo in URL?");
             break;
     }
     $doctrine = $this->container->get("doctrine");
     $this->server = new $className($doctrine, $this->storageApi);
     // Verify token of the user
     $this->tokenInfo = $this->storageApi->verifyToken();
 }
 /**
  *
  * Init backend class and storage API
  *
  * @param Request $request
  */
 public function preExecute(Request $request)
 {
     parent::preExecute($request);
     $this->factory = $this->container->get('provisioning_bundle.server_factory');
     // Verify token of the user
     $this->tokenInfo = $this->storageApi->verifyToken();
 }
 /**
  * @param Request $request
  */
 public function preExecute(Request $request)
 {
     parent::preExecute($request);
     if ($request->get("driver")) {
         $this->checkDriver($request->get("driver"));
         $component = $this->getParameter("app_name") . '-' . $request->get("driver");
         $this->checkComponent($component);
         $this->componentName = $component;
         $this->driver = $request->get("driver");
     }
 }
 /**
  * Controller init
  */
 public function preExecute(Request $request)
 {
     parent::preExecute($request);
     $this->logger = $this->container->get("logger");
     /**
      * @var DebugSyslogHandler $handlerForDebug
      */
     $handlerForDebug = $this->container->get('monolog.handler.orchestratorbundle.syslog_handler');
     $handlerForDebug->setFormatter($this->container->get('syrup.monolog.formatter'));
     $this->logger->pushHandler($handlerForDebug);
 }
 public function preExecute(Request $request)
 {
     parent::preExecute($request);
     $this->configuration = $this->container->get('wr_google_drive.configuration');
     $this->configuration->setStorageApi($this->storageApi);
 }