italia / eudi-wallet-it-python

Python toolchain for building an OpenID4VP RP with a SATOSA backend compliant with the Italian Wallet implementation profile
Apache License 2.0
17 stars 14 forks source link

Using request-html for Cross Device flow within the integration test #265

Closed peppelinux closed 3 weeks ago

peppelinux commented 2 months ago

we may use this library to test js execution

https://pypi.org/project/requests-html/

peppelinux commented 2 months ago

see here the current approach: https://github.com/italia/eudi-wallet-it-python/pull/259/files#diff-02395ae70aa3b4e327a37e8a392006b85efbdfbdf609393475ffe2e0596be463R38

Zicchio commented 2 months ago

Expanding the issue for the readers of the future, which might need some amount of context to understand where this issue emerged.

The current design of the cross device integration test has very limited capabilities regarding the behaviour of the javascript running in the QRcode page. In particular we need to verify the following minimumm requirements:

  1. the status endpoint (invoked by by a polling js) yields the correct status code across the different authentication steps;
  2. after the authentication flow is completed, the page must be updated to display a button which leads the user to the redirect uri

At the moment of writing this post, step (1) is done by parsing the html page scouting for the js variable which holds the status endpoint (which is plain dirty); step (2) is not done at all.

peppelinux commented 1 month ago

playwrite seems to be better https://github.com/microsoft/playwright-python

Zicchio commented 1 month ago

playwrite seems to be better https://github.com/microsoft/playwright-python

It appears that this approach is promising.

Will follow with a pull request when the test is compplete.

Note that some isssues already emerged. For example if I'm not mistaken this does not work https://github.com/italia/eudi-wallet-it-python/blob/da470746de8ddf2f0839ec659e769af51d3b6b66/example/satosa/templates/qr_code.html#L141-L146 as href is not a valid attribute for tag <button>, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button