使用 Jmeter 登录 Facebook [英] Facebook Login using Jmeter
问题描述
我想使用 Jmeter 对我的 Heroku 应用程序进行负载测试.要访问该应用程序的功能,我需要先通过 Facebook 登录.我尝试使用代理服务器进行浏览器录制.但问题是 facebook 返回的代码参数 (response_type) 硬编码在回调 URI 中.所以它在运行 Jmeter 脚本时给出异常(代码过期异常).
I want to do a load test my Heroku application using Jmeter. To access the functionality of the application, I need to login through Facebook first. I tried with browser recording using proxy server. But the problem is the code parameter (response_type) returned by facebook is hard coded in the callback URI. So its giving exception (Code expired exception) while running the Jmeter script.
我可以在 https://www.facebook.com/dialog/permissions.request
URL 的响应标头中查看代码.所以我需要从这个header动态抓取这段代码,并放入回调URL的code参数中.
I am able to view the code in response header of https://www.facebook.com/dialog/permissions.request
URL. So I need to grab this code from this header dynamically and put in the code parameter of callback URL.
为此,我在 Jmeter 中的 /dialog/permissions.request
URL 下使用 Regular Expression Extractor.
For this I am using Regular Expression Extractor in Jmeter under /dialog/permissions.request
URL.
我的响应标头如下所示:
My response header looks like below:
Cache-Control private, no-cache, no-store, must-revalidate
Date Wed, 26 Dec 2012 13:37:17 GMT
Expires Sat, 01 Jan 2000 00:00:00 GMT
Location http://myapplication.herokuapp.com/oauth/authenticate/facebook?code=SOME-CODE
P3P CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
我想提取这个 code=some code
并使用正则表达式提取器将其放入下一个 URL.
I want to extract this code=some code
and put it in the next URL using regular expression extractor.
推荐答案
我不知道 JMeter 上下文,但正则表达式可以是这样的:
I don't know the JMeter context, but the regex can be something like:
?code=(.*)
您可能需要将反斜杠加倍.如果将标题作为一个整体进行检查,$
可能会出现问题,您可能可以将其替换为
.
You might need to double the backslash. The $
can be problematic if the header is checked as a whole, you can replace it with
perhaps.
我发现 tester 从 JMeter 页面 并将其用于您提供的标题内容.显然 $
不是必需的,搜索在一行边界上停止.仍然不确定将反斜杠加倍.实验.
I found the tester pointed from the JMeter page and used it against the header content you gave. Apparently the $
was not necessary, the search is stopping on a line bound. Still not sure about doubling the backslash. Experiment.
这篇关于使用 Jmeter 登录 Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!