Forum Discussion
Hello again nmrao ,
nmrao wrote:How about
context.randomNumber
If you are testing in groovy script, the above should work.
great news. This definitely works:
log.info(context.randomNumber)
log.info(context.randomNumber)
log.info(context.randomNumber)
log.info(context.randomNumber)
log.info(context.randomNumber)
and the output is:
Thu Jul 15 11:49:07 CEST 2021:INFO:637.6823442157611
Thu Jul 15 11:49:07 CEST 2021:INFO:516.7372824953289
Thu Jul 15 11:49:07 CEST 2021:INFO:628.5712519826241
Thu Jul 15 11:49:07 CEST 2021:INFO:353.6060359250122
Thu Jul 15 11:49:07 CEST 2021:INFO:656.1003869084848
But this is not yet what I'd like to see: I'd like to assign the "randomNumber" value provided as the value of a "left-hand-side" property, e.g. at test case or test suite or even global level.
Of course, I can always achieve this by writing custom Groovy code that does this assignment, such as
testRunner.testCase.setPropertyValue("randomNumberProvided", context.randomNumber)
but this would obviously require an additional test step in any test case that would like to use the value from the value provider.
So I am assuming that there MUST be an easier way to do this by typical SoapUI expansible property notation?
Many thanks one more time!
Best regards
Andreas
Would you like to use randomNumber in test request such as SOAP or REST?
say <id><randomNumber></id>
There are other options such
<id>${= System.currentTimeMillis()}</id>
or
<id>${= java.util.UUID.randomUUID().text()}</id>
Please see if the above approach works in your case.
- awl3 years agoOccasional Contributor
Hi again,
nmrao wrote:Would you like to use randomNumber in test request such as SOAP or REST?
no - my goal for the plugin is even (much) more complex: I want to use a named ValueProvider but in addition, pass parameters to a concrete usage of this ValueProvider, such as
Value Provider Name ("valueName") == "vaultSecret"
and then use it like
${vaultSecret#some_path_within_a_Vault_instance_representing_a_secret_value}
Do you happen to know whether it's possible to pass such a property parameter value ("some_path_within_a_Vault_instance_representing_a_secret_value") into the ValueProvider class, i.e. can I access it using the PropertyExpansionContext that is passed to my
public String getValue(PropertyExpansionContext propertyExpansionContext) { (...) }
method?
Thanks a million one more time for your kind help! 👍
awl- nmrao3 years agoChampion Level 3
Thank you for the details.
Somewhere it still not hit my brain, the final use case. But your use case seems to be interesting.
If I understand it better, probably can try something.
These are some other uses found for DataProviders found in the source, Not sure if that is of any help to you.
https://github.com/SmartBear/soapui/search?q=DynamicPropertyResolver
- awl3 years agoOccasional Contributor
Hi again, Rao,
nmrao wrote:Somewhere it still not hit my brain, the final use case. But your use case seems to be interesting.
If I understand it better, probably can try something.
These are some other uses found for DataProviders found in the source, Not sure if that is of any help to you.
https://github.com/SmartBear/soapui/search?q=DynamicPropertyResolver
and thanks for your continued help.
The use case is to read SoapUI property values dynamically (during the test run) from a secret external store (in our case, e.g. Vault, or the Pleasant Password Server, or even a Keepass file).
This will work fine if I can register a ValueProvider which does not provide a value for which no input parameters have been needed to calculate the result (like the random number, like the current test step or the project dir).
For my use case, it is crucial that the ValueProvider implementation, in the parameter that is passed to the getValue method, i.e. in the PropertyExpansionContext also gets this additional information from the property usage, i.e. instead of just
${vaultSecret}
I would configure
${vaultSecret#\\path\in\vault\to\database\password}
and then my custom ValueProvider code should be able to take "\\path\in\vault\to\database\password" from the PropertyExpansionContext and use it to "calculate", i.e.look this value up in Vault, and return it as the property's value.
Did I succeed in making myself clear enough now? 😉
I'll try to run SoapUI with the Java debugger attached, and then see what is available in the PropertyExpansionContext.
Thanks & best regards
awl
Related Content
- 2 months agoStoplight
- 5 years agoBostonKevin
- 4 years agohakonruud
Recent Discussions
- 6 days agoruchisingh