I've a scenario like
user logs in ( /login)
navigate to the reservations page to get all the reservation id
(/reservations)
Through json path extractor it gets first reservation id from the
JSON.($..reservationLists..id[0], reservationid)
navigate to the first reservation id (/reservation/${reservationid})
In every page it navigates , the HTTP header manager needs the handShakeKey
applicable to that page which is basically combination of url, secretKey,
publicKey. ( secretKey , publicKey are both static but url changes )
For static urls like ( /login, /reservations) I've added a BSF pre-processor
at beginning and declare variables and use those variables in the HTTP
Header Manager as ${handshakeKey_reservations}, ${handshakeKey_login} etc
which works perfectly fine.
var urls = ["login", "reservations", "logout", "profile"];
for (var i = 0; i < urls.length; i++) {
var handShakeKeyForStaticUrls =
CryptoJS.SHA1("/"+urls[i]+"abcdediiebneC"+"12345678");
handShakeKeyForStaticUrls =
handShakeKeyForStaticUrls.toString(CryptoJS.enc.Base64);
vars.put("handshakeKey_"+urls[i], handShakeKeyForStaticUrls);
}
Now the problem is for Dynamic url (/reservation/${reservationid},
/reservation/${reservationid}/summary etc.......)
I was thinking to write a java script function something like
function getHandShakeKey(url)
{
var handShakeKeyForDynamicUrls = CryptoJS.SHA1(url+"abcdeffe"+"12345678");
handShakeKeyForDynamicUrls =
handShakeKeyForDynamicUrls.toString(CryptoJS.enc.Base64);
//return handShakeKeyForDynamicUrls;
vars.put("handShakeKeyForDynamicUrls", handShakeKeyForDynamicUrls);
}
Then in the HTTP header manager I would do like
handshakeKey
${_javaScript(getHandShakeKey("/reservation/${reservationid}"))}
So question is Where I can register this java script function so that I can
call it everywhere .
Though the workaround I've done is at the moment, adding a BSF post
processor to each http sampler which contains dynamic url and generating and
declaring handShakeKey applicable for that url only and using the same in
the corresponding HTTP header manager. I need to get rid of this.
--
View this message in context:
http://jmeter.512774.n5.nabble.com/how-to-register-and-call-the-external-javascript-function-in-jmeter-tp5718378.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]