how to implement jmeter request post from a cURL command

时间秒杀一切 提交于 2019-12-12 16:17:24

问题


I need to implement a jmeter script from this cURL command:

curl -X POST -u "Oezvjl4Ffju8Y0sLTXwfTuUHyHMa:vwe7v7AaontzlOfiefCRjrYWpUwa"
-H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
-d "grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&assertion=PD94bWwgd...."
-k https://$host/oauth2/token

The -u flag should specify the <Client Id>:<Client Secret> value. The assertion parameter should specify the base64url encoded SAML2.0 assertion.

How do I value the parameter -u and -d in jmeter request? I try using HTTP Header Manager as below:

Content-Type: application/x-www-form-urlencoded;charset=UTF-8
client_id: Oezvjl4Ffju8Y0sLTXwfTuUHyHMa
code: vwe7v7AaontzlOfiefCRjrYWpUwa

and I put grant_type=... in the body data of http post request.. but it doesn't work.


回答1:


Easier way: - just record the call.

  1. Launch JMeter's HTTP(S) Test Script Recorder
  2. In shell:
    • export http_proxy=http://localhost:8080/
    • curl .......

Captured request will be under Recording Controller.

Harder way: - if you want complete control

JMeter equivalent will look as follows:

  • Thread Group
    • HTTP Request
      • HTTP Header Manager

HTTP Request Configuration:

  • Server Name or IP: $host
  • Protocol: https
  • Method: POST
  • Content encoding: UTF-8
  • Path: /oauth2/token
  • Body data: grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer&assertion=PD94bWwgd....

HTTP Header Manager Configuration:

  • Name: Authorization
  • Value: Basic T2V6dmpsNEZmanU4WTBzTFRYd2ZUdVVIeUhNYTp2d2U3djdBYW9udHpsT2ZpZWZDUmpyWVdwVXdh


来源:https://stackoverflow.com/questions/26016684/how-to-implement-jmeter-request-post-from-a-curl-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!