Fixes after repp-apidoc update

This commit is contained in:
Sergei Tsõganov 2022-07-12 15:42:49 +03:00
parent c7701ce1b1
commit 26cb791586
11 changed files with 25 additions and 38 deletions

View file

@ -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

View file

@ -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

View file

@ -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])

View file

@ -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'

View file

@ -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,13 +48,14 @@ 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: [],
params.require(:data).permit(:type, :id,
:domains, nameserver: [], domains: [],
attributes: [:hostname, { ipv4: [], ipv6: [] }])
.tap do |data|
data.require(:type)

View file

@ -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

View file

@ -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?

View file

@ -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 }

View file

@ -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,

View file

@ -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

View file

@ -11,8 +11,9 @@ class DoRequestTest < ActiveSupport::TestCase
@domain = domains(:shop)
@user = users(:api_bestnames)
@request.body = { data: { type: 'nameserver', id: @nameserver.hostname,
domains: ["shop.test"],
@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
@ -20,23 +21,13 @@ class DoRequestTest < ActiveSupport::TestCase
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