Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in dnssec and fix other bugs (#57) #58

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyepp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
PyEPP Package
"""
__version__ = "0.0.4-alpha.4"
__version__ = "0.0.5"

from pyepp.epp import EppCommunicator, EppResultCode, EppCommunicatorException
43 changes: 22 additions & 21 deletions pyepp/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class DomainData:
expiry_date: Optional[str] = ''
transfer_date: Optional[str] = ''
password: Optional[str] = ''
dns_sec: Optional[DSRecordData] = None
dns_key: Optional[DSRecordKeyData] = None
dns_sec: Optional[list[DSRecordData]] = None


class Domain(BaseCommand):
Expand Down Expand Up @@ -173,26 +172,28 @@ def info(self, domain_name: str, client_transaction_id: Optional[str] = None) ->
'transfer_date': raw_response.find('trDate').text if raw_response.find('trDate') else None,
'password': raw_response.find('pw').text if raw_response.find('pw') else None,
'period': None,
'dns_sec': DSRecordData(**{
'key_tag': raw_response.find('keyTag').text,
'algorithm': raw_response.find('alg').text,
'digest_type': raw_response.find('digestType').text,
'digest': raw_response.find('digest').text,
'dns_key': {
'flag': raw_response.find('flag').text,
'protocol': raw_response.find('protocol').text,
'algorithm': raw_response.find('algorithm').text,
'public_key': raw_response.find('public_key').text,
} if raw_response.find('keyData') else None
}) if raw_response.find('dsData') else None,
'dns_key': DSRecordKeyData(**{
'flag': raw_response.find('flag').text,
'protocol': raw_response.find('protocol').text,
'algorithm': raw_response.find('algorithm').text,
'public_key': raw_response.find('public_key').text,
}) if raw_response.find('keyData') else None
'dns_sec': None,
}

dns_sec = []
all_ds_data = raw_response.find_all('dsData')
for ds_data in all_ds_data:
dns_sec.append(DSRecordData(**{
'key_tag': ds_data.find('keyTag').text,
'algorithm': ds_data.find('alg').text,
'digest_type': ds_data.find('digestType').text,
'digest': ds_data.find('digest').text,
'dns_key': {
'flag': ds_data.find('flags').text,
'protocol': ds_data.find('protocol').text,
'algorithm': ds_data.find('alg').text,
'public_key': ds_data.find('pubKey').text,
} if ds_data.find('keyData') else None
}))

if dns_sec:
result_data['dns_sec'] = dns_sec

result.result_data = DomainData(**result_data)

return result
Expand Down Expand Up @@ -272,7 +273,7 @@ def transfer(self, domain_name: str, password: str, period: Optional[int] = None
def update(self, domain_name: str,
registrant: Optional[str] = None,
admin: Optional[str] = None,
tech: Optional[str] = None,
tech: Optional[str] = None,
add_billings: Optional[list[str]] = None,
remove_billings: Optional[list[str]] = None,
add_statues: Optional[list[tuple]] = None,
Expand Down
125 changes: 122 additions & 3 deletions tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,54 @@ def test_info(self) -> None:
'<domain:exDate>2024-02-23T21:56:22.713Z</domain:exDate>\n'
'</domain:infData>\n'
'</resData>\n'
'<extension>\n'
'<secDNS:infData '
'xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>1</secDNS:digestType>\n'
'<secDNS:digest>4ffb0f3f0fb5edbaa0067d1cd94bb545249cfea2</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>14</secDNS:alg>\n'
'<secDNS:pubKey>1fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>2</secDNS:digestType>\n'
'<secDNS:digest>024c96b094aaad3892babb303e02587f7d6f8f749fef9ff642e3bb8bfc2e0dcf</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:pubKey>2fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>4</secDNS:digestType>\n'
'<secDNS:digest>14d92f9f1e82c0906e2003b9e3401de4024f705724ef14d848fc2708d5714d5572db040faa3e317753e6577c7e70cbb8</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:pubKey>3fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'</secDNS:infData>\n'
'<rgp:infData xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">\n'
'<rgp:rgpStatus s="addPeriod"/>\n'
'</rgp:infData>\n'
'<regtype:infData '
'xmlns:regtype="urn:ietf:params:xml:ns:regtype-0.1">\n'
'<regtype:type>standard</regtype:type>\n'
'</regtype:infData>\n'
'</extension>\n'
'<trID>\n'
'<svTRID>CIRA-000063163743-0000000003</svTRID>\n'
'</trID>\n'
Expand Down Expand Up @@ -148,11 +196,58 @@ def test_info(self) -> None:
'<domain:exDate>2024-02-23T21:56:22.713Z</domain:exDate>\n'
'</domain:infData>\n'
'</resData>\n'
'<extension>\n'
'<secDNS:infData '
'xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>1</secDNS:digestType>\n'
'<secDNS:digest>4ffb0f3f0fb5edbaa0067d1cd94bb545249cfea2</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>14</secDNS:alg>\n'
'<secDNS:pubKey>1fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>2</secDNS:digestType>\n'
'<secDNS:digest>024c96b094aaad3892babb303e02587f7d6f8f749fef9ff642e3bb8bfc2e0dcf</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:pubKey>2fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'<secDNS:dsData>\n'
'<secDNS:keyTag>17600</secDNS:keyTag>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:digestType>4</secDNS:digestType>\n'
'<secDNS:digest>14d92f9f1e82c0906e2003b9e3401de4024f705724ef14d848fc2708d5714d5572db040faa3e317753e6577c7e70cbb8</secDNS:digest>\n'
'<secDNS:keyData>\n'
'<secDNS:flags>257</secDNS:flags>\n'
'<secDNS:protocol>3</secDNS:protocol>\n'
'<secDNS:alg>13</secDNS:alg>\n'
'<secDNS:pubKey>3fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg==</secDNS:pubKey>\n'
'</secDNS:keyData>\n'
'</secDNS:dsData>\n'
'</secDNS:infData>\n'
'<rgp:infData xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">\n'
'<rgp:rgpStatus s="addPeriod"/>\n'
'</rgp:infData>\n'
'<regtype:infData '
'xmlns:regtype="urn:ietf:params:xml:ns:regtype-0.1">\n'
'<regtype:type>standard</regtype:type>\n'
'</regtype:infData>\n'
'</extension>\n'
'<trID>\n'
'<svTRID>CIRA-000063163743-0000000003</svTRID>\n'
'</trID>\n'
'</response>',
'reason': None,
'repository_object_id': '9204701-INZ',
'result_data': DomainData(domain_name='internet.nz',
sponsoring_client_id='933',
Expand All @@ -169,13 +264,37 @@ def test_info(self) -> None:
expiry_date='2024-02-23T21:56:22.713Z',
transfer_date=None,
password=None,
period=None),
period=None,
dns_sec=[DSRecordData(key_tag='17600',
algorithm='13',
digest_type='1',
digest='4ffb0f3f0fb5edbaa0067d1cd94bb545249cfea2',
dns_key={'algorithm': '13',
'flag': '257',
'protocol': '3',
'public_key': '1fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg=='}),
DSRecordData(key_tag='17600',
algorithm='13',
digest_type='2',
digest='024c96b094aaad3892babb303e02587f7d6f8f749fef9ff642e3bb8bfc2e0dcf',
dns_key={'algorithm': '13',
'flag': '257',
'protocol': '3',
'public_key': '2fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg=='}),
DSRecordData(key_tag='17600',
algorithm='13',
digest_type='4',
digest='14d92f9f1e82c0906e2003b9e3401de4024f705724ef14d848fc2708d5714d5572db040faa3e317753e6577c7e70cbb8',
dns_key={'algorithm': '13',
'flag': '257',
'protocol': '3',
'public_key': '3fHiagyGUIxsDmeYaaKOWceffQn7QTaCwM1y6Oy1zYRpndxu/6WAHM99p/X/dM7t+RcGahZ8+GlX5JHkbyaMllg=='})]
),
'server_transaction_id': 'CIRA-000063163743-0000000003'})

domain.execute = MagicMock(return_value=execute_result)

result = domain.info('internet.nz')

self.assertEqual(result, expected_result)

def test_create(self) -> None:
Expand Down