如何捕获在jmeter中使用javascript创建的动态值 [英] How to capture dynamic values created using javascript in jmeter

查看:706
本文介绍了如何捕获在jmeter中使用javascript创建的动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个JMeter脚本,但是登录失败。原因是密码正在使用RSA算法加密,那就是使用javascript。所以在录制时保存的密码不能正常工作,我无法获取加密密码的动态值,因为它是使用JMeter不支持的javascript进行加密的。由于在运行时使用JavaScript,我无法使用正则表达式查看响应数据,因为这不是响应的一部分。



我正在尝试登录Tableau报告服务器。

解决方案

我使用NEOLOAD有同样的问题,所以我在Auth POST之前添加了以下脚本。

  //从VariableManager获取变量值
var doLoginIDString = context.variableManager.getValue(doLoginID);
if(doLoginIDString == null){
context.fail(Variable'doLoginID'not found);
}

logger.debug(doLoginIDString =+ doLoginIDString);

var rsa = new RSAKey();
rsa.setPublic(doLoginIDString,'10001');
var res = rsa.encrypt('< USER_PASSWORD>');
logger.debug(encrypted_var =+ res);
if(res){
context.variableManager.setValue(crypted_Password,res);
}

VariableManager是一个NEOLOAD变量Manager:)



doLoginID是一个基于字符串创建的变量,由服务器传递给您,用于输入密码。这个字符串可以在LoginPage的源代码中找到。



crypted_Password是我为POST crypted参数创建的一个变量。



访问登录页面时,RSAKey(),setPublic()和encrypt()都包含在从服务器下载的.js文件中。我只是把这些文件包含在我的项目库里,它的工作。



我不知道JMeter是否一样,但希望这能帮助你了解你的需要做。


I am trying to run a JMeter script but it is failing at login. The reason is, password is getting encrypted using RSA algorithm and that is using javascript. so the password that is saved at the time of recording wont work and I am not able to get the dynamic value of encrypted password as it is being encrypted using javascript which is not supported by JMeter. because of javascript usage at runtime, I can not use regular expression to look in response data as this is not part of response.

I am trying to login to Tableau reporting server.

解决方案

I had the same problem using NEOLOAD, so I included the following script before the Auth POST.

// Get variable value from VariableManager
var doLoginIDString = context.variableManager.getValue("doLoginID");
if (doLoginIDString==null) {
    context.fail("Variable 'doLoginID' not found");
}

logger.debug("doLoginIDString="+doLoginIDString);

var rsa = new RSAKey();
rsa.setPublic(doLoginIDString,'10001');
var res = rsa.encrypt('<USER_PASSWORD>');
logger.debug("encrypted_var= "+res);
if (res) {
     context.variableManager.setValue("crypted_Password",res);
}

VariableManager is a NEOLOAD variable Manager :)

"doLoginID" is a variable I created based on a string which is passed by the server for you to encript with your password. This string can be found in LoginPage's source code.

"crypted_Password" is a variable I created for POST crypted parameter.

RSAKey(), setPublic() and encrypt() are included in .js files you download from the server when you access login page. I just include those files in to my project's library and it worked.

I don't know if with JMeter is the same, but hope this helps you to understand what you need to do.

这篇关于如何捕获在jmeter中使用javascript创建的动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆