mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 07:26:22 +02:00
Fixes after repp-apidoc update
This commit is contained in:
parent
c7701ce1b1
commit
26cb791586
11 changed files with 25 additions and 38 deletions
|
@ -63,7 +63,7 @@ module Repp
|
||||||
desc 'Check contact code availability'
|
desc 'Check contact code availability'
|
||||||
def check
|
def check
|
||||||
contact = Epp::Contact.find_by(code: params[:id])
|
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)
|
render_success(data: data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Repp
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
render_success(data: { domain: { name: @domain.name, id: @domain.uuid } })
|
render_success(data: { domain: { name: @domain.name } })
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_renew
|
def bulk_renew
|
||||||
|
|
|
@ -7,7 +7,6 @@ module Repp
|
||||||
|
|
||||||
api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status'
|
api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status'
|
||||||
param :domain_name, String, desc: 'Domain name'
|
param :domain_name, String, desc: 'Domain name'
|
||||||
param :status, String, desc: 'Status to be removed'
|
|
||||||
desc 'Remove status from specific domain'
|
desc 'Remove status from specific domain'
|
||||||
def destroy
|
def destroy
|
||||||
return editing_failed unless domain_with_status?(params[:id])
|
return editing_failed unless domain_with_status?(params[:id])
|
||||||
|
@ -22,7 +21,6 @@ module Repp
|
||||||
|
|
||||||
api :PUT, '/repp/v1/domains/:domain_name/statuses/:status'
|
api :PUT, '/repp/v1/domains/:domain_name/statuses/:status'
|
||||||
param :domain_name, String, desc: 'Domain name'
|
param :domain_name, String, desc: 'Domain name'
|
||||||
param :status, String, desc: 'Status to be added'
|
|
||||||
desc 'Add status to specific domain'
|
desc 'Add status to specific domain'
|
||||||
def update
|
def update
|
||||||
return editing_failed if domain_with_status?(params[:id])
|
return editing_failed if domain_with_status?(params[:id])
|
||||||
|
|
|
@ -101,7 +101,7 @@ module Repp
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
render_success(data: { domain: { name: @domain.name, id: @domain.uuid } })
|
render_success(data: { domain: { name: @domain.name } })
|
||||||
end
|
end
|
||||||
|
|
||||||
api :GET, '/repp/v1/domains/:domain_name/transfer_info'
|
api :GET, '/repp/v1/domains/:domain_name/transfer_info'
|
||||||
|
|
|
@ -30,7 +30,6 @@ module Repp
|
||||||
.add_nameservers(hostname_params[:attributes],
|
.add_nameservers(hostname_params[:attributes],
|
||||||
domains: domains_from_params)
|
domains: domains_from_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
render_success(data: data_format_for_success(affected, errored))
|
render_success(data: data_format_for_success(affected, errored))
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
handle_errors(e.record)
|
handle_errors(e.record)
|
||||||
|
@ -49,13 +48,14 @@ module Repp
|
||||||
type: 'nameserver',
|
type: 'nameserver',
|
||||||
id: hostname_params[:attributes][:hostname],
|
id: hostname_params[:attributes][:hostname],
|
||||||
attributes: hostname_params[:attributes],
|
attributes: hostname_params[:attributes],
|
||||||
affected_domains: affected_domains,
|
affected_domains: affected_domains || [],
|
||||||
skipped_domains: errored_domains,
|
skipped_domains: errored_domains || [],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def hostname_params
|
def hostname_params
|
||||||
params.require(:data).permit(:type, :id, nameserver: [], domains: [],
|
params.require(:data).permit(:type, :id,
|
||||||
|
:domains, nameserver: [], domains: [],
|
||||||
attributes: [:hostname, { ipv4: [], ipv6: [] }])
|
attributes: [:hostname, { ipv4: [], ipv6: [] }])
|
||||||
.tap do |data|
|
.tap do |data|
|
||||||
data.require(:type)
|
data.require(:type)
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Actions
|
||||||
|
|
||||||
contact_code = params[:registrant][:code]
|
contact_code = params[:registrant][:code]
|
||||||
contact = Contact.find_by(code: contact_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])
|
regt = Registrant.find_by(code: params[:registrant][:code])
|
||||||
unless regt
|
unless regt
|
||||||
|
|
|
@ -188,9 +188,9 @@ class Registrar < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_nameservers(new_attributes, domains: [])
|
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)
|
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?
|
self.domains.where(name: approved_list).find_each(&:update_whois_record) if approved_list.any?
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Serializers
|
||||||
def to_json(obj = contact)
|
def to_json(obj = contact)
|
||||||
return simple_object if @simplify
|
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,
|
created_at: obj.created_at, auth_info: obj.auth_info, email: obj.email,
|
||||||
statuses: statuses, disclosed_attributes: obj.disclosed_attributes,
|
statuses: statuses, disclosed_attributes: obj.disclosed_attributes,
|
||||||
registrar: registrar }
|
registrar: registrar }
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Serializers
|
||||||
return simple_object if @simplify
|
return simple_object if @simplify
|
||||||
|
|
||||||
json = {
|
json = {
|
||||||
id: obj.uuid, name: obj.name, registrant: registrant,
|
name: obj.name, registrant: registrant,
|
||||||
created_at: obj.created_at, updated_at: obj.updated_at,
|
created_at: obj.created_at, updated_at: obj.updated_at,
|
||||||
expire_time: obj.expire_time,
|
expire_time: obj.expire_time,
|
||||||
outzone_at: obj.outzone_at, delete_date: obj.delete_date,
|
outzone_at: obj.outzone_at, delete_date: obj.delete_date,
|
||||||
|
@ -53,7 +53,6 @@ module Serializers
|
||||||
def registrant
|
def registrant
|
||||||
rant = domain.registrant
|
rant = domain.registrant
|
||||||
{
|
{
|
||||||
id: rant.uuid,
|
|
||||||
name: rant.name,
|
name: rant.name,
|
||||||
code: rant.code,
|
code: rant.code,
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,6 @@ module Serializers
|
||||||
|
|
||||||
def simple_object
|
def simple_object
|
||||||
json = {
|
json = {
|
||||||
id: domain.uuid,
|
|
||||||
name: domain.name,
|
name: domain.name,
|
||||||
expire_time: domain.expire_time,
|
expire_time: domain.expire_time,
|
||||||
registrant: registrant,
|
registrant: registrant,
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest
|
||||||
json = JSON.parse(response.body, symbolize_names: true)
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_response :ok
|
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]
|
assert_equal true, json[:data][:contact][:available]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest
|
||||||
json = JSON.parse(response.body, symbolize_names: true)
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_response :ok
|
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]
|
assert_equal false, json[:data][:contact][:available]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,9 @@ class DoRequestTest < ActiveSupport::TestCase
|
||||||
@domain = domains(:shop)
|
@domain = domains(:shop)
|
||||||
@user = users(:api_bestnames)
|
@user = users(:api_bestnames)
|
||||||
|
|
||||||
@request.body = { data: { type: 'nameserver', id: @nameserver.hostname,
|
@request.body = { data: { type: 'nameserver',
|
||||||
domains: ["shop.test"],
|
id: @nameserver.hostname,
|
||||||
|
domains: ['shop.test'],
|
||||||
attributes: { hostname: 'new-ns.bestnames.test',
|
attributes: { hostname: 'new-ns.bestnames.test',
|
||||||
ipv4: '192.0.2.55',
|
ipv4: '192.0.2.55',
|
||||||
ipv6: '2001:db8::55' } } }.to_json
|
ipv6: '2001:db8::55' } } }.to_json
|
||||||
|
@ -20,23 +21,13 @@ class DoRequestTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_request_occurs
|
def test_request_occurs
|
||||||
stub_request(:put, "http://epp:3000/repp/v1/registrar/nameservers").
|
stub_request(:put, "#{ENV['repp_url']}registrar/nameservers")
|
||||||
with(
|
.to_return(status: 200, body: ['shop.test'], headers: {})
|
||||||
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: {})
|
|
||||||
|
|
||||||
action = Actions::DoRequest.new(@request, @uri)
|
action = Actions::DoRequest.new(@request, @uri)
|
||||||
response = action.call
|
response = action.call
|
||||||
|
|
||||||
assert_equal response.body, ["shop.test"]
|
assert_equal response.body, ['shop.test']
|
||||||
assert_equal response.code, "200"
|
assert_equal response.code, '200'
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue