mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Modify tests for availability API to return false on error
This commit is contained in:
parent
9c7bbd31ec
commit
c75891ee90
3 changed files with 15 additions and 12 deletions
|
@ -108,10 +108,9 @@ class AvailableViewTest(MockEppLib):
|
||||||
request.user = self.user
|
request.user = self.user
|
||||||
response = available(request, domain=bad_string)
|
response = available(request, domain=bad_string)
|
||||||
self.assertFalse(json.loads(response.content)["available"])
|
self.assertFalse(json.loads(response.content)["available"])
|
||||||
# domain set to raise error successfully raises error
|
# domain set to raise error returns false for availability
|
||||||
with self.assertRaises(RegistryError):
|
error_domain_available = available(request, "errordomain.gov")
|
||||||
error_domain_available = available(request, "errordomain.gov")
|
self.assertFalse(json.loads(error_domain_available.content)["available"])
|
||||||
self.assertFalse(json.loads(error_domain_available.content)["available"])
|
|
||||||
|
|
||||||
|
|
||||||
class AvailableAPITest(MockEppLib):
|
class AvailableAPITest(MockEppLib):
|
||||||
|
|
|
@ -89,11 +89,14 @@ def available(request, domain=""):
|
||||||
{"available": False, "message": DOMAIN_API_MESSAGES["invalid"]}
|
{"available": False, "message": DOMAIN_API_MESSAGES["invalid"]}
|
||||||
)
|
)
|
||||||
# a domain is available if it is NOT in the list of current domains
|
# a domain is available if it is NOT in the list of current domains
|
||||||
if check_domain_available(domain):
|
try:
|
||||||
return JsonResponse(
|
if check_domain_available(domain):
|
||||||
{"available": True, "message": DOMAIN_API_MESSAGES["success"]}
|
return JsonResponse(
|
||||||
)
|
{"available": True, "message": DOMAIN_API_MESSAGES["success"]}
|
||||||
else:
|
)
|
||||||
return JsonResponse(
|
else:
|
||||||
{"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]}
|
return JsonResponse(
|
||||||
)
|
{"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]}
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
raise RegistryError("Registry cannot find domain availability.")
|
||||||
|
|
|
@ -116,6 +116,7 @@ class TestURLAuth(TestCase):
|
||||||
"/openid/callback",
|
"/openid/callback",
|
||||||
"/openid/callback/login/",
|
"/openid/callback/login/",
|
||||||
"/openid/callback/logout/",
|
"/openid/callback/logout/",
|
||||||
|
"/api/v1/available"
|
||||||
]
|
]
|
||||||
|
|
||||||
def assertURLIsProtectedByAuth(self, url):
|
def assertURLIsProtectedByAuth(self, url):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue