diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-04-26 23:16:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 23:16:46 (GMT) |
commit | 7244c0060dc3ef909f34b0791c3e7490b0340d5e (patch) | |
tree | 33af92f2923bc24556a6b2c8897442d2a8764a78 /Lib/test/audit-tests.py | |
parent | 52cd6d5e1b2bece0d8efb58b1af41071c914ebe6 (diff) | |
download | cpython-7244c0060dc3ef909f34b0791c3e7490b0340d5e.zip cpython-7244c0060dc3ef909f34b0791c3e7490b0340d5e.tar.gz cpython-7244c0060dc3ef909f34b0791c3e7490b0340d5e.tar.bz2 |
bpo-43762: Add audit events for loading of sqlite3 extensions (GH-25246)
Diffstat (limited to 'Lib/test/audit-tests.py')
-rw-r--r-- | Lib/test/audit-tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py index 2addf97..ed42451 100644 --- a/Lib/test/audit-tests.py +++ b/Lib/test/audit-tests.py @@ -359,6 +359,27 @@ def test_http_client(): conn.close() +def test_sqlite3(): + import sqlite3 + + def hook(event, *args): + if event.startswith("sqlite3."): + print(event, *args) + + sys.addaudithook(hook) + cx = sqlite3.connect(":memory:") + + # Configured without --enable-loadable-sqlite-extensions + if hasattr(sqlite3.Connection, "enable_load_extension"): + cx.enable_load_extension(False) + try: + cx.load_extension("test") + except sqlite3.OperationalError: + pass + else: + raise RuntimeError("Expected sqlite3.load_extension to fail") + + if __name__ == "__main__": from test.support import suppress_msvcrt_asserts |