在JMeter测试计划中为POST方法设置HTTP请求采样器
我有一个Web应用程序,其中所有页面/服务都使用基于中央身份验证服务(CAS)的安全性进行保护.我需要使用HTTP POST请求在页面上执行负载测试,但不知道如何为此具有通过CAS安全性访问权限的POST方法配置HTTP Request Sampler. 我可以获取故障单以从浏览器手动访问页面,如下所示:
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
现在,我想为设置HTTP POST请求采样器:
Now I want to set up HTTP POST Request Sampler for :
http://<server>:<portY>/Xyz/pages/details.xhtml
使用上方链接中的authorization
.
我以前在JMeter中没有使用过HTTP Request POST采样器,也没有使用可用的解决方案真正获得所需的输出.
I haven't used HTTP Request POST sampler before in JMeter, and not really getting the desired output using the available solution.
最简单的方法:
使用HTTP测试脚本记录器,该记录器记录来自浏览器的流量并使用HTTP Sampler
构建JMeter测试计划.
Use HTTP Test Script recorder, which records the traffic from the browser and build JMeter Test Plan using HTTP Sampler
.
另一种方法是,将HTTP Samplers
手动添加到Thread Group
.从Method
下拉列表中选择Post
.提及请求Body data
部分的正文.如果要向请求中添加标头(例如Authorization
标头),请添加HTTP Header Manager
.
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.
注意:请勿通过访问浏览器手动获取Authorization
值.记录导航,因此将为该请求添加HTTP Sampler.添加Regular Expression Extractor
以从响应中检索授权值并将其存储在变量中,以便可以在POST请求中使用它.
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.
注意::添加HTTP Cookie Manager
(如果在录制过程中尚未添加),以便JMeter自动处理基于Cookie的身份验证.
Note: Add HTTP Cookie Manager
(if not already added during recording) so that JMeter automatically takes care of Cookie based authentication.
参考文献:
- HTTP Sampler
- Test Script Recorder
- Regular Expression Extractor