Rails load using httperf

I am trying to download a Rails test application (3.2.13) using httperf. It worked very well for pages that do not require cookies. But I could not get it to work on pages requiring cookies. I use Gregg Pollack httperf ( https://github.com/Gregg/httperf_big_cookies ) because the official version does not support large cookies.

Here is the command I used:

httperf --session-cookie --wsesslog=1,5,path.txt --rate=1 --timeout=15 --server=localhost --port=3000

And this is the path.txt file:

  /log_in /sessions method=POST contents='utf8=✓&remember_me=1&commit=Login& email=john@widgetsco.com &password=password' 

The cookies method always returns nil inside controllers.

So, please offer me how I can overcome the problem or the best tool (console-based) for testing the loading of rails applications.

+4
source share
1 answer

You probably have problems with the CSRF check that comes with the rails. Check your logs, and if you see the following line, then the reason:

 WARNING: Can't verify CSRF token authenticity 

A workaround could be to create a secret / master token that will be used for your tests by checking the CSRF, and then tell your application to accept it as valid, for example, add the following line to your ApplicationController right after the line "protect_from_forgery ":

 skip_before_filter :verify_authenticity_token, :if =>lambda{ params[:authenticity_token].present? && params[:authenticity_token] == 'YOUR_SECRET_TOKEN' } 

then in httperf tests you should send your main token with parameters: & authenticity_token = YOUR_SECRET_TOKEN

+5
source

Source: https://habr.com/ru/post/1487074/


All Articles