How to capture dynamic values ​​created using javascript in jmeter

I am trying to run a JMeter script, but it does not work on login. The reason is that the password is encrypted using the RSA algorithm and uses javascript. therefore, the password that is saved during recording does not work, and I cannot get the dynamic value of the encrypted password, because it is encrypted using javascript, which is not supported by JMeter. due to the use of javascript at runtime, I cannot use a regular expression to search the response data, as this is not part of the answer.

I am trying to log in to the Tableau report server.

0
source share
3 answers

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

// 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 that I created based on the string that the server sends to enter your password. This string can be found in the LoginPage source code.

"crypted_Password" is a variable created for the encrypted POST parameter.

RSAKey (), setPublic () and encrypt () are included in the .js files that you download from the server when accessing the login page. I just include these files in my project library and it worked.

I don’t know if it matches with JMeter, but hope this helps you understand what you need to do.

+1
source

I also did not find and did not answer this, but what I did was add the tableau_online_id and workgroup_session_id cookies in the user variables, every time I run the tests.

So, I first log in using a browser and set these cookies as JMeter cookies using variables.

0
source

You can encrypt the password on the fly using a similar approach in JMeter, for example JSR223 Sampler provides JavaScript support through Mozilla Rhino or Oracle Nashorn so you can use the same JavaScript code to encrypt the password as an expression.

However, JavaScript is not very efficient in terms of performance if you need to model hundreds of concurrent users, so you have to do hundreds of encryption per second. JavaScript can become a bottleneck, and it is better to consider using the groovy language with the JSR223 Sampler. See Beanshell vs JSR223 vs Java JMeter Scripting: you've been waiting for a performance! for a detailed explanation, groovy engine instructions for installing and writing scripts.

0
source

Source: https://habr.com/ru/post/1239204/


All Articles