Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter authenticity token with Rails App

I am trying to do a JMeter post operation to a simle rails app but I am getting the following back:

Started POST "/flights/" for 127.0.0.1 at 2015-05-04 12:40:15 -0700 Processing by FlightsController#create as HTML Parameters: {"authenticity_token"=>"$(LOGIN_AUTH_TOKEN)"} Can't verify CSRF token authenticity Completed 422 Unprocessable Entity in 3ms (ActiveRecord: 0.0ms)

I have implemented the suggestion about creating a regular expression extractor for the authenticity login as shown here:

Regular Expression Extractor

and here is the http request:

http post request

Any help appreciated and thanks in advance, Slavko

like image 482
user3570192 Avatar asked Nov 10 '22 14:11

user3570192


1 Answers

  • Move the Regular Expression Extractor as the child element of the first HTTP Request.
  • Regular expression could be name=authenticity_token type=hidden value=(.*?)"
  • In the next request, access authenticity_token by using ${LOGIN_AUTH_TOKEN} (Not by $(LOGIN_AUTH_TOKEN))
like image 194
vins Avatar answered Nov 14 '22 22:11

vins