diff --git a/app/controllers/repp/v1/contacts_controller.rb b/app/controllers/repp/v1/contacts_controller.rb index d6c4439c5..f9c58303c 100644 --- a/app/controllers/repp/v1/contacts_controller.rb +++ b/app/controllers/repp/v1/contacts_controller.rb @@ -63,7 +63,7 @@ module Repp desc 'Check contact code availability' def check contact = Epp::Contact.find_by(code: params[:id]) - data = { contact: { id: params[:id], available: contact.nil? } } + data = { contact: { code: params[:id], available: contact.nil? } } render_success(data: data) end diff --git a/app/controllers/repp/v1/domains/renews_controller.rb b/app/controllers/repp/v1/domains/renews_controller.rb index 26365dffc..9aba3e41b 100644 --- a/app/controllers/repp/v1/domains/renews_controller.rb +++ b/app/controllers/repp/v1/domains/renews_controller.rb @@ -22,7 +22,7 @@ module Repp return end - render_success(data: { domain: { name: @domain.name, id: @domain.uuid } }) + render_success(data: { domain: { name: @domain.name } }) end def bulk_renew diff --git a/app/controllers/repp/v1/domains/statuses_controller.rb b/app/controllers/repp/v1/domains/statuses_controller.rb index ee15655df..d46725c46 100644 --- a/app/controllers/repp/v1/domains/statuses_controller.rb +++ b/app/controllers/repp/v1/domains/statuses_controller.rb @@ -7,7 +7,6 @@ module Repp api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status' param :domain_name, String, desc: 'Domain name' - param :status, String, desc: 'Status to be removed' desc 'Remove status from specific domain' def destroy return editing_failed unless domain_with_status?(params[:id]) @@ -22,7 +21,6 @@ module Repp api :PUT, '/repp/v1/domains/:domain_name/statuses/:status' param :domain_name, String, desc: 'Domain name' - param :status, String, desc: 'Status to be added' desc 'Add status to specific domain' def update return editing_failed if domain_with_status?(params[:id]) diff --git a/app/controllers/repp/v1/domains_controller.rb b/app/controllers/repp/v1/domains_controller.rb index 00005e84d..ba40b13e2 100644 --- a/app/controllers/repp/v1/domains_controller.rb +++ b/app/controllers/repp/v1/domains_controller.rb @@ -101,7 +101,7 @@ module Repp return end - render_success(data: { domain: { name: @domain.name, id: @domain.uuid } }) + render_success(data: { domain: { name: @domain.name } }) end api :GET, '/repp/v1/domains/:domain_name/transfer_info' diff --git a/app/controllers/repp/v1/registrar/nameservers_controller.rb b/app/controllers/repp/v1/registrar/nameservers_controller.rb index fbd4c03ec..b3c6d8412 100644 --- a/app/controllers/repp/v1/registrar/nameservers_controller.rb +++ b/app/controllers/repp/v1/registrar/nameservers_controller.rb @@ -30,7 +30,6 @@ module Repp .add_nameservers(hostname_params[:attributes], domains: domains_from_params) end - render_success(data: data_format_for_success(affected, errored)) rescue ActiveRecord::RecordInvalid => e handle_errors(e.record) @@ -49,14 +48,15 @@ module Repp type: 'nameserver', id: hostname_params[:attributes][:hostname], attributes: hostname_params[:attributes], - affected_domains: affected_domains, - skipped_domains: errored_domains, + affected_domains: affected_domains || [], + skipped_domains: errored_domains || [], } end def hostname_params - params.require(:data).permit(:type, :id, nameserver: [], domains: [], - attributes: [:hostname, { ipv4: [], ipv6: [] }]) + params.require(:data).permit(:type, :id, + :domains, nameserver: [], domains: [], + attributes: [:hostname, { ipv4: [], ipv6: [] }]) .tap do |data| data.require(:type) data.require(:attributes).require([:hostname]) diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb index 377f90e40..ff6eccce2 100644 --- a/app/interactions/actions/domain_update.rb +++ b/app/interactions/actions/domain_update.rb @@ -48,7 +48,7 @@ module Actions contact_code = params[:registrant][:code] contact = Contact.find_by(code: contact_code) - validate_email(contact.email) + validate_email(contact.email) if contact regt = Registrant.find_by(code: params[:registrant][:code]) unless regt diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 0ea0bfb13..4c0098de0 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -188,9 +188,9 @@ class Registrar < ApplicationRecord end def add_nameservers(new_attributes, domains: []) - transaction do - return if domains.empty? + return [] if domains.empty? + transaction do approved_list = domain_list_processing(domains: domains, new_attributes: new_attributes) self.domains.where(name: approved_list).find_each(&:update_whois_record) if approved_list.any? diff --git a/lib/serializers/repp/contact.rb b/lib/serializers/repp/contact.rb index 11d5457ae..5afab98f0 100644 --- a/lib/serializers/repp/contact.rb +++ b/lib/serializers/repp/contact.rb @@ -15,7 +15,7 @@ module Serializers def to_json(obj = contact) return simple_object if @simplify - json = { id: obj.uuid, code: obj.code, name: obj.name, ident: ident, phone: obj.phone, + json = { code: obj.code, name: obj.name, ident: ident, phone: obj.phone, created_at: obj.created_at, auth_info: obj.auth_info, email: obj.email, statuses: statuses, disclosed_attributes: obj.disclosed_attributes, registrar: registrar } diff --git a/lib/serializers/repp/domain.rb b/lib/serializers/repp/domain.rb index cd0be8e25..c851a1f0d 100644 --- a/lib/serializers/repp/domain.rb +++ b/lib/serializers/repp/domain.rb @@ -15,7 +15,7 @@ module Serializers return simple_object if @simplify json = { - id: obj.uuid, name: obj.name, registrant: registrant, + name: obj.name, registrant: registrant, 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, @@ -53,7 +53,6 @@ module Serializers def registrant rant = domain.registrant { - id: rant.uuid, name: rant.name, code: rant.code, } @@ -71,7 +70,6 @@ module Serializers def simple_object json = { - id: domain.uuid, name: domain.name, expire_time: domain.expire_time, registrant: registrant, diff --git a/test/integration/repp/v1/contacts/check_test.rb b/test/integration/repp/v1/contacts/check_test.rb index be0d979b1..6fc716638 100644 --- a/test/integration/repp/v1/contacts/check_test.rb +++ b/test/integration/repp/v1/contacts/check_test.rb @@ -14,7 +14,7 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest json = JSON.parse(response.body, symbolize_names: true) assert_response :ok - assert_equal 'nonexistant:code', json[:data][:contact][:id] + assert_equal 'nonexistant:code', json[:data][:contact][:code] assert_equal true, json[:data][:contact][:available] end @@ -24,7 +24,7 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest json = JSON.parse(response.body, symbolize_names: true) assert_response :ok - assert_equal contact.code, json[:data][:contact][:id] + assert_equal contact.code, json[:data][:contact][:code] assert_equal false, json[:data][:contact][:available] end end diff --git a/test/interactions/do_request_test.rb b/test/interactions/do_request_test.rb index a26eb0451..f73f71ad6 100644 --- a/test/interactions/do_request_test.rb +++ b/test/interactions/do_request_test.rb @@ -11,32 +11,23 @@ class DoRequestTest < ActiveSupport::TestCase @domain = domains(:shop) @user = users(:api_bestnames) - @request.body = { data: { type: 'nameserver', id: @nameserver.hostname, - domains: ["shop.test"], - attributes: { hostname: 'new-ns.bestnames.test', - ipv4: '192.0.2.55', - ipv6: '2001:db8::55' } } }.to_json + @request.body = { data: { type: 'nameserver', + id: @nameserver.hostname, + domains: ['shop.test'], + attributes: { hostname: 'new-ns.bestnames.test', + ipv4: '192.0.2.55', + ipv6: '2001:db8::55' } } }.to_json @request.basic_auth(@user.username, @user.plain_text_password) end def test_request_occurs - stub_request(:put, "http://epp:3000/repp/v1/registrar/nameservers"). - with( - body: "{\"data\":{\"type\":\"nameserver\",\"id\":\"ns1.bestnames.test\",\"domains\":[\"shop.test\"],\"attributes\":{\"hostname\":\"new-ns.bestnames.test\",\"ipv4\":\"192.0.2.55\",\"ipv6\":\"2001:db8::55\"}}}", - headers: { - 'Accept'=>'*/*', - 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Authorization'=>'Basic dGVzdF9iZXN0bmFtZXM6dGVzdHRlc3Q=', - 'Content-Type'=>'application/json', - 'Host'=>'epp:3000', - 'User-Agent'=>'Ruby' - }). - to_return(status: 200, body: ["shop.test"], headers: {}) + stub_request(:put, "#{ENV['repp_url']}registrar/nameservers") + .to_return(status: 200, body: ['shop.test'], headers: {}) action = Actions::DoRequest.new(@request, @uri) response = action.call - assert_equal response.body, ["shop.test"] - assert_equal response.code, "200" + assert_equal response.body, ['shop.test'] + assert_equal response.code, '200' end end \ No newline at end of file