SoapUI how to generate dynamically request password? - request

I need to generate the password of the request dynamically, because I need to concatenate it with a timestamp and encode the result with SHA-256 to get the actual password.
Is there a way to generate that password to every request?
Where should the script be created to generate the password, and how can it be added to the request or to a variable that is read in the request?

You have full access to the Groovy language in SoapUI. You can do any sort of coding in a Groovy script test step. Then you can store the resulting value in a property:
testRunner.testCase.setPropertyValue("passwordVar", passwdResult)
And in the request XML you parameterize the value to be read from the property:
<passwordNode>${#TestCase#passwordVar}</passwordNode>
The only catch is that you will have to execute the Groovy step before the SOAP request step, but that can be done at test case level, or in a loop in Groovy, depending on your project structure. I usually have a Groovy script that:
does calculations or SQL to get input values
sets properties
calls the SOAP steps
extract required response values from resp XML
in a loop.

Related

How to read multiple values in one row from csv file to post body as variable in Jmeter

How to make an Post HTTP request Body from multiple values in a single column from a CSV file?
In CSV file, under the transactional_currencies, I need to insert two or more values as per requirement.
This is the Json Body need to pass in Post HTTP request Body
{
"country_name": "${country}",
"status": "$ {status}",
"transactional_currencies": ["${transactional_currencies[0]", "${transactional_currencies[1]"]
}``
``
I'm not sure about what did you ask but let's give it a try
You should define a delimiter character in your CSV dataset config element.
For example
Single Line in our CSV: sample#sample.com,testusername,testpassword
After adding a CSV data config to your project, open the configuration panel.
Choose your delimiter character as " , " since the line above has
some commas.
Choose variable names as "email", "username" and "password"
Now you have splitted a single csv line into 3 different variables.
On your request's body, write these variables as ${email} , ${username}
, ${password}
Not with the CSV Data Set Config
If you have fixed number of entries in the transactional_currencies (i.e. always 2) you can use __CSVRead() function where you will be able to decide when to go to the next entry/row.
If the number of entries in the transactional_currencies is dynamic, you can go for JSR223 PreProcessor and build your request body using Groovy language as it's described in the Apache Groovy - Parsing and producing JSON article

Use all rows from the table returned by JDBC request

I use JDBC request for selecting users who log in to the application. The results return correctly but I noticed that HTTP Sampler uses only the first result from the table.
I use also ForEach Controller to avoid getting the column name as a result but don't think that it is related to the issue.
The table contains a few results and I want to use them all one by one for each new log-in.
Have you defined "Variable Names" under JDBC Request sampler? It should be done like this:
This way you will get the following JMeter Variables:
businessId_#=number of rows
businessId_1=value from 1st row
businessId_2=value frmo 2nd row
and this way you will be able to iterate them using ForEach Controller
More information:
JDBC Request sampler documentation
Debugging JDBC Sampler Results in JMeter

How to change the order of the compose connector in logic apps(azure). By default it is asc order

I get the data in a json format, in which i have table details (it has n number of rows and columns ). I want to send a mail and include the row details in the mail body. Right now i am able to send the mail and include the row details. I am using a compose connector to define the required rows. But the output is always in ascending order.(I want to display Message column first and then the Count column, but i always get Count column first and then Message column) I want to customize the output.
I tried using initialize connector but since i am using the for-each loop i can not use Initialize connector. (Initialize connector have to be initialized at top.
Before triggering the logic app
After triggering the logic app
Current output i am getting:
I want to customize the output i.e Message column first and then the count column
This is an expected behaviour that shouldn't have side effects if you stick to the JSON format. It's because JavaScript JSON libraries default to alphabetical ordering of properties.
However if you insist on custom order, you could refer to my answer before create new json object using compose connector. You need create a string with the input you want the compose it or parse it to json.

How to write more than ~1,500 characters to a fusion table cell via the SQL API

I have an AppEngine app using the Google API Python Client to access the Fusion Tables API over OAuth. When trying to run UPDATE commands, the API client is putting my whole SQL statement into the query string in the URL.
So when I write a SQL statement like this...
UPDATE <table ID> SET <column> = 'some really long piece of text...' WHERE ROWID = '1'
...I get an API call like this:
POST https://www.googleapis.com/fusiontables/v1/query?sql=UPDATE+<table ID>+SET+<column>+%3D+%27some+really+long+piece+of+text...%27+WHERE+ROWID+%3D+%271%27&alt=json
All this works fine for most things. But I'm encountering errors when writing more than ~1,500 characters (depending on how many of those are special characters I have to escape) to that cell. The answer to another question says the limit to the number of characters in a cell is 1,000,000. I'm assuming this may be because the URL is getting just way too long (for something in the pipeline from AppEngine to the Fusion Tables API servers), maybe kind of like the issue addressed in this question.
With other APIs, I'm used to sending parameters in form data for POST requests not the query string, which keeps the URL a manageable size. But the Fusion Tables API docs seem to suggest that the query string is the proper place and that nothing should be sent in the request body. The API client seems to be dutifully following this pattern (and in fact using that as the default behavior for ALL Google APIs??).
So my question is threefold:
Does anyone know if the URL can get too long as I suspect is happening?
Is the query string really the only place to send the SQL statement or will if I find a way to include it in the request body will the API accept that?
If the query string really is the only way and it really can get too long, is there another way to post large strings to fusion table cells?
So I tried it. The answer to number 2 is that you CAN put the query in the request body as form data and the API will take it (contrary to what the docs suggest). My request to Fusion Tables from App Engine now looks like this:
import httplib2
import urllib
value = 'Some really long string...'
# http is an instance of httplib2.Http
http.request('https://www.googleapis.com/fusiontables/v1/query?alt=json',
method='POST',
body=urllib.urlencode({
'sql': unicode('UPDATE <table ID>' +
' SET <column>=\'' + value + '\'' +
' WHERE ROWID = \'1\'').encode('utf-8')
}),
headers={'Content-Type': 'application/x-www-form-urlencoded'})
Note that I believe the Content-Type header is necessary, but I haven't tried it without it.
I also left some unicode and UTF-8 encoding stuff in there because chances are, for anyone who needs to support a few thousand characters, a few of those characters might be non-ascii and urllib.urlencode doesn't like non-ascii characters...
I'd still appreciate an answer to numbers 1 and 3 if anyone has any more information, but this seems to work for me for now. I'm curious as to why using form data in the request body wasn't the default approach from the beginning for the Fusion Tables team...

How to read database (JDBC Request) result into variables in Jmeter

I want to read Database result into variables so I can use it for later requests.
How can i do it?
What if i want to return from database multiple
columns, or even rows? can loop the returned table same way i can
with "CSV Data Set Config"?
--edit--
Ok, i found this solution that uses regular expression to parse the response, but this solution and other like it doesn't work for me, because they require me to change SQL queries so Jmeter could parse them more "easily". I'm using Jmeter to do testing (load testing), and the last thing I want is to maintain 2 different codes, one for "testing" and other for "runtime".
Is there a "specific" JDBC Request solution that enable me to read result into variables using the concept of result-sets and columns?
Using The Regular Expression shouldn't affect what your SQL statement looks like. If you need to modify which part of the response you store in variable, use a Beanshell sampler with java code to parse out the response and store into a variable.
You can loop through the returned table, by using a FOREACH controller, referencing the variable name in the reg ex. Make sure in your reg ex, you set the match value to -1 to capture every possible match.

Resources