Allow changing auth info on contact update #2833

This commit is contained in:
Martin Lensment 2015-08-13 14:20:39 +03:00
parent ba5d1b8e4d
commit 2598b4aa2f
5 changed files with 40 additions and 24 deletions

View file

@ -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

View file

@ -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' },

View file

@ -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