Commit Graph

16 Commits (88eb64745e1a9ce6be67fb0f65fee35f7f43ad75)

Author SHA1 Message Date
Alex Willmer 1c0253f201 mitogen: Raise TypeError on `mitogen.utils.cast(custom_str)` failures
If casting a string fails then raise a TypeError. This is potentially an API
breaking change; chosen as the lesser evil vs. allowing silent errors.

`cast()` relies on `bytes(obj)` & `str(obj)` returning the respective
supertype. That's no longer the case for `AnsibleUnsafeBytes` &
`AnsibleUnsafeText`; since fixes/mitigations for  CVE-2023-5764.

fixes #1046, refs #977

See also
- https://github.com/advisories/GHSA-7j69-qfc3-2fq9
- https://github.com/ansible/ansible/pull/82293
8 months ago
Alex Willmer e101cc4f44 mitogen.utils: Preserve docstring of functions decorated @with_router
Co-authored-by: Rezart Qelibari <gast-kontakt+mitogen@astzweig.de>

Replaces #837
Fixes #836
3 years ago
Alex Willmer 18c89de5a9 Remove unused module imports 3 years ago
Alex Willmer a8317c2393 tests: Remove unittest2, use stdlib unittest
unittest2 is incomplatible with Python 3.10
3 years ago
Alex Willmer 4b39013ef4 tests: Compatiblity shim for threading.Thread.is_alive()
On Python >= 3.8 thread.isAlive() is deprecated (removed in Python 3.9.
On Python <= 2.5 thread.is_alive() isn't present (added in Python 2.6).
4 years ago
David Wilson 8026e54b9b tests: move affinity_test to Ansible tests. 6 years ago
David Wilson e77048ec2d utils: pad out reset_affinity() and integrate with detach_popen() 6 years ago
David Wilson 25bffc424d issue #477: util/fakessh/two_three_compat fixes. 6 years ago
David Wilson 8a0b343760 issue #406: test for FD leak after every TestCase 6 years ago
Alex Willmer 03be0afeeb tests: Add tests of mitogen.utils.cast() 6 years ago
Alex Willmer 7e01c5bed5 Import and use unittest2 without aliasing it 7 years ago
Alex Willmer e8e023ce59 Use specific TestCase assertions throughout tests
e.g. assert x == y -> self.assertEqual(x, y);
self.assertTrue(isinstance(x, y)) -> self.assertIsInstance(x, y)

These specific methods give more useful errors in the case of a test
failure.
7 years ago
Alex Willmer 17da6e9998 Use unittest2 in all tests
This allows using features such as TestCase,assertIsInstance on Python
2.6 and earlier.
7 years ago
David Wilson bee1a86aa1 Let utils_test run directly too. 7 years ago
Alex Willmer d706b7d6b8 Update lingering references to with_broker & run_with_broker
A previous commit renamed run_with_broker() and with_broker() to
run_with_router() and with_router() respctively. Some references were
missed.
7 years ago
David Wilson e7ff6259a3 Initial commit. 7 years ago