Extract variable policy not working - documentation

I have configured my extract variable policy to the following
<ExtractVariables name="ExtractURIVariables">
<URIPath>
<Pattern>/{username}/age/{age}/*</Pattern>
</URIPath>
</ExtractVariables>
but when it executes I cannot see the username and age variables set .

Your policy works correctly, but it is expecting a URL like the following:
{proxybase}/bob/age/35/somethinghere
because the /* is not optional.
It will not match
{proxybase}/bob/age/35
You can use the following:
<ExtractVariables name="ExtractURIVariables">
<URIPath>
<Pattern>/{username}/age/{age}</Pattern>
<Pattern>/{username}/age/{age}/*</Pattern>
</URIPath>
</ExtractVariables>
When more than one pattern is supplied, the first match will be selected.
The updated policy would match
{proxybase}/bob/age/35
{proxybase}/bob/age/35/somethinghere
If you want to match any number of following URI levels, use two asterisks instead of one.

Related

Request couchbase with two where conditions

How is it possible to write a couchbase request in order to choose the first condition in where if it is defined or the second one if the first one is undefined.
I tried somethings like :
SELECT id FROM auto as a WHERE IFMISSINGORNULL(ARRAY_LENGTH(a.data[0])>1, ARRAY_LENGTH(a.data[1])>1)
In this request if a.data[0] is defined, I want to check the length of a.data[0] and if a.data[0] is not defined, I want to check the length of a.data[1].
Condition should look as follows
WHERE ARRAY_LENGTH(IFNULL(a.data[0], a.data[1])) > 1
IFNULL(a.data[0], a.data[1])
returns first argument if it is NOT NULL
second argument when first one is NULL

Axiomatics - condition editor

I have a subject like "accessTo" = ["123", "123-edit"]
and a resource like "interestedId" = "123"
Now I'm trying to write a condition - where it checks "interestedId" concatenated with "-edit" equals "123-edit" in "AccessTo".
Im trying to write rule like this
anyOfAny_xacml1(function[stringEqual], "accessTo", "interestedId"+"-edit")
It is not allowing to do this.
Any help is appreciated.
In addition to the answer from Keerthi S ...
If you know there should only be one value of interestedId then you can do this to prevent the indeterminate from happening:
stringBagSize(interestedId) == 1 && anyOfAny(function[stringEqual], accessTo, stringOneAndOnly(interestedId) + "-edit")
If more than value is present then evaluation stops prior to reaching the function that expects only one value. This condition would return false if more than one value is present.
On the other hand if interestedId can have multiple values then this would work:
anyOfAny(function[stringEqual], accessTo, map(function[stringConcatenate],interestedId, "-edit"))
The map function will apply the stringConcatenate function to all values in the bag.
Since Axiomatics products are compliant with XACML specification, all attributes by default are assumed to contain multiple values(called as 'bags').
So if you would like to append a string to an attribute use stringOneAndOnly XACML function for the attribute to indicate that the attribute can have only one value.
So assuming you mean accessTo has attribute ID as Attributes.access_subject.subject_id, interestedId has the attribute ID as Attributes.resource.resource_id and anyOfAny_xacml1 is equivalent to anyOfAny XACML function, the resulting condition would look like,
anyOfAny(function[stringEqual], Attributes.access_subject.subject_id, stringOneAndOnly(Attributes.resource.resource_id) + "-edit")

Can Karate generate multiple query parameters with the same name?

I need to pass multiple query parameters with the same name in a URL, but I am having problems getting it to work with Karate. In my case, the URL should look like this:
http://mytestapi.com/v1/orders?sort=order.orderNumber&sort=order.customer.name,DESC
Notice 2 query parameters named "sort". I attempted to create these query string parameters with Karate, but only the last "sort" parameter gets created in the query string. Here are the ways I tried to do this:
Given path 'v1/orders'
And param sort = 'order.orderNumber'
And param sort = 'order.customer.name,DESC'
And header Authorization = authInfo.token
And method get
Then status 200
And:
Given path 'v1/orders'
And params sort = { sort: 'order.orderNumber', sort: 'order.customer.name,DESC' }
And header Authorization = authInfo.token
And method get
Then status 200
And:
Given path 'v1/order?sort=order.orderNumber&sort=order.customer.name,DESC'
And header Authorization = authInfo.token
And method get
Then status 200
The first two ways provide the same query string result: ?sort=order.customer.name%2CDESC
The last example does not work because the ? get encoded, which was expected and explained in this post - Karate API Tests - Escaping '?' in the url in a feature file
It's clear that the second "sort" param is overriding the first and only one parameter is being added to the URL. I have gone through the Karate documentation, which is very good, but I have not found a way to add multiple parameters with the same name.
So, is there a way in Karate to set multiple URL query parameters with the same name?
Yes you can generate multiple query parameters with the same name in karate
All values of similar key should be provided in an array.
Given path 'v1/orders'
And params {"sort":["order.orderNumber","order.customer.name,DESC"]}
And header Authorization = authInfo.token
And method get
Then status 200
And for setting single parameter using param it will be like
And param sort = ["order.orderNumber","order.customer.name,DESC"]

MediaWiki API: return less results from a generator than the default of 10

The following link returns information for 10 pages.
http://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=Skydive&format=json&gsrprop=snippet&prop=info&inprop=url&rawcontinue
How do I get this query to return information for just one page?
Setting ptlimit, cmlimit, ect ... to 1 give me the following error.
Unrecognized parameter ptlimit
The gsroffset defaults to 10. I tried putting this parameter into the query but it just added whatever number I put to 10.
You used generator=search, so you have to check the parameters in API:Search where you discover it's called srlimit; prefix a g because you use it as generator, that gives a gsrlimit=1.
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=Skydive&format=json&gsrprop=snippet&prop=info&inprop=url&rawcontinue&gsrlimit=1
{"query-continue":{"search":{"gsroffset":1}},"query":{"pages":{"19723982":{"pageid":19723982,"ns":0,"title":"Parachuting","index":1,"contentmodel":"wikitext","pagelanguage":"en","touched":"2015-07-21T16:28:32Z","lastrevid":670810888,"length":44466,"fullurl":"https://en.wikipedia.org/wiki/Parachuting","editurl":"https://en.wikipedia.org/w/index.php?title=Parachuting&action=edit","canonicalurl":"https://en.wikipedia.org/wiki/Parachuting"}}}}

Propper use of matchnr for jmeter variables

I need count rows in table. So I use reg. exp. extractor. But response assertion ends with error and tried to find exactly rows:${ROWS_matchnr}.
I tried google, but I only find a few non-functional recommendations.
Thread Group
Http Cookie Manager
Http Request
Regular Expression Extractor(ROWS, row-(.*), $1$, 0, )
Response Assertion(rows:${ROWS_matchnr})
Change the value you have in the Match No field from 0 to -1. As documented in the, ahem, useless official help:
If the match number is set to a negative number, then all the possible matches in the sampler data are processed. The variables are set as follows:
refName_matchNr - the number of matches found; could be 0
refName_n, where n = 1,2,3 etc - the strings as generated by the template
refName_n_gm, where m=0,1,2 - the groups for match n
refName - always set to the default value
refName_gn - not set
Then change ${ROWS_matchnr} to ${ROWS_matchNr} (capital N) and it should work.
If you still have issues then use a Debug Sampler to see what is getting returned from the regex.