Setting up HTTP Request Sampler for POST Method in

2019-07-11 03:25发布

问题:

I have a web application where all the pages/services are secured using Central Authentication Service (CAS) based security. I need to perform a load testing on a page using HTTP POST request but have no idea how to configure HTTP Request Sampler for this POST method having access through security of CAS. I can get the Ticket to get access to the page manually from the browser which is as follows:

https://<server>:<portX>/testweb-cas/oauth2.0/callbackAuthorize?ticket=ST-17-J5jknSbPrU1pQ5vFK0bL-testweb.au 

Now I want to set up HTTP POST Request Sampler for :

http://<server>:<portY>/Xyz/pages/details.xhtml using authorization from above link.

I haven't used HTTP Request POST sampler before in JMeter, and not really getting the desired output using the available solution.

回答1:

Easiest way:

Use HTTP Test Script recorder, which records the traffic from the browser and build JMeter Test Plan using HTTP Sampler.

Another way is, to manually add HTTP Samplers to the Thread Group. Select Post from Method drop down. Mention the body of the request Body data section. Add HTTP Header Manager if you want to add Headers to the request, like Authorization header.

Note: Don't take Authorization value manually by visiting the browser. Record the navigation, so HTTP Sampler will be added for that request. Add Regular Expression Extractor to retrieve Authorization value from the response and store it in a variable, so that you can use it in the POST request.

Note: Add HTTP Cookie Manager (if not already added during recording) so that JMeter automatically takes care of Cookie based authentication.

References:

  1. HTTP Sampler
  2. Test Script Recorder
  3. Regular Expression Extractor