PYTHON-2904 Further language modernization
This commit is contained in:
parent
ad4315134c
commit
f64c5aa940
@ -394,7 +394,7 @@ class Cursor(object):
|
||||
# Make a shallow copy so we can cleanly rewind or clone.
|
||||
spec = self.__spec.copy()
|
||||
|
||||
# White-listed commands must be wrapped in $query.
|
||||
# Allow-listed commands must be wrapped in $query.
|
||||
if "$query" not in spec:
|
||||
# $query has to come first
|
||||
spec = SON([("$query", spec)])
|
||||
|
||||
@ -435,12 +435,12 @@ class MongoClient(common.BaseObject):
|
||||
``tlsAllowInvalidCertificates=False`` implies ``tls=True``.
|
||||
Defaults to ``False``. Think very carefully before setting this
|
||||
to ``True`` as that could make your application vulnerable to
|
||||
man-in-the-middle attacks.
|
||||
on-path attackers.
|
||||
- `tlsAllowInvalidHostnames`: (boolean) If ``True``, disables TLS
|
||||
hostname verification. ``tlsAllowInvalidHostnames=False`` implies
|
||||
``tls=True``. Defaults to ``False``. Think very carefully before
|
||||
setting this to ``True`` as that could make your application
|
||||
vulnerable to man-in-the-middle attacks.
|
||||
vulnerable to on-path attackers.
|
||||
- `tlsCAFile`: A file containing a single or a bundle of
|
||||
"certification authority" certificates, which are used to validate
|
||||
certificates passed from the other end of the connection.
|
||||
|
||||
@ -35,7 +35,7 @@ from test.utils import (delay,
|
||||
rs_or_single_client,
|
||||
rs_or_single_client_noauth,
|
||||
single_client_noauth,
|
||||
WhiteListEventListener)
|
||||
AllowListEventListener)
|
||||
|
||||
# YOU MUST RUN KINIT BEFORE RUNNING GSSAPI TESTS ON UNIX.
|
||||
GSSAPI_HOST = os.environ.get('GSSAPI_HOST')
|
||||
@ -354,7 +354,7 @@ class TestSCRAM(IntegrationTest):
|
||||
super(TestSCRAM, self).setUp()
|
||||
self._SENSITIVE_COMMANDS = monitoring._SENSITIVE_COMMANDS
|
||||
monitoring._SENSITIVE_COMMANDS = set([])
|
||||
self.listener = WhiteListEventListener("saslStart")
|
||||
self.listener = AllowListEventListener("saslStart")
|
||||
|
||||
def tearDown(self):
|
||||
monitoring._SENSITIVE_COMMANDS = self._SENSITIVE_COMMANDS
|
||||
@ -363,7 +363,7 @@ class TestSCRAM(IntegrationTest):
|
||||
super(TestSCRAM, self).tearDown()
|
||||
|
||||
def test_scram_skip_empty_exchange(self):
|
||||
listener = WhiteListEventListener("saslStart", "saslContinue")
|
||||
listener = AllowListEventListener("saslStart", "saslContinue")
|
||||
client_context.create_user(
|
||||
'testscram', 'sha256', 'pwd', roles=['dbOwner'],
|
||||
mechanisms=['SCRAM-SHA-256'])
|
||||
|
||||
@ -45,7 +45,7 @@ from pymongo.write_concern import WriteConcern
|
||||
from test import client_context, unittest, IntegrationTest
|
||||
from test.unified_format import generate_test_classes
|
||||
from test.utils import (
|
||||
EventListener, WhiteListEventListener, rs_or_single_client, wait_until)
|
||||
EventListener, AllowListEventListener, rs_or_single_client, wait_until)
|
||||
|
||||
|
||||
class TestChangeStreamBase(IntegrationTest):
|
||||
@ -60,8 +60,8 @@ class TestChangeStreamBase(IntegrationTest):
|
||||
return self.change_stream_with_client(self.client, *args, **kwargs)
|
||||
|
||||
def client_with_listener(self, *commands):
|
||||
"""Return a client with a WhiteListEventListener."""
|
||||
listener = WhiteListEventListener(*commands)
|
||||
"""Return a client with a AllowListEventListener."""
|
||||
listener = AllowListEventListener(*commands)
|
||||
client = rs_or_single_client(event_listeners=[listener])
|
||||
self.addCleanup(client.close)
|
||||
return client, listener
|
||||
@ -445,7 +445,7 @@ class APITestsMixin(object):
|
||||
|
||||
class ProseSpecTestsMixin(object):
|
||||
def _client_with_listener(self, *commands):
|
||||
listener = WhiteListEventListener(*commands)
|
||||
listener = AllowListEventListener(*commands)
|
||||
client = rs_or_single_client(event_listeners=[listener])
|
||||
self.addCleanup(client.close)
|
||||
return client, listener
|
||||
@ -474,7 +474,7 @@ class ProseSpecTestsMixin(object):
|
||||
"""Predicts what the resume token should currently be for server
|
||||
versions that support postBatchResumeToken. Assumes the stream has
|
||||
never returned any changes if previous_change is None. Assumes
|
||||
listener is a WhiteListEventListener that listens for aggregate and
|
||||
listener is a AllowListEventListener that listens for aggregate and
|
||||
getMore commands."""
|
||||
if previous_change is None or stream._cursor._has_next():
|
||||
token = self._get_expected_resume_token_legacy(
|
||||
@ -1047,7 +1047,7 @@ class TestAllLegacyScenarios(IntegrationTest):
|
||||
@client_context.require_connection
|
||||
def setUpClass(cls):
|
||||
super(TestAllLegacyScenarios, cls).setUpClass()
|
||||
cls.listener = WhiteListEventListener("aggregate", "getMore")
|
||||
cls.listener = AllowListEventListener("aggregate", "getMore")
|
||||
cls.client = rs_or_single_client(event_listeners=[cls.listener])
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -44,7 +44,7 @@ from test.utils import (EventListener,
|
||||
OvertCommandListener,
|
||||
ignore_deprecations,
|
||||
rs_or_single_client,
|
||||
WhiteListEventListener)
|
||||
AllowListEventListener)
|
||||
|
||||
|
||||
class TestCursor(IntegrationTest):
|
||||
@ -231,7 +231,7 @@ class TestCursor(IntegrationTest):
|
||||
10).max_await_time_ms(90)
|
||||
self.assertEqual(90, cursor._Cursor__max_await_time_ms)
|
||||
|
||||
listener = WhiteListEventListener('find', 'getMore')
|
||||
listener = AllowListEventListener('find', 'getMore')
|
||||
coll = rs_or_single_client(
|
||||
event_listeners=[listener])[self.db.name].pymongo_test
|
||||
results = listener.results
|
||||
@ -349,7 +349,7 @@ class TestCursor(IntegrationTest):
|
||||
|
||||
def test_explain_with_read_concern(self):
|
||||
# Do not add readConcern level to explain.
|
||||
listener = WhiteListEventListener("explain")
|
||||
listener = AllowListEventListener("explain")
|
||||
client = rs_or_single_client(event_listeners=[listener])
|
||||
self.addCleanup(client.close)
|
||||
coll = client.pymongo_test.test.with_options(
|
||||
@ -1221,7 +1221,7 @@ class TestCursor(IntegrationTest):
|
||||
gc.collect()
|
||||
self.client._process_periodic_tasks()
|
||||
|
||||
listener = WhiteListEventListener("killCursors")
|
||||
listener = AllowListEventListener("killCursors")
|
||||
results = listener.results
|
||||
client = rs_or_single_client(event_listeners=[listener])
|
||||
self.addCleanup(client.close)
|
||||
@ -1268,7 +1268,7 @@ class TestCursor(IntegrationTest):
|
||||
|
||||
@client_context.require_version_min(3, 6)
|
||||
def test_getMore_does_not_send_readPreference(self):
|
||||
listener = WhiteListEventListener('find', 'getMore')
|
||||
listener = AllowListEventListener('find', 'getMore')
|
||||
client = rs_or_single_client(
|
||||
event_listeners=[listener])
|
||||
self.addCleanup(client.close)
|
||||
|
||||
@ -60,7 +60,7 @@ from test.utils import (TestCreator,
|
||||
camel_to_snake_args,
|
||||
OvertCommandListener,
|
||||
TopologyEventListener,
|
||||
WhiteListEventListener,
|
||||
AllowListEventListener,
|
||||
rs_or_single_client,
|
||||
wait_until)
|
||||
from test.utils_spec_runner import SpecRunner
|
||||
@ -1287,7 +1287,7 @@ class AzureGCPEncryptionTestMixin(object):
|
||||
keyvault_namespace,
|
||||
schema_map=self.SCHEMA_MAP)
|
||||
|
||||
insert_listener = WhiteListEventListener('insert')
|
||||
insert_listener = AllowListEventListener('insert')
|
||||
client = rs_or_single_client(
|
||||
auto_encryption_opts=encryption_opts,
|
||||
event_listeners=[insert_listener])
|
||||
|
||||
@ -162,23 +162,23 @@ class TopologyEventListener(monitoring.TopologyListener):
|
||||
self.results.clear()
|
||||
|
||||
|
||||
class WhiteListEventListener(EventListener):
|
||||
class AllowListEventListener(EventListener):
|
||||
|
||||
def __init__(self, *commands):
|
||||
self.commands = set(commands)
|
||||
super(WhiteListEventListener, self).__init__()
|
||||
super(AllowListEventListener, self).__init__()
|
||||
|
||||
def started(self, event):
|
||||
if event.command_name in self.commands:
|
||||
super(WhiteListEventListener, self).started(event)
|
||||
super(AllowListEventListener, self).started(event)
|
||||
|
||||
def succeeded(self, event):
|
||||
if event.command_name in self.commands:
|
||||
super(WhiteListEventListener, self).succeeded(event)
|
||||
super(AllowListEventListener, self).succeeded(event)
|
||||
|
||||
def failed(self, event):
|
||||
if event.command_name in self.commands:
|
||||
super(WhiteListEventListener, self).failed(event)
|
||||
super(AllowListEventListener, self).failed(event)
|
||||
|
||||
|
||||
class OvertCommandListener(EventListener):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user