diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 85abb8b81..582a621ff 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -99,6 +99,7 @@ class Epp::ContactsController < EppController msg: I18n.t('errors.messages.required_attribute_missing', key: 'ident country code missing') } end + contact_org_disabled @prefix = nil requires 'extension > extdata > ident' end @@ -111,6 +112,7 @@ class Epp::ContactsController < EppController msg: I18n.t('errors.messages.required_parameter_missing', key: 'add, rem or chg') } end + contact_org_disabled requires 'id', 'authInfo > pw' @prefix = nil end @@ -120,4 +122,13 @@ class Epp::ContactsController < EppController requires 'id', 'authInfo > pw' @prefix = nil end + + def contact_org_disabled + return true if ENV['contact_org_enabled'] == 'true' + return true if params[:parsed_frame].css('postalInfo org').text.blank? + epp_errors << { + code: '2306', + msg: I18n.t(:parameter_value_policy_error) + } + end end diff --git a/config/application-example.yml b/config/application-example.yml index 31e5771fc..3e621f04a 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -3,6 +3,10 @@ app_name: .EE Registry zonefile_export_dir: 'export/zonefiles' +# Contact epp will not accept org value by default +# and returns 2306 "Parameter value policy error" +contact_org_enabled: 'false' + # You can use `rake secret` to generate a secure secret key. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! diff --git a/config/locales/en.yml b/config/locales/en.yml index 49263383b..7b02af598 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -489,3 +489,4 @@ en: sign_this_request: 'Sign this request' revoke_this_certificate: 'Revoke this certificate' crt_revoked: 'CRT (revoked)' + parameter_value_policy_error: 'Parameter value policy error' diff --git a/doc/epp/contact.md b/doc/epp/contact.md index f6b8ed8eb..49857ae04 100644 --- a/doc/epp/contact.md +++ b/doc/epp/contact.md @@ -16,7 +16,7 @@ Contact Mapping protocol short version: 0-1 Contact id, optional, generated automatically if missing 1 Postal information container 1 Full name of the contact - 0-1 Name of organization + 0 Org is not supported and should be blank 1 Address container 0-n Street name 1 City name @@ -47,7 +47,7 @@ Contact Mapping protocol short version: 1 Change container 1 Postal information container 0-1 Full name of the contact - 0-1 Name of organization + 0 Org is not supported and should be blank 0-1 Address container 0-n Street name 0-1 City name diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index d4ff7dfe8..0308575fc 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -138,15 +138,20 @@ describe 'EPP Contact', epp: true do end it 'successfully saves custom code' do - response = create_request( - { id: { value: '12345' } } - ) - + response = create_request({ id: { value: '12345' } }) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' Contact.last.code.should == 'registrar1:12345' end + + it 'should return parameter value policy errror' do + response = create_request({ postalInfo: { org: { value: 'should not save' } } }) + response[:msg].should == 'Parameter value policy error' + response[:result_code].should == '2306' + + Contact.last.org_name.should == nil + end end context 'update command' do @@ -269,6 +274,19 @@ describe 'EPP Contact', epp: true do Contact.find_by(code: 'sh8013').ident_type.should == 'birthday' end + + it 'should return parameter value policy errror for org update' do + response = update_request({ + id: { value: 'sh8013' }, + chg: { + postalInfo: { org: { value: 'should not save' } } + } + }) + response[:msg].should == 'Parameter value policy error' + response[:result_code].should == '2306' + + Contact.find_by(code: 'sh8013').org_name.should == nil + end end context 'delete command' do