mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
parent
340e61804b
commit
4b836f1476
23 changed files with 54 additions and 47 deletions
|
@ -6,11 +6,11 @@ module Repp
|
|||
post '/' do
|
||||
params['domainTransfers'].each do |domain_transfer|
|
||||
domain_name = domain_transfer['domainName']
|
||||
auth_info = domain_transfer['authInfo']
|
||||
transfer_code = domain_transfer['transferCode']
|
||||
new_registrar = current_user.registrar
|
||||
|
||||
domain = Domain.find_by(name: domain_name)
|
||||
domain.transfer(registrar: new_registrar, auth_info: auth_info)
|
||||
domain.transfer(registrar: new_registrar, transfer_code: transfer_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module Repp
|
|||
domain = ident =~ /\A[0-9]+\z/ ? Domain.find_by(id: ident) : Domain.find_by_idn(ident)
|
||||
|
||||
error! I18n.t('errors.messages.epp_domain_not_found'), 404 unless domain
|
||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.auth_info.eql? request.headers['Auth-Code']
|
||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.transfer_code.eql? request.headers['Auth-Code']
|
||||
|
||||
contact_repp_json = proc{|contact|
|
||||
contact.as_json.slice("code", "name", "ident", "ident_type", "ident_country_code", "phone", "email", "street", "city", "zip","country_code", "statuses")
|
||||
|
|
|
@ -54,14 +54,14 @@ class Ability
|
|||
# can(:create, :epp_request)
|
||||
|
||||
# Epp::Domain
|
||||
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.auth_info == pw }
|
||||
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.transfer_code == pw }
|
||||
can(:check, Epp::Domain)
|
||||
can(:create, Epp::Domain)
|
||||
can(:renew, Epp::Domain) { |d| d.registrar_id == @user.registrar_id }
|
||||
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw }
|
||||
can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
can(:transfer, Epp::Domain) { |d, pw| d.transfer_code == pw }
|
||||
can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw }
|
||||
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw }
|
||||
|
|
|
@ -2,17 +2,17 @@ module Concerns::Domain::Transferable
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_initialize :generate_auth_info, if: :new_record?
|
||||
after_initialize :generate_transfer_code, if: :new_record?
|
||||
end
|
||||
|
||||
def transfer(new_registrar)
|
||||
self.registrar = new_registrar
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_auth_info
|
||||
self.auth_info = SecureRandom.hex
|
||||
def generate_transfer_code
|
||||
self.transfer_code = SecureRandom.hex
|
||||
end
|
||||
end
|
||||
|
|
|
@ -100,7 +100,7 @@ class Epp::Domain < Domain
|
|||
[:puny_label, :too_long, { obj: 'name', val: name_puny }]
|
||||
],
|
||||
'2201' => [ # Authorisation error
|
||||
[:auth_info, :wrong_pw]
|
||||
[:transfer_code, :wrong_pw]
|
||||
],
|
||||
'2202' => [
|
||||
[:base, :invalid_auth_information_reserved]
|
||||
|
@ -182,7 +182,7 @@ class Epp::Domain < Domain
|
|||
# at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action)
|
||||
|
||||
pw = frame.css('authInfo > pw').text
|
||||
at[:auth_info] = pw if pw.present?
|
||||
at[:transfer_code] = pw if pw.present?
|
||||
|
||||
if new_record?
|
||||
dnskey_frame = frame.css('extension create')
|
||||
|
@ -722,7 +722,7 @@ class Epp::Domain < Domain
|
|||
if dt.approved?
|
||||
transfer_contacts(current_user.registrar_id)
|
||||
dt.notify_losing_registrar(old_contact_codes, old_registrant_code)
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
self.registrar = current_user.registrar
|
||||
end
|
||||
|
||||
|
@ -751,7 +751,7 @@ class Epp::Domain < Domain
|
|||
)
|
||||
|
||||
transfer_contacts(pt.transfer_to_id)
|
||||
generate_auth_info
|
||||
generate_transfer_code
|
||||
self.registrar = pt.transfer_to
|
||||
|
||||
attach_legal_document(self.class.parse_legal_document_from_frame(frame))
|
||||
|
@ -872,7 +872,7 @@ class Epp::Domain < Domain
|
|||
|
||||
# For domain transfer
|
||||
def authenticate(pw)
|
||||
errors.add(:auth_info, :wrong_pw) if pw != auth_info
|
||||
errors.add(:transfer_code, :wrong_pw) if pw != transfer_code
|
||||
errors.empty?
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class DomainPresenter
|
||||
delegate :name, :auth_info, :registrant_name, :registrant_id, :registrant_code, to: :domain
|
||||
delegate :name, :transfer_code, :registrant_name, :registrant_id, :registrant_code, to: :domain
|
||||
|
||||
def initialize(domain:, view:)
|
||||
@domain = domain
|
||||
|
|
|
@ -19,7 +19,7 @@ class Registrar::DomainListCSVPresenter
|
|||
def header
|
||||
columns = %w(
|
||||
domain_name
|
||||
auth_info
|
||||
transfer_code
|
||||
registrant_name
|
||||
registrant_code
|
||||
expire_time
|
||||
|
@ -33,7 +33,7 @@ class Registrar::DomainListCSVPresenter
|
|||
def domain_to_row(domain:)
|
||||
row = []
|
||||
row[0] = domain.name
|
||||
row[1] = domain.auth_info
|
||||
row[1] = domain.transfer_code
|
||||
row[2] = domain.registrant_name
|
||||
row[3] = domain.registrant_code
|
||||
row[4] = domain.expire_date
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<dt><%= t(:registrar_name) %></dt>
|
||||
<dd><%= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) %></dd>
|
||||
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<%= tag :input, type: 'text', value: @domain.auth_info, readonly: true,
|
||||
<%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
|
||||
class: 'form-control input-sm' %>
|
||||
</dd>
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ xml.epp_head do
|
|||
|
||||
if can? :view_password, @domain, @password
|
||||
xml.tag!('domain:authInfo') do
|
||||
xml.tag!('domain:pw', @domain.auth_info)
|
||||
xml.tag!('domain:pw', @domain.transfer_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<dt><%= t(:registrar_name) %></dt>
|
||||
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
|
||||
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<%= tag :input, type: 'text', value: @domain.auth_info, readonly: true,
|
||||
<%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
|
||||
class: 'form-control input-sm' %>
|
||||
</dd>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt><%= Domain.human_attribute_name :auth_info %></dt>
|
||||
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
|
||||
<dd>
|
||||
<% if @data.css('pw').text.present? %>
|
||||
<%= tag(:input, type: 'text', value: @data.css('pw').text, readonly: true,
|
||||
|
|
|
@ -79,7 +79,7 @@ en:
|
|||
period:
|
||||
not_a_number: 'Period is not a number'
|
||||
not_an_integer: 'Period must be an integer'
|
||||
auth_info:
|
||||
transfer_code:
|
||||
wrong_pw: 'Authorization error'
|
||||
domain_statuses:
|
||||
invalid: 'Statuses are invalid'
|
||||
|
|
|
@ -7,7 +7,7 @@ en:
|
|||
transfer_btn: Transfer
|
||||
csv:
|
||||
domain_name: Domain
|
||||
auth_info: Auth info
|
||||
transfer_code: Transfer code
|
||||
registrant_name: Registrant name
|
||||
registrant_code: Registrant code
|
||||
expire_time: Date of expiry
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class RenameDomainsAuthInfoToTransferCode < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :domains, :auth_info, :transfer_code
|
||||
end
|
||||
end
|
|
@ -998,7 +998,7 @@ CREATE TABLE domains (
|
|||
valid_from timestamp without time zone,
|
||||
valid_to timestamp without time zone,
|
||||
registrant_id integer NOT NULL,
|
||||
auth_info character varying,
|
||||
transfer_code character varying,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
name_dirty character varying,
|
||||
|
@ -5046,3 +5046,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180120182712');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180120183441');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180121165304');
|
||||
|
||||
|
|
|
@ -921,7 +921,7 @@
|
|||
<text text-anchor="start" x="1958.5" y="-2136.3" font-family="Times,serif" font-size="14.00">valid_from :datetime</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2121.3" font-family="Times,serif" font-size="14.00">valid_to :datetime</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2106.3" font-family="Times,serif" font-size="14.00">registrant_id :integer</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2091.3" font-family="Times,serif" font-size="14.00">auth_info :string</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2091.3" font-family="Times,serif" font-size="14.00">transfer_code :string</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2076.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2061.3" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
|
||||
<text text-anchor="start" x="1958.5" y="-2046.3" font-family="Times,serif" font-size="14.00">name_dirty :string</text>
|
||||
|
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 228 KiB |
|
@ -39,7 +39,7 @@ Content-Type: application/json
|
|||
"valid_from": "2015-09-09T09:11:14.861Z",
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
"auth_info": "98oiewslkfkd",
|
||||
"transfer_code": "98oiewslkfkd",
|
||||
"created_at": "2015-09-09T09:11:14.861Z",
|
||||
"updated_at": "2015-09-09T09:11:14.860Z",
|
||||
"name_dirty": "domain0.ee",
|
||||
|
|
|
@ -340,7 +340,7 @@ namespace :import do
|
|||
registered_at
|
||||
valid_from
|
||||
valid_to
|
||||
auth_info
|
||||
transfer_code
|
||||
created_at
|
||||
updated_at
|
||||
name_dirty
|
||||
|
|
|
@ -151,7 +151,7 @@ RSpec.describe DomainPresenter do
|
|||
|
||||
domain_delegatable_attributes = %i(
|
||||
name
|
||||
auth_info
|
||||
transfer_code
|
||||
registrant_name
|
||||
registrant_id
|
||||
registrant_code
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
|
||||
class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
def test_post_to_domain_transfers
|
||||
request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, authInfo: domains(:shop).auth_info }] }
|
||||
request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, transferCode: domains(:shop).transfer_code }] }
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :created
|
||||
|
||||
|
|
6
test/fixtures/domains.yml
vendored
6
test/fixtures/domains.yml
vendored
|
@ -3,7 +3,7 @@ shop:
|
|||
name_dirty: shop.test
|
||||
registrar: bestnames
|
||||
registrant: john
|
||||
auth_info: 65078d5
|
||||
transfer_code: 65078d5
|
||||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
|
@ -13,7 +13,7 @@ airport:
|
|||
name_dirty: airport.test
|
||||
registrar: bestnames
|
||||
registrant: john
|
||||
auth_info: 55438j5
|
||||
transfer_code: 55438j5
|
||||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
|
@ -23,7 +23,7 @@ library:
|
|||
name_dirty: library.test
|
||||
registrar: bestnames
|
||||
registrant: acme_ltd
|
||||
auth_info: 45118f5
|
||||
transfer_code: 45118f5
|
||||
valid_to: 2010-07-05
|
||||
period: 1
|
||||
period_unit: m
|
||||
|
|
|
@ -7,7 +7,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest
|
|||
|
||||
def test_downloads_domain_list_as_csv
|
||||
expected_csv = <<-CSV.strip_heredoc
|
||||
Domain,Auth info,Registrant name,Registrant code,Date of expiry
|
||||
Domain,Transfer code,Registrant name,Registrant code,Date of expiry
|
||||
library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05
|
||||
shop.test,65078d5,John,john-001,2010-07-05
|
||||
airport.test,55438j5,John,john-001,2010-07-05
|
||||
|
|
|
@ -9,28 +9,28 @@ class DomainTest < ActiveSupport::TestCase
|
|||
assert @domain.valid?
|
||||
end
|
||||
|
||||
def test_generates_random_auth_info_if_new
|
||||
def test_generates_random_transfer_code_if_new
|
||||
domain = Domain.new
|
||||
another_domain = Domain.new
|
||||
|
||||
refute_empty domain.auth_info
|
||||
refute_empty another_domain.auth_info
|
||||
refute_equal domain.auth_info, another_domain.auth_info
|
||||
refute_empty domain.transfer_code
|
||||
refute_empty another_domain.transfer_code
|
||||
refute_equal domain.transfer_code, another_domain.transfer_code
|
||||
end
|
||||
|
||||
def test_does_not_regenerate_auth_info_if_persisted
|
||||
original_auth_info = @domain.auth_info
|
||||
def test_does_not_regenerate_transfer_code_if_persisted
|
||||
original_transfer_code = @domain.transfer_code
|
||||
@domain.save!
|
||||
@domain.reload
|
||||
assert_equal original_auth_info, @domain.auth_info
|
||||
assert_equal original_transfer_code, @domain.transfer_code
|
||||
end
|
||||
|
||||
def test_transfers_domain
|
||||
old_auth_info = @domain.auth_info
|
||||
old_transfer_code = @domain.transfer_code
|
||||
new_registrar = registrars(:goodnames)
|
||||
@domain.transfer(new_registrar)
|
||||
|
||||
assert_equal new_registrar, @domain.registrar
|
||||
refute_same @domain.auth_info, old_auth_info
|
||||
refute_same @domain.transfer_code, old_transfer_code
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue