mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 09:37:03 +02:00
wip commit
This commit is contained in:
parent
4db5b94b36
commit
34106286a6
4 changed files with 48 additions and 5 deletions
|
@ -67,6 +67,9 @@ class RegistryError(Exception):
|
||||||
def should_retry(self):
|
def should_retry(self):
|
||||||
return self.code == ErrorCode.COMMAND_FAILED
|
return self.code == ErrorCode.COMMAND_FAILED
|
||||||
|
|
||||||
|
def is_session_error(self):
|
||||||
|
return self.code is not None and (self.code >= 2501 and self.code <= 2502)
|
||||||
|
|
||||||
def is_server_error(self):
|
def is_server_error(self):
|
||||||
return self.code is not None and (self.code >= 2400 and self.code <= 2500)
|
return self.code is not None and (self.code >= 2400 and self.code <= 2500)
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,16 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
obj.place_client_hold()
|
obj.place_client_hold()
|
||||||
obj.save()
|
obj.save()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
# if error is an error from the registry, display useful
|
||||||
|
# and readable error
|
||||||
|
if err.code:
|
||||||
|
self.message_user(
|
||||||
|
request,
|
||||||
|
"Error placing the hold with the registry: {err}",
|
||||||
|
messages.ERROR
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# all other type error messages, display the error
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
self.message_user(
|
self.message_user(
|
||||||
|
@ -328,6 +338,16 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
obj.revert_client_hold()
|
obj.revert_client_hold()
|
||||||
obj.save()
|
obj.save()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
# if error is an error from the registry, display useful
|
||||||
|
# and readable error
|
||||||
|
if err.code:
|
||||||
|
self.message_user(
|
||||||
|
request,
|
||||||
|
"Error removing the hold in the registry: {err}",
|
||||||
|
messages.ERROR
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# all other type error messages, display the error
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
self.message_user(
|
self.message_user(
|
||||||
|
|
|
@ -635,13 +635,29 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""This domain should not be active.
|
"""This domain should not be active.
|
||||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||||
request = commands.UpdateDomain(name=self.name, add=[self.clientHoldStatus()])
|
request = commands.UpdateDomain(name=self.name, add=[self.clientHoldStatus()])
|
||||||
|
try:
|
||||||
registry.send(request, cleaned=True)
|
registry.send(request, cleaned=True)
|
||||||
|
self._invalidate_cache()
|
||||||
|
except RegistryError as err:
|
||||||
|
# if registry error occurs, log the error, and raise it as well
|
||||||
|
logger.error(
|
||||||
|
f"registry error placing client hold: {err}"
|
||||||
|
)
|
||||||
|
raise (err)
|
||||||
|
|
||||||
def _remove_client_hold(self):
|
def _remove_client_hold(self):
|
||||||
"""This domain is okay to be active.
|
"""This domain is okay to be active.
|
||||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||||
request = commands.UpdateDomain(name=self.name, rem=[self.clientHoldStatus()])
|
request = commands.UpdateDomain(name=self.name, rem=[self.clientHoldStatus()])
|
||||||
|
try:
|
||||||
registry.send(request, cleaned=True)
|
registry.send(request, cleaned=True)
|
||||||
|
self._invalidate_cache()
|
||||||
|
except RegistryError as err:
|
||||||
|
# if registry error occurs, log the error, and raise it as well
|
||||||
|
logger.error(
|
||||||
|
f"registry error removing client hold: {err}"
|
||||||
|
)
|
||||||
|
raise (err)
|
||||||
|
|
||||||
def _delete_domain(self):
|
def _delete_domain(self):
|
||||||
"""This domain should be deleted from the registry
|
"""This domain should be deleted from the registry
|
||||||
|
|
|
@ -634,7 +634,11 @@ class TestAnalystClientHold(TestCase):
|
||||||
Given the analyst is logged in
|
Given the analyst is logged in
|
||||||
And a domain exists in the registry
|
And a domain exists in the registry
|
||||||
"""
|
"""
|
||||||
pass
|
super().setUp()
|
||||||
|
self.domain, _ = Domain.objects.get_or_create(name="security.gov")
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
@skip("not implemented yet")
|
@skip("not implemented yet")
|
||||||
def test_analyst_places_client_hold(self):
|
def test_analyst_places_client_hold(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue