simplesamlphp / simplesamlphp-test-framework

Test framework for SimpleSAMLphp and related repositories
GNU Lesser General Public License v2.1
0 stars 2 forks source link

test module with redirectTrustedURL #3

Open jmoral opened 8 months ago

jmoral commented 8 months ago

I am trying to write some unit tests to https://github.com/simplesamlphp/simplesamlphp-module-expirycheck/

is it possible to test Auth\ProcessingFilter in a module which uses a $httpUtils->redirectTrustedURL?

$filter->process($request);

https://github.com/simplesamlphp/simplesamlphp-module-expirycheck/blob/211ed0f229df807e3def38d55d1a42c89e406a04/src/Auth/Process/ExpiryDate.php#L191

throws this exception

InvalidArgumentException: Unable to parse base url: http://localhost

/xxx/simplesamlphp-module-expirycheck/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Utils/HTTP.php:1011
/xxx/simplesamlphp-module-expirycheck/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Utils/HTTP.php:886
/xxx/simplesamlphp-module-expirycheck/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Utils/HTTP.php:954
/xxx/simplesamlphp-module-expirycheck/src/Auth/Process/ExpiryDate.php:191
/xxx/simplesamlphp-module-expirycheck/tests/src/Auth/Process/ExpiryDateTest.php:170

ERRORS!
Tests: 17, Assertions: 40, Errors: 1, Warnings: 1.

any help is welcome

Regards

tvdijen commented 8 months ago

Unfortunately no, this is not possible due to the fact that $httpUtils->redirectTrustedURL() never returns. We are working on migrating the entire codebase to Symfony responses, so that a call to $httpUtils->redirectTrustedURL() would return a RedirectResponse