使用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的响应标头中的代码.因此,我需要从该标头中动态获取此代码,并将其放入回调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下使用正则表达式提取器.
For this I am using Regular Expression Extractor in Jmeter under /dialog/permissions.request
URL.
我的响应标题如下:
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=(.*)
您可能需要将反斜杠加倍.如果将标头整体检查,则$
可能会出现问题,您可以将其替换为\n
.
You might need to double the backslash. The $
can be problematic if the header is checked as a whole, you can replace it with \n
perhaps.
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屋!