From 8ef8147b063fddf3c948e088b8fcd051f4a976b2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 7 Jul 2015 18:52:58 +0300 Subject: [PATCH 01/20] Add reserved domains management #2565 --- CHANGELOG.md | 3 + .../admin/blocked_domains_controller.rb | 4 +- .../admin/reserved_domains_controller.rb | 30 ++++++++ app/models/ability.rb | 1 + app/views/admin/reserved_domains/index.haml | 10 +++ config/locales/en.yml | 2 + config/routes.rb | 1 + ...0150707104937_refactor_reserved_domains.rb | 6 ++ ...150707154543_increase_decimal_precision.rb | 11 +++ db/schema-read-only.rb | 15 ++-- db/structure.sql | 69 +++++++++++++++---- 11 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 app/controllers/admin/reserved_domains_controller.rb create mode 100644 app/views/admin/reserved_domains/index.haml create mode 100644 db/migrate/20150707104937_refactor_reserved_domains.rb create mode 100644 db/migrate/20150707154543_increase_decimal_precision.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 24b3f92b6..d61a6fbd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +07.07.2015 +* Before applyling 20150707104937_refactor_reserved_domains.rb migration, enable hstore extension in db + 01.07.2015 * Added que init script example at doc/que directory, please setup que accornding to doc/que/README.md diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 82b1dcc5a..c890cf2b0 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -13,10 +13,12 @@ class Admin::BlockedDomainsController < AdminController if bd.update(names: names) flash[:notice] = I18n.t('record_updated') + redirect_to :back else + @blocked_domains = params[:blocked_domains] flash.now[:alert] = I18n.t('failed_to_update_record') + render :index end - redirect_to :back end end diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb new file mode 100644 index 000000000..eb3a5faae --- /dev/null +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -0,0 +1,30 @@ +class Admin::ReservedDomainsController < AdminController + load_and_authorize_resource + + def index + rd = ReservedDomain.first_or_initialize + @reserved_domains = rd.names.to_yaml + end + + def create + @reserved_domains = params[:reserved_domains] + + begin + names = YAML.load(params[:reserved_domains]) + rescue + flash.now[:alert] = I18n.t('invalid_yaml') + logger.warn 'Invalid YAML' + render :index and return + end + + rd = ReservedDomain.first_or_create + + if rd.update(names: names) + flash[:notice] = I18n.t('record_updated') + redirect_to :back + else + flash.now[:alert] = I18n.t('failed_to_update_record') + render :index + end + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index c02e5847c..b7c763708 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -107,6 +107,7 @@ class Ability customer_service can :manage, Setting can :manage, BlockedDomain + can :manage, ReservedDomain can :manage, ZonefileSetting can :manage, DomainVersion can :manage, Pricelist diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index.haml new file mode 100644 index 000000000..9dd6955bd --- /dev/null +++ b/app/views/admin/reserved_domains/index.haml @@ -0,0 +1,10 @@ += render 'shared/title', name: t(:reserved_domains) + += form_tag([:admin, :reserved_domains]) do |f| + .row + .col-md-12 + = text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30 + %hr + .row + .col-md-12.text-right + %button.btn.btn-warning=t(:save) diff --git a/config/locales/en.yml b/config/locales/en.yml index bd358aaac..1c9754932 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -861,3 +861,5 @@ en: receipt_date_until: 'Receipt date until' add_credit: 'Add credit' export_csv: 'Export CSV' + reserved_domains: 'Reserved domains' + invalid_yaml: 'Invalid YAML' diff --git a/config/routes.rb b/config/routes.rb index e7ad5a63b..96cddbdf2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -190,6 +190,7 @@ Rails.application.routes.draw do resources :settings resources :blocked_domains + resources :reserved_domains resources :registrars do resources :api_users diff --git a/db/migrate/20150707104937_refactor_reserved_domains.rb b/db/migrate/20150707104937_refactor_reserved_domains.rb new file mode 100644 index 000000000..6f6c00682 --- /dev/null +++ b/db/migrate/20150707104937_refactor_reserved_domains.rb @@ -0,0 +1,6 @@ +class RefactorReservedDomains < ActiveRecord::Migration + def change + remove_column :reserved_domains, :name + add_column :reserved_domains, :names, :hstore + end +end diff --git a/db/migrate/20150707154543_increase_decimal_precision.rb b/db/migrate/20150707154543_increase_decimal_precision.rb new file mode 100644 index 000000000..47cf59997 --- /dev/null +++ b/db/migrate/20150707154543_increase_decimal_precision.rb @@ -0,0 +1,11 @@ +class IncreaseDecimalPrecision < ActiveRecord::Migration + def change + change_column :account_activities, :sum, :decimal, precision: 10, scale: 2 + change_column :accounts, :balance, :decimal, precision: 10, scale: 2, default: 0.0, null: false + change_column :bank_transactions, :sum, :decimal, precision: 10, scale: 2 + change_column :banklink_transactions, :vk_amount, :decimal, precision: 10, scale: 2 + change_column :invoice_items, :price, :decimal, precision: 10, scale: 2 + change_column :invoices, :vat_prc, :decimal, precision: 10, scale: 2 + change_column :invoices, :sum_cache, :decimal, precision: 10, scale: 2 + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 768be3160..174cd27d7 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,10 +11,11 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150706091724) do +ActiveRecord::Schema.define(version: 20150707154543) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + enable_extension "hstore" create_table "account_activities", force: :cascade do |t| t.integer "account_id" @@ -212,6 +213,12 @@ ActiveRecord::Schema.define(version: 20150706091724) do t.string "updator_str" end + create_table "data_migrations", id: false, force: :cascade do |t| + t.string "version", null: false + end + + add_index "data_migrations", ["version"], name: "unique_data_migrations", unique: true, using: :btree + create_table "delegation_signers", force: :cascade do |t| t.integer "domain_id" t.string "key_tag" @@ -928,7 +935,7 @@ ActiveRecord::Schema.define(version: 20150706091724) do create_table "que_jobs", id: false, force: :cascade do |t| t.integer "priority", limit: 2, default: 100, null: false - t.datetime "run_at", default: '2015-06-30 14:16:50', null: false + t.datetime "run_at", default: '2015-06-30 14:16:49', null: false t.integer "job_id", limit: 8, default: 0, null: false t.text "job_class", null: false t.json "args", default: [], null: false @@ -978,11 +985,11 @@ ActiveRecord::Schema.define(version: 20150706091724) do add_index "registrars", ["code"], name: "index_registrars_on_code", using: :btree create_table "reserved_domains", force: :cascade do |t| - t.string "name" t.datetime "created_at" t.datetime "updated_at" t.string "creator_str" t.string "updator_str" + t.hstore "names" end create_table "settings", force: :cascade do |t| @@ -1020,7 +1027,7 @@ ActiveRecord::Schema.define(version: 20150706091724) do t.text "crt" t.string "type" t.string "registrant_ident" - t.string "encrypted_password", default: "" + t.string "encrypted_password", default: "", null: false t.datetime "remember_created_at" t.integer "failed_attempts", default: 0, null: false t.datetime "locked_at" diff --git a/db/structure.sql b/db/structure.sql index 7b0a41ae6..17187a88f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23,6 +23,20 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; +-- +-- Name: hstore; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; + + +-- +-- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; + + SET search_path = public, pg_catalog; -- @@ -41,7 +55,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text ret text; BEGIN -- define filters - include_filter = '%' || i_origin; + include_filter = '%.' || i_origin; -- for %.%.% IF i_origin ~ '\.' THEN @@ -74,7 +88,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text SELECT concat(d.name_puny, '. IN NS ', ns.hostname, '.') FROM domains d JOIN nameservers ns ON ns.domain_id = d.id - WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter + WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter OR d.name = i_origin ORDER BY d.name ), chr(10) @@ -237,7 +251,7 @@ CREATE TABLE accounts ( id integer NOT NULL, registrar_id integer, account_type character varying, - balance numeric(10,2) DEFAULT 0 NOT NULL, + balance numeric(10,2) DEFAULT 0.0 NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, currency character varying, @@ -673,6 +687,15 @@ CREATE SEQUENCE countries_id_seq ALTER SEQUENCE countries_id_seq OWNED BY countries.id; +-- +-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -; Tablespace: +-- + +CREATE TABLE data_migrations ( + version character varying NOT NULL +); + + -- -- Name: delegation_signers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2358,7 +2381,7 @@ CREATE TABLE pricelists ( id integer NOT NULL, "desc" character varying, category character varying, - price_cents numeric(10,2) DEFAULT 0 NOT NULL, + price_cents numeric(10,2) DEFAULT 0.0 NOT NULL, price_currency character varying DEFAULT 'EUR'::character varying NOT NULL, valid_from timestamp without time zone, valid_to timestamp without time zone, @@ -2396,7 +2419,7 @@ ALTER SEQUENCE pricelists_id_seq OWNED BY pricelists.id; CREATE TABLE que_jobs ( priority smallint DEFAULT 100 NOT NULL, - run_at timestamp without time zone DEFAULT '2015-06-30 14:16:50.905537'::timestamp without time zone NOT NULL, + run_at timestamp without time zone DEFAULT '2015-06-30 14:16:49.190473'::timestamp without time zone NOT NULL, job_id bigint DEFAULT 0 NOT NULL, job_class text NOT NULL, args json DEFAULT '[]'::json NOT NULL, @@ -2497,11 +2520,11 @@ ALTER SEQUENCE registrars_id_seq OWNED BY registrars.id; CREATE TABLE reserved_domains ( id integer NOT NULL, - name character varying, created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, - updator_str character varying + updator_str character varying, + names hstore ); @@ -2596,7 +2619,7 @@ CREATE TABLE users ( crt text, type character varying, registrant_ident character varying, - encrypted_password character varying DEFAULT ''::character varying, + encrypted_password character varying DEFAULT ''::character varying NOT NULL, remember_created_at timestamp without time zone, failed_attempts integer DEFAULT 0 NOT NULL, locked_at timestamp without time zone @@ -4452,6 +4475,13 @@ CREATE INDEX index_whois_records_on_domain_id ON whois_records USING btree (doma CREATE INDEX index_whois_records_on_registrar_id ON whois_records USING btree (registrar_id); +-- +-- Name: unique_data_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (version); + + -- -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4667,8 +4697,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150227092508'); INSERT INTO schema_migrations (version) VALUES ('20150227113121'); -INSERT INTO schema_migrations (version) VALUES ('20150302130224'); - INSERT INTO schema_migrations (version) VALUES ('20150302161712'); INSERT INTO schema_migrations (version) VALUES ('20150303130729'); @@ -4727,8 +4755,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150417082723'); INSERT INTO schema_migrations (version) VALUES ('20150421134820'); -INSERT INTO schema_migrations (version) VALUES ('20150422090645'); - INSERT INTO schema_migrations (version) VALUES ('20150422092514'); INSERT INTO schema_migrations (version) VALUES ('20150422132631'); @@ -4773,8 +4799,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150519115050'); INSERT INTO schema_migrations (version) VALUES ('20150519140853'); -INSERT INTO schema_migrations (version) VALUES ('20150519142542'); - INSERT INTO schema_migrations (version) VALUES ('20150519144118'); INSERT INTO schema_migrations (version) VALUES ('20150520163237'); @@ -4787,7 +4811,9 @@ INSERT INTO schema_migrations (version) VALUES ('20150522164020'); INSERT INTO schema_migrations (version) VALUES ('20150525075550'); -INSERT INTO schema_migrations (version) VALUES ('20150603141054'); +INSERT INTO schema_migrations (version) VALUES ('20150601083516'); + +INSERT INTO schema_migrations (version) VALUES ('20150601083800'); INSERT INTO schema_migrations (version) VALUES ('20150603141549'); @@ -4795,8 +4821,12 @@ INSERT INTO schema_migrations (version) VALUES ('20150603211318'); INSERT INTO schema_migrations (version) VALUES ('20150603212659'); +INSERT INTO schema_migrations (version) VALUES ('20150609093515'); + INSERT INTO schema_migrations (version) VALUES ('20150609103333'); +INSERT INTO schema_migrations (version) VALUES ('20150610111019'); + INSERT INTO schema_migrations (version) VALUES ('20150610112238'); INSERT INTO schema_migrations (version) VALUES ('20150610144547'); @@ -4805,8 +4835,17 @@ INSERT INTO schema_migrations (version) VALUES ('20150611124920'); INSERT INTO schema_migrations (version) VALUES ('20150612123111'); +INSERT INTO schema_migrations (version) VALUES ('20150612125720'); + INSERT INTO schema_migrations (version) VALUES ('20150701074344'); +INSERT INTO schema_migrations (version) VALUES ('20150703084206'); + INSERT INTO schema_migrations (version) VALUES ('20150703084632'); INSERT INTO schema_migrations (version) VALUES ('20150706091724'); + +INSERT INTO schema_migrations (version) VALUES ('20150707104937'); + +INSERT INTO schema_migrations (version) VALUES ('20150707154543'); + From 647d074b8b217c91211a83a0f90b1161cb479bda Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 8 Jul 2015 16:04:56 +0300 Subject: [PATCH 02/20] Check reserved domain on create #2565 --- app/models/domain.rb | 25 +++++++++++++++++++++++++ app/models/domain_status.rb | 1 + app/models/epp/domain.rb | 5 ++++- app/validators/domain_name_validator.rb | 7 ++++--- config/locales/en.yml | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index ae81ce474..1b1c840f6 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -78,12 +78,26 @@ class Domain < ActiveRecord::Base after_initialize -> { self.statuses = [] if statuses.nil? } + after_create :update_reserved_domains + def update_reserved_domains + return unless reserved? + rd = ReservedDomain.first + rd.names[name] = SecureRandom.hex + rd.save + end + validates :name_dirty, domain_name: true, uniqueness: true validates :puny_label, length: { maximum: 63 } validates :period, numericality: { only_integer: true } validates :registrant, :registrar, presence: true validate :validate_period + validate :validate_reservation + def validate_reservation + return if persisted? + return if !reserved? || reserved_pw == auth_info + errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info) + end validates :nameservers, object_count: { min: -> { Setting.ns_min_count }, @@ -247,6 +261,14 @@ class Domain < ActiveRecord::Base @registrant_typeahead || registrant.try(:name) || nil end + def reserved? + reserved_pw.present? + end + + def reserved_pw + ReservedDomain.select("names -> '#{name}' AS pw").first.pw + end + def pending_transfer domain_transfers.find_by(status: DomainTransfer::PENDING) end @@ -452,6 +474,7 @@ class Domain < ActiveRecord::Base # rubocop:disable Lint/Loop def generate_auth_info + return if auth_info.present? begin self.auth_info = SecureRandom.hex end while self.class.exists?(auth_info: auth_info) @@ -493,6 +516,8 @@ class Domain < ActiveRecord::Base end def manage_automatic_statuses + statuses << DomainStatus::RESERVED if new_record? && reserved? + # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? if statuses.empty? && valid? statuses << DomainStatus::OK diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb index b33b5446c..0f984b4e7 100644 --- a/app/models/domain_status.rb +++ b/app/models/domain_status.rb @@ -71,6 +71,7 @@ class DomainStatus < ActiveRecord::Base FORCE_DELETE = 'forceDelete' DELETE_CANDIDATE = 'deleteCandidate' EXPIRED = 'expired' + RESERVED = 'reserved' STATUSES = [ CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD, diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 69072a398..b98aa83b1 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -66,7 +66,8 @@ class Epp::Domain < Domain [:name_dirty, :blocked, { value: { obj: 'name', val: name_dirty } }] ], '2304' => [ # Object status prohibits operation - [:base, :domain_status_prohibits_operation] + [:base, :domain_status_prohibits_operation], + [:base, :domain_is_reserved_and_requires_correct_auth_info] ], '2306' => [ # Parameter policy error [:period, :out_of_range, { value: { obj: 'period', val: period } }], @@ -112,6 +113,8 @@ class Epp::Domain < Domain at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y' + at[:auth_info] = frame.css('pw').text if new_record? + # at[:statuses] = domain_statuses_attrs(frame, action) # binding.pry at[:nameservers_attributes] = nameservers_attrs(frame, action) diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index ff6ef69f6..1ac609a5a 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -6,8 +6,8 @@ class DomainNameValidator < ActiveModel::EachValidator record.errors[attribute] << (options[:message] || record.errors.generate_message(attribute, :invalid)) elsif !self.class.validate_blocked(value) record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :blocked))) - elsif !self.class.validate_reservation(value) - record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :reserved))) + # elsif !self.class.validate_reservation(value) + # record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :reserved))) end end # rubocop: enable Metrics/PerceivedComplexity @@ -42,8 +42,9 @@ class DomainNameValidator < ActiveModel::EachValidator BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0 end - def validate_reservation(value) + def validate_reservation(record, value) return true unless value + return true if record.reserved_pw == record.auth_info !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 1c9754932..943f453fd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,6 +60,7 @@ en: ds_data_not_allowed: 'dsData object is not allowed' ds_data_with_key_not_allowed: 'dsData object with key data is not allowed' key_data_not_allowed: 'keyData object is not allowed' + domain_is_reserved_and_requires_correct_auth_info: 'Domain is reserved and requires correct auth info' name_dirty: invalid: 'Domain name is invalid' reserved: 'Domain name is reserved' From b6dd532171a25d213b5e4512d5e3001ad32852db Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 8 Jul 2015 18:00:21 +0300 Subject: [PATCH 03/20] Test fixes #2565 --- app/models/domain.rb | 3 +-- app/models/epp/domain.rb | 2 +- app/models/reserved_domain.rb | 6 ++++++ app/validators/domain_name_validator.rb | 10 +++++----- config/locales/en.yml | 2 +- spec/epp/domain_spec.rb | 6 +++--- spec/fabricators/reserved_domain_fabricator.rb | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 1b1c840f6..b57a2c44b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -266,7 +266,7 @@ class Domain < ActiveRecord::Base end def reserved_pw - ReservedDomain.select("names -> '#{name}' AS pw").first.pw + ReservedDomain.pw_for(name) end def pending_transfer @@ -474,7 +474,6 @@ class Domain < ActiveRecord::Base # rubocop:disable Lint/Loop def generate_auth_info - return if auth_info.present? begin self.auth_info = SecureRandom.hex end while self.class.exists?(auth_info: auth_info) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index b98aa83b1..626477675 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -745,7 +745,7 @@ class Epp::Domain < Domain next end - unless DomainNameValidator.validate_reservation(x) + if ReservedDomain.pw_for(x).present? res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') } next end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 807c44f91..61a57ec50 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -1,3 +1,9 @@ class ReservedDomain < ActiveRecord::Base include Versions # version/reserved_domain_version.rb + + class << self + def pw_for(domain_name) + select("names -> '#{domain_name}' AS pw").first.try(:pw) + end + end end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 1ac609a5a..325fe447a 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -42,10 +42,10 @@ class DomainNameValidator < ActiveModel::EachValidator BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0 end - def validate_reservation(record, value) - return true unless value - return true if record.reserved_pw == record.auth_info - !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) - end + # def validate_reservation(record, value) + # return true unless value + # return true if record.reserved_pw == record.auth_info + # !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) + # end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 943f453fd..228002ec0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -239,7 +239,7 @@ en: errors: messages: blank: 'is missing' - epp_domain_reserved: 'Domain name is reserved or restricted' + epp_domain_reserved: 'Domain name is reserved' epp_obj_does_not_exist: 'Object does not exist' epp_command_failed: 'Command failed' epp_authorization_error: 'Authorization error' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index d4430ac15..442ca16a1 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -224,8 +224,8 @@ describe 'EPP Domain', epp: true do xml = domain_create_xml(name: { value: '1162.ee' }) response = epp_plain_request(xml) - response[:result_code].should == '2302' - response[:msg].should == 'Domain name is reserved [name_dirty]' + response[:result_code].should == '2304' + response[:msg].should == 'Domain is reserved and requires correct auth info' response[:clTRID].should == 'ABC-12345' end @@ -1419,8 +1419,8 @@ describe 'EPP Domain', epp: true do login_as :registrar2 do epp_plain_request(xml) # transfer domain response = epp_plain_request(xml) # attempt second transfer - response[:result_code].should == '2201' response[:msg].should == 'Authorization error' + response[:result_code].should == '2201' end end diff --git a/spec/fabricators/reserved_domain_fabricator.rb b/spec/fabricators/reserved_domain_fabricator.rb index f14948902..672fa3e53 100644 --- a/spec/fabricators/reserved_domain_fabricator.rb +++ b/spec/fabricators/reserved_domain_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:reserved_domain) do - name '1162.ee' + names { { '1162.ee': 'abc' } } end From 664d49c37a0ad795069fb8925750cbab4a355ea2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 8 Jul 2015 18:13:17 +0300 Subject: [PATCH 04/20] Add reserved domain create test #2565 --- spec/epp/domain_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 442ca16a1..deb707da1 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -227,6 +227,23 @@ describe 'EPP Domain', epp: true do response[:result_code].should == '2304' response[:msg].should == 'Domain is reserved and requires correct auth info' response[:clTRID].should == 'ABC-12345' + + xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'wrong_pw' } }) + response = epp_plain_request(xml) + response[:result_code].should == '2304' + response[:msg].should == 'Domain is reserved and requires correct auth info' + end + + it 'creates a reserved domain with correct auth info' do + xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'abc' } }) + + response = epp_plain_request(xml) + response[:msg].should == 'Command completed successfully' + response[:result_code].should == '1000' + + d = Domain.last + d.statuses.should match_array(['reserved']) + d.auth_info.should_not == 'abc' # should generate entirely new auth info after domain create end it 'does not create blocked domain' do From 3454faa959763a32961e7db49876fc087d9865f2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 10:53:39 +0300 Subject: [PATCH 05/20] Refactor + new test #2565 --- app/models/domain.rb | 8 ++++---- spec/epp/domain_spec.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index b57a2c44b..f8a693028 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -80,7 +80,7 @@ class Domain < ActiveRecord::Base after_create :update_reserved_domains def update_reserved_domains - return unless reserved? + return unless in_reserved_list? rd = ReservedDomain.first rd.names[name] = SecureRandom.hex rd.save @@ -95,7 +95,7 @@ class Domain < ActiveRecord::Base validate :validate_reservation def validate_reservation return if persisted? - return if !reserved? || reserved_pw == auth_info + return if !in_reserved_list? || reserved_pw == auth_info errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info) end @@ -261,7 +261,7 @@ class Domain < ActiveRecord::Base @registrant_typeahead || registrant.try(:name) || nil end - def reserved? + def in_reserved_list? reserved_pw.present? end @@ -515,7 +515,7 @@ class Domain < ActiveRecord::Base end def manage_automatic_statuses - statuses << DomainStatus::RESERVED if new_record? && reserved? + statuses << DomainStatus::RESERVED if new_record? && in_reserved_list? # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? if statuses.empty? && valid? diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index deb707da1..ebcbedd68 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1490,6 +1490,33 @@ describe 'EPP Domain', epp: true do d.pending_update?.should == false end + it 'should keep reserved status after reserved domain update' do + domain.statuses = ['reserved'] + domain.save + + xml_params = { + name: { value: domain.name }, + chg: [ + registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } } + ] + } + + response = epp_plain_request(domain_update_xml(xml_params, {}, { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + })) + + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + d = Domain.last + d.statuses.should match_array(['reserved']) + end + it 'updates a domain' do existing_pw = domain.auth_info From 873070cb96c6102e27175bdab77b935416c1daa6 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 12:21:34 +0300 Subject: [PATCH 06/20] Set normal statuses for reserved domains #2746 --- app/models/domain.rb | 3 ++- spec/epp/domain_spec.rb | 47 +++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index f8a693028..5745242a0 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -515,7 +515,8 @@ class Domain < ActiveRecord::Base end def manage_automatic_statuses - statuses << DomainStatus::RESERVED if new_record? && in_reserved_list? + # TODO: Remove this line if EIS decides not to create reserved status #2565 + # statuses << DomainStatus::RESERVED if new_record? && in_reserved_list? # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? if statuses.empty? && valid? diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index ebcbedd68..13abf606f 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -242,7 +242,7 @@ describe 'EPP Domain', epp: true do response[:result_code].should == '1000' d = Domain.last - d.statuses.should match_array(['reserved']) + d.statuses.should match_array(['ok']) d.auth_info.should_not == 'abc' # should generate entirely new auth info after domain create end @@ -1490,32 +1490,33 @@ describe 'EPP Domain', epp: true do d.pending_update?.should == false end - it 'should keep reserved status after reserved domain update' do - domain.statuses = ['reserved'] - domain.save + # TODO: Remove this test if EIS decides not to create reserved status #2565 + # it 'should keep reserved status after reserved domain update' do + # domain.statuses = ['reserved'] + # domain.save - xml_params = { - name: { value: domain.name }, - chg: [ - registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } } - ] - } + # xml_params = { + # name: { value: domain.name }, + # chg: [ + # registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } } + # ] + # } - response = epp_plain_request(domain_update_xml(xml_params, {}, { - _anonymus: [ - legalDocument: { - value: 'dGVzdCBmYWlsCg==', - attrs: { type: 'pdf' } - } - ] - })) + # response = epp_plain_request(domain_update_xml(xml_params, {}, { + # _anonymus: [ + # legalDocument: { + # value: 'dGVzdCBmYWlsCg==', + # attrs: { type: 'pdf' } + # } + # ] + # })) - response[:results][0][:msg].should == 'Command completed successfully' - response[:results][0][:result_code].should == '1000' + # response[:results][0][:msg].should == 'Command completed successfully' + # response[:results][0][:result_code].should == '1000' - d = Domain.last - d.statuses.should match_array(['reserved']) - end + # d = Domain.last + # d.statuses.should match_array(['reserved']) + # end it 'updates a domain' do existing_pw = domain.auth_info From 55b746a4283101b69d7a0e35feb899620a4af71a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 12:55:41 +0300 Subject: [PATCH 07/20] Add reserved boolean to domain #2565 --- app/models/domain.rb | 1 + ...0709092549_add_reserved_field_to_domain.rb | 5 ++++ db/schema-read-only.rb | 7 +++--- db/structure.sql | 23 ++++--------------- spec/epp/domain_spec.rb | 2 ++ 5 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20150709092549_add_reserved_field_to_domain.rb diff --git a/app/models/domain.rb b/app/models/domain.rb index 5745242a0..d67b8f929 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -61,6 +61,7 @@ class Domain < ActiveRecord::Base before_create :generate_auth_info before_create :set_validity_dates + before_create -> { self.reserved = in_reserved_list?; nil } before_update :manage_statuses def manage_statuses return unless registrant_id_changed? diff --git a/db/migrate/20150709092549_add_reserved_field_to_domain.rb b/db/migrate/20150709092549_add_reserved_field_to_domain.rb new file mode 100644 index 000000000..676253575 --- /dev/null +++ b/db/migrate/20150709092549_add_reserved_field_to_domain.rb @@ -0,0 +1,5 @@ +class AddReservedFieldToDomain < ActiveRecord::Migration + def change + add_column :domains, :reserved, :boolean, default: false + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index 174cd27d7..21e70ef04 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150707154543) do +ActiveRecord::Schema.define(version: 20150709092549) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -323,7 +323,8 @@ ActiveRecord::Schema.define(version: 20150707154543) do t.string "registrant_verification_token" t.json "pending_json" t.datetime "force_delete_at" - t.string "statuses", array: true + t.string "statuses", array: true + t.boolean "reserved", default: false end add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree @@ -935,7 +936,7 @@ ActiveRecord::Schema.define(version: 20150707154543) do create_table "que_jobs", id: false, force: :cascade do |t| t.integer "priority", limit: 2, default: 100, null: false - t.datetime "run_at", default: '2015-06-30 14:16:49', null: false + t.datetime "run_at", default: '2015-06-30 14:16:50', null: false t.integer "job_id", limit: 8, default: 0, null: false t.text "job_class", null: false t.json "args", default: [], null: false diff --git a/db/structure.sql b/db/structure.sql index 17187a88f..f102344a1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -942,7 +942,8 @@ CREATE TABLE domains ( registrant_verification_token character varying, pending_json json, force_delete_at timestamp without time zone, - statuses character varying[] + statuses character varying[], + reserved boolean DEFAULT false ); @@ -2419,7 +2420,7 @@ ALTER SEQUENCE pricelists_id_seq OWNED BY pricelists.id; CREATE TABLE que_jobs ( priority smallint DEFAULT 100 NOT NULL, - run_at timestamp without time zone DEFAULT '2015-06-30 14:16:49.190473'::timestamp without time zone NOT NULL, + run_at timestamp without time zone DEFAULT '2015-06-30 14:16:50.905537'::timestamp without time zone NOT NULL, job_id bigint DEFAULT 0 NOT NULL, job_class text NOT NULL, args json DEFAULT '[]'::json NOT NULL, @@ -4807,26 +4808,14 @@ INSERT INTO schema_migrations (version) VALUES ('20150520164507'); INSERT INTO schema_migrations (version) VALUES ('20150521120145'); -INSERT INTO schema_migrations (version) VALUES ('20150522164020'); - -INSERT INTO schema_migrations (version) VALUES ('20150525075550'); - -INSERT INTO schema_migrations (version) VALUES ('20150601083516'); - -INSERT INTO schema_migrations (version) VALUES ('20150601083800'); - INSERT INTO schema_migrations (version) VALUES ('20150603141549'); INSERT INTO schema_migrations (version) VALUES ('20150603211318'); INSERT INTO schema_migrations (version) VALUES ('20150603212659'); -INSERT INTO schema_migrations (version) VALUES ('20150609093515'); - INSERT INTO schema_migrations (version) VALUES ('20150609103333'); -INSERT INTO schema_migrations (version) VALUES ('20150610111019'); - INSERT INTO schema_migrations (version) VALUES ('20150610112238'); INSERT INTO schema_migrations (version) VALUES ('20150610144547'); @@ -4835,12 +4824,8 @@ INSERT INTO schema_migrations (version) VALUES ('20150611124920'); INSERT INTO schema_migrations (version) VALUES ('20150612123111'); -INSERT INTO schema_migrations (version) VALUES ('20150612125720'); - INSERT INTO schema_migrations (version) VALUES ('20150701074344'); -INSERT INTO schema_migrations (version) VALUES ('20150703084206'); - INSERT INTO schema_migrations (version) VALUES ('20150703084632'); INSERT INTO schema_migrations (version) VALUES ('20150706091724'); @@ -4849,3 +4834,5 @@ INSERT INTO schema_migrations (version) VALUES ('20150707104937'); INSERT INTO schema_migrations (version) VALUES ('20150707154543'); +INSERT INTO schema_migrations (version) VALUES ('20150709092549'); + diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 13abf606f..ac5f37ff6 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -144,6 +144,7 @@ describe 'EPP Domain', epp: true do response[:result_code].should == '1000' d = Domain.last d.legal_documents.count.should == 1 + d.reserved.should == false end # it 'creates ria.ee with valid ds record' do @@ -244,6 +245,7 @@ describe 'EPP Domain', epp: true do d = Domain.last d.statuses.should match_array(['ok']) d.auth_info.should_not == 'abc' # should generate entirely new auth info after domain create + d.reserved.should == true end it 'does not create blocked domain' do From bf2c0c6bb781e886ad850696b027f0261d564712 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 13:04:16 +0300 Subject: [PATCH 08/20] Fix rubocop #2565 --- app/controllers/admin/blocked_domains_controller.rb | 1 - app/validators/domain_name_validator.rb | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index c890cf2b0..2df3f90d9 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -19,6 +19,5 @@ class Admin::BlockedDomainsController < AdminController flash.now[:alert] = I18n.t('failed_to_update_record') render :index end - end end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 325fe447a..79fec0291 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -1,17 +1,11 @@ class DomainNameValidator < ActiveModel::EachValidator - # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Metrics/CyclomaticComplexity def validate_each(record, attribute, value) if !self.class.validate_format(value) record.errors[attribute] << (options[:message] || record.errors.generate_message(attribute, :invalid)) elsif !self.class.validate_blocked(value) record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :blocked))) - # elsif !self.class.validate_reservation(value) - # record.errors.add(attribute, (options[:message] || record.errors.generate_message(attribute, :reserved))) end end - # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/CyclomaticComplexity class << self def validate_format(value) @@ -41,11 +35,5 @@ class DomainNameValidator < ActiveModel::EachValidator return true unless value BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0 end - - # def validate_reservation(record, value) - # return true unless value - # return true if record.reserved_pw == record.auth_info - # !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) - # end end end From d99c00172265786e8342bbec3cb9e0541ffbbbd2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 13:16:14 +0300 Subject: [PATCH 09/20] Add reserved domains feature test #2565 --- spec/features/admin/reserved_domain_spec.rb | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/features/admin/reserved_domain_spec.rb diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb new file mode 100644 index 000000000..f2e510ff9 --- /dev/null +++ b/spec/features/admin/reserved_domain_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +feature 'ReservedDomain', type: :feature do + before :all do + @user = Fabricate(:admin_user) + end + + before do + sign_in @user + end + + it 'should manage reserved domains' do + visit admin_reserved_domains_url + page.should have_content('Reserved domains') + + d = Fabricate.build(:domain, name: '110.ee') + d.valid? + d.errors.full_messages.should match_array([]) + + fill_in 'reserved_domains', with: "110.ee: testpw" + click_button 'Save' + + page.should have_content('Record updated') + page.should have_content('110.ee: testpw') + + d.valid? + d.errors.full_messages.should match_array(["Domain is reserved and requires correct auth info"]) + end +end From ad7dc80b765a8685c558c0f3de2662b2b1727bd2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 13:18:40 +0300 Subject: [PATCH 10/20] Improve reserved test #2565 --- spec/features/admin/reserved_domain_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb index f2e510ff9..b4e57882d 100644 --- a/spec/features/admin/reserved_domain_spec.rb +++ b/spec/features/admin/reserved_domain_spec.rb @@ -23,7 +23,11 @@ feature 'ReservedDomain', type: :feature do page.should have_content('Record updated') page.should have_content('110.ee: testpw') - d.valid? + d.valid?.should == false d.errors.full_messages.should match_array(["Domain is reserved and requires correct auth info"]) + + d.auth_info = 'testpw' + d.valid?.should == true + d.errors.full_messages.should match_array([]) end end From 94adc9496f7b4ec28dcd0cea192b98627a0ef54e Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 13:21:41 +0300 Subject: [PATCH 11/20] Reserved test to check for wrong password #2565 --- spec/features/admin/reserved_domain_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb index b4e57882d..7fc6f4ae2 100644 --- a/spec/features/admin/reserved_domain_spec.rb +++ b/spec/features/admin/reserved_domain_spec.rb @@ -26,6 +26,9 @@ feature 'ReservedDomain', type: :feature do d.valid?.should == false d.errors.full_messages.should match_array(["Domain is reserved and requires correct auth info"]) + d.auth_info = 'wrongpw' + d.valid?.should == false + d.auth_info = 'testpw' d.valid?.should == true d.errors.full_messages.should match_array([]) From bfdabaacf3a3f5f00cbb17855720cf53eaa60f22 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 17:57:33 +0300 Subject: [PATCH 12/20] Add new element, error messages, fix tests #2565 --- app/models/domain.rb | 21 ++++++++----- app/models/epp/domain.rb | 11 ++++--- config/locales/en.yml | 3 +- doc/schemas/eis-1.0.xsd | 20 ++++++++++++- spec/epp/domain_spec.rb | 33 +++++++++++++++++---- spec/features/admin/reserved_domain_spec.rb | 8 +++-- spec/support/epp.rb | 6 ++-- 7 files changed, 77 insertions(+), 25 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index d67b8f929..0359bc890 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -96,8 +96,17 @@ class Domain < ActiveRecord::Base validate :validate_reservation def validate_reservation return if persisted? - return if !in_reserved_list? || reserved_pw == auth_info - errors.add(:base, :domain_is_reserved_and_requires_correct_auth_info) + return if !in_reserved_list? + + if reserved_pw.blank? + errors.add(:base, :required_parameter_missing_reserved) + return false + end + + if ReservedDomain.pw_for(name) != reserved_pw + errors.add(:base, :invalid_auth_information_reserved) + return false + end end validates :nameservers, object_count: { @@ -149,7 +158,7 @@ class Domain < ActiveRecord::Base end attr_accessor :registrant_typeahead, :update_me, :deliver_emails, - :epp_pending_update, :epp_pending_delete + :epp_pending_update, :epp_pending_delete, :reserved_pw def subordinate_nameservers nameservers.select { |x| x.hostname.end_with?(name) } @@ -263,11 +272,7 @@ class Domain < ActiveRecord::Base end def in_reserved_list? - reserved_pw.present? - end - - def reserved_pw - ReservedDomain.pw_for(name) + ReservedDomain.pw_for(name).present? end def pending_transfer diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 626477675..c95ba7bed 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -25,7 +25,8 @@ class Epp::Domain < Domain ], '2003' => [ # Required parameter missing [:registrant, :blank], - [:registrar, :blank] + [:registrar, :blank], + [:base, :required_parameter_missing_reserved] ], '2004' => [ # Parameter value range error [:nameservers, :out_of_range, @@ -60,14 +61,16 @@ class Epp::Domain < Domain '2201' => [ # Authorisation error [:auth_info, :wrong_pw] ], + '2202' => [ + [:base, :invalid_auth_information_reserved] + ], '2302' => [ # Object exists [:name_dirty, :taken, { value: { obj: 'name', val: name_dirty } }], [:name_dirty, :reserved, { value: { obj: 'name', val: name_dirty } }], [:name_dirty, :blocked, { value: { obj: 'name', val: name_dirty } }] ], '2304' => [ # Object status prohibits operation - [:base, :domain_status_prohibits_operation], - [:base, :domain_is_reserved_and_requires_correct_auth_info] + [:base, :domain_status_prohibits_operation] ], '2306' => [ # Parameter policy error [:period, :out_of_range, { value: { obj: 'period', val: period } }], @@ -113,7 +116,7 @@ class Epp::Domain < Domain at[:period_unit] = Epp::Domain.parse_period_unit_from_frame(frame) || 'y' - at[:auth_info] = frame.css('pw').text if new_record? + at[:reserved_pw] = frame.css('reserved > pw').text # at[:statuses] = domain_statuses_attrs(frame, action) # binding.pry diff --git a/config/locales/en.yml b/config/locales/en.yml index 228002ec0..aabea6468 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,7 +60,8 @@ en: ds_data_not_allowed: 'dsData object is not allowed' ds_data_with_key_not_allowed: 'dsData object with key data is not allowed' key_data_not_allowed: 'keyData object is not allowed' - domain_is_reserved_and_requires_correct_auth_info: 'Domain is reserved and requires correct auth info' + required_parameter_missing_reserved: 'Required parameter missing; reserved>pw element required for reserved domains' + invalid_auth_information_reserved: 'Invalid authorization information; invalid reserved>pw value' name_dirty: invalid: 'Domain name is invalid' reserved: 'Domain name is reserved' diff --git a/doc/schemas/eis-1.0.xsd b/doc/schemas/eis-1.0.xsd index 262d94581..70393f340 100644 --- a/doc/schemas/eis-1.0.xsd +++ b/doc/schemas/eis-1.0.xsd @@ -24,13 +24,31 @@ + + + + + + + + + + + + + + + + diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index ac5f37ff6..1326ff0e7 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -225,18 +225,39 @@ describe 'EPP Domain', epp: true do xml = domain_create_xml(name: { value: '1162.ee' }) response = epp_plain_request(xml) - response[:result_code].should == '2304' - response[:msg].should == 'Domain is reserved and requires correct auth info' + response[:msg].should == 'Required parameter missing; reserved>pw element required for reserved domains' + response[:result_code].should == '2003' response[:clTRID].should == 'ABC-12345' - xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'wrong_pw' } }) + xml = domain_create_xml({name: { value: '1162.ee' }}, {}, { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + }, + reserved: { + pw: { value: 'wrong_pw' } + } + ] + }) + response = epp_plain_request(xml) - response[:result_code].should == '2304' - response[:msg].should == 'Domain is reserved and requires correct auth info' + response[:msg].should == 'Invalid authorization information; invalid reserved>pw value' + response[:result_code].should == '2202' end it 'creates a reserved domain with correct auth info' do - xml = domain_create_xml(name: { value: '1162.ee' }, authInfo: { pw: { value: 'abc' } }) + xml = domain_create_xml({name: { value: '1162.ee' }}, {}, { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + }, + reserved: { + pw: { value: 'abc' } + } + ] + }) response = epp_plain_request(xml) response[:msg].should == 'Command completed successfully' diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb index 7fc6f4ae2..d8f2dfb95 100644 --- a/spec/features/admin/reserved_domain_spec.rb +++ b/spec/features/admin/reserved_domain_spec.rb @@ -24,12 +24,14 @@ feature 'ReservedDomain', type: :feature do page.should have_content('110.ee: testpw') d.valid?.should == false - d.errors.full_messages.should match_array(["Domain is reserved and requires correct auth info"]) + d.errors.full_messages.should match_array( + ["Required parameter missing; reserved>pw element required for reserved domains"] + ) - d.auth_info = 'wrongpw' + d.reserved_pw = 'wrongpw' d.valid?.should == false - d.auth_info = 'testpw' + d.reserved_pw = 'testpw' d.valid?.should == true d.errors.full_messages.should match_array([]) end diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 5e9847d48..0193787f5 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -144,7 +144,7 @@ module Epp end # rubocop: disable Metrics/MethodLength - def domain_create_xml(xml_params = {}, dnssec_params = {}) + def domain_create_xml(xml_params = {}, dnssec_params = {}, custom_params = {}) defaults = { name: { value: next_domain_name }, period: { value: '1', attrs: { unit: 'y' } }, @@ -185,7 +185,7 @@ module Epp dnssec_params = dnssec_defaults.deep_merge(dnssec_params) if dnssec_params != false - custom_params = { + custom_defaults = { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -194,6 +194,8 @@ module Epp ] } + custom_params = custom_defaults.deep_merge(custom_params) if custom_params != false + epp_xml = EppXml::Domain.new(cl_trid: 'ABC-12345') epp_xml.create(xml_params, dnssec_params, custom_params) end From d46bd5b4aa8354fb8dd93874c848439d2c271c6c Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 18:00:47 +0300 Subject: [PATCH 13/20] Improve EIS xsd #2565 --- doc/schemas/eis-1.0.xsd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/schemas/eis-1.0.xsd b/doc/schemas/eis-1.0.xsd index 70393f340..2612b5e57 100644 --- a/doc/schemas/eis-1.0.xsd +++ b/doc/schemas/eis-1.0.xsd @@ -15,12 +15,12 @@ Child elements found in EPP commands. --> - + - + @@ -38,7 +38,7 @@ - + From 344a0a9ca7e654184696733cc630e18dc134ee02 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 18:11:13 +0300 Subject: [PATCH 14/20] Remove redundant code #2565 --- app/models/domain.rb | 3 --- spec/epp/domain_spec.rb | 29 ----------------------------- 2 files changed, 32 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 0359bc890..b0148cf30 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -521,9 +521,6 @@ class Domain < ActiveRecord::Base end def manage_automatic_statuses - # TODO: Remove this line if EIS decides not to create reserved status #2565 - # statuses << DomainStatus::RESERVED if new_record? && in_reserved_list? - # domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable? if statuses.empty? && valid? statuses << DomainStatus::OK diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 1326ff0e7..728bf19ca 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -265,7 +265,6 @@ describe 'EPP Domain', epp: true do d = Domain.last d.statuses.should match_array(['ok']) - d.auth_info.should_not == 'abc' # should generate entirely new auth info after domain create d.reserved.should == true end @@ -1513,34 +1512,6 @@ describe 'EPP Domain', epp: true do d.pending_update?.should == false end - # TODO: Remove this test if EIS decides not to create reserved status #2565 - # it 'should keep reserved status after reserved domain update' do - # domain.statuses = ['reserved'] - # domain.save - - # xml_params = { - # name: { value: domain.name }, - # chg: [ - # registrant: { value: 'FIXED:CITIZEN_1234', attrs: { verified: 'yes' } } - # ] - # } - - # response = epp_plain_request(domain_update_xml(xml_params, {}, { - # _anonymus: [ - # legalDocument: { - # value: 'dGVzdCBmYWlsCg==', - # attrs: { type: 'pdf' } - # } - # ] - # })) - - # response[:results][0][:msg].should == 'Command completed successfully' - # response[:results][0][:result_code].should == '1000' - - # d = Domain.last - # d.statuses.should match_array(['reserved']) - # end - it 'updates a domain' do existing_pw = domain.auth_info From d5045cb66ab2039192dfd401e28e4358b34eb9f2 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 18:21:47 +0300 Subject: [PATCH 15/20] Improve reserved domain feature test #2565 --- spec/features/admin/reserved_domain_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/features/admin/reserved_domain_spec.rb b/spec/features/admin/reserved_domain_spec.rb index d8f2dfb95..9c780285f 100644 --- a/spec/features/admin/reserved_domain_spec.rb +++ b/spec/features/admin/reserved_domain_spec.rb @@ -34,5 +34,10 @@ feature 'ReservedDomain', type: :feature do d.reserved_pw = 'testpw' d.valid?.should == true d.errors.full_messages.should match_array([]) + + d.save + visit admin_reserved_domains_url + page.should have_content('110.ee') + page.should_not have_content('110.ee: testpw') end end From 048ab8a4756de2d4325722e9cc3d57971c9e59ef Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 9 Jul 2015 18:27:36 +0300 Subject: [PATCH 16/20] Fix rubocop #2565 --- app/models/domain.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index b0148cf30..49dcb9cfc 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -95,18 +95,15 @@ class Domain < ActiveRecord::Base validate :validate_period validate :validate_reservation def validate_reservation - return if persisted? - return if !in_reserved_list? + return if persisted? || !in_reserved_list? if reserved_pw.blank? errors.add(:base, :required_parameter_missing_reserved) return false end - if ReservedDomain.pw_for(name) != reserved_pw - errors.add(:base, :invalid_auth_information_reserved) - return false - end + return if ReservedDomain.pw_for(name) == reserved_pw + errors.add(:base, :invalid_auth_information_reserved) end validates :nameservers, object_count: { From 5f1df12b48f41feee4e9fbafc6904226ef720dae Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 10 Jul 2015 11:16:53 +0300 Subject: [PATCH 17/20] Add reserved pw field for registrar domain form #2565 --- app/models/depp/domain.rb | 14 ++++++++------ .../registrar/domains/form_partials/_general.haml | 13 ++++++++++--- config/locales/en.yml | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index 649d00964..d4a51ac06 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -132,7 +132,7 @@ module Depp # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/AbcSize - def construct_params_from_server_data(data) + def construct_params_from_server_data(data) ret = default_params ret[:name] = data.css('name').text ret[:registrant] = data.css('registrant').text @@ -182,16 +182,18 @@ module Depp # rubocop:enable Metrics/AbcSize def construct_custom_params_hash(domain_params) - custom_params = {} + custom_params = { _anonymus: [] } if domain_params[:legal_document].present? type = domain_params[:legal_document].original_filename.split('.').last.downcase - custom_params = { - _anonymus: [ - legalDocument: { value: Base64.encode64(domain_params[:legal_document].read), attrs: { type: type } } - ] + custom_params[:_anonymus] << { + legalDocument: { value: Base64.encode64(domain_params[:legal_document].read), attrs: { type: type } } } end + if domain_params[:reserved_pw].present? + custom_params[:_anonymus] << { reserved: { pw: { value: domain_params[:reserved_pw] } } } + end + custom_params end diff --git a/app/views/registrar/domains/form_partials/_general.haml b/app/views/registrar/domains/form_partials/_general.haml index bde4ff67f..8057a1848 100644 --- a/app/views/registrar/domains/form_partials/_general.haml +++ b/app/views/registrar/domains/form_partials/_general.haml @@ -5,7 +5,7 @@ = label_tag :domain_name, t(:name), class: 'required' .col-md-7 - readonly = params[:domain_name] ? true : false - = text_field_tag('domain[name]', @domain_params[:name], + = text_field_tag('domain[name]', @domain_params[:name], class: 'form-control', readonly: readonly, required: true) - unless params[:domain_name] @@ -13,13 +13,20 @@ .col-md-3.control-label = label_tag :domain_period, t(:period), class: 'required' .col-md-7 - = select_tag 'domain[period]', + = select_tag 'domain[period]', options_for_select(Depp::Domain::PERIODS, @domain_params[:period]), { class: 'form-control' } .form-group .col-md-3.control-label = label_tag :domain_registrant, t(:registrant), class: 'required' .col-md-7 - = select_tag "domain[registrant]", + = select_tag "domain[registrant]", options_for_select(@contacts_autocomplete_map, selected: @domain_params[:registrant]), include_blank: true, class: 'js-combobox', required: true + + - unless params[:domain_name] + .form-group + .col-md-3.control-label + = label_tag :domain_reserved_pw, t(:reserved_pw) + .col-md-7 + = text_field_tag('domain[reserved_pw]', @domain_params[:reserved_pw], class: 'form-control') diff --git a/config/locales/en.yml b/config/locales/en.yml index aabea6468..6ffd49079 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -865,3 +865,4 @@ en: export_csv: 'Export CSV' reserved_domains: 'Reserved domains' invalid_yaml: 'Invalid YAML' + reserved_pw: 'Reserved pw' From 6daf082129b5fe6a08b5f909f93a0dbd69b34f7a Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 10 Jul 2015 12:04:12 +0300 Subject: [PATCH 18/20] Add menu link #2565 --- app/views/layouts/admin/application.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/layouts/admin/application.haml b/app/views/layouts/admin/application.haml index 8fac692f5..da411864c 100644 --- a/app/views/layouts/admin/application.haml +++ b/app/views/layouts/admin/application.haml @@ -60,6 +60,7 @@ %li= link_to t(:settings), admin_settings_path %li= link_to t(:zonefile), admin_zonefile_settings_path %li= link_to t(:blocked_domains), admin_blocked_domains_path + %li= link_to t(:reserved_domains), admin_reserved_domains_path -# %li= link_to t(:domains_history), admin_domain_versions_path %li= link_to t(:epp_logs), admin_epp_logs_path %li= link_to t(:repp_logs), admin_repp_logs_path From c4da9c86a654030b7b8717625db1a7fe3470b7a9 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 10 Jul 2015 15:42:14 +0300 Subject: [PATCH 19/20] Introduce request op to domain transfer #2746 --- app/controllers/epp/domains_controller.rb | 2 +- app/models/epp/domain.rb | 4 +- config/locales/en.yml | 1 + spec/epp/domain_spec.rb | 122 ++++++++++++++++++++-- spec/support/epp.rb | 2 +- 5 files changed, 121 insertions(+), 10 deletions(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index a50b96003..e3188786f 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -179,7 +179,7 @@ class Epp::DomainsController < EppController requires 'name' @prefix = nil - requires_attribute 'transfer', 'op', values: %(approve, query, reject) + requires_attribute 'transfer', 'op', values: %(approve, query, reject, request) end def find_domain diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c95ba7bed..bb9ab55ce 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -461,6 +461,8 @@ class Epp::Domain < Domain def transfer(frame, action, current_user) case action when 'query' + return domain_transfers.last if domain_transfers.any? + when 'request' return pending_transfer if pending_transfer return query_transfer(frame, current_user) when 'approve' @@ -468,7 +470,7 @@ class Epp::Domain < Domain when 'reject' return reject_transfer(frame, current_user) if pending_transfer end - add_epp_error('2303', nil, nil, I18n.t('pending_transfer_was_not_found')) + add_epp_error('2303', nil, nil, I18n.t('no_transfers_found')) end # TODO: Eager load problems here. Investigate how it's possible not to query contact again diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ffd49079..5c2bcd344 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -866,3 +866,4 @@ en: reserved_domains: 'Reserved domains' invalid_yaml: 'Invalid YAML' reserved_pw: 'Reserved pw' + no_transfers_found: 'No transfers found' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 728bf19ca..f88db572a 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -839,7 +839,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -887,7 +887,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -965,7 +965,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1401,7 +1401,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: 'test' } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1415,12 +1415,12 @@ describe 'EPP Domain', epp: true do response[:msg].should == 'Authorization error' end - it 'ignores transfer wha registrant registrar requests transfer' do + it 'ignores transfer when domain already belongs to registrar' do pw = domain.auth_info xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1446,7 +1446,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1482,6 +1482,114 @@ describe 'EPP Domain', epp: true do response[:result_code].should == '2303' end + it 'should not return transfers when there are none' do + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: domain.auth_info } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'No transfers found' + response[:results][0][:result_code].should == '2303' + end + + it 'should allow querying domain transfer' do + Setting.transfer_wait_time = 1 + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'request', { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + }) + + login_as :registrar2 do + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'pending' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'pending' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + end + + # approves pending transfer + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'approve', { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + }) + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + # query should return last completed transfer + domain.reload + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'clientApproved' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + + Setting.transfer_wait_time = 0 + end + ### UPDATE ### it 'should update right away without update pending status' do existing_pw = domain.auth_info diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 0193787f5..698284735 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -349,7 +349,7 @@ module Epp epp_xml.check(xml_params) end - def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {}) + def domain_transfer_xml(xml_params = {}, op = 'request', custom_params = {}) defaults = { name: { value: next_domain_name }, authInfo: { From e1c5fca90d0f5180583a17641881cf6610946bf9 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 10 Jul 2015 16:04:31 +0300 Subject: [PATCH 20/20] Registrar portal transfer improvement, test fixes #2746 --- app/models/depp/domain.rb | 3 ++- app/views/registrar/domains/transfer_index.haml | 2 +- spec/epp/domain_spec.rb | 2 +- spec/epp/epp_helper_spec.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index d4a51ac06..fa252819e 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -79,7 +79,8 @@ module Depp end def transfer(params) - op = params[:query] ? 'query' : nil + op = params[:request] ? 'request' : nil + op = params[:query] ? 'query' : op op = params[:approve] ? 'approve' : op op = params[:reject] ? 'reject' : op diff --git a/app/views/registrar/domains/transfer_index.haml b/app/views/registrar/domains/transfer_index.haml index ecc5ff1a4..ccdfea305 100644 --- a/app/views/registrar/domains/transfer_index.haml +++ b/app/views/registrar/domains/transfer_index.haml @@ -22,6 +22,6 @@ = file_field_tag 'legal_document' .form-group .col-md-10.text-right - %button.btn.btn-warning{ name: 'query' }= t(:transfer) + %button.btn.btn-warning{ name: 'request' }= t(:transfer) /%button.btn.btn-warning{ name: 'approve' }= t(:approve) /%button.btn.btn-warning{ name: 'reject' }= t(:reject) diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index f88db572a..c19c9cbff 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1478,7 +1478,7 @@ describe 'EPP Domain', epp: true do }) response = epp_plain_request(xml) - response[:msg].should == 'Pending transfer was not found' + response[:msg].should == 'No transfers found' response[:result_code].should == '2303' end diff --git a/spec/epp/epp_helper_spec.rb b/spec/epp/epp_helper_spec.rb index 65a9fcc8d..7b85a1ab1 100644 --- a/spec/epp/epp_helper_spec.rb +++ b/spec/epp/epp_helper_spec.rb @@ -10,7 +10,7 @@ describe 'EPP Helper', epp: true do expected = Nokogiri::XML(' - + ' + dn + '