diff --git a/app/controllers/repp/v1/domains_controller.rb b/app/controllers/repp/v1/domains_controller.rb index 99d8c44e5..56de83661 100644 --- a/app/controllers/repp/v1/domains_controller.rb +++ b/app/controllers/repp/v1/domains_controller.rb @@ -28,6 +28,8 @@ module Repp param :domain, Hash, required: true, desc: 'Parameters for new domain' do param :name, String, required: true, desc: 'Domain name to be registered' param :registrant, String, required: true, desc: 'Registrant contact code' + param :reserved_pw, String, required: false, desc: 'Reserved password for domain' + param :transfer_code, String, required: false, desc: 'Desired transfer code for domain' param :period, Integer, required: true, desc: 'Registration period in months or years' param :period_unit, String, required: true, desc: 'Period type (month m) or (year y)' param :nameservers_attributes, Array, required: false, desc: 'Domain nameservers' do @@ -71,7 +73,7 @@ module Repp param :verified, [true, false], required: false, desc: 'Registrant change is already verified' end - param :auth_info, String, required: false, desc: 'New authorization code' + param :transfer_code, String, required: false, desc: 'New authorization code' end def update action = Actions::DomainUpdate.new(@domain, params[:domain], false) @@ -215,10 +217,10 @@ module Repp def domain_create_params params.require(:domain).permit(:name, :registrant, :period, :period_unit, :registrar, + :transfer_code, :reserved_pw, dnskeys_attributes: [%i[flags alg protocol public_key]], nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]], - admin_contacts: [], - tech_contacts: []) + admin_contacts: [], tech_contacts: []) end end end diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb index 0df036654..7da22e539 100644 --- a/app/interactions/actions/domain_update.rb +++ b/app/interactions/actions/domain_update.rb @@ -35,7 +35,7 @@ module Actions end def validate_domain_integrity - domain.auth_info = params[:auth_info] if params[:auth_info] + domain.auth_info = params[:transfer_code] if params[:transfer_code] return unless domain.discarded? diff --git a/lib/deserializers/xml/domain_update.rb b/lib/deserializers/xml/domain_update.rb index 86250a368..eb1b22296 100644 --- a/lib/deserializers/xml/domain_update.rb +++ b/lib/deserializers/xml/domain_update.rb @@ -15,7 +15,7 @@ module Deserializers def call obj = { domain: frame.css('name')&.text, registrant: registrant, contacts: contacts, - auth_info: if_present('authInfo > pw'), nameservers: nameservers, + transfer_code: if_present('authInfo > pw'), nameservers: nameservers, registrar_id: registrar, statuses: statuses, dns_keys: dns_keys, reserved_pw: if_present('reserved > pw'), legal_document: @legal_document } diff --git a/lib/serializers/repp/domain.rb b/lib/serializers/repp/domain.rb index 5821e1568..0f81b6417 100644 --- a/lib/serializers/repp/domain.rb +++ b/lib/serializers/repp/domain.rb @@ -12,7 +12,7 @@ module Serializers name: obj.name, registrant: obj.registrant.code, created_at: obj.created_at, updated_at: obj.updated_at, expire_time: obj.expire_time, outzone_at: obj.outzone_at, delete_date: obj.delete_date, force_delete_date: obj.force_delete_date, - authorization_code: obj.auth_info, contacts: contacts, nameservers: nameservers, + transfer_code: obj.auth_info, contacts: contacts, nameservers: nameservers, dnssec_keys: dnssec_keys, statuses: obj.statuses } diff --git a/test/integration/repp/v1/domains/create_test.rb b/test/integration/repp/v1/domains/create_test.rb index bcce43e58..7907e709e 100644 --- a/test/integration/repp/v1/domains/create_test.rb +++ b/test/integration/repp/v1/domains/create_test.rb @@ -110,4 +110,28 @@ class ReppV1DomainsCreateTest < ActionDispatch::IntegrationTest assert_equal tech_contact, domain.tech_domain_contacts.first.contact assert_equal admin_contact, domain.admin_domain_contacts.first.contact end + + def test_creates_new_domain_with_desired_transfer_code + @auth_headers['Content-Type'] = 'application/json' + contact = contacts(:john) + + payload = { + domain: { + name: 'domeener.test', + registrant: contact.code, + transfer_code: 'ABADIATS', + period: 1, + period_unit: 'y' + } + } + + post "/repp/v1/domains", headers: @auth_headers, params: payload.to_json + json = JSON.parse(response.body, symbolize_names: true) + assert_response :ok + assert_equal 1000, json[:code] + assert_equal 'Command completed successfully', json[:message] + + assert @user.registrar.domains.find_by(name: 'domeener.test').present? + assert_equal 'ABADIATS', @user.registrar.domains.find_by(name: 'domeener.test').transfer_code + end end