From 2f0b0c35d42804f59ee4eb2d9a35a1b4d639cfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20Keskk=C3=BCla?= Date: Mon, 11 Aug 2014 15:52:16 +0300 Subject: [PATCH] Validateing rest of the contact requests --- app/helpers/epp/contacts_helper.rb | 22 +++++++++++++++++++ spec/epp/contact_spec.rb | 8 +++++++ .../requests/contacts/update_missing_attr.xml | 11 ++++++++++ 3 files changed, 41 insertions(+) create mode 100644 spec/epp/requests/contacts/update_missing_attr.xml diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index b8613634d..ec4195446 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -10,6 +10,7 @@ module Epp::ContactsHelper end def update_contact + #TODO add support for rem and add code = params_hash['epp']['command']['update']['update'][:id] @contact = Contact.where(code: code).first stamp @contact @@ -78,6 +79,27 @@ module Epp::ContactsHelper ['authInfo']]) end + def validate_contact_update_request + @ph = params_hash['epp']['command']['update']['update'] + xml_attrs_present?(@ph, [['id'] ]) + end + + def validate_contact_delete_request + @ph = params_hash['epp']['command']['delete']['delete'] + xml_attrs_present?(@ph, [ ['id'] ] ) + end + + def validate_contact_check_request + @ph = params_hash['epp']['command']['check']['check'] + xml_attrs_present?(@ph, [ ['id'] ]) + end + + def validate_contact_info_request + @ph = params_hash['epp']['command']['info']['info'] + xml_attrs_present?(@ph, [ ['id'] ]) + end + + def contact_and_address_attributes ph = params_hash['epp']['command'][params[:command]][params[:command]] ph = ph[:chg] if params[:command] == 'update' diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index cd77afda2..afe805a9b 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -6,6 +6,7 @@ describe 'EPP Contact', epp: true do context 'with valid user' do before(:each) { Fabricate(:epp_user) } + #Tests for the new error system it "doesn't create contact with attributes missing" do response = epp_request('contacts/create_missing_attr.xml') expect(response[:results][0][:result_code]).to eq('2003') @@ -15,6 +16,13 @@ describe 'EPP Contact', epp: true do expect(response[:results][1][:msg]).to eq('Required parameter missing: authInfo') end + it "doesn't update contact with attributes missing" do + response = epp_request('contacts/update_missing_attr.xml') + + expect(response[:results][0][:result_code]).to eq('2003') + expect(response[:results][0][:msg]).to eq('Required parameter missing: id') + end + # incomplete it 'creates a contact' do response = epp_request('contacts/create.xml') diff --git a/spec/epp/requests/contacts/update_missing_attr.xml b/spec/epp/requests/contacts/update_missing_attr.xml new file mode 100644 index 000000000..f8e17a8a1 --- /dev/null +++ b/spec/epp/requests/contacts/update_missing_attr.xml @@ -0,0 +1,11 @@ + + + + + + + + ABC-12345 + +