public function setup() { $this->enablePlugins('sfDoctrinePlugin'); $this->enablePlugins('sfDoctrineGuardPlugin'); $this->enablePlugins('sfFormExtraPlugin'); $this->enablePlugins('sfCASPlugin'); $this->enablePlugins('sfUTCCASPlugin'); $this->enablePlugins('sfImageTransformPlugin'); $this->enablePlugins('sfXssSafePlugin'); sfForm::disableCSRFProtection(); require_once sfConfig::get('sf_lib_dir') . '/vendor/ginger-client/autoload.php'; $this->enablePlugins('sfTCPDFPlugin'); }
public function _initialize() { if (!file_exists($this->config['project_dir'] . '/config/ProjectConfiguration.class.php')) { throw new \Codeception\Exception\ModuleConfigException('Symfony1', 'config/ProjectConfiguration.class.php not found. This file is required for running symfony1'); } require_once $this->config['project_dir'] . '/config/ProjectConfiguration.class.php'; $conf = \ProjectConfiguration::getApplicationConfiguration($this->config['app'], 'test', true); \sfContext::createInstance($conf); // chdir(\sfConfig::get('sf_web_dir')); $this->browser = new \sfBrowser($this->config['url']); $this->browser->get($this->config['url']); \sfForm::disableCSRFProtection(); }
$f = new FormTest(array(), array(), false); $t->ok(!$f->isCSRFProtected(), '->isCSRFProtected() returns true if the form is CSRF protected'); sfForm::enableCSRFProtection('mygreatsecret'); $f = new FormTest(); $v = $f->getValidatorSchema(); $t->is($v[sfForm::getCSRFFieldName()]->getOption('token'), '*mygreatsecret*', '::enableCSRFProtection() can take a secret argument'); // ->enableLocalCSRFProtection() ->disableLocalCSRFProtection() $t->diag('->enableLocalCSRFProtection() ->disableLocalCSRFProtection()'); $f = new TestForm3(); sfForm::disableCSRFProtection(); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form'); sfForm::enableCSRFProtection(); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form, even if the global CSRF protection is enabled'); $f = new TestForm3(array(), array(), 'foo'); $t->ok(!$f->isCSRFProtected(), '->disableLocalCSRFProtection() disabled CSRF protection for the current form, even a CSRF secret is provided in the constructor'); sfForm::disableCSRFProtection(); $f = new TestForm4(); $t->ok($f->isCSRFProtected(), '->enableLocalCSRFProtection() enables CSRF protection when passed null and global CSRF is disabled'); $f = new TestForm4(array(), array('csrf_secret' => '**localsecret**')); $t->ok($f->isCSRFProtected(), '->enableLocalCSRFProtection() enables CSRF protection when passed a string global CSRF is disabled'); // ::getCSRFFieldName() ::setCSRFFieldName() $t->diag('::getCSRFFieldName() ::setCSRFFieldName()'); sfForm::enableCSRFProtection(); sfForm::setCSRFFieldName('_token_'); $f = new FormTest(); $v = $f->getValidatorSchema(); $t->ok(isset($v['_token_']), '::setCSRFFieldName() changes the CSRF token field name'); $t->is(sfForm::getCSRFFieldName(), '_token_', '::getCSRFFieldName() returns the CSRF token field name'); // ->isMultipart() $t->diag('->isMultipart()'); $f = new FormTest();
/** * @param sfWebRequest $request */ public function executeRenameNode(sfWebRequest $request) { // Appel AJAX requis. $this->forward404Unless($request->isXmlHttpRequest()); $this->setLayout(sfView::NONE); $this->getResponse()->setContentType('application/json'); // Vérification des paramètres. $this->checkUpParameters($request); sfForm::disableCSRFProtection(); $JSONResponse = array(); $this->ei_node = Doctrine_Core::getTable("EiDataSetStructure")->find($request->getParameter("ei_node_id")); // On instancie le formulaire en fonction du type de noeud. if ($this->ei_node instanceof EiNodeDataSet) { $this->form = new EiNodeDataSetForm($this->ei_node); $JSONResponse = $this->processFormNode($request, $this->form); $type = 'Node'; } elseif ($this->ei_node instanceof EiLeafDataSet) { $this->ei_leaf = $this->ei_node; $this->form = new EiLeafDataSetForm($this->ei_node); $JSONResponse = $this->processFormLeaf($request, $this->form); $type = 'Attribute'; } if (!$JSONResponse) { $JSONResponse = $this->createJSONResponse('saved', 'ok', $type); } return $this->renderText(json_encode($JSONResponse)); }