Respond to PR feedback

This commit is contained in:
Seamus Johnston 2023-04-28 16:02:30 -05:00
parent e386a039b2
commit 39c54fa79f
No known key found for this signature in database
GPG key ID: 2F21225985069105
5 changed files with 20 additions and 19 deletions

View file

@ -88,8 +88,7 @@ openssl req -new -x509 -days 365 \
``` ```
(Hint: (If you can't use openssl on your computer directly, you can access it using Docker as `docker run --platform=linux/amd64 -it --rm -v $(pwd):/apps -w /apps alpine/openssl`.)
`docker run --platform=linux/amd64 -it --rm -v $(pwd):/apps -w /apps alpine/openssl`.)
Encode them using: Encode them using:

View file

@ -4,6 +4,7 @@ from types import SimpleNamespace
try: try:
from epplib import constants from epplib import constants
except ImportError: except ImportError:
# allow epplibwrapper to load without epplib, for testing and development
pass pass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,3 +1,5 @@
"""Provide a wrapper around epplib to handle authentication and errors."""
import logging import logging
from time import sleep from time import sleep
@ -21,12 +23,12 @@ try:
# Write cert and key to disk # Write cert and key to disk
CERT = Cert() CERT = Cert()
KEY = Key() KEY = Key()
except Exception as err: except Exception:
CERT = None # type: ignore CERT = None # type: ignore
KEY = None # type: ignore KEY = None # type: ignore
logger.warning(err)
logger.warning( logger.warning(
"Problem with client certificate. Registrar cannot contact registry." "Problem with client certificate. Registrar cannot contact registry.",
exc_info=True,
) )
@ -68,31 +70,31 @@ class EPPLibWrapper:
with self._connect as wire: with self._connect as wire:
response = wire.send(command) response = wire.send(command)
except (ValueError, ParsingError) as err: except (ValueError, ParsingError) as err:
logger.debug(err)
logger.warning( logger.warning(
"%s failed to execute due to some syntax error." "%s failed to execute due to some syntax error."
% command.__class__.__name__ % command.__class__.__name__,
exc_info=True,
) )
raise RegistryError() from err raise RegistryError() from err
except TransportError as err: except TransportError as err:
logger.debug(err)
logger.warning( logger.warning(
"%s failed to execute due to a connection error." "%s failed to execute due to a connection error."
% command.__class__.__name__ % command.__class__.__name__,
exc_info=True,
) )
raise RegistryError() from err raise RegistryError() from err
except LoginError as err: except LoginError as err:
logger.debug(err)
logger.warning( logger.warning(
"%s failed to execute due to a registry login error." "%s failed to execute due to a registry login error."
% command.__class__.__name__ % command.__class__.__name__,
exc_info=True,
) )
raise RegistryError() from err raise RegistryError() from err
except Exception as err: except Exception as err:
logger.debug(err)
logger.warning( logger.warning(
"%s failed to execute due to an unknown error." "%s failed to execute due to an unknown error."
% command.__class__.__name__ % command.__class__.__name__,
exc_info=True,
) )
raise RegistryError() from err raise RegistryError() from err
else: else:
@ -119,7 +121,8 @@ try:
# Initialize epplib # Initialize epplib
CLIENT = EPPLibWrapper() CLIENT = EPPLibWrapper()
logger.debug("registry client initialized") logger.debug("registry client initialized")
except Exception as err: except Exception:
CLIENT = None # type: ignore CLIENT = None # type: ignore
logger.warning(err) logger.warning(
logger.warning("Unable to configure epplib. Registrar cannot contact registry.") "Unable to configure epplib. Registrar cannot contact registry.", exc_info=True
)

View file

@ -7,8 +7,6 @@ from django.db import models
from django_fsm import FSMField, transition # type: ignore from django_fsm import FSMField, transition # type: ignore
from api.views import in_domains from api.views import in_domains
# from epplibwrapper import CLIENT as registry, commands
from registrar.utility import errors from registrar.utility import errors
from .utility.time_stamped_model import TimeStampedModel from .utility.time_stamped_model import TimeStampedModel

View file

@ -6,4 +6,4 @@ set -o pipefail
# Make sure that django's `collectstatic` has been run locally before pushing up to any environment, # Make sure that django's `collectstatic` has been run locally before pushing up to any environment,
# so that the styles and static assets to show up correctly on any environment. # so that the styles and static assets to show up correctly on any environment.
gunicorn registrar.config.wsgi -t 60 --preload gunicorn registrar.config.wsgi -t 60