This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » functional test with csrf
functional test with csrf [message #97913] Thu, 22 April 2010 22:00
micheal  is currently offline micheal
Messages: 2
Registered: November 2009
Location: Poland
Junior Member
Hello,

I trying wrote functional tests for login action, but form class in this action (like all all another forms in my project) use csrf protection. how wrote functional test for actions with forms with csrf protection?

I try that:

<?php

include(dirname(__FILE__).'/../../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());

$browser->
  info('Testowanie logowania do panelu administracyjnego')->
  get('/user/login')->
  with('request')->begin()->
    isParameter('module', 'user')->
    isParameter('action', 'login')->
  end()->

  click('Zaloguj', array('login' => array(
    'user_name'  => 'admin',
    'password'   => 'zaq123edc',
  )), array('method' => 'post', '_with_csrf' => true))->
  with('form')->begin()->
    hasErrors(3)->
    isError('user_name', 'required')->
    isError('password', 'required')->
    isError('_csrf_token', 'required')->
  end()
;


but it doesn't working, I get

Quote:

> Testowanie logowania do panelu administracyjnego
# get /user/login
ok 1 - request parameter module is user
ok 2 - request parameter action is login
# post /user/login


no form has been submitted.


1..2
# Looks like everything went fine.
Previous Topic:User accounts
Next Topic:Admin Generator for Frontend Applications
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software