summaryrefslogtreecommitdiff
path: root/tests/test_authcookie.py
Commit message (Collapse)AuthorAgeFilesLines
* Replace 'from . import' with absolute imports.Matěj Cepl2021-01-141-1/+1
|
* Mass removal of deprecated constructs.Matěj Cepl2020-12-021-2/+2
| | | | | * Replace unittest.makeSuite with unittest.TestLoader().loadTestsFromTestCase * import unittest from relative import
* PEP8isationMatěj Cepl2018-03-201-4/+1
| | | | | | | Specially replace complicated construct with unittest2 to one import to M2Crypto top module. Also, Rand.load_file should have first parameter as bytes(), not str().
* Replace util.py3{bytes,str} with six.ensure_{binary,text}Matěj Cepl2018-03-191-3/+3
|
* Make sure changed strings are securely mangled.Matěj Cepl2017-10-111-3/+14
| | | | | | | | Simple rules (like entering 'X' to random part of string) are not 100% secure, because the string may actually have that value in the place. ROT-13 encoding doesn't work on digits, so I try this. Fixes #138.
* AuthCookie: made more Py3 compliantMarkus Heiser2017-10-111-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The load() method of http.BaseCookie has been change substantial in Python 3. Unfortunately this is not documented in the online docs, the only hint I found, was a comment in the http.cookie module:: We first parse the whole cookie string and reject it if it's syntactically invalid (this helps avoid some classes of injection attacks). This means, cookies with a leading 'Set-Cookie:' string like:: 'Set-Cookie: _M2AUTH_="exp=1485714802.7772.... "' are no longer valid for BaseCookie.load() and will **silently** result in an unset/empty Cookie. Here is a small Py3 example:: >>> from http.cookies import SimpleCookie >>> C1 = SimpleCookie() >>> C1["foo"] = "bar" >>> C2.output() 'Set-Cookie: foo=bar' >>> C2 = SimpleCookie() >>> C2.load(C.output()) >>> C2.output() '' Loaded cookie is unset, see empty string on last line of the example above. This also affects the AuthCookie.isGoodCookieString() method, which uses BaseCookie.load() to validate a cookie!! The workaround is to use an empty header argument when using outpout():: >>> C2.load(C.output(header="")) >>> C2.output() 'Set-Cookie: foo=bar' To get in use of this workaround, AuthCookie.output() is fixed in a way it is more BaseCookie compliant. BTW: AuthCookieJar.isGoodCookieString returned ambiguous bool or int values, which is also fixed within in this patch (return always a bool value). Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
* Let floats be floats and behave accordingly.Matěj Cepl2017-03-241-11/+19
| | | | | | | | | | | AuthCookie.exp is float so don’t convert it from/to str unecessarily and don’t use assertEqual on it (it should be assertAlmostEqual). Add logging in case something goes wrong. Collecting error data in case test_cookie_str_changed_mac goes wrong. Fixes #157
* Remove superfluous logging and clean up comments.Matěj Cepl2017-03-241-5/+5
| | | | This should be NOOP functionally.
* M2Crypto/AuthCookie.py: Add PEP-484 type hints in comments.Matěj Cepl2016-06-141-19/+26
|
* Fix whitespace using suggestions from autopep8Craig Rodrigues2015-12-011-4/+3
|
* I mean, compatibility with python < 2.0 or similar ... really?Matěj Cepl2015-11-191-3/+1
|
* Strip trailinig spaces and expand tabs.Matěj Cepl2015-11-191-2/+2
| | | | | | | Just run $ find . -name \*.py -exec sed -r -i -e "s/\t/ /g" '{}' \; $ find . -name \*.py -exec sed -r -i -e "s/[ ]+$//" '{}' \;
* Replace self.fail* with self.assert*Matěj Cepl2015-10-171-24/+24
| | | | Negative logic makes it less readable.
* Fix spurious test failures in test_cookie_str_changed_*Miloslav Trmač2015-10-131-3/+3
| | | | | | | | | | | The test tests that a modification of MAC is detected by replacing one character by 'X', but from time to time the original MAC may have an 'X' in that place, in which case the modification doesn’t happen. To reproduce: for i in $(seq 1 1000); do j=$(python tests/test_authcookie.py 2>&1); if echo "$j" | grep -q FAIL; then echo "$i": "$j"; break; fi; done Fixes #53
* Switch unit testing to have at least 2.7 unittest API available.Matěj Cepl2015-10-131-1/+6
| | | | Fixes #48
* Make all test methods start with test_, so that running individual suites works,Heikki Toivonen2006-12-151-18/+18
| | | | | | | | for example: python setup.py test --test-suite=tests.test_x509 -q git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@504 2715db39-9adf-0310-9c64-84f055769b4b
* Bug 7451, it seems Python 2.5 does not output a semicolon when there is justHeikki Toivonen2006-12-041-2/+4
| | | | | | one cookie to set, so changing the test to account for that difference. git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@484 2715db39-9adf-0310-9c64-84f055769b4b
* Removed RCS_id, RCS_ID and _RCS_id from Python files. UnneededHeikki Toivonen2006-03-201-2/+0
| | | | | | bloat, and made working with diffs more difficult than it needed to. git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@383 2715db39-9adf-0310-9c64-84f055769b4b
* Fix $ mess (diff always shows changes).Heikki Toivonen2005-06-091-1/+1
| | | | git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@299 2715db39-9adf-0310-9c64-84f055769b4b
* Prepare for import into CVS.Ng Pheng Siong2002-12-231-7/+2
| | | | git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@141 2715db39-9adf-0310-9c64-84f055769b4b
* Initial revisionNg Pheng Siong2002-01-111-0/+152
git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@129 2715db39-9adf-0310-9c64-84f055769b4b