Update pipfile

This commit is contained in:
zandercymatics 2023-10-16 13:33:11 -06:00
parent a9e4d34099
commit 7bb6bb9e7d
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
7 changed files with 36 additions and 41 deletions

View file

@ -25,6 +25,7 @@ django-phonenumber-field = {extras = ["phonenumberslite"], version = "*"}
boto3 = "*" boto3 = "*"
typing-extensions ='*' typing-extensions ='*'
django-login-required-middleware = "*" django-login-required-middleware = "*"
gevent = "*"
fred-epplib = {git = "https://github.com/cisagov/epplib.git", ref = "master"} fred-epplib = {git = "https://github.com/cisagov/epplib.git", ref = "master"}
geventconnpool = {git = "https://github.com/rasky/geventconnpool.git", ref = "1bbb93a714a331a069adf27265fe582d9ba7ecd4"} geventconnpool = {git = "https://github.com/rasky/geventconnpool.git", ref = "1bbb93a714a331a069adf27265fe582d9ba7ecd4"}

3
src/Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "a3a996c98e72cee37bc89a3b95fab6ae4b396d5663eb4fe66a80684154bc90e0" "sha256": "67b51a57b7d9d7d70d1eeca3515e169cd614d575a7213f31251f9dde43e1f748"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": {}, "requires": {},
@ -433,6 +433,7 @@
"sha256:fae8d5b5b8fa2a8f63b39f5447168b02db10c888a3e387ed7af2bd1b8612e543", "sha256:fae8d5b5b8fa2a8f63b39f5447168b02db10c888a3e387ed7af2bd1b8612e543",
"sha256:fde6402c5432b835fbb7698f1c7f2809c8d6b2bd9d047ac1f5a7c1d5aa569303" "sha256:fde6402c5432b835fbb7698f1c7f2809c8d6b2bd9d047ac1f5a7c1d5aa569303"
], ],
"index": "pypi",
"markers": "python_version >= '3.8'", "markers": "python_version >= '3.8'",
"version": "==23.9.1" "version": "==23.9.1"
}, },

View file

@ -36,6 +36,7 @@ except Exception:
exc_info=True, exc_info=True,
) )
class EPPLibWrapper: class EPPLibWrapper:
""" """
A wrapper over epplib's client. A wrapper over epplib's client.
@ -69,9 +70,7 @@ class EPPLibWrapper:
# Pool size # Pool size
"size": settings.EPP_CONNECTION_POOL_SIZE, "size": settings.EPP_CONNECTION_POOL_SIZE,
# Which errors the pool should look out for # Which errors the pool should look out for
"exc_classes": ( "exc_classes": (TransportError,),
TransportError,
),
# Occasionally pings the registry to keep the connection alive. # Occasionally pings the registry to keep the connection alive.
# Value in seconds => (keepalive / size) # Value in seconds => (keepalive / size)
"keepalive": settings.POOL_KEEP_ALIVE, "keepalive": settings.POOL_KEEP_ALIVE,
@ -133,7 +132,7 @@ class EPPLibWrapper:
# try to prevent use of this method without appropriate safeguards # try to prevent use of this method without appropriate safeguards
if not cleaned: if not cleaned:
raise ValueError("Please sanitize user input before sending it.") raise ValueError("Please sanitize user input before sending it.")
# Reopen the pool if its closed # Reopen the pool if its closed
if not self.pool_status.pool_running: if not self.pool_status.pool_running:
# We want to reopen the connection pool, # We want to reopen the connection pool,
@ -160,12 +159,12 @@ class EPPLibWrapper:
else: # don't try again else: # don't try again
raise err raise err
def start_connection_pool(self, restart_pool_if_exists = True): def start_connection_pool(self, restart_pool_if_exists=True):
"""Starts a connection pool for the registry. """Starts a connection pool for the registry.
restart_pool_if_exists -> bool: restart_pool_if_exists -> bool:
If an instance of the pool already exists, If an instance of the pool already exists,
then then that instance will be killed first. then then that instance will be killed first.
It is generally recommended to keep this enabled.""" It is generally recommended to keep this enabled."""
# Since we reuse the same creds for each pool, we can test on # Since we reuse the same creds for each pool, we can test on
# one socket, and if successful, then we know we can connect. # one socket, and if successful, then we know we can connect.
@ -179,13 +178,13 @@ class EPPLibWrapper:
return return
else: else:
self.pool_status.connection_success = True self.pool_status.connection_success = True
# If this function is reinvoked, then ensure # If this function is reinvoked, then ensure
# that we don't have duplicate data sitting around. # that we don't have duplicate data sitting around.
if self._pool is not None and restart_pool_if_exists: if self._pool is not None and restart_pool_if_exists:
logger.info("Connection pool restarting...") logger.info("Connection pool restarting...")
self.kill_pool() self.kill_pool()
self._pool = EPPConnectionPool( self._pool = EPPConnectionPool(
client=self._client, login=self._login, options=self.pool_options client=self._client, login=self._login, options=self.pool_options
) )
@ -193,7 +192,7 @@ class EPPLibWrapper:
self.pool_status.pool_hanging = False self.pool_status.pool_hanging = False
logger.info("Connection pool started") logger.info("Connection pool started")
def kill_pool(self): def kill_pool(self):
"""Kills the existing pool. Use this instead """Kills the existing pool. Use this instead
of self._pool = None, as that doesn't clear of self._pool = None, as that doesn't clear
@ -203,9 +202,7 @@ class EPPLibWrapper:
self._pool = None self._pool = None
self.pool_status.pool_running = False self.pool_status.pool_running = False
return return
logger.info( logger.info("kill_pool() was invoked but there was no pool to delete")
"kill_pool() was invoked but there was no pool to delete"
)
def _test_registry_connection_success(self): def _test_registry_connection_success(self):
"""Check that determines if our login """Check that determines if our login

View file

@ -79,7 +79,7 @@ class RegistryError(Exception):
def is_client_error(self): def is_client_error(self):
return self.code is not None and (self.code >= 2000 and self.code <= 2308) return self.code is not None and (self.code >= 2000 and self.code <= 2308)
def is_not_retryable(self): def is_not_retryable(self):
pass pass

View file

@ -22,6 +22,7 @@ logger = logging.getLogger(__name__)
@patch("djangooidc.views.CLIENT", autospec=True) @patch("djangooidc.views.CLIENT", autospec=True)
class TestConnectionPool(MockEppLib): class TestConnectionPool(MockEppLib):
"""Tests for our connection pooling behaviour""" """Tests for our connection pooling behaviour"""
def setUp(self): def setUp(self):
""" """
Background: Background:
@ -33,9 +34,7 @@ class TestConnectionPool(MockEppLib):
# Current pool size # Current pool size
"size": 1, "size": 1,
# Which errors the pool should look out for # Which errors the pool should look out for
"exc_classes": ( "exc_classes": (TransportError,),
TransportError,
),
# Occasionally pings the registry to keep the connection alive. # Occasionally pings the registry to keep the connection alive.
# Value in seconds => (keepalive / size) # Value in seconds => (keepalive / size)
"keepalive": 60, "keepalive": 60,
@ -43,7 +42,7 @@ class TestConnectionPool(MockEppLib):
def tearDown(self): def tearDown(self):
super().tearDown() super().tearDown()
def user_info(*args): def user_info(*args):
return { return {
"sub": "TEST", "sub": "TEST",
@ -69,16 +68,16 @@ class TestConnectionPool(MockEppLib):
# in client.py. They should remain unchanged, # in client.py. They should remain unchanged,
# and if they aren't, something went wrong. # and if they aren't, something went wrong.
expected_login = commands.Login( expected_login = commands.Login(
cl_id='nothing', cl_id="nothing",
password='nothing', password="nothing",
obj_uris=[ obj_uris=[
'urn:ietf:params:xml:ns:domain-1.0', "urn:ietf:params:xml:ns:domain-1.0",
'urn:ietf:params:xml:ns:contact-1.0' "urn:ietf:params:xml:ns:contact-1.0",
], ],
new_pw=None, new_pw=None,
version='1.0', version="1.0",
lang='en', lang="en",
ext_uris=[] ext_uris=[],
) )
# Key/cert will generate a new file everytime. # Key/cert will generate a new file everytime.
@ -94,7 +93,7 @@ class TestConnectionPool(MockEppLib):
).__dict__ ).__dict__
except Exception as err: except Exception as err:
self.fail(err) self.fail(err)
# We don't care about checking if the objects are both of # We don't care about checking if the objects are both of
# the same reference, we only care about data parity, so # the same reference, we only care about data parity, so
# we do a dict conversion. # we do a dict conversion.
@ -118,15 +117,14 @@ class TestConnectionPool(MockEppLib):
@skip("not implemented yet") @skip("not implemented yet")
def test_pool_timesout(self): def test_pool_timesout(self):
"""The pool timesout and restarts""" """The pool timesout and restarts"""
raise raise
@skip("not implemented yet") @skip("not implemented yet")
def test_multiple_users_send_data(self): def test_multiple_users_send_data(self):
"""Multiple users send data concurrently""" """Multiple users send data concurrently"""
raise raise
@skip("not implemented yet") @skip("not implemented yet")
def test_pool_sends_data(self): def test_pool_sends_data(self):
"""A .send is invoked on the pool""" """A .send is invoked on the pool"""
raise raise

View file

@ -22,6 +22,7 @@ class EPPConnectionPool(ConnectionPool):
options (dict): Options for the ConnectionPool options (dict): Options for the ConnectionPool
base class base class
""" """
def __init__(self, client, login, options: dict): def __init__(self, client, login, options: dict):
# For storing shared credentials # For storing shared credentials
self._client = client self._client = client
@ -51,11 +52,11 @@ class EPPConnectionPool(ConnectionPool):
"""Creates and returns a socket instance""" """Creates and returns a socket instance"""
socket = Socket(client, login) socket = Socket(client, login)
return socket return socket
def get_connections(self): def get_connections(self):
"""Returns the connection queue""" """Returns the connection queue"""
return self.conn return self.conn
def kill_all_connections(self): def kill_all_connections(self):
"""Kills all active connections in the pool.""" """Kills all active connections in the pool."""
try: try:
@ -66,11 +67,9 @@ class EPPConnectionPool(ConnectionPool):
self.lock.release() self.lock.release()
# TODO - connection pool err # TODO - connection pool err
except Exception as err: except Exception as err:
logger.error( logger.error("Could not kill all connections.")
"Could not kill all connections."
)
raise err raise err
def repopulate_all_connections(self): def repopulate_all_connections(self):
"""Regenerates the connection pool. """Regenerates the connection pool.
If any connections exist, kill them first. If any connections exist, kill them first.
@ -80,6 +79,4 @@ class EPPConnectionPool(ConnectionPool):
for i in range(self.size): for i in range(self.size):
self.lock.acquire() self.lock.acquire()
for i in range(self.size): for i in range(self.size):
gevent.spawn_later(self.SPAWN_FREQUENCY*i, self._addOne) gevent.spawn_later(self.SPAWN_FREQUENCY * i, self._addOne)

View file

@ -1,5 +1,6 @@
class PoolStatus: class PoolStatus:
"""A list of Booleans to keep track of Pool Status""" """A list of Booleans to keep track of Pool Status"""
def __init__(self): def __init__(self):
self.pool_running = False self.pool_running = False
self.connection_success = False self.connection_success = False