diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-03-31 11:57:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 11:57:06 (GMT) |
commit | 6a0ee60db4cee4a01bae1a2922d21a859e9ea2ed (patch) | |
tree | e0bbdc81cac241010112b8712b9328dec5b16c0f /Lib/test/audit-tests.py | |
parent | 6c9a2a831ea235fad7a6398bba395f4c776dc85c (diff) | |
download | cpython-6a0ee60db4cee4a01bae1a2922d21a859e9ea2ed.zip cpython-6a0ee60db4cee4a01bae1a2922d21a859e9ea2ed.tar.gz cpython-6a0ee60db4cee4a01bae1a2922d21a859e9ea2ed.tar.bz2 |
bpo-40121: Fixes audit event raised on creating a new socket (GH-19238)
(cherry picked from commit 63ba5cccf484b9ec23dfbf4cf7ffdc833eda98c3)
Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'Lib/test/audit-tests.py')
-rw-r--r-- | Lib/test/audit-tests.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py index 33f3209..dda52a5 100644 --- a/Lib/test/audit-tests.py +++ b/Lib/test/audit-tests.py @@ -327,6 +327,28 @@ def test_winreg(): CloseKey(kv) +def test_socket(): + import socket + + def hook(event, args): + if event.startswith("socket."): + print(event, *args) + + sys.addaudithook(hook) + + socket.gethostname() + + # Don't care if this fails, we just want the audit message + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + # Don't care if this fails, we just want the audit message + sock.bind(('127.0.0.1', 8080)) + except error: + pass + finally: + sock.close() + + if __name__ == "__main__": from test.libregrtest.setup import suppress_msvcrt_asserts |