mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 09:07:02 +02:00
cleaned up tests
This commit is contained in:
parent
9e8aa2dee3
commit
cb15b7d029
2 changed files with 29 additions and 33 deletions
|
@ -704,22 +704,19 @@ class MockEppLib(TestCase):
|
||||||
"alg": 1,
|
"alg": 1,
|
||||||
"pubKey": "AQPJ////4Q==",
|
"pubKey": "AQPJ////4Q==",
|
||||||
}
|
}
|
||||||
dnssecExtensionWithDsData: Mapping[Any, Any] = {
|
dnssecExtensionWithDsData = extensions.DNSSECExtension(**{
|
||||||
"dsData": [common.DSData(**addDsData1)], # type: ignore
|
"dsData": [common.DSData(**addDsData1)],
|
||||||
}
|
})
|
||||||
dnssecExtensionWithMultDsData: Mapping[str, Any] = {
|
dnssecExtensionWithMultDsData = extensions.DNSSECExtension(**{
|
||||||
"dsData": [
|
"dsData": [
|
||||||
common.DSData(**addDsData1), # type: ignore
|
common.DSData(**addDsData1), # type: ignore
|
||||||
common.DSData(**addDsData2), # type: ignore
|
common.DSData(**addDsData2), # type: ignore
|
||||||
],
|
],
|
||||||
}
|
})
|
||||||
dnssecExtensionWithKeyData: Mapping[str, Any] = {
|
dnssecExtensionWithKeyData = extensions.DNSSECExtension(**{
|
||||||
"keyData": [common.DNSSECKeyData(**keyDataDict)], # type: ignore
|
"keyData": [common.DNSSECKeyData(**keyDataDict)], # type: ignore
|
||||||
}
|
})
|
||||||
dnssecExtensionRemovingDsData: Mapping[Any, Any] = {
|
dnssecExtensionRemovingDsData = extensions.DNSSECExtension()
|
||||||
"dsData": None,
|
|
||||||
"keyData": None,
|
|
||||||
}
|
|
||||||
|
|
||||||
def mockSend(self, _request, cleaned):
|
def mockSend(self, _request, cleaned):
|
||||||
"""Mocks the registry.send function used inside of domain.py
|
"""Mocks the registry.send function used inside of domain.py
|
||||||
|
@ -765,7 +762,7 @@ class MockEppLib(TestCase):
|
||||||
return MagicMock(
|
return MagicMock(
|
||||||
res_data=[self.mockDataInfoDomain],
|
res_data=[self.mockDataInfoDomain],
|
||||||
extensions=[
|
extensions=[
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
self.dnssecExtensionWithDsData
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
elif getattr(_request, "name", None) == "dnssec-multdsdata.gov":
|
elif getattr(_request, "name", None) == "dnssec-multdsdata.gov":
|
||||||
|
@ -775,7 +772,7 @@ class MockEppLib(TestCase):
|
||||||
return MagicMock(
|
return MagicMock(
|
||||||
res_data=[self.mockDataInfoDomain],
|
res_data=[self.mockDataInfoDomain],
|
||||||
extensions=[
|
extensions=[
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithMultDsData)
|
self.dnssecExtensionWithMultDsData
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
elif getattr(_request, "name", None) == "dnssec-keydata.gov":
|
elif getattr(_request, "name", None) == "dnssec-keydata.gov":
|
||||||
|
@ -785,7 +782,7 @@ class MockEppLib(TestCase):
|
||||||
return MagicMock(
|
return MagicMock(
|
||||||
res_data=[self.mockDataInfoDomain],
|
res_data=[self.mockDataInfoDomain],
|
||||||
extensions=[
|
extensions=[
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithKeyData)
|
self.dnssecExtensionWithKeyData
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
elif getattr(_request, "name", None) == "dnssec-none.gov":
|
elif getattr(_request, "name", None) == "dnssec-none.gov":
|
||||||
|
|
|
@ -1035,9 +1035,8 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(
|
domain.dnssecdata = self.dnssecExtensionWithDsData
|
||||||
**self.dnssecExtensionWithDsData
|
|
||||||
)
|
|
||||||
# get the DNS SEC extension added to the UpdateDomain command and
|
# get the DNS SEC extension added to the UpdateDomain command and
|
||||||
# verify that it is properly sent
|
# verify that it is properly sent
|
||||||
# args[0] is the _request sent to registry
|
# args[0] is the _request sent to registry
|
||||||
|
@ -1046,7 +1045,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
args[0].extensions[0],
|
args[0].extensions[0],
|
||||||
self.createUpdateExtension(
|
self.createUpdateExtension(
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
self.dnssecExtensionWithDsData
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# test that the dnssecdata getter is functioning properly
|
# test that the dnssecdata getter is functioning properly
|
||||||
|
@ -1079,7 +1078,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
dnssecdata_get.dsData, self.dnssecExtensionWithDsData["dsData"]
|
dnssecdata_get.dsData, self.dnssecExtensionWithDsData.dsData
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_dnssec_is_idempotent(self):
|
def test_dnssec_is_idempotent(self):
|
||||||
|
@ -1096,15 +1095,15 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
3 - setter causes the getter to call info domain on next get from cache
|
3 - setter causes the getter to call info domain on next get from cache
|
||||||
4 - UpdateDomain command is not called on second setter (no change)
|
4 - UpdateDomain command is not called on second setter (no change)
|
||||||
5 - getter properly parses dnssecdata from InfoDomain response and sets to cache
|
5 - getter properly parses dnssecdata from InfoDomain response and sets to cache
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
||||||
|
|
||||||
# set the dnssecdata once
|
# set the dnssecdata once
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
domain.dnssecdata = self.dnssecExtensionWithDsData
|
||||||
# set the dnssecdata again
|
# set the dnssecdata again
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
domain.dnssecdata = self.dnssecExtensionWithDsData
|
||||||
# test that the dnssecdata getter is functioning properly
|
# test that the dnssecdata getter is functioning properly
|
||||||
dnssecdata_get = domain.dnssecdata
|
dnssecdata_get = domain.dnssecdata
|
||||||
self.mockedSendFunction.assert_has_calls(
|
self.mockedSendFunction.assert_has_calls(
|
||||||
|
@ -1141,7 +1140,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
dnssecdata_get.dsData, self.dnssecExtensionWithDsData["dsData"]
|
dnssecdata_get.dsData, self.dnssecExtensionWithDsData.dsData
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_user_adds_dnssec_data_multiple_dsdata(self):
|
def test_user_adds_dnssec_data_multiple_dsdata(self):
|
||||||
|
@ -1159,7 +1158,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
|
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-multdsdata.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-multdsdata.gov")
|
||||||
|
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithMultDsData)
|
domain.dnssecdata = self.dnssecExtensionWithMultDsData
|
||||||
# get the DNS SEC extension added to the UpdateDomain command
|
# get the DNS SEC extension added to the UpdateDomain command
|
||||||
# and verify that it is properly sent
|
# and verify that it is properly sent
|
||||||
# args[0] is the _request sent to registry
|
# args[0] is the _request sent to registry
|
||||||
|
@ -1168,7 +1167,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
args[0].extensions[0],
|
args[0].extensions[0],
|
||||||
self.createUpdateExtension(
|
self.createUpdateExtension(
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithMultDsData)
|
self.dnssecExtensionWithMultDsData
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# test that the dnssecdata getter is functioning properly
|
# test that the dnssecdata getter is functioning properly
|
||||||
|
@ -1195,7 +1194,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
dnssecdata_get.dsData, self.dnssecExtensionWithMultDsData["dsData"]
|
dnssecdata_get.dsData, self.dnssecExtensionWithMultDsData.dsData
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_user_removes_dnssec_data(self):
|
def test_user_removes_dnssec_data(self):
|
||||||
|
@ -1215,8 +1214,8 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
||||||
# dnssecdata_get_initial = domain.dnssecdata # call to force initial mock
|
# dnssecdata_get_initial = domain.dnssecdata # call to force initial mock
|
||||||
# domain._invalidate_cache()
|
# domain._invalidate_cache()
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
domain.dnssecdata = self.dnssecExtensionWithDsData
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionRemovingDsData)
|
domain.dnssecdata = self.dnssecExtensionRemovingDsData
|
||||||
# get the DNS SEC extension added to the UpdateDomain command and
|
# get the DNS SEC extension added to the UpdateDomain command and
|
||||||
# verify that it is properly sent
|
# verify that it is properly sent
|
||||||
# args[0] is the _request sent to registry
|
# args[0] is the _request sent to registry
|
||||||
|
@ -1225,7 +1224,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
args[0].extensions[0],
|
args[0].extensions[0],
|
||||||
self.createUpdateExtension(
|
self.createUpdateExtension(
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithDsData),
|
self.dnssecExtensionWithDsData,
|
||||||
remove=True,
|
remove=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1281,7 +1280,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
|
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-keydata.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-keydata.gov")
|
||||||
|
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithKeyData)
|
domain.dnssecdata = self.dnssecExtensionWithKeyData
|
||||||
# get the DNS SEC extension added to the UpdateDomain command
|
# get the DNS SEC extension added to the UpdateDomain command
|
||||||
# and verify that it is properly sent
|
# and verify that it is properly sent
|
||||||
# args[0] is the _request sent to registry
|
# args[0] is the _request sent to registry
|
||||||
|
@ -1290,7 +1289,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
args[0].extensions[0],
|
args[0].extensions[0],
|
||||||
self.createUpdateExtension(
|
self.createUpdateExtension(
|
||||||
extensions.DNSSECExtension(**self.dnssecExtensionWithKeyData)
|
self.dnssecExtensionWithKeyData
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# test that the dnssecdata getter is functioning properly
|
# test that the dnssecdata getter is functioning properly
|
||||||
|
@ -1317,7 +1316,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
dnssecdata_get.keyData, self.dnssecExtensionWithKeyData["keyData"]
|
dnssecdata_get.keyData, self.dnssecExtensionWithKeyData.keyData
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_update_is_unsuccessful(self):
|
def test_update_is_unsuccessful(self):
|
||||||
|
@ -1330,7 +1329,7 @@ class TestRegistrantDNSSEC(MockEppLib):
|
||||||
domain, _ = Domain.objects.get_or_create(name="dnssec-invalid.gov")
|
domain, _ = Domain.objects.get_or_create(name="dnssec-invalid.gov")
|
||||||
|
|
||||||
with self.assertRaises(RegistryError) as err:
|
with self.assertRaises(RegistryError) as err:
|
||||||
domain.dnssecdata = extensions.DNSSECExtension(**self.dnssecExtensionWithDsData)
|
domain.dnssecdata = self.dnssecExtensionWithDsData
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
err.is_client_error() or err.is_session_error() or err.is_server_error()
|
err.is_client_error() or err.is_session_error() or err.is_server_error()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue