Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to post restricted access form in JMeter

Using JMeter, I want to test the page. After fill in and submit the form, some insert into database is performed (adding new trip).

Path: /ProjectName/admin/addTrip.html
Method: POST
Parameters:
basePrice 500.0
hotelId 2
description Some text

The main issue is that the page is available after log in. And I don't know how to log in with j_spring_security_check using JMeter.

I tried to use Login Config Element as the parent of HTTP Request to addTrip page. As the result in View Result Tree -> Response data I get the login form. Of course this is not expected result.

Next I tried to use HTTP Request to login page.

Path: /ProjectName/j_spring_security_check
Method: POST
Parameters:
j_password mypassword
j_login mylogin

The result seems to be fine. View Result Tree -> Response data shows the correct (after login) page. On the same level in thread group I added Http Request of addTrip. The result is the same as in the previous case - login page. No after addTrip page and no insert to database.

like image 777
LancerX Avatar asked Aug 30 '12 18:08

LancerX


1 Answers

Your plan must be missing:

  • cookie manager

And you probably didn't handle right the spring security login phase which includes redirect.

The best solution for you is to use JMeter Proxy Recording. If you're a beginner in JMeter read:

  • http://jmeter.apache.org/usermanual/build-web-test-plan.html

  • http://jmeter.apache.org/usermanual/best-practices.html

  • http://jmeter.apache.org/usermanual/hints_and_tips.html

Then for each component you will use you can read:

  • http://jmeter.apache.org/usermanual/component_reference.html
like image 181
UBIK LOAD PACK Avatar answered Oct 12 '22 08:10

UBIK LOAD PACK