mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
Allow changing auth info on contact update #2833
This commit is contained in:
parent
ba5d1b8e4d
commit
2598b4aa2f
5 changed files with 40 additions and 24 deletions
|
@ -60,7 +60,7 @@ class Epp::ContactsController < EppController
|
||||||
|
|
||||||
def find_contact
|
def find_contact
|
||||||
code = params[:parsed_frame].css('id').text.strip.upcase
|
code = params[:parsed_frame].css('id').text.strip.upcase
|
||||||
|
|
||||||
@contact = Epp::Contact.find_by_epp_code(code)
|
@contact = Epp::Contact.find_by_epp_code(code)
|
||||||
|
|
||||||
if @contact.blank?
|
if @contact.blank?
|
||||||
|
|
|
@ -244,9 +244,9 @@ class Contact < ActiveRecord::Base
|
||||||
@generate_auth_info_disabled = true
|
@generate_auth_info_disabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def auth_info=(pw)
|
# def auth_info=(pw)
|
||||||
self[:auth_info] = pw if new_record?
|
# self[:auth_info] = pw if new_record?
|
||||||
end
|
# end
|
||||||
|
|
||||||
def code=(code)
|
def code=(code)
|
||||||
self[:code] = code if new_record? # cannot change code later
|
self[:code] = code if new_record? # cannot change code later
|
||||||
|
|
|
@ -26,8 +26,8 @@ class Epp::Contact < Contact
|
||||||
f = frame
|
f = frame
|
||||||
at = {}.with_indifferent_access
|
at = {}.with_indifferent_access
|
||||||
if rem
|
if rem
|
||||||
at[:name] = nil if f.css('postalInfo name').present?
|
at[:name] = nil if f.css('postalInfo name').present?
|
||||||
at[:org_name] = nil if f.css('postalInfo org').present?
|
at[:org_name] = nil if f.css('postalInfo org').present?
|
||||||
at[:email] = nil if f.css('email').present?
|
at[:email] = nil if f.css('email').present?
|
||||||
at[:fax] = nil if f.css('fax').present?
|
at[:fax] = nil if f.css('fax').present?
|
||||||
at[:phone] = nil if f.css('voice').present?
|
at[:phone] = nil if f.css('voice').present?
|
||||||
|
@ -37,8 +37,8 @@ class Epp::Contact < Contact
|
||||||
at[:state] = nil if f.css('postalInfo addr sp').present?
|
at[:state] = nil if f.css('postalInfo addr sp').present?
|
||||||
at[:country_code] = nil if f.css('postalInfo addr cc').present?
|
at[:country_code] = nil if f.css('postalInfo addr cc').present?
|
||||||
else
|
else
|
||||||
at[:name] = f.css('postalInfo name').text if f.css('postalInfo name').present?
|
at[:name] = f.css('postalInfo name').text if f.css('postalInfo name').present?
|
||||||
at[:org_name] = f.css('postalInfo org').text if f.css('postalInfo org').present?
|
at[:org_name] = f.css('postalInfo org').text if f.css('postalInfo org').present?
|
||||||
at[:email] = f.css('email').text if f.css('email').present?
|
at[:email] = f.css('email').text if f.css('email').present?
|
||||||
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?
|
||||||
|
@ -47,12 +47,12 @@ class Epp::Contact < Contact
|
||||||
at[:street] = f.css('postalInfo addr street').text if f.css('postalInfo addr street').present?
|
at[:street] = f.css('postalInfo addr street').text if f.css('postalInfo addr street').present?
|
||||||
at[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
|
at[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
|
||||||
at[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
|
at[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').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?
|
||||||
end
|
end
|
||||||
|
|
||||||
legal_frame = f.css('legalDocument').first
|
legal_frame = f.css('legalDocument').first
|
||||||
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.merge!(ident_attrs(f.css('ident').first))
|
||||||
at
|
at
|
||||||
|
@ -154,7 +154,7 @@ class Epp::Contact < Contact
|
||||||
at.deep_merge!(self.class.attrs_from(frame.css('add')))
|
at.deep_merge!(self.class.attrs_from(frame.css('add')))
|
||||||
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
||||||
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)
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
super(at)
|
super(at)
|
||||||
end
|
end
|
||||||
|
|
|
@ -515,6 +515,22 @@ describe 'EPP Contact', epp: true do
|
||||||
Setting.client_status_editing_enabled = true
|
Setting.client_status_editing_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should update auth info' do
|
||||||
|
xml = @epp_xml.update({
|
||||||
|
id: { value: 'FIRST0:SH8013' },
|
||||||
|
chg: {
|
||||||
|
authInfo: { pw: { value: 'newpassword' } }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
puts Nokogiri xml
|
||||||
|
response = epp_plain_request(xml, :xml)
|
||||||
|
response[:results][0][:msg].should == 'Command completed successfully'
|
||||||
|
response[:results][0][:result_code].should == '1000'
|
||||||
|
|
||||||
|
contact = Contact.find_by(code: 'FIRST0:SH8013')
|
||||||
|
contact.auth_info.should == 'newpassword'
|
||||||
|
end
|
||||||
|
|
||||||
it 'should add value voice value' do
|
it 'should add value voice value' do
|
||||||
xml = @epp_xml.update({
|
xml = @epp_xml.update({
|
||||||
id: { value: 'FIRST0:SH8013' },
|
id: { value: 'FIRST0:SH8013' },
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe Contact do
|
||||||
"City is missing",
|
"City is missing",
|
||||||
"Country code is missing",
|
"Country code is missing",
|
||||||
"Street is missing",
|
"Street is missing",
|
||||||
"Zip is missing"
|
"Zip is missing"
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ describe Contact do
|
||||||
@contact.ident_country_code = 'INVALID'
|
@contact.ident_country_code = 'INVALID'
|
||||||
@contact.valid?
|
@contact.valid?
|
||||||
|
|
||||||
@contact.errors[:ident].should ==
|
@contact.errors[:ident].should ==
|
||||||
['Ident country code is not valid, should be in ISO_3166-1 alpha 2 format']
|
['Ident country code is not valid, should be in ISO_3166-1 alpha 2 format']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ describe Contact do
|
||||||
|
|
||||||
it 'should not remove ok status after save' do
|
it 'should not remove ok status after save' do
|
||||||
@contact.statuses.should == %w(ok)
|
@contact.statuses.should == %w(ok)
|
||||||
@contact.save
|
@contact.save
|
||||||
@contact.statuses.should == %w(ok)
|
@contact.statuses.should == %w(ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -296,8 +296,8 @@ describe Contact do
|
||||||
|
|
||||||
context 'after create' do
|
context 'after create' do
|
||||||
it 'should not generate a new code when code is present' do
|
it 'should not generate a new code when code is present' do
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = Fabricate.build(:contact,
|
||||||
code: 'FIXED:new-code',
|
code: 'FIXED:new-code',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact.code.should == 'FIXED:new-code' # still new record
|
@contact.code.should == 'FIXED:new-code' # still new record
|
||||||
@contact.save.should == true
|
@contact.save.should == true
|
||||||
|
@ -305,15 +305,15 @@ describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not allaw to use same code' do
|
it 'should not allaw to use same code' do
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = Fabricate.build(:contact,
|
||||||
code: 'FIXED:new-code',
|
code: 'FIXED:new-code',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact.code.should == 'FIXED:new-code' # still new record
|
@contact.code.should == 'FIXED:new-code' # still new record
|
||||||
@contact.save.should == true
|
@contact.save.should == true
|
||||||
@contact.code.should == 'FIXED:NEW-CODE'
|
@contact.code.should == 'FIXED:NEW-CODE'
|
||||||
|
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = Fabricate.build(:contact,
|
||||||
code: 'FIXED:new-code',
|
code: 'FIXED:new-code',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact.code.should == 'FIXED:new-code' # still new record
|
@contact.code.should == 'FIXED:new-code' # still new record
|
||||||
@contact.valid?
|
@contact.valid?
|
||||||
|
@ -321,10 +321,10 @@ describe Contact do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should generate a new password' do
|
it 'should generate a new password' do
|
||||||
@contact = Fabricate.build(:contact, code: '123asd', auth_info: 'qwe321')
|
@contact = Fabricate.build(:contact, code: '123asd', auth_info: nil)
|
||||||
@contact.auth_info.should == 'qwe321'
|
@contact.auth_info.should == nil
|
||||||
@contact.save.should == true
|
@contact.save.should == true
|
||||||
@contact.auth_info.should_not == 'qwe321'
|
@contact.auth_info.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not allow same code' do
|
it 'should not allow same code' do
|
||||||
|
@ -359,7 +359,7 @@ describe Contact do
|
||||||
|
|
||||||
context 'after update' do
|
context 'after update' do
|
||||||
before :all do
|
before :all do
|
||||||
@contact = Fabricate.build(:contact,
|
@contact = Fabricate.build(:contact,
|
||||||
code: '123asd',
|
code: '123asd',
|
||||||
auth_info: 'qwe321')
|
auth_info: 'qwe321')
|
||||||
@contact.save
|
@contact.save
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue