diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index b1121ff4c..b8613634d 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -67,6 +67,17 @@ module Epp::ContactsHelper private + def validate_contact_create_request + @ph = params_hash['epp']['command']['create']['create'] + xml_attrs_present?(@ph, [['id'], + ['postalInfo'], + ['postalInfo', 'name'], + ['postalInfo', 'addr'], + ['postalInfo', 'addr', 'city'], + ['postalInfo', 'addr', 'cc'], + ['authInfo']]) + 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 8eb8dd7d8..cd77afda2 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -6,6 +6,15 @@ describe 'EPP Contact', epp: true do context 'with valid user' do before(:each) { Fabricate(:epp_user) } + 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') + expect(response[:results][1][:result_code]).to eq('2003') + + expect(response[:results][0][:msg]).to eq('Required parameter missing: cc') + expect(response[:results][1][:msg]).to eq('Required parameter missing: authInfo') + end + # incomplete it 'creates a contact' do response = epp_request('contacts/create.xml') diff --git a/spec/epp/requests/contacts/create_missing_attr.xml b/spec/epp/requests/contacts/create_missing_attr.xml new file mode 100644 index 000000000..9ccb9049c --- /dev/null +++ b/spec/epp/requests/contacts/create_missing_attr.xml @@ -0,0 +1,19 @@ + + + + + + sh8013 + + John Doe + + Dulles + + + jdoe@example.com + + + ABC-12345 + +