Hi Ozan,
you are indeed right. Issue seems to be the "Map Value"-assertion. Here you can't explicitely specify the variable type and the output variable seems to be from type string.
So is there any way to work with this assertion (or similar one) and get integer values as output or do I have to rearrange it with an "At least"-folder?
EDIT: I must recognize, that the latency for this JS-Assertion is really bad. It took around 5million ns, whereas the XPath-assertion took only around 40k ns. So I think JS is not an option for us at all. Or are there any tricks to optimize this?
Thank you!
Ciao Stefan :)
Original Message:
Sent: 09-10-2019 07:21 AM
From: Ozan Okan
Subject: Calculate Integer Variables
Hi
It is working as it suppose to be.
You are passing string variables so it is normally concats. Pass int vars and you will get 8.
Regards
Original Message:
Sent: 09-10-2019 06:35 AM
From: Stefan Klotz
Subject: Calculate Integer Variables
Hi Albert,
thanks for the hint with the Javascript-assertion. I also found it in the meanwhile. But it doesn't make a mathmatic operation. It behaves like concatenate, means 3+5 is NOT becoming 8, but 35 :(
And as mentioned in the documentation, the internal JS-function eval() is NOT allowed.
But it seems to work with the "Evaluate Response XPath"-Assertion. Just enter "$value1 + $value2" in the XPath-field (without " and without curly brackets).
The result will then be displayed as "8.0" (in case of 3+5). A following integer comparison is working fine.
I also tried the "Expression"-option in the "Compare Variable"-Assertion using ${value1} + ${value2}, but this also doesn't seem to work.
Any other ideas?
I heard, that there is an external math-assertion available via support. Is this true and can this be made available here or do I have to raise an official ticket for this?
And would there be any advantages in regards to performance in comparison to the XPath method?
Thank you!
Ciao Stefan :)
Original Message:
Sent: 09-10-2019 02:43 AM
From: Albert Traveria Molero
Subject: Calculate Integer Variables
Hello Stefan,
I would suggest that you use the javascript assertion so you can perform multiple operations and calculations.
https://docops.ca.com/ca-api-gateway/9-4/en/policy-assertions/assertion-palette/service-availability-assertions/execute-javascript-assertion
something like:
var var1 = context.getVariable('variable1');
var var2 = context.getVariable('variable2');
var var3 = var1 + var2;
if(var3 > 5){
//let's get the party started
}else{
//let's get the party started anyway :P
}
context.setVariable('varResult', var3);
Kind regards,
Albert.
------------------------------
Security Engineer
ELCA
Original Message:
Sent: 09-09-2019 06:39 AM
From: Stefan Klotz
Subject: Calculate Integer Variables
This is maybe a stupid question, but how can I calculate with Integer variables?
For example variable1=3 and variable2=5 and I want to set a new variable as sum of both like ${variable1}+${variable2}.
Is this somehow possible and if yes, with which assertion in which syntax?
Alternativly it would also be fine to use calculation within the "Compare"-assertion.
Any ideas and hints are welcome.
Thank you!
Ciao Stefan :)