Need to convert &quot &amp &lt to ", & , < in jmeter - jmeter

I am trying to circumvent ADFS authentication and when i sign in to the application i get the below response from the server:
name="wresult" value="<t:RequestSecurityTokenResponse
xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"><t:Lifetime><wsu:Created
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-02-10T09:28:07.059Z</wsu:Created><wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-02-10T10:28:07.059Z</wsu:Expires></t:Lifetime><wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><wsa:EndpointReference
xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Address>https://gh-prem.accesscontrol.windows.net/</wsa:Address></wsa:EndpointReference></wsp:AppliesTo><t:RequestedSecurityToken><saml:Assertion
MajorVersion="1" MinorVersion="1"> AssertionID="_cb580c90-d0ac-49a8-a9c4-3ecb8b0a54d1"
Issuer="http://abc.abc.dev.comt/adfs/services/trust"
IssueInstant="2017-02-10T09:28:07.075Z"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><saml:Conditions NotBefore="2017-02-10T09:28:07.059Z"
NotOnOrAfter="2017-02-10T10:28:07.059Z"><saml:AudienceRestrictionCondition><saml:Audience>https://gh-prem.accesscontrol.windows.net/</saml:Audience></saml:AudienceRestrictionCondition></saml:Conditions><saml:AttributeStatement><saml:Subject><saml:SubjectConfirmation><saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod></saml:SubjectConfirmation></saml:Subject><saml:Attribute
AttributeName="name"
How to convert the &quot and &lt in jmeter. Since the POST body of the next sampler take the attributes as below:
<t:RequestSecurityTokenResponse
xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"><t:Lifetime><wsu:Created
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-02-06T10:06:14.384Z</wsu:Created><wsu:Expires
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-02-06T11:06:14.384Z</wsu:Expires></t:Lifetime><wsp:AppliesTo
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Address>https://gh-prem.accesscontrol.windows.net/</wsa:Address></wsa:EndpointReference></wsp:AppliesTo><t:RequestedSecurityToken><saml:Assertion
MajorVersion="1" MinorVersion="1"
AssertionID="_99273d06-e73c-4ce5-acf5-6ba43c8c7990"
Issuer="http://xxx.xxx-dev.comt/adfs/services/trust"
IssueInstant="2017-02-06T10:06:14.400Z"
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"><saml:Conditions
NotBefore="2017-02-06T10:06:14.384Z"
NotOnOrAfter="2017-02-06T11:06:14.384Z"><saml:AudienceRestrictionCondition><saml:Audience>https://gh-prem.accesscontrol.windows.net/</saml:Audience></saml:AudienceRestrictionCondition></saml:Conditions><saml:AttributeStatement><saml:Subject><saml:SubjectConfirmation><saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod></saml:SubjectConfirmation></saml:Subject><saml:Attribute
AttributeName="name"
AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims"><saml:AttributeValue>
Could you please help me in solving this issue with some screenshots
I got few tips on how to use Beanshell pre processor but its not helping me or im not sure how to implement beanshell to mitigate the issue.
Note: I am using content encoding as utf-8

Take a look at __unescapeHtml() function, it can decode HTML-encoded strings on-the-fly
You can use this function directly in the HTTP Request sampler body or wherever else.
See How to Use JMeter Functions posts series for more information on JMeter Functions, how they can be used, what are limitations, etc.

This is what I did to mitigate the issue. hope it helps for the newbees (Big thanks to Dmitri Tikhanski)
The above token is SAML 1.1 token that is generated as the response to a GET method. If your using ADFS authentication you will get a big HTML in which you will have - WA, Wresult, Wctx. (for me only wresult(SAML 1.1 token) which was a correlation candidate)
Extract the wresult as following using RegularExpression Extractor.
enter image description here
and the captured Wresult to be replaced in /v2/wsfederation with the function __unescapeHtml.
enter image description here
Note: 1) Wa result in my case its not dynamic
2) wctx string is a static string.
Hope this helps. thanks.

Related

JMeter Encoding issue

I need to extract a value from http response which is in the
format "test/23|temp value"
and need to pass it in next request string body as "test%2F%7Ctemp+value"
I believe we are doing some form of encoding. how can we achieve this in JMeter ?
Appreciate if any one can help.
Take a look at __urlencode() function
${__urlencode(test/23|temp value)}
it does percent-encoding of the input and returns the result in the place where it's called in the runtime:
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

How to add a variable from Json extractor into an array in JMeter?

I'm new here and also a beginner on JMeter and maybe this was already answered in an old post that I didn't find, sorry if this is the case.
I had this Post request I need to send with all these IDs that vary according to the account
Post Request
In order to get all of the IDs, I used the JSon extractor to put then into a variable
JSon extractor, then I got all the FieldIDs that I need.
ID extracted
But now how can I add this variable inside the request? I tried something like {"ids":"${fieldId}","includeBoundary":true} but it didn't work. How can I use this?
Please see: HTTP Request parameter dialog example
If you need to extract the whole response, save it into a JMeter Variable and send it back to another endpoint - the easiest way is using Boundary Extractor providing empty left and right boundaries
If you need more complex transformations - take a look at JSR223 Test Elements and Groovy language
I solved my problem in a so easy way(damn it)!!!!
On the Json extractor I just marked the option "Computer concatenation var (suffix_ALL)" then on the debbuger I got all IDs I needed in only one line and finally on my request I just add on the body data the line {"ids": [${fieldId_ALL}],"includeBoundary":true} and bingo it worked like a charm!!!!

How to get URL having ".../?where={'key1' : 'value1' , 'key2' : 'value2':.........}" in Jmeter http request

I need to load test one Python api in below URL format:
//IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
I tried to pass the key value pair through csv as well as directly in http request but getting error message.
java.net.URISyntaxException: Illegal character in query at index 47:
http://IP:PORT/Sub_Part/?where={"KEY1":"VALUE1","KEY2":"VALUE2","KEY3":"VALUE3"}
Here key and value are dummy data I have placed here for easy understanding.
Please help me with correct syntax for this URL.
Thanks in advance for all your help.
In REST APIs, JSON objects are typically sent (POST) or returned in the body of the request. They are not typically encoded as part of the URL.
For a GET request, you can either pass the information as segments in the url or as querystring parameters.
For more details refer here, How to send a GET request with a "/" in the query
As per HTML URL Encoding Reference:
URLs can only be sent over the Internet using the ASCII character-set.
so you need to define the request in JMeter's HTTP Request sampler as follows:
Pay attention to URL Encode? checkbox, it has to be ticked otherwise the parameter will be sent "as is"
Another option is using __urlencode() function like:
http://IP:PORT/Sub_Part/?where=${__urlencode({"KEY1":"VALUE1"\,"KEY2":"VALUE2"\,"KEY3":"VALUE3"})}
which will generate an encoded sequence which you could use in the URL path:
%7B%22KEY1%22%3A%22VALUE1%22%2C%22KEY2%22%3A%22VALUE2%22%2C%22KEY3%22%3A%22VALUE3%22%7D
as you can see, all non-ASCII characters where removed.
Check out Apache JMeter Functions - An Introduction to learn more about JMeter Functions concept.

How to pass the response header to authorized api using Jmeter?

I am using Regular Expression Extractor for extracting the header values.
Here is my test plan structure.
I am getting a response in login api is
I want to extract the SRToke, Id1, Id2 and Id3 values from above response header. So I have used Regular Expression Extractor as below
I have also used BeanShell PostProcessor
Now I am getting the error 401 in result
Please give me the solution, what I have done wrong here?
First you need to extract the variables from Response Header section of your Login request. Please refer how to capture from here. https://stackoverflow.com/a/57391175/4481179
After extracting, use HTTP Header Manager as a child of Eventlist Sampler and pass that extracted value as shown below:
You get an error about 401 because you did not add authorized success. You need to know the flow of the system. Maybe its need another parameter beside one parameter BEARER like you.
I think Beanshell won't be required as you are not correlating from cookies, try to find the missing header under the 401 transaction something like Authorization and place the correlated variable there.

How to prepare POST data from a previous HTTP response?

I've used Fiddler to capture these HTTP calls. Here's the problem:
I have a HTTP-POST data that looks like below:
Notice how it has many 'employeeIds' and also 'shiftSumIds'.
Now, these Ids are from a previous HTTP response that looks like below:
Is there an easy way to extract those Ids and prepare the POST data? Thanks in advance.
--Ishti
Short answer is JSON Path Extractor available via JMeter Plugins which is designed for getting "interesting" values from JSON data. See Using the XPath Extractor in JMeter guide (look for "Parsing JSON" chapter) for installation instructions and some form of JSON Path language reference.
If it is not enough and you will need some assistance in constructing JSON Path query and building HTTP Request from it - please include text version of response and request using i.e. http://paste.org service as reading large amount of text from small screenshot isn't very handy and chance of getting the answer is minimal

Resources