SAML-Toolkits / python3-saml

MIT License
682 stars 304 forks source link

tests: Update expiry dates for responses #269

Closed zhaofengli closed 3 years ago

zhaofengli commented 3 years ago

The following test inputs have NotOnOrAfter values that are expired:

./responses/unsigned_response_with_miliseconds.xm.base64
./responses/no_audience.xml.base64
./responses/invalids/invalid_subjectconfirmation_noa.xml.base64
./responses/invalids/response_encrypted_attrs.xml.base64
./responses/invalids/invalid_issuer_assertion.xml.base64
./responses/invalids/no_subjectconfirmation_data.xml.base64
./responses/invalids/invalid_audience.xml.base64
./responses/invalids/invalid_subjectconfirmation_inresponse.xml.base64
./responses/invalids/no_nameid.xml.base64
./responses/invalids/invalid_subjectconfirmation_recipient.xml.base64
./responses/invalids/invalid_issuer_message.xml.base64
./responses/invalids/encrypted_attrs.xml.base64
./responses/invalids/invalid_sessionindex.xml.base64
./responses/invalids/no_subjectconfirmation_method.xml.base64

They are causing errors in tests like:

======================================================================
FAIL: testIsInValidSubjectConfirmation (tests.src.OneLogin.saml2_tests.response_test.OneLogin_Saml2_Response_Test)
Tests the is_valid method of the OneLogin_Saml2_Response class
----------------------------------------------------------------------
onelogin.saml2.errors.OneLogin_Saml2_ValidationError: Could not validate timestamp: expired. Check system clock.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/build/source/tests/src/OneLogin/saml2_tests/response_test.py", line 1311, in testIsInValidSubjectConfirmation
    response.is_valid(request_data, raise_exceptions=True)
AssertionError: "A valid SubjectConfirmation was not found on this Response" does not match "Could not validate timestamp: expired. Check system clock."

Ugly one-liner that created this patch:

find . -name '*.base64' -exec sh -c "base64 -d {} | if grep 2021-06 > /dev/null; then echo {}; base64 -d {} | sed s/2021/2099/g | base64 -w 0 | sponge {}; fi " \;
pitbulk commented 3 years ago

Thanks for taking the time updating those files