mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 20:27:30 +02:00
Fix some CC issues
This commit is contained in:
parent
2ca9697b46
commit
d1cd0867c8
13 changed files with 72 additions and 63 deletions
4
Gemfile
4
Gemfile
|
@ -2,6 +2,7 @@ source 'https://rubygems.org'
|
|||
|
||||
# core
|
||||
gem 'active_interaction', '~> 3.8'
|
||||
gem 'apipie-rails', '~> 0.5.18'
|
||||
gem 'bootsnap', '>= 1.1.0', require: false
|
||||
gem 'iso8601', '0.12.1' # for dates and times
|
||||
gem 'rails', '~> 6.0'
|
||||
|
@ -78,7 +79,6 @@ gem 'wkhtmltopdf-binary', '~> 0.12.5.1'
|
|||
|
||||
gem 'directo', github: 'internetee/directo', branch: 'master'
|
||||
|
||||
|
||||
group :development, :test do
|
||||
gem 'pry', '0.10.1'
|
||||
gem 'puma'
|
||||
|
@ -92,5 +92,3 @@ group :test do
|
|||
gem 'webdrivers'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
gem "apipie-rails", "~> 0.5.18"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module Repp
|
||||
module V1
|
||||
class AccountsController < BaseController
|
||||
|
||||
api :GET, '/repp/v1/accounts/balance'
|
||||
desc "Get account's balance"
|
||||
def balance
|
||||
|
|
|
@ -9,7 +9,8 @@ module Repp
|
|||
|
||||
before_action :set_paper_trail_whodunnit
|
||||
|
||||
rescue_from ActionController::ParameterMissing, Apipie::ParamInvalid, Apipie::ParamMissing do |exception|
|
||||
rescue_from ActionController::ParameterMissing, Apipie::ParamInvalid,
|
||||
Apipie::ParamMissing do |exception|
|
||||
render json: { code: 2003, message: exception }, status: :bad_request
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,13 @@ module Repp
|
|||
before_action :set_new_contact, only: [:update]
|
||||
before_action :set_domain, only: %i[index create destroy]
|
||||
|
||||
def_param_group :contacts_apidoc do
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
end
|
||||
|
||||
api :GET, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "View domain's admin and tech contacts"
|
||||
def index
|
||||
|
@ -17,11 +24,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :POST, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "Link new contact(s) to domain"
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
desc 'Link new contact(s) to domain'
|
||||
param_group :contacts_apidoc
|
||||
def create
|
||||
contact_create_params[:contacts].each { |c| c[:action] = 'add' }
|
||||
action = Actions::DomainUpdate.new(@domain, contact_create_params, current_user)
|
||||
|
@ -35,11 +39,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :DELETE, '/repp/v1/domains/:domain_name/contacts'
|
||||
desc "Remove contact(s) from domain"
|
||||
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
|
||||
param :code, String, required: true, desc: 'Contact code'
|
||||
param :type, String, required: true, desc: 'Role of contact (admin/tech)'
|
||||
end
|
||||
desc 'Remove contact(s) from domain'
|
||||
param_group :contacts_apidoc
|
||||
def destroy
|
||||
contact_create_params[:contacts].each { |c| c[:action] = 'rem' }
|
||||
action = Actions::DomainUpdate.new(@domain, contact_create_params, current_user)
|
||||
|
|
|
@ -4,6 +4,13 @@ module Repp
|
|||
class DnssecController < BaseController
|
||||
before_action :set_domain, only: %i[index create destroy]
|
||||
|
||||
def_param_group :dns_keys_apidoc do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
end
|
||||
|
||||
api :GET, '/repp/v1/domains/:domain_name/dnssec'
|
||||
desc "View specific domain's DNSSEC keys"
|
||||
def index
|
||||
|
@ -15,10 +22,7 @@ module Repp
|
|||
api :POST, '/repp/v1/domains/:domain_name/dnssec'
|
||||
desc 'Create a new DNSSEC key(s) for domain'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of new DNSSEC keys' do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
param_group :dns_keys_apidoc, DnssecController
|
||||
end
|
||||
def create
|
||||
dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'add' }
|
||||
|
@ -33,11 +37,8 @@ module Repp
|
|||
end
|
||||
|
||||
api :DELETE, 'repp/v1/domains/:domain_name/dnssec'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of removable DNSSEC keys' do
|
||||
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
|
||||
param :protocol, String, required: true, desc: 'Key protocol (3)'
|
||||
param :alg, String, required: true, desc: 'DNSSEC key algorithm (3,5,6,7,8,10,13,14)'
|
||||
param :public_key, String, required: true, desc: 'DNSSEC public key'
|
||||
param :dns_keys, Array, required: true, desc: 'Array of new DNSSEC keys' do
|
||||
param_group :dns_keys_apidoc, DnssecController
|
||||
end
|
||||
def destroy
|
||||
dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'rem' }
|
||||
|
|
|
@ -4,14 +4,14 @@ module Repp
|
|||
class StatusesController < BaseController
|
||||
before_action :set_domain, only: %i[update destroy]
|
||||
before_action :verify_status
|
||||
before_action :verify_status_removal, only: [:destroy]
|
||||
before_action :verify_status_create, only: [:update]
|
||||
|
||||
api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status'
|
||||
desc 'Remove status from specific domain'
|
||||
param :domain_name, String, required: true, desc: 'Domain name'
|
||||
param :status, String, required: true, desc: 'Status to be removed'
|
||||
def destroy
|
||||
return editing_failed unless @domain.statuses.include?(params[:id])
|
||||
|
||||
@domain.statuses = @domain.statuses.delete(params[:id])
|
||||
if @domain.save
|
||||
render_success
|
||||
|
@ -25,8 +25,12 @@ module Repp
|
|||
param :domain_name, String, required: true, desc: 'Domain name'
|
||||
param :status, String, required: true, desc: 'Status to be added'
|
||||
def update
|
||||
return editing_failed if @domain.statuses.include?(params[:id])
|
||||
|
||||
@domain.statuses = @domain.statuses << params[:id]
|
||||
# rubocop:disable Style/AndOr
|
||||
handle_errors(@domain) and return unless @domain.save
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
render_success(data: { domain: @domain.name, status: params[:id] })
|
||||
end
|
||||
|
@ -39,23 +43,16 @@ module Repp
|
|||
|
||||
return if allowed_statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
@domain.add_epp_error('2306', nil, nil,
|
||||
"#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
|
||||
def verify_status_removal
|
||||
def editing_failed
|
||||
stat = params[:id]
|
||||
return if @domain.statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
|
||||
def verify_status_create
|
||||
stat = params[:id]
|
||||
return unless @domain.statuses.include?(stat)
|
||||
|
||||
@domain.add_epp_error('2306', nil, nil, "#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
@domain.add_epp_error('2306', nil, nil,
|
||||
"#{I18n.t(:client_side_status_editing_error)}: status #{stat}")
|
||||
handle_errors(@domain)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,8 +24,9 @@ module Repp
|
|||
private
|
||||
|
||||
def set_domain
|
||||
domain_id = transfer_params[:domain_id]
|
||||
h = {}
|
||||
h[transfer_params[:domain_id].match?(/\A[0-9]+\z/) ? :id : :name] = transfer_params[:domain_id]
|
||||
h[domain_id.match?(/\A[0-9]+\z/) ? :id : :name] = domain_id
|
||||
@domain = Epp::Domain.find_by!(h)
|
||||
end
|
||||
|
||||
|
|
|
@ -38,13 +38,12 @@ module Repp
|
|||
param :ipv4, Array, desc: 'Array of IPv4 addresses'
|
||||
param :ipv6, Array, desc: 'Array of IPv4 addresses'
|
||||
end
|
||||
param :admin_domain_contacts_attributes, Array, required: false, desc: 'Admin domain contacts codes'
|
||||
param :tech_domain_contacts_attributes, Array, required: false, desc: 'Tech domain contacts codes'
|
||||
param :admin_domain_contacts_attributes, Array, required: false,
|
||||
desc: 'Admin domain contacts codes'
|
||||
param :tech_domain_contacts_attributes, Array, required: false,
|
||||
desc: 'Tech domain contacts codes'
|
||||
param :dnskeys_attributes, Array, required: false, desc: 'DNSSEC keys for domain' do
|
||||
param :flags, String, required: true, desc: 'Flag of DNSSEC key'
|
||||
param :protocol, String, required: true, desc: 'Protocol of DNSSEC key'
|
||||
param :alg, String, required: true, desc: 'Algorithm of DNSSEC key'
|
||||
param :public_key, String, required: true, desc: 'Public key of DNSSEC key'
|
||||
param_group :dns_keys_apidoc, Repp::V1::Domains::DnssecController
|
||||
end
|
||||
end
|
||||
returns code: 200, desc: 'Successful domain registration response' do
|
||||
|
@ -61,7 +60,9 @@ module Repp
|
|||
@domain = Epp::Domain.new
|
||||
action = Actions::DomainCreate.new(@domain, domain_create_params)
|
||||
|
||||
# rubocop:disable Style/AndOr
|
||||
handle_errors(@domain) and return unless action.call
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
render_success(data: { domain: { name: @domain.name } })
|
||||
end
|
||||
|
@ -72,7 +73,8 @@ module Repp
|
|||
param :domain, Hash, required: true, desc: 'Changes of domain object' do
|
||||
param :registrant, Hash, required: false, desc: 'New registrant object' do
|
||||
param :code, String, required: true, desc: 'New registrant contact code'
|
||||
param :verified, [true, false], required: false, desc: 'Registrant change is already verified'
|
||||
param :verified, [true, false], required: false,
|
||||
desc: 'Registrant change is already verified'
|
||||
end
|
||||
param :auth_info, String, required: false, desc: 'New authorization code'
|
||||
end
|
||||
|
@ -119,13 +121,17 @@ module Repp
|
|||
api :DELETE, '/repp/v1/domains/:domain_name'
|
||||
desc 'Delete specific domain'
|
||||
param :delete, Hash, required: true, desc: 'Object holding verified key' do
|
||||
param :verified, [true, false], required: true, desc: 'Whether to ask registrant verification or not'
|
||||
param :verified, [true, false], required: true,
|
||||
desc: 'Whether to ask registrant verification or not'
|
||||
end
|
||||
def destroy
|
||||
action = Actions::DomainDelete.new(@domain, params, current_user.registrar)
|
||||
handle_errors(@domain) and return unless action.call
|
||||
|
||||
render_success(data: { domain: { name: @domain.name }})
|
||||
# rubocop:disable Style/AndOr
|
||||
handle_errors(@domain) and return unless action.call
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
render_success(data: { domain: { name: @domain.name } })
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -202,8 +208,8 @@ module Repp
|
|||
end
|
||||
|
||||
def domain_create_params
|
||||
params.require(:domain).require([:name, :registrant_id, :period, :period_unit])
|
||||
params.require(:domain).permit(:name, :registrant_id, :period, :period_unit, :registrar_id)
|
||||
params.require(:domain).require(%i[name registrant_id period period_unit])
|
||||
params.require(:domain).permit(%i[name registrant_id period period_unit registrar_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,12 @@ module Repp
|
|||
desc 'Get the latest unread poll message'
|
||||
def index
|
||||
@notification = current_user.unread_notifications.order('created_at DESC').take
|
||||
render_success(data: nil) and return unless @notification
|
||||
|
||||
data = @notification.as_json(only: [:id, :text, :attached_obj_id,
|
||||
:attached_obj_type])
|
||||
# rubocop:disable Style/AndOr
|
||||
render_success(data: nil) and return unless @notification
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
data = @notification.as_json(only: %i[id text attached_obj_id attached_obj_type])
|
||||
|
||||
render_success(data: data)
|
||||
end
|
||||
|
@ -20,8 +22,7 @@ module Repp
|
|||
desc 'Get a specific poll message'
|
||||
def show
|
||||
@notification = current_user.registrar.notifications.find(params[:id])
|
||||
data = @notification.as_json(only: [:id, :text, :attached_obj_id,
|
||||
:attached_obj_type])
|
||||
data = @notification.as_json(only: %i[id text attached_obj_id attached_obj_type])
|
||||
|
||||
render_success(data: data)
|
||||
end
|
||||
|
@ -29,10 +30,12 @@ module Repp
|
|||
api :PUT, '/repp/v1/registrar/notifications'
|
||||
desc 'Mark poll message as read'
|
||||
param :notification, Hash, required: true do
|
||||
param :read, [true], required: true, desc: "Set as true to mark as read"
|
||||
param :read, [true], required: true, desc: 'Set as true to mark as read'
|
||||
end
|
||||
def update
|
||||
# rubocop:disable Style/AndOr
|
||||
handle_errors(@notification) and return unless @notification.mark_as_read
|
||||
# rubocop:enable Style/AndOr
|
||||
|
||||
render_success(data: { notification_id: @notification.id, read: true })
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module Domains
|
|||
|
||||
domain.add_epp_error(2104, nil, nil, I18n.t(:active_price_missing_for_this_operation))
|
||||
errors.add(:domain, I18n.t(:active_price_missing_for_operation_with_domain,
|
||||
domain: domain.name))
|
||||
domain: domain.name))
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ module Actions
|
|||
end
|
||||
|
||||
def assign_nameservers
|
||||
domain.nameservers_attributes = params[:nameservers_attributes] if params[:nameservers_attributes]
|
||||
return unless params[:nameservers_attributes]
|
||||
|
||||
domain.nameservers_attributes = params[:nameservers_attributes]
|
||||
end
|
||||
|
||||
def assign_contact(contact_code, admin: true)
|
||||
|
|
|
@ -21,9 +21,9 @@ module Actions
|
|||
end
|
||||
|
||||
task = Domains::BulkRenew::SingleDomainRenew.run(domain: domain,
|
||||
period: params[:period],
|
||||
unit: params[:period_unit],
|
||||
registrar: user)
|
||||
period: params[:period],
|
||||
unit: params[:period_unit],
|
||||
registrar: user)
|
||||
|
||||
task.valid?
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ module Serializers
|
|||
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,
|
||||
dnssec_keys: dnssec_keys, statuses: obj.statuses,
|
||||
dnssec_keys: dnssec_keys, statuses: obj.statuses
|
||||
}
|
||||
|
||||
json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue