Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert of response cookies #5

Closed
jcamiel opened this issue Aug 31, 2020 · 0 comments
Closed

Assert of response cookies #5

jcamiel opened this issue Aug 31, 2020 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Aug 31, 2020

The current query cookie return the cookie value (and ignores the other attributes such as path, domain, ...)
cookie "theme" equals "light"

It would be interesting to fully support cookies as defined in the http spec.

the query cookie could return a Cookie Object instead of a simple string.
This object would include a mandatory string value, an optional domain, an option value, ...

The predicate equals (and matches?) could then be applied on this query taking a String value.
There are several options for the semantic of this String value.

For example

cookie "sessionToken" equals "abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT"
the path and domain must not be defined in the response cookie

cookie "LSID" equals "DQAAAK…Eaem_vYg; Path=/accounts; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly"
the order of attributes does not matter

cookie "LSID" matches "DQAAAK…Eaem_vYg; Path=/accounts; Expires=.*; Secure; HttpOnly"
when you need to use a regex you explicitly use the matched predicate

instead it could be easier to omit the attribute to ignore the attribute.
cookie "LSID" equals "DQAAAK…Eaem_vYg; Path=/accounts; Secure; HttpOnly"
you don't check the Expires attribute at all. It does not matter whether it is present on not.
But then, how do you check whether a cookie is a session cookie?


Another option: ´cookie´ could be extended as a query expression like jsonpath/xpath:

Check value:
cookie "toto" equals "tata"

Check expires:
cookie "toto[expires]" equals "Wed, 09 Jun 2021 10:18:14 GMT"
cookie "toto[expires]" exist

Check Path:
cookie "toto[path]" matches "/test.*"

We can borrow XPath syntax for attribute:

cookie "toto[@path]" equals "/domain"

Or we can create another type of query ´cookiepath’ and keep the actual ´cookie´ query.


Possible query syntax:

  • cookie "toto[expires]" exist
  • cookie "toto[@expires]" exist
  • cookie "toto.expires" exist
  • cookie "toto@expires" exist

=> cookie "toto[Expires]" exist is accepted as the syntax

Possible attributes:
Expires=
Max-Age=
Domain=
Path=
Secure
HttpOnly
SameSite=Strict
SameSite=Lax
SameSite=None

cookie "toto[max-age]" exist
cookie "toto[Max-Age]" exist equivalent


Template variable should probably also be supported for the cookie name.
cookie "{{cookie_name}}[Expired]"


Definition of queries in the grammar

xpath-query 	= "xpath" sp sp* quoted-string
cookie-query 	= "cookie" sp sp* quoted-string

contrary to xpath, the cookie-query is both specific to hurl and very easy.
it could be fully described as follow

cookie-query 	= "cookie" sp sp* """  cookie-query-expr  """
cookie-query-expr = cookie-query-name ( "[" sp* cookie-query-attribute sp* "]" )
cookie-query-name = <[a-zA-Z0-9{}]+>
cookie-query-attribute = Value | value
                       | Expires | expires
                       | Max-Age | max-age
                       | Domain | domain
                       | Path | path
                       | Secure | secure
                       | HttpOnly | httponly
                       | SameSite | samesite

The parsing implementation can choose to be a bit stricter than the grammar

for example,
rejecting escape character
cookie "toto\u{5B}Expires]"

accepting variable only for the cookie name
cookie "toto[{{field}}]"

@jcamiel jcamiel added the enhancement New feature or request label Aug 31, 2020
@jcamiel jcamiel closed this as completed Aug 31, 2020
@lepapareil lepapareil added this to the 0.99 milestone Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants