mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +02:00
Ident now in extension section
This commit is contained in:
parent
cec7a27177
commit
58176b3cfa
4 changed files with 81 additions and 36 deletions
|
@ -90,7 +90,7 @@ class Epp::ContactsController < EppController
|
||||||
@prefix = 'create > create >'
|
@prefix = 'create > create >'
|
||||||
requires(
|
requires(
|
||||||
'postalInfo > name', 'postalInfo > addr > city',
|
'postalInfo > name', 'postalInfo > addr > city',
|
||||||
'postalInfo > addr > cc', 'ident', 'voice', 'email'
|
'postalInfo > addr > cc', 'voice', 'email'
|
||||||
)
|
)
|
||||||
ident = params[:parsed_frame].css('ident')
|
ident = params[:parsed_frame].css('ident')
|
||||||
if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank?
|
if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank?
|
||||||
|
@ -100,6 +100,7 @@ class Epp::ContactsController < EppController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@prefix = nil
|
@prefix = nil
|
||||||
|
requires 'extension > extdata > ident'
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_update
|
def validate_update
|
||||||
|
|
|
@ -18,13 +18,6 @@ class Epp::Contact < Contact
|
||||||
at[:fax] = f.css('fax').text if f.css('fax').present?
|
at[:fax] = f.css('fax').text if f.css('fax').present?
|
||||||
at[:phone] = f.css('voice').text if f.css('voice').present?
|
at[:phone] = f.css('voice').text if f.css('voice').present?
|
||||||
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
|
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
|
||||||
|
|
||||||
if f.css('ident').present? && f.css('ident').attr('type').present?
|
|
||||||
at[:ident] = f.css('ident').text
|
|
||||||
at[:ident_type] = f.css('ident').attr('type').try(:text)
|
|
||||||
at[:ident_country_code] = f.css('ident').attr('cc').try(:text)
|
|
||||||
end
|
|
||||||
|
|
||||||
at[:address_attributes] = {}.with_indifferent_access
|
at[:address_attributes] = {}.with_indifferent_access
|
||||||
sat = at[:address_attributes]
|
sat = at[:address_attributes]
|
||||||
sat[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
|
sat[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
|
||||||
|
@ -38,7 +31,7 @@ class Epp::Contact < Contact
|
||||||
if legal_frame.present?
|
if legal_frame.present?
|
||||||
at[:legal_documents_attributes] = legal_document_attrs(legal_frame)
|
at[:legal_documents_attributes] = legal_document_attrs(legal_frame)
|
||||||
end
|
end
|
||||||
|
at.merge!(ident_attrs(f.css('ident').first))
|
||||||
at
|
at
|
||||||
end
|
end
|
||||||
# rubocop: enable Metrics/MethodLength
|
# rubocop: enable Metrics/MethodLength
|
||||||
|
@ -63,10 +56,27 @@ class Epp::Contact < Contact
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ident_attrs(ident_frame)
|
||||||
|
return {} if ident_frame.blank?
|
||||||
|
return {} if ident_frame.try('text').blank?
|
||||||
|
return {} if ident_frame.attr('type').blank?
|
||||||
|
return {} if ident_frame.attr('cc').blank?
|
||||||
|
|
||||||
|
{
|
||||||
|
ident: ident_frame.text,
|
||||||
|
ident_type: ident_frame.attr('type'),
|
||||||
|
ident_country_code: ident_frame.attr('cc')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def legal_document_attrs(legal_frame)
|
def legal_document_attrs(legal_frame)
|
||||||
|
return [] if legal_frame.blank?
|
||||||
|
return [] if legal_frame.try('text').blank?
|
||||||
|
return [] if legal_frame.attr('type').blank?
|
||||||
|
|
||||||
[{
|
[{
|
||||||
body: legal_frame.text,
|
body: legal_frame.text,
|
||||||
document_type: legal_frame['type']
|
document_type: legal_frame.attr('type')
|
||||||
}]
|
}]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,6 +103,7 @@ class Epp::Contact < Contact
|
||||||
return super if frame.blank?
|
return super if frame.blank?
|
||||||
at = {}.with_indifferent_access
|
at = {}.with_indifferent_access
|
||||||
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
||||||
|
at.merge!(self.class.ident_attrs(frame.css('ident').first))
|
||||||
legal_frame = frame.css('legalDocument').first
|
legal_frame = frame.css('legalDocument').first
|
||||||
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@ Contact Mapping protocol short version:
|
||||||
<contact:cc> 1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2
|
<contact:cc> 1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2
|
||||||
<contact:voice> 1 Phone number in format \+ddd.d+
|
<contact:voice> 1 Phone number in format \+ddd.d+
|
||||||
<contact:email> 1 E-mail
|
<contact:email> 1 E-mail
|
||||||
<contact:ident> 1 Contact identificator
|
<extension> 1
|
||||||
|
<eis:extdata> 1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
||||||
|
<eis:ident> 1 Contact identificator
|
||||||
Attribute: type="bic/priv/birthday"
|
Attribute: type="bic/priv/birthday"
|
||||||
"bic" # Business registry code
|
"bic" # Business registry code
|
||||||
"priv" # National idendtification number
|
"priv" # National idendtification number
|
||||||
"birthday" # Birthday date in format in DD-MM-YYYY
|
"birthday" # Birthday date in format in DD-MM-YYYY
|
||||||
<extension> 1
|
<eis:legalDocument> 0-1 Base64 encoded document
|
||||||
<eis:extdata> 1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
|
||||||
<eis:legalDocument> 1 Base64 encoded document
|
|
||||||
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
||||||
|
|
||||||
[EXAMPLE REQUEST AND RESPONSE](/doc/epp-examples.md#epp-contact-with-valid-user-create-command-successfully-creates-a-contact)
|
[EXAMPLE REQUEST AND RESPONSE](/doc/epp-examples.md#epp-contact-with-valid-user-create-command-successfully-creates-a-contact)
|
||||||
|
@ -56,15 +56,15 @@ Contact Mapping protocol short version:
|
||||||
<contact:cc> 0-1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2
|
<contact:cc> 0-1 Country code, 2 letters uppercase, in ISO_3166-1 alpha 2
|
||||||
<contact:voice> 0-1 Phone number in format \+ddd.d+
|
<contact:voice> 0-1 Phone number in format \+ddd.d+
|
||||||
<contact:email> 0-1 E-mail
|
<contact:email> 0-1 E-mail
|
||||||
<contact:ident> 0-1 Contact identificator
|
|
||||||
Attribute: type="bic/priv/birthday"
|
|
||||||
"bic" # Business registry code
|
|
||||||
"priv" # National idendtification number
|
|
||||||
"birthday" # Birthday date in format in DD-MM-YYYY
|
|
||||||
<contact:authInfo> 0-1 Required if registrar is not the owner of the contact.
|
<contact:authInfo> 0-1 Required if registrar is not the owner of the contact.
|
||||||
<contact:pw> 1 Contact password. Attribute: roid="String"
|
<contact:pw> 1 Contact password. Attribute: roid="String"
|
||||||
<extension> 0-1
|
<extension> 0-1
|
||||||
<eis:extdata> 0-1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
<eis:extdata> 0-1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
||||||
|
<eis:ident> 0-1 Contact identificator
|
||||||
|
Attribute: type="bic/priv/birthday"
|
||||||
|
"bic" # Business registry code
|
||||||
|
"priv" # National idendtification number
|
||||||
|
"birthday" # Birthday date in format in DD-MM-YYYY
|
||||||
<eis:legalDocument> 0-1 Base64 encoded document.
|
<eis:legalDocument> 0-1 Base64 encoded document.
|
||||||
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ Contact Mapping protocol short version:
|
||||||
<contact:id> 1 Contact id
|
<contact:id> 1 Contact id
|
||||||
<contact:authInfo> 0-1 Required if registrar is not the owner of the contact.
|
<contact:authInfo> 0-1 Required if registrar is not the owner of the contact.
|
||||||
<contact:pw> 1 Contact password. Attribute: roid="String"
|
<contact:pw> 1 Contact password. Attribute: roid="String"
|
||||||
<extension> 1
|
<extension> 0-1
|
||||||
<eis:extdata> 1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
<eis:extdata> 0-1 Attribute: xmlns:eis="urn:ee:eis:xml:epp:eis-1.0"
|
||||||
<eis:legalDocument> 1 Base64 encoded document.
|
<eis:legalDocument> 0-1 Base64 encoded document.
|
||||||
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
Attribute: type="pdf/bdoc/ddoc/zip/rar/gz/tar/7z"
|
||||||
<clTRID> 0-1 Client transaction id
|
<clTRID> 0-1 Client transaction id
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,23 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
@contact = Fabricate(:contact, registrar: @registrar1)
|
@contact = Fabricate(:contact, registrar: @registrar1)
|
||||||
|
|
||||||
@legal_document = {
|
@extension = {
|
||||||
legalDocument: {
|
legalDocument: {
|
||||||
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
attrs: { type: 'pdf' }
|
attrs: { type: 'pdf' }
|
||||||
|
},
|
||||||
|
ident: {
|
||||||
|
value: '37605030299',
|
||||||
|
attrs: { type: 'priv', cc: 'EE' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid user' do
|
context 'with valid user' do
|
||||||
context 'create command' do
|
context 'create command' do
|
||||||
def create_request(overwrites = {})
|
def create_request(overwrites = {}, extension = {})
|
||||||
|
extension = @extension if extension.blank?
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
postalInfo: {
|
postalInfo: {
|
||||||
name: { value: 'John Doe' },
|
name: { value: 'John Doe' },
|
||||||
|
@ -36,10 +42,9 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
voice: { value: '+372.1234567' },
|
voice: { value: '+372.1234567' },
|
||||||
email: { value: 'test@example.example' },
|
email: { value: 'test@example.example' }
|
||||||
ident: { value: '37605030299', attrs: { type: 'priv', cc: 'EE' } }
|
|
||||||
}
|
}
|
||||||
create_xml = @epp_xml.create(defaults.deep_merge(overwrites), @legal_document)
|
create_xml = @epp_xml.create(defaults.deep_merge(overwrites), extension)
|
||||||
epp_plain_request(create_xml, :xml)
|
epp_plain_request(create_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,11 +57,11 @@ describe 'EPP Contact', epp: true do
|
||||||
response[:results][2][:msg].should ==
|
response[:results][2][:msg].should ==
|
||||||
'Required parameter missing: create > create > postalInfo > addr > cc [cc]'
|
'Required parameter missing: create > create > postalInfo > addr > cc [cc]'
|
||||||
response[:results][3][:msg].should ==
|
response[:results][3][:msg].should ==
|
||||||
'Required parameter missing: create > create > ident [ident]'
|
|
||||||
response[:results][4][:msg].should ==
|
|
||||||
'Required parameter missing: create > create > voice [voice]'
|
'Required parameter missing: create > create > voice [voice]'
|
||||||
response[:results][5][:msg].should ==
|
response[:results][4][:msg].should ==
|
||||||
'Required parameter missing: create > create > email [email]'
|
'Required parameter missing: create > create > email [email]'
|
||||||
|
response[:results][5][:msg].should ==
|
||||||
|
'Required parameter missing: extension > extdata > ident [ident]'
|
||||||
|
|
||||||
response[:results][0][:result_code].should == '2003'
|
response[:results][0][:result_code].should == '2003'
|
||||||
response[:results][1][:result_code].should == '2003'
|
response[:results][1][:result_code].should == '2003'
|
||||||
|
@ -91,9 +96,17 @@ describe 'EPP Contact', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'successfully saves ident type' do
|
it 'successfully saves ident type' do
|
||||||
response = create_request(
|
extension = {
|
||||||
{ ident: { value: '1990-22-12', attrs: { type: 'birthday' } } }
|
legalDocument: {
|
||||||
)
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
},
|
||||||
|
ident: {
|
||||||
|
value: '1990-22-12',
|
||||||
|
attrs: { type: 'birthday', cc: 'US' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response = create_request({}, extension)
|
||||||
|
|
||||||
response[:msg].should == 'Command completed successfully'
|
response[:msg].should == 'Command completed successfully'
|
||||||
response[:result_code].should == '1000'
|
response[:result_code].should == '1000'
|
||||||
|
@ -147,7 +160,9 @@ describe 'EPP Contact', epp: true do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_request(overwrites = {})
|
def update_request(overwrites = {}, extension = {})
|
||||||
|
extension = @extension if extension.blank?
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
id: { value: 'asd123123er' },
|
id: { value: 'asd123123er' },
|
||||||
authInfo: { pw: { value: 'password' } },
|
authInfo: { pw: { value: 'password' } },
|
||||||
|
@ -165,7 +180,7 @@ describe 'EPP Contact', epp: true do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_xml = @epp_xml.update(defaults.deep_merge(overwrites), @legal_document)
|
update_xml = @epp_xml.update(defaults.deep_merge(overwrites), extension)
|
||||||
epp_plain_request(update_xml, :xml)
|
epp_plain_request(update_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -236,6 +251,24 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
@contact.reload.code.should == 'sh8013'
|
@contact.reload.code.should == 'sh8013'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should update ident' do
|
||||||
|
extension = {
|
||||||
|
legalDocument: {
|
||||||
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
attrs: { type: 'pdf' }
|
||||||
|
},
|
||||||
|
ident: {
|
||||||
|
value: '1990-22-12',
|
||||||
|
attrs: { type: 'birthday', cc: 'US' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response = update_request({ id: { value: 'sh8013' } }, extension)
|
||||||
|
response[:msg].should == 'Command completed successfully'
|
||||||
|
response[:result_code].should == '1000'
|
||||||
|
|
||||||
|
Contact.find_by(code: 'sh8013').ident_type.should == 'birthday'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'delete command' do
|
context 'delete command' do
|
||||||
|
@ -248,7 +281,7 @@ describe 'EPP Contact', epp: true do
|
||||||
id: { value: @contact.code },
|
id: { value: @contact.code },
|
||||||
authInfo: { pw: { value: @contact.auth_info } }
|
authInfo: { pw: { value: @contact.auth_info } }
|
||||||
}
|
}
|
||||||
delete_xml = @epp_xml.delete(defaults.deep_merge(overwrites), @legal_document)
|
delete_xml = @epp_xml.delete(defaults.deep_merge(overwrites), @extension)
|
||||||
epp_plain_request(delete_xml, :xml)
|
epp_plain_request(delete_xml, :xml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue