Skip to content

Commit 124ae91

Browse files
committed
solved issue with multiple nameservers items in the EPP request
1 parent b7721da commit 124ae91

File tree

4 files changed

+37
-27
lines changed

4 files changed

+37
-27
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ venv:
2020
test: venv
2121
PYTHONPATH=./src ./venv/bin/pytest -vv --color=yes --capture=no --log-cli-level=DEBUG ./tests
2222

23+
test/%:
24+
PYTHONPATH=./src ./venv/bin/pytest -vv $*
25+
2326
rabbitmq_server_dev:
2427
@echo "Starting RabbitMQ server, admin dashboard is available here: http://127.0.0.1:15672"
2528
@rabbitmq-server

src/epp/commands/domain.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
single = "<domain:name>%s</domain:name>"
22

3-
43
single_contact1 = '<domain:contact type="%(type)s">%(id)s</domain:contact>'
54

65
single_contact2 = ' <domain:contact type="%(type)s">%(id)s</domain:contact>'
76

8-
97
single_contact_update = '<domain:contact type="%(type)s">%(id)s</domain:contact>'
108

11-
129
single_registrant = """
1310
<domain:registrant>%s</domain:registrant>"""
1411

12+
multiple_nameservers = """ <domain:ns>
13+
%s
14+
</domain:ns>"""
1515

16-
single_nameserver = " <domain:ns><domain:hostObj>%s</domain:hostObj></domain:ns>"
16+
single_nameserver = " <domain:hostObj>%s</domain:hostObj>"
1717

18-
single_nameserver2 = " <domain:ns><domain:hostObj>%s</domain:hostObj></domain:ns>"
18+
multiple_nameservers2 = """ <domain:ns>
19+
%s
20+
</domain:ns>"""
1921

22+
single_nameserver2 = " <domain:hostObj>%s</domain:hostObj>"
2023

2124
auth_info = """ <domain:authInfo><domain:pw>%s</domain:pw></domain:authInfo>
2225
"""
2326

2427
auth_info2 = """ <domain:authInfo><domain:pw>%s</domain:pw></domain:authInfo>
2528
"""
2629

27-
2830
period = '<domain:period unit="%(units)s">%(value)s</domain:period>'
2931

30-
3132
check = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
3233
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3334
<command>
@@ -40,7 +41,6 @@
4041
</command>
4142
</epp>"""
4243

43-
4444
info = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
4545
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
4646
<command>
@@ -53,7 +53,6 @@
5353
</command>
5454
</epp>"""
5555

56-
5756
create = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
5857
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
5958
<command>
@@ -72,7 +71,6 @@
7271
</command>
7372
</epp>"""
7473

75-
7674
renew = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
7775
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
7876
<command>
@@ -87,7 +85,6 @@
8785
</command>
8886
</epp>"""
8987

90-
9188
update = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
9289
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
9390
<command>
@@ -110,15 +107,13 @@
110107
</command>
111108
</epp>"""
112109

113-
114110
restore_request_extension = """
115111
<extension>
116112
<rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">
117113
<rgp:restore op="request"></rgp:restore>
118114
</rgp:update>
119115
</extension>"""
120116

121-
122117
restore_report_extension = """
123118
<extension>
124119
<rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">
@@ -137,7 +132,6 @@
137132
</rgp:update>
138133
</extension>"""
139134

140-
141135
transfer = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
142136
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
143137
<command>
@@ -151,7 +145,6 @@
151145
</command>
152146
</epp>"""
153147

154-
155148
transferstatus = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
156149
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
157150
<command>

src/epp/epp_client.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
import hashlib
66
import time
77
import re
8+
import warnings
89

910
from bs4 import BeautifulSoup # @UnresolvedImport
1011

12+
try:
13+
from bs4.builder import XMLParsedAsHTMLWarning # @UnresolvedImport
14+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
15+
except:
16+
pass
17+
1118
#------------------------------------------------------------------------------
1219

1320
logger = logging.getLogger(__name__)
@@ -109,7 +116,7 @@ def open(self, timeout=15):
109116
try:
110117
if self.cert_path and self.key_path:
111118
# Create an SSL context
112-
ssl_context = SSLContext(PROTOCOL_TLS_CLIENT)
119+
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
113120
# Load the client certificate and the key
114121
ssl_context.load_cert_chain(certfile=self.cert_path, keyfile=self.key_path, password=self.cert_password)
115122
# Remove warnings (Be careful)
@@ -444,9 +451,9 @@ def domain_create(self, domain_name, registrant, nameservers=[], period=1, perio
444451
cltrid=make_cltrid(),
445452
domain_name=domain_name,
446453
registrant=registrant,
447-
nameservers='\n'.join([
454+
nameservers=(commands.domain.multiple_nameservers % ('\n'.join([
448455
commands.domain.single_nameserver % ns for ns in nameservers
449-
]),
456+
]))) if nameservers else '',
450457
period='' if period is None else commands.domain.period % dict(value=period, units=period_units or 'y'),
451458
contact_admin='' if not contact_admin else commands.domain.single_contact1 % dict(type='admin', id=contact_admin),
452459
contact_billing='' if not contact_billing else commands.domain.single_contact1 % dict(type='billing', id=contact_billing),
@@ -475,12 +482,12 @@ def domain_update(self, domain_name, auth_info=None,
475482
cltrid=make_cltrid(),
476483
domain_name=domain_name,
477484
auth_info='' if not auth_info else commands.domain.auth_info2 % auth_info,
478-
add_nameservers='\n'.join([
485+
add_nameservers=(commands.domain.multiple_nameservers2 % ('\n'.join([
479486
commands.domain.single_nameserver2 % ns for ns in add_nameservers
480-
]),
481-
remove_nameservers='\n'.join([
487+
]))) if add_nameservers else '',
488+
remove_nameservers=(commands.domain.multiple_nameservers2 % ('\n'.join([
482489
commands.domain.single_nameserver2 % ns for ns in remove_nameservers
483-
]),
490+
]))) if remove_nameservers else '',
484491
add_contacts='\n'.join([
485492
commands.domain.single_contact2 % c for c in add_contacts
486493
]),

tests/epp/test_rpc_server.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,10 @@ def test_cmd_domain_create(self):
650650
<domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
651651
<domain:name>atest51.tld</domain:name>
652652
<domain:period unit="y">5</domain:period>
653-
<domain:ns><domain:hostObj>ns1.google.com</domain:hostObj></domain:ns>
654-
<domain:ns><domain:hostObj>ns2.google.com</domain:hostObj></domain:ns>
653+
<domain:ns>
654+
<domain:hostObj>ns1.google.com</domain:hostObj>
655+
<domain:hostObj>ns2.google.com</domain:hostObj>
656+
</domain:ns>
655657
<domain:registrant>registrant02</domain:registrant>
656658
<domain:contact type="admin">admin02</domain:contact>
657659
<domain:contact type="billing">billing02</domain:contact>
@@ -740,7 +742,7 @@ def test_cmd_domain_update(self):
740742
'name': 'atest51.tld',
741743
'change_registrant': 'registrant03',
742744
'add_nameservers': ['ns3.google.com', ],
743-
'remove_nameservers': ['ns2.google.com', ],
745+
'remove_nameservers': ['ns2.google.com', 'ns3.google.com', ],
744746
'rgp_restore_report': {
745747
'pre_data': 'Pre-delete registration data not provided',
746748
'post_data': 'Post-restore registration data not provided',
@@ -767,11 +769,16 @@ def test_cmd_domain_update(self):
767769
<domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
768770
<domain:name>atest51.tld</domain:name>
769771
<domain:add>
770-
<domain:ns><domain:hostObj>ns3.google.com</domain:hostObj></domain:ns>
772+
<domain:ns>
773+
<domain:hostObj>ns3.google.com</domain:hostObj>
774+
</domain:ns>
771775
<domain:contact type="admin">admin03</domain:contact>
772776
</domain:add>
773777
<domain:rem>
774-
<domain:ns><domain:hostObj>ns2.google.com</domain:hostObj></domain:ns>
778+
<domain:ns>
779+
<domain:hostObj>ns2.google.com</domain:hostObj>
780+
<domain:hostObj>ns3.google.com</domain:hostObj>
781+
</domain:ns>
775782
<domain:contact type="tech">tech02</domain:contact>
776783
</domain:rem>
777784
<domain:chg>

0 commit comments

Comments
 (0)