Contact info request should return smaal contact info when pw is blank

This commit is contained in:
Priit Tark 2015-04-01 12:02:24 +03:00
parent 6f9660d413
commit a994767330
2 changed files with 19 additions and 3 deletions

View file

@ -19,6 +19,7 @@ class Ability
# rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/LineLength
def epp def epp
# Epp::Domain # Epp::Domain
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw } can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
@ -29,7 +30,7 @@ class Ability
can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw } can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw }
# Epp::Contact # Epp::Contact
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw } can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw }
can(:view_full_info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw } can(:view_full_info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
can(:check, Epp::Contact) can(:check, Epp::Contact)
can(:create, Epp::Contact) can(:create, Epp::Contact)
@ -38,6 +39,7 @@ class Ability
can(:renew, Epp::Contact) can(:renew, Epp::Contact)
can(:view_password, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw } can(:view_password, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
end end
# rubocop: enable Metrics/LineLength
# rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/PerceivedComplexity

View file

@ -519,7 +519,7 @@ describe 'EPP Contact', epp: true do
response[:results].count.should == 1 response[:results].count.should == 1
end end
it 'returns no authorization error for wrong user but correct pw' do it 'returns no authorization error for wrong user but correct password' do
login_as :registrar2 do login_as :registrar2 do
response = info_request response = info_request
@ -534,7 +534,7 @@ describe 'EPP Contact', epp: true do
end end
end end
it 'returns authorization error for wrong user and wrong pw' do it 'returns authorization error for wrong user and wrong password' do
login_as :registrar2 do login_as :registrar2 do
response = info_request({ authInfo: { pw: { value: 'wrong-pw' } } }) response = info_request({ authInfo: { pw: { value: 'wrong-pw' } } })
response[:msg].should == 'Authorization error' response[:msg].should == 'Authorization error'
@ -547,6 +547,20 @@ describe 'EPP Contact', epp: true do
contact.css('voice').first.try(:text).should == nil contact.css('voice').first.try(:text).should == nil
end end
end end
it 'returns no authorization error for wrong user and no password' do
login_as :registrar2 do
response = info_request({ authInfo: { pw: { value: '' } } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
response[:results].count.should == 1
contact = response[:parsed].css('resData infData')
contact.css('postalInfo addr city').first.try(:text).should == nil
contact.css('email').first.try(:text).should == nil
contact.css('voice').first.try(:text).should == nil
end
end
end end
context 'renew command' do context 'renew command' do