Forum Discussion
6 Replies
Sort By
- omatzuraSuper ContributorHi!
please try creating a script assertion with the following content:
assert messageExchange.responseHeaders["Set-Cookie"].equals( "MyName=MyValue;" )
regards!
/Ole
eviware.com - bob_ingallsNew ContributorThanks, Ole. Works great except that I want to check for a variable within the cookie. For example, "MyValue=somedata${Property#propertyName}somemoredata"
In other words, each each time I run this the cookie value changes dependent on a property I send to the request.
Is that possible? - omatzuraSuper ContributorHi!
Try the following:
def value = messageExchange.responseHeaders["Set-Cookie"]
assert( value.equals( context.expand( 'MyValue=somedata${Property#propertyName}somemoredata' ))
regards!
/Ole
eviware.com - bob_ingallsNew ContributorThanks Ole.
Is it possible to add a wild card to this? For example, there is a date string (the cookie expires on...). I don't really care what the date is so it's OK to just replace it with a wildcard.
So the whole cookie looks like this:
MATCH=%7B%22mmUser%22%3A%22mmuser${Properties#number}%22%2C%22mmOpenId%22%3A%22OpenID${Properties#number}%22%7D; Domain=.xxx.net; Expires=Sun, 15-Mar-2009 14:02:46 GMT; Path=/
And I want to search for:
MATCH=%7B%22mmUser%22%3A%22mmuser${Properties#number}%22%2C%22mmOpenId%22%3A%22OpenID${Properties#number}%22%7D; Domain=.xxx.net; Expires=* - omatzuraSuper ContributorHi,
well, easiest is maybe to just trim the Set-Cookie string after the expires value;
def value = messageExchange.responseHeaders["Set-Cookie"]
value = value.substring( 0, value.indexOf( "; Expires=" ))
...
(this will of course also remove the "; Expires=" part of the header..)
would that work?
regards,
/Ole
eviware.com - bob_ingallsNew ContributorThis works perfectly. Thanks for all your help.
Related Content
- 8 years agorvteja1990
- 8 years agomgroen2