diff --git a/.codeclimate.yml b/.codeclimate.yml
index 7a1e597ec..77b7917a2 100644
--- a/.codeclimate.yml
+++ b/.codeclimate.yml
@@ -32,6 +32,9 @@ plugins:
rubocop:
enabled: true
channel: rubocop-0-74
+ checks:
+ Rubocop/Style/ClassAndModuleChildren:
+ enabled: false
checks:
method-lines:
config:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9afedbf17..d2e51445e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,44 @@
+18.03.2021
+* Added tests for renew and domain status management [#1886](https://github.com/internetee/registry/pull/1886)
+
+12.03.2021
+* Removed old classnames from notifications [#1878](https://github.com/internetee/registry/pull/1878)
+* improved test coverage [#1860](https://github.com/internetee/registry/pull/1860)
+* added test for whois record delete [#1811](https://github.com/internetee/registry/pull/1811)
+
+11.03.2021
+* Account activity in registrar and REPP now return balance with each record [#1819](https://github.com/internetee/registry/issues/1819)
+* Fixed CookieOverflow error with large authentication service keys [#1879](https://github.com/internetee/registry/pull/1879)
+
+10.03.2021
+* Registrant API returns full contact details for admin contacts [#1876](https://github.com/internetee/registry/pull/1876)
+
+09.03.2021
+* AWS message id saving over API [#1877](https://github.com/internetee/registry/pull/1877)
+* Enabled Zeitwerk autoloader [#1872](https://github.com/internetee/registry/issues/1872)
+
+04.03.2021
+* Removed old registrant portal from the project [#1826](https://github.com/internetee/registry/issues/1826)
+
+03.03.2021
+* Email notification is sent in case of pendingupdate expiry [#897](https://github.com/internetee/registry/issues/897)
+
+26.02.2021
+* Domain delete is not affected by updateProhibited [#1844](https://github.com/internetee/registry/issues/1844)
+* Registrant API fix for handling eidas personal identificators [#1864](https://github.com/internetee/registry/pull/1864)
+
+23.02.2021
+* UpdateProhibited status affects bulk actions in REPP [#1818](https://github.com/internetee/registry/issues/1818)
+* Registrant api domain request now excludes tech only domains by default [#1836](https://github.com/internetee/registry/pull/1836)
+
+22.02.2021
+* serverDeleteProhibited prohibts delete action [#1849](https://github.com/internetee/registry/issues/1849)
+
+19.02.2021
+* Update prohibited staatus is kept after renew [#1843](https://github.com/internetee/registry/issues/1843)
+* Fixed clientHold and serverManualInzone status conflict issue [#1845](https://github.com/internetee/registry/issues/1845)
+* Replacing registrant object with another that has the same ident data set does not require registrant verification [#1852](https://github.com/internetee/registry/issues/1852)
+
11.02.2021
* Poll messages on locking and unlocking a domain [#1828](https://github.com/internetee/registry/issues/1828)
* Registrar's prefix is now checked and added to contact id for info and check requests [#1832](https://github.com/internetee/registry/issues/1832)
diff --git a/app/controllers/admin/contact_versions_controller.rb b/app/controllers/admin/contact_versions_controller.rb
index 834353cf4..9638b341f 100644
--- a/app/controllers/admin/contact_versions_controller.rb
+++ b/app/controllers/admin/contact_versions_controller.rb
@@ -2,12 +2,12 @@ module Admin
class ContactVersionsController < BaseController
include ObjectVersionsHelper
- load_and_authorize_resource
+ load_and_authorize_resource class: Version::ContactVersion
def index
params[:q] ||= {}
- @q = ContactVersion.search(params[:q])
+ @q = Version::ContactVersion.search(params[:q])
@versions = @q.result.page(params[:page])
search_params = params[:q].deep_dup
@@ -23,7 +23,7 @@ module Admin
end
end
- versions = ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
+ versions = Version::ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
@@ -32,8 +32,8 @@ module Admin
def show
per_page = 7
- @version = ContactVersion.find(params[:id])
- @versions = ContactVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
+ @version = Version::ContactVersion.find(params[:id])
+ @versions = Version::ContactVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
@versions_map = @versions.all.map(&:id)
# what we do is calc amount of results until needed version
@@ -49,7 +49,7 @@ module Admin
end
def search
- render json: ContactVersion.search_by_query(params[:q])
+ render json: Version::ContactVersion.search_by_query(params[:q])
end
def create_where_string(key, value)
diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb
index b6245f6ea..2d054f73d 100644
--- a/app/controllers/admin/domain_versions_controller.rb
+++ b/app/controllers/admin/domain_versions_controller.rb
@@ -2,12 +2,12 @@ module Admin
class DomainVersionsController < BaseController
include ObjectVersionsHelper
- load_and_authorize_resource
+ load_and_authorize_resource class: Version::DomainVersion
def index
params[:q] ||= {}
- @q = DomainVersion.includes(:item).search(params[:q])
+ @q = Version::DomainVersion.includes(:item).search(params[:q])
@versions = @q.result.page(params[:page])
search_params = params[:q].deep_dup
@@ -40,7 +40,7 @@ module Admin
whereS += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrars.present?
whereS += " AND 1=0" if registrars == []
- versions = DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
+ versions = Version::DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
@@ -50,8 +50,8 @@ module Admin
def show
per_page = 7
- @version = DomainVersion.find(params[:id])
- @versions = DomainVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
+ @version = Version::DomainVersion.find(params[:id])
+ @versions = Version::DomainVersion.where(item_id: @version.item_id).order(created_at: :desc, id: :desc)
@versions_map = @versions.all.map(&:id)
# what we do is calc amount of results until needed version
@@ -67,7 +67,7 @@ module Admin
end
def search
- render json: DomainVersion.search_by_query(params[:q])
+ render json: Version::DomainVersion.search_by_query(params[:q])
end
def create_where_string(key, value)
diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb
index 2b5977f59..1ef73e9ef 100644
--- a/app/controllers/api/v1/contact_requests_controller.rb
+++ b/app/controllers/api/v1/contact_requests_controller.rb
@@ -23,14 +23,15 @@ module Api
record = ContactRequest.find_by(id: id)
return :not_found unless record
- record.update_status(contact_request_params)
+ record.update_record(contact_request_params)
render json: record, status: :ok
rescue StandardError
head :bad_request
end
def contact_request_params
- params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :ip)
+ params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :ip,
+ :message_id)
end
end
end
diff --git a/app/controllers/api/v1/registrant/auth_controller.rb b/app/controllers/api/v1/registrant/auth_controller.rb
index 03dfa45f3..728ef696d 100644
--- a/app/controllers/api/v1/registrant/auth_controller.rb
+++ b/app/controllers/api/v1/registrant/auth_controller.rb
@@ -19,6 +19,9 @@ module Api
token = create_token(user)
if token
+ msg = "Bearer for #{eid_params[:first_name]} #{eid_params[:last_name]} " \
+ "(#{eid_params[:ident]}) - '#{token[:access_token]}'"
+ ToStdout.msg(msg) unless Rails.env.production?
render json: token
else
render json: { errors: [{ base: ['Cannot create generate session token'] }] }
@@ -37,7 +40,7 @@ module Api
obj.require(key)
end
- params.permit(required_params)
+ params.permit(required_params + [:country_code])
end
def create_token(user)
diff --git a/app/controllers/api/v1/registrant/domains_controller.rb b/app/controllers/api/v1/registrant/domains_controller.rb
index 73b534598..94d2c865a 100644
--- a/app/controllers/api/v1/registrant/domains_controller.rb
+++ b/app/controllers/api/v1/registrant/domains_controller.rb
@@ -4,6 +4,8 @@ module Api
module V1
module Registrant
class DomainsController < ::Api::V1::Registrant::BaseController
+ before_action :set_tech_flag, only: [:show]
+
def index
limit = params[:limit] || 200
offset = params[:offset] || 0
@@ -25,7 +27,8 @@ module Api
serializer.to_json
end
- render json: { count: domains.count, domains: serialized_domains }
+ render json: { total: current_user_domains_total_count, count: domains.count,
+ domains: serialized_domains }
end
def show
@@ -41,10 +44,22 @@ module Api
private
- def current_user_domains
- current_registrant_user.domains
+ def set_tech_flag
+ # current_user_domains scope depends on tech flag
+ # However, if it's not present, tech contact can not see specific domain entry at all.
+ params.merge!(tech: 'true')
+ end
+
+ def current_user_domains_total_count
+ current_registrant_user.domains.count
rescue CompanyRegister::NotAvailableError
- current_registrant_user.direct_domains
+ current_registrant_user.direct_domains.count
+ end
+
+ def current_user_domains
+ current_registrant_user.domains(admin: params[:tech] != 'true')
+ rescue CompanyRegister::NotAvailableError
+ current_registrant_user.direct_domains(admin: params[:tech] != 'true')
end
end
end
diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb
index 060931796..a93fa300d 100644
--- a/app/controllers/epp/polls_controller.rb
+++ b/app/controllers/epp/polls_controller.rb
@@ -12,9 +12,11 @@ module Epp
@notification = current_user.unread_notifications.order('created_at DESC').take
render_epp_response 'epp/poll/poll_no_messages' and return unless @notification
+
if @notification.attached_obj_type && @notification.attached_obj_id
begin
- @object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id)
+ @object = object_by_type(@notification.attached_obj_type)
+ .find(@notification.attached_obj_id)
rescue => problem
# the data model might be inconsistent; or ...
# this could happen if the registrar does not dequeue messages, and then the domain was deleted
@@ -31,6 +33,12 @@ module Epp
render_epp_response 'epp/poll/poll_req'
end
+ def object_by_type(object_type)
+ Object.const_get(object_type)
+ rescue NameError
+ Object.const_get("Version::#{object_type}")
+ end
+
def ack_poll
@notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb
deleted file mode 100644
index 49070ebde..000000000
--- a/app/controllers/registrant/contacts_controller.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-class Registrant::ContactsController < RegistrantController
- helper_method :domain
- helper_method :fax_enabled?
- helper_method :domain_filter_params
- skip_authorization_check only: %i[edit update]
- before_action :set_contact, only: [:show]
-
- def show
- @requester_contact = Contact.find_by(ident: current_registrant_user.ident)
- authorize! :read, @contact
- end
-
- def edit
- @contact = current_user_contacts.find(params[:id])
- end
-
- def update
- @contact = current_user_contacts.find(params[:id])
- @contact.attributes = contact_params
- response = update_contact_via_api(@contact.uuid)
- updated = response.is_a?(Net::HTTPSuccess)
-
- if updated
- redirect_to registrant_domain_contact_url(domain, @contact), notice: t('.updated')
- else
- parsed_response = JSON.parse(response.body, symbolize_names: true)
- @errors = parsed_response[:errors]
- render :edit
- end
- end
-
- private
-
- def set_contact
- id = params[:id]
- contact = domain.contacts.find_by(id: id) || current_user_contacts.find_by(id: id)
- contact ||= Contact.find_by(id: id, ident: domain.registrant.ident)
- @contact = contact
- end
-
- def domain
- current_user_domains.find(params[:domain_id])
- end
-
- def contact_params
- permitted = %i[
- name
- email
- phone
- ]
-
- permitted << :fax if fax_enabled?
- permitted += %i[street zip city state country_code] if Contact.address_processing?
- params.require(:contact).permit(*permitted)
- end
-
- def access_token
- uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/auth/eid")
- request = Net::HTTP::Post.new(uri)
- request.form_data = access_token_request_params
-
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
- http.request(request)
- end
-
- json_doc = JSON.parse(response.body, symbolize_names: true)
- json_doc[:access_token]
- end
-
- def access_token_request_params
- { ident: current_registrant_user.ident,
- first_name: current_registrant_user.first_name,
- last_name: current_registrant_user.last_name }
- end
-
- def fax_enabled?
- ENV['fax_enabled'] == 'true'
- end
-
- def contact_update_api_params
- params = contact_params
- params = normalize_address_attributes_for_api(params) if Contact.address_processing?
- params
- end
-
- def normalize_address_attributes_for_api(params)
- normalized = params
- address_parts = {}
-
- Contact.address_attribute_names.each do |attr|
- attr = attr.to_sym
- address_parts[attr] = params[attr]
- normalized.delete(attr)
- end
-
- normalized[:address] = address_parts
- normalized
- end
-
- def update_contact_via_api(uuid)
- uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/contacts/#{uuid}")
- request = Net::HTTP::Patch.new(uri)
- request['Authorization'] = "Bearer #{access_token}"
- request['Content-type'] = 'application/json'
- request.body = contact_update_api_params.to_json
-
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
- http.request(request)
- end
- end
-
- def domain_filter_params
- params.permit(:domain_filter)
- end
-end
diff --git a/app/controllers/registrant/domain_delete_confirms_controller.rb b/app/controllers/registrant/domain_delete_confirms_controller.rb
deleted file mode 100644
index 337ca2403..000000000
--- a/app/controllers/registrant/domain_delete_confirms_controller.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-class Registrant::DomainDeleteConfirmsController < RegistrantController
- skip_before_action :authenticate_registrant_user!, only: [:show, :update]
- skip_authorization_check only: [:show, :update]
-
- def show
- return if params[:confirmed] || params[:rejected]
-
- @domain = Domain.find(params[:id])
- @domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
- end
-
- def update
- @domain = Domain.find(params[:id])
- unless @domain.registrant_delete_confirmable?(params[:token])
- flash[:alert] = t(:registrant_domain_verification_failed)
- return render 'show'
- end
-
- @registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
- verification_token: params[:token])
-
- initiator = current_registrant_user ? current_registrant_user.username :
- t(:user_not_authenticated)
-
- confirmed = params[:confirmed] ? true : false
- action = if confirmed
- @registrant_verification.domain_registrant_delete_confirm!("email link #{initiator}")
- else
- @registrant_verification.domain_registrant_delete_reject!("email link #{initiator}")
- end
-
- fail_msg = t("registrant_domain_delete_#{confirmed ? 'confirmed' : 'rejected'}_failed".to_sym)
- success_msg = t("registrant_domain_verification_#{confirmed ? 'confirmed' : 'rejected'}".to_sym)
-
- flash[:alert] = action ? success_msg : fail_msg
- (render 'show' && return) unless action
-
- if confirmed
- redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
- else
- redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
- end
- end
-end
diff --git a/app/controllers/registrant/domain_update_confirms_controller.rb b/app/controllers/registrant/domain_update_confirms_controller.rb
deleted file mode 100644
index 0e4f2a582..000000000
--- a/app/controllers/registrant/domain_update_confirms_controller.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-class Registrant::DomainUpdateConfirmsController < RegistrantController
- skip_before_action :authenticate_registrant_user!, only: %i[show update]
- skip_authorization_check only: %i[show update]
-
- def show
- return if params[:confirmed] || params[:rejected]
- @domain = Domain.find(params[:id])
- @domain = nil unless @domain.registrant_update_confirmable?(params[:token])
- end
-
- def update
- @domain = Domain.find(params[:id])
- unless @domain.registrant_update_confirmable?(params[:token])
- flash[:alert] = t(:registrant_domain_verification_failed)
- return render 'show'
- end
-
- @registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
- verification_token: params[:token])
-
- initiator = current_registrant_user ? current_registrant_user.username :
- t(:user_not_authenticated)
-
- if params[:rejected]
- if @registrant_verification.domain_registrant_change_reject!("email link, #{initiator}")
- flash[:notice] = t(:registrant_domain_verification_rejected)
- redirect_to registrant_domain_update_confirm_path(@domain.id, rejected: true)
- else
- flash[:alert] = t(:registrant_domain_verification_rejected_failed)
- return render 'show'
- end
- elsif params[:confirmed]
- if @registrant_verification.domain_registrant_change_confirm!("email link, #{initiator}")
- Dispute.close_by_domain(@domain.name) if @domain.disputed?
-
- flash[:notice] = t(:registrant_domain_verification_confirmed)
- redirect_to registrant_domain_update_confirm_path(@domain.id, confirmed: true)
- else
- flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
- return render 'show'
- end
- end
- end
-end
diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb
deleted file mode 100644
index 216f87e54..000000000
--- a/app/controllers/registrant/domains_controller.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-class Registrant::DomainsController < RegistrantController
- def index
- authorize! :view, :registrant_domains
-
- params[:q] ||= {}
- normalize_search_parameters do
- @q = current_user_domains.search(search_params)
- end
-
- domains = @q.result
-
- respond_to do |format|
- format.html do
- @domains = domains.page(params[:page])
- domains_per_page = params[:results_per_page].to_i
- @domains = @domains.per(domains_per_page) if domains_per_page.positive?
- end
- format.csv do
- raw_csv = @q.result.to_csv
- send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
- end
- format.pdf do
- view = ActionView::Base.new(ActionController::Base.view_paths, domains: domains)
- raw_html = view.render(file: 'registrant/domains/list_pdf', layout: false)
- raw_pdf = domains.pdf(raw_html)
-
- send_data raw_pdf, filename: 'domains.pdf'
- end
- end
- end
-
- def show
- @domain = current_user_domains.find(params[:id])
- authorize! :read, @domain
- end
-
- def confirmation
- authorize! :view, :registrant_domains
- domain = current_user_domains.find(params[:id])
-
- if (domain.statuses.include?(DomainStatus::PENDING_UPDATE) ||
- domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
- domain.pending_json.present?
-
- @domain = domain
- @confirmation_url = confirmation_url(domain)
- else
- flash[:warning] = I18n.t('available_verification_url_not_found')
- redirect_to registrant_domain_path(domain)
- end
- end
-
- private
-
- def normalize_search_parameters
- ca_cache = params[:q][:valid_to_lteq]
- begin
- end_time = params[:q][:valid_to_lteq].try(:to_date)
- params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
- rescue
- logger.warn('Invalid date')
- end
- yield
- params[:q][:valid_to_lteq] = ca_cache
- end
-
- def confirmation_url(domain)
- if domain.statuses.include?(DomainStatus::PENDING_UPDATE)
- registrant_domain_update_confirm_url(token: domain.registrant_verification_token)
- elsif domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
- registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
- end
- end
-
- def search_params
- params.require(:q).permit(:name_matches, :registrant_ident_eq, :valid_to_gteq, :valid_to_lteq,
- :results_per_page)
- end
-end
diff --git a/app/controllers/registrant/registrars_controller.rb b/app/controllers/registrant/registrars_controller.rb
deleted file mode 100644
index 7bb101bb9..000000000
--- a/app/controllers/registrant/registrars_controller.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class Registrant::RegistrarsController < RegistrantController
- def show
- @registrar = Registrar.find(params[:id])
- authorize! :read, @registrar
- end
-end
\ No newline at end of file
diff --git a/app/controllers/registrant/sessions_controller.rb b/app/controllers/registrant/sessions_controller.rb
deleted file mode 100644
index 73b6d52da..000000000
--- a/app/controllers/registrant/sessions_controller.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-class Registrant::SessionsController < Devise::SessionsController
- layout 'registrant/application'
-
- private
-
- def after_sign_in_path_for(_resource_or_scope)
- registrant_root_path
- end
-
- def after_sign_out_path_for(_resource_or_scope)
- new_registrant_user_session_path
- end
-
- def user_for_paper_trail
- current_registrant_user.present? ? current_registrant_user.id_role_username : 'anonymous'
- end
-end
diff --git a/app/controllers/registrar/base_controller.rb b/app/controllers/registrar/base_controller.rb
index 54bed977b..2aad861b8 100644
--- a/app/controllers/registrar/base_controller.rb
+++ b/app/controllers/registrar/base_controller.rb
@@ -17,7 +17,7 @@ class Registrar
private
def check_ip_restriction
- ip_restriction = Authorization::RestrictedIP.new(request.ip)
+ ip_restriction = Authorization::RestrictedIp.new(request.ip)
allowed = ip_restriction.can_access_registrar_area?(current_registrar_user.registrar)
return if allowed
diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb
index 1a46da463..2e268af0b 100644
--- a/app/controllers/registrar/domains_controller.rb
+++ b/app/controllers/registrar/domains_controller.rb
@@ -49,7 +49,7 @@ class Registrar
domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
end
- raw_csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters,
+ raw_csv = Registrar::DomainListCsvPresenter.new(domains: domain_presenters,
view: view_context).to_s
filename = "Domains_#{l(Time.zone.now, format: :filename)}.csv"
send_data raw_csv, filename: filename, type: "#{Mime[:csv]}; charset=utf-8"
diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb
index e413c4feb..ec7cda148 100644
--- a/app/controllers/registrar/sessions_controller.rb
+++ b/app/controllers/registrar/sessions_controller.rb
@@ -72,7 +72,7 @@ class Registrar
end
def check_ip_restriction
- ip_restriction = Authorization::RestrictedIP.new(request.ip)
+ ip_restriction = Authorization::RestrictedIp.new(request.ip)
allowed = ip_restriction.can_access_registrar_area_sign_in_page?
return if allowed
diff --git a/app/controllers/repp/v1/accounts_controller.rb b/app/controllers/repp/v1/accounts_controller.rb
index 7397b274d..388bc9a94 100644
--- a/app/controllers/repp/v1/accounts_controller.rb
+++ b/app/controllers/repp/v1/accounts_controller.rb
@@ -6,8 +6,28 @@ module Repp
def balance
resp = { balance: current_user.registrar.cash_account.balance,
currency: current_user.registrar.cash_account.currency }
+ resp[:transactions] = activities if params[:detailed] == 'true'
render_success(data: resp)
end
+
+ def activities
+ arr = []
+ registrar_activities.each do |a|
+ arr << { created_at: a.created_at, description: a.description,
+ type: a.activity_type == 'add_credit' ? 'credit' : 'debit',
+ sum: a.sum, balance: a.new_balance }
+ end
+
+ arr
+ end
+
+ def registrar_activities
+ activities = current_user.registrar.cash_account.activities.order(created_at: :desc)
+ activities = activities.where('created_at >= ?', params[:from]) if params[:from]
+ activities = activities.where('created_at <= ?', params[:until]) if params[:until]
+
+ activities
+ end
end
end
end
diff --git a/app/controllers/sso/tara_controller.rb b/app/controllers/sso/tara_controller.rb
index 37c8ab608..eb046730b 100644
--- a/app/controllers/sso/tara_controller.rb
+++ b/app/controllers/sso/tara_controller.rb
@@ -14,7 +14,7 @@ module Sso
# rubocop:disable Style/AndOr
def callback(user, registrar: true)
- session[:omniauth_hash] = user_hash
+ session[:omniauth_hash] = user_hash.delete_if { |key, _| key == 'credentials' }
(show_error(registrar: registrar) and return) unless user
flash[:notice] = t(:signed_in_successfully)
diff --git a/app/interactions/actions/contact_delete.rb b/app/interactions/actions/contact_delete.rb
index 27b131756..69f803f6e 100644
--- a/app/interactions/actions/contact_delete.rb
+++ b/app/interactions/actions/contact_delete.rb
@@ -19,6 +19,11 @@ module Actions
return
end
+ if contact.delete_prohibited?
+ contact.errors.add(:statuses, :delete_prohibited)
+ return
+ end
+
commit
end
diff --git a/app/interactions/actions/domain_renew.rb b/app/interactions/actions/domain_renew.rb
index 9ad11efaf..58e0662ae 100644
--- a/app/interactions/actions/domain_renew.rb
+++ b/app/interactions/actions/domain_renew.rb
@@ -11,6 +11,7 @@ module Actions
end
def call
+ domain.is_renewal = true
if !domain.renewable? || domain.invalid?
domain.add_renew_epp_errors
false
diff --git a/app/interactions/domains/expired_pendings/process_clean.rb b/app/interactions/domains/expired_pendings/process_clean.rb
index c6277c3c5..63a8f1ba5 100644
--- a/app/interactions/domains/expired_pendings/process_clean.rb
+++ b/app/interactions/domains/expired_pendings/process_clean.rb
@@ -17,7 +17,9 @@ module Domains
def notify_pending_update
RegistrantChangeMailer.expired(domain: domain,
registrar: domain.registrar,
- registrant: domain.registrant).deliver_later
+ registrant: domain.registrant,
+ send_to: [domain.new_registrant_email,
+ domain.registrant.email]).deliver_later
end
def notify_pending_delete
diff --git a/app/jobs/registrant_change_expired_email_job.rb b/app/jobs/registrant_change_expired_email_job.rb
deleted file mode 100644
index 3c1bc35e2..000000000
--- a/app/jobs/registrant_change_expired_email_job.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class RegistrantChangeExpiredEmailJob < Que::Job
- def run(domain_id)
- domain = Domain.find(domain_id)
- log(domain)
- RegistrantChangeMailer.expired(domain: domain,
- registrar: domain.registrar,
- registrant: domain.registrant).deliver_now
- end
-
- private
-
- def log(domain)
- message = "Send RegistrantChangeMailer#expired email for domain #{domain.name} (##{domain.id}) to #{domain.new_registrant_email}"
- logger.info(message)
- end
-
- def logger
- Rails.logger
- end
-end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index af5d59d63..2fdb84366 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -6,10 +6,6 @@ class ApplicationMailer < ActionMailer::Base
token = domain.registrant_verification_token
base_url = ENV['registrant_portal_verifications_base_url']
- url = registrant_domain_delete_confirm_url(domain, token: token) if method == 'delete'
- url ||= registrant_domain_update_confirm_url(domain, token: token)
- return url if base_url.blank?
-
"#{base_url}/confirmation/#{domain.name_puny}/#{method}/#{token}"
end
end
diff --git a/app/mailers/interceptors/punycode_interceptor.rb b/app/mailers/interceptors/punycode_interceptor.rb
index 0680a7371..3bd38ebee 100644
--- a/app/mailers/interceptors/punycode_interceptor.rb
+++ b/app/mailers/interceptors/punycode_interceptor.rb
@@ -1,4 +1,4 @@
-class PunycodeInterceptor
+class Interceptors::PunycodeInterceptor
class << self
def delivering_email(message)
message.from = encode_addresses_as_punycode(message.from)
@@ -21,4 +21,4 @@ class PunycodeInterceptor
SimpleIDN.to_ascii(domain_part)
end
end
-end
\ No newline at end of file
+end
diff --git a/app/mailers/registrant_change_mailer.rb b/app/mailers/registrant_change_mailer.rb
index 8f43f4ab5..101e6c3e1 100644
--- a/app/mailers/registrant_change_mailer.rb
+++ b/app/mailers/registrant_change_mailer.rb
@@ -38,13 +38,13 @@ class RegistrantChangeMailer < ApplicationMailer
mail(to: domain.new_registrant_email, subject: subject)
end
- def expired(domain:, registrar:, registrant:)
+ def expired(domain:, registrar:, registrant:, send_to:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
subject = default_i18n_subject(domain_name: domain.name)
- mail(to: domain.new_registrant_email, subject: subject)
+ mail(to: send_to, subject: subject)
end
private
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 0bee01f9c..66a8793bc 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -89,8 +89,8 @@ class Ability
can :manage, BlockedDomain
can :manage, ReservedDomain
can :manage, DNS::Zone
- can :manage, DomainVersion
- can :manage, ContactVersion
+ can :manage, Version::DomainVersion
+ can :manage, Version::ContactVersion
can :manage, Billing::Price
can :manage, User
can :manage, ApiUser
diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb
index d8e6be4d4..9df64209a 100644
--- a/app/models/account_activity.rb
+++ b/app/models/account_activity.rb
@@ -13,6 +13,9 @@ class AccountActivity < ApplicationRecord
def update_balance
account.balance += sum
account.save
+
+ self.new_balance = account.balance
+ save
end
class << self
diff --git a/app/models/action.rb b/app/models/action.rb
index 273dee821..ac5ee7f72 100644
--- a/app/models/action.rb
+++ b/app/models/action.rb
@@ -1,5 +1,5 @@
class Action < ApplicationRecord
- has_paper_trail versions: { class_name: 'ActionVersion' }
+ has_paper_trail versions: { class_name: 'Version::ActionVersion' }
belongs_to :user
belongs_to :contact
diff --git a/app/models/authorization/restricted_ip.rb b/app/models/authorization/restricted_ip.rb
index b3c7b7cdb..41bb15f98 100644
--- a/app/models/authorization/restricted_ip.rb
+++ b/app/models/authorization/restricted_ip.rb
@@ -1,5 +1,5 @@
module Authorization
- class RestrictedIP
+ class RestrictedIp
def initialize(ip)
@ip = ip
end
diff --git a/app/models/billing/price.rb b/app/models/billing/price.rb
index 642cac17c..9cd32f55c 100644
--- a/app/models/billing/price.rb
+++ b/app/models/billing/price.rb
@@ -1,6 +1,6 @@
module Billing
class Price < ApplicationRecord
- include Concerns::Billing::Price::Expirable
+ include Billing::Price::Expirable
include Versions
belongs_to :zone, class_name: 'DNS::Zone', required: true
diff --git a/app/models/concerns/billing/price/expirable.rb b/app/models/concerns/billing/price/expirable.rb
index c0e05832a..2387bf320 100644
--- a/app/models/concerns/billing/price/expirable.rb
+++ b/app/models/concerns/billing/price/expirable.rb
@@ -1,4 +1,4 @@
-module Concerns::Billing::Price::Expirable
+module Billing::Price::Expirable
extend ActiveSupport::Concern
class_methods do
diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb
index 4526e04c5..ca2d19b1b 100644
--- a/app/models/concerns/contact/archivable.rb
+++ b/app/models/concerns/contact/archivable.rb
@@ -1,68 +1,64 @@
-module Concerns
- module Contact
- module Archivable
- extend ActiveSupport::Concern
+module Contact::Archivable
+ extend ActiveSupport::Concern
- class_methods do
- def archivable
- unlinked.find_each.select(&:archivable?)
- end
- end
-
- def archivable?(post: false)
- inactive = inactive?
-
- log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post
-
- inactive
- end
-
- def archive(verified: false, notify: true, extra_log: false)
- unless verified
- raise 'Contact cannot be archived' unless archivable?(post: true)
- end
-
- notify_registrar_about_archivation if notify
- write_to_registrar_log if extra_log
- destroy!
- end
-
- private
-
- def notify_registrar_about_archivation
- registrar.notifications.create!(
- text: I18n.t('contact_has_been_archived',
- contact_code: code, orphan_months: Setting.orphans_contacts_in_months)
- )
- end
-
- def inactive?
- if DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
- return true
- end
-
- DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago
- end
-
- def inactivity_period
- Setting.orphans_contacts_in_months.months
- end
-
- def log(msg)
- @log ||= Logger.new(STDOUT)
- @log.info(msg)
- end
-
- def write_to_registrar_log
- registrar_name = registrar.accounting_customer_code
- archive_path = ENV['contact_archivation_log_file_dir']
- registrar_log_path = "#{archive_path}/#{registrar_name}.txt"
- FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path)
-
- f = File.new(registrar_log_path, 'a+')
- f.write("#{code}\n")
- f.close
- end
+ class_methods do
+ def archivable
+ unlinked.find_each.select(&:archivable?)
end
end
+
+ def archivable?(post: false)
+ inactive = inactive?
+
+ log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post
+
+ inactive
+ end
+
+ def archive(verified: false, notify: true, extra_log: false)
+ unless verified
+ raise 'Contact cannot be archived' unless archivable?(post: true)
+ end
+
+ notify_registrar_about_archivation if notify
+ write_to_registrar_log if extra_log
+ destroy!
+ end
+
+ private
+
+ def notify_registrar_about_archivation
+ registrar.notifications.create!(
+ text: I18n.t('contact_has_been_archived',
+ contact_code: code, orphan_months: Setting.orphans_contacts_in_months)
+ )
+ end
+
+ def inactive?
+ if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period)
+ return true
+ end
+
+ Version::DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago
+ end
+
+ def inactivity_period
+ Setting.orphans_contacts_in_months.months
+ end
+
+ def log(msg)
+ @log ||= Logger.new(STDOUT)
+ @log.info(msg)
+ end
+
+ def write_to_registrar_log
+ registrar_name = registrar.accounting_customer_code
+ archive_path = ENV['contact_archivation_log_file_dir']
+ registrar_log_path = "#{archive_path}/#{registrar_name}.txt"
+ FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path)
+
+ f = File.new(registrar_log_path, 'a+')
+ f.write("#{code}\n")
+ f.close
+ end
end
diff --git a/app/models/concerns/contact/disclosable.rb b/app/models/concerns/contact/disclosable.rb
index 6c3b81849..a61b240b1 100644
--- a/app/models/concerns/contact/disclosable.rb
+++ b/app/models/concerns/contact/disclosable.rb
@@ -1,26 +1,22 @@
-module Concerns
- module Contact
- module Disclosable
- extend ActiveSupport::Concern
+module Contact::Disclosable
+ extend ActiveSupport::Concern
- class_methods do
- attr_accessor :disclosable_attributes
- end
+ class_methods do
+ attr_accessor :disclosable_attributes
+ end
- included do
- self.disclosable_attributes = %w[name email]
- validate :validate_disclosed_attributes
- end
+ included do
+ self.disclosable_attributes = %w[name email]
+ validate :validate_disclosed_attributes
+ end
- private
+ private
- def validate_disclosed_attributes
- return if disclosed_attributes.empty?
+ def validate_disclosed_attributes
+ return if disclosed_attributes.empty?
- has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
- .any?
- errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
- end
- end
+ has_undisclosable_attributes = (disclosed_attributes - self.class.disclosable_attributes)
+ .any?
+ errors.add(:disclosed_attributes, :invalid) if has_undisclosable_attributes
end
end
diff --git a/app/models/concerns/contact/identical.rb b/app/models/concerns/contact/identical.rb
index 5327d1704..d9bcf1046 100644
--- a/app/models/concerns/contact/identical.rb
+++ b/app/models/concerns/contact/identical.rb
@@ -1,4 +1,4 @@
-module Concerns::Contact::Identical
+module Contact::Identical
extend ActiveSupport::Concern
IDENTIFIABLE_ATTRIBUTES = %w[
diff --git a/app/models/concerns/domain/activatable.rb b/app/models/concerns/domain/activatable.rb
index 58ff822d9..ae1bd6f7b 100644
--- a/app/models/concerns/domain/activatable.rb
+++ b/app/models/concerns/domain/activatable.rb
@@ -1,4 +1,4 @@
-module Concerns::Domain::Activatable
+module Domain::Activatable
extend ActiveSupport::Concern
def active?
diff --git a/app/models/concerns/domain/bulk_updatable.rb b/app/models/concerns/domain/bulk_updatable.rb
index a0aadb95f..6a462e1af 100644
--- a/app/models/concerns/domain/bulk_updatable.rb
+++ b/app/models/concerns/domain/bulk_updatable.rb
@@ -1,17 +1,13 @@
-module Concerns
- module Domain
- module BulkUpdatable
- extend ActiveSupport::Concern
+module Domain::BulkUpdatable
+ extend ActiveSupport::Concern
- def bulk_update_prohibited?
- discarded? || statuses_blocks_update?
- end
+ def bulk_update_prohibited?
+ discarded? || statuses_blocks_update?
+ end
- def statuses_blocks_update?
- prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED,
- DomainStatus::CLIENT_UPDATE_PROHIBITED]
- prohibited_array.any? { |block_status| statuses.include?(block_status) }
- end
- end
+ def statuses_blocks_update?
+ prohibited_array = [DomainStatus::SERVER_UPDATE_PROHIBITED,
+ DomainStatus::CLIENT_UPDATE_PROHIBITED]
+ prohibited_array.any? { |block_status| statuses.include?(block_status) }
end
end
diff --git a/app/models/concerns/domain/deletable.rb b/app/models/concerns/domain/deletable.rb
index 81518c739..50c418feb 100644
--- a/app/models/concerns/domain/deletable.rb
+++ b/app/models/concerns/domain/deletable.rb
@@ -1,6 +1,12 @@
-module Concerns::Domain::Deletable
+module Domain::Deletable
extend ActiveSupport::Concern
+ DELETE_STATUSES = [
+ DomainStatus::PENDING_DELETE_CONFIRMATION,
+ DomainStatus::PENDING_DELETE,
+ DomainStatus::FORCE_DELETE,
+ ].freeze
+
private
def delete_later
diff --git a/app/models/concerns/domain/discardable.rb b/app/models/concerns/domain/discardable.rb
index 25547af0f..abb105d80 100644
--- a/app/models/concerns/domain/discardable.rb
+++ b/app/models/concerns/domain/discardable.rb
@@ -1,4 +1,4 @@
-module Concerns::Domain::Discardable
+module Domain::Discardable
extend ActiveSupport::Concern
def keep
diff --git a/app/models/concerns/domain/disputable.rb b/app/models/concerns/domain/disputable.rb
index a05d7cea6..a70d8b7cf 100644
--- a/app/models/concerns/domain/disputable.rb
+++ b/app/models/concerns/domain/disputable.rb
@@ -1,44 +1,40 @@
# frozen_string_literal: true
-module Concerns
- module Domain
- module Disputable
- extend ActiveSupport::Concern
+module Domain::Disputable
+ extend ActiveSupport::Concern
- included do
- validate :validate_disputed
- end
+ included do
+ validate :validate_disputed
+ end
- def mark_as_disputed
- statuses.push(DomainStatus::DISPUTED) unless statuses.include?(DomainStatus::DISPUTED)
- save
- end
+ def mark_as_disputed
+ statuses.push(DomainStatus::DISPUTED) unless statuses.include?(DomainStatus::DISPUTED)
+ save
+ end
- def unmark_as_disputed
- statuses.delete_if { |status| status == DomainStatus::DISPUTED }
- save
- end
+ def unmark_as_disputed
+ statuses.delete_if { |status| status == DomainStatus::DISPUTED }
+ save
+ end
- def in_disputed_list?
- @in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
- end
+ def in_disputed_list?
+ @in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
+ end
- def disputed?
- Dispute.active.where(domain_name: name).any?
- end
+ def disputed?
+ Dispute.active.where(domain_name: name).any?
+ end
- def validate_disputed
- return if persisted? || !in_disputed_list?
+ def validate_disputed
+ return if persisted? || !in_disputed_list?
- if reserved_pw.blank?
- errors.add(:base, :required_parameter_missing_disputed)
- return false
- end
-
- return if Dispute.valid_auth?(name, reserved_pw)
-
- errors.add(:base, :invalid_auth_information_reserved)
- end
+ if reserved_pw.blank?
+ errors.add(:base, :required_parameter_missing_disputed)
+ return false
end
+
+ return if Dispute.valid_auth?(name, reserved_pw)
+
+ errors.add(:base, :invalid_auth_information_reserved)
end
end
diff --git a/app/models/concerns/domain/expirable.rb b/app/models/concerns/domain/expirable.rb
index f4e8b61f8..1710f9dcd 100644
--- a/app/models/concerns/domain/expirable.rb
+++ b/app/models/concerns/domain/expirable.rb
@@ -1,4 +1,4 @@
-module Concerns::Domain::Expirable
+module Domain::Expirable
extend ActiveSupport::Concern
included do
diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb
index 87e9a957b..ca13eb5d1 100644
--- a/app/models/concerns/domain/force_delete.rb
+++ b/app/models/concerns/domain/force_delete.rb
@@ -1,4 +1,4 @@
-module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
+module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
extend ActiveSupport::Concern
included do
@@ -11,6 +11,11 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
lambda {
where("(force_delete_data->>'contact_notification_sent_date') is null")
}
+
+ HOLD_STATUSES = [
+ DomainStatus::SERVER_HOLD,
+ DomainStatus::CLIENT_HOLD,
+ ].freeze
end
class_methods do
@@ -19,6 +24,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
end
end
+ def hold_status?
+ HOLD_STATUSES.any? { |status| statuses.include? status }
+ end
+
def notification_template(explicit: nil)
reason = explicit&.downcase
return reason if %w[invalid_email invalid_phone].include?(reason)
diff --git a/app/models/concerns/domain/registry_lockable.rb b/app/models/concerns/domain/registry_lockable.rb
index 2325e4b60..2e80b7dda 100644
--- a/app/models/concerns/domain/registry_lockable.rb
+++ b/app/models/concerns/domain/registry_lockable.rb
@@ -1,63 +1,59 @@
-module Concerns
- module Domain
- module RegistryLockable
- extend ActiveSupport::Concern
+module Domain::RegistryLockable
+ extend ActiveSupport::Concern
- def apply_registry_lock
- return unless registry_lockable?
- return if locked_by_registrant?
+ def apply_registry_lock
+ return unless registry_lockable?
+ return if locked_by_registrant?
- transaction do
- statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
- statuses << DomainStatus::SERVER_DELETE_PROHIBITED
- statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
- self.locked_by_registrant_at = Time.zone.now
- alert_registrar_lock_changes!(lock: true)
+ transaction do
+ statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
+ statuses << DomainStatus::SERVER_DELETE_PROHIBITED
+ statuses << DomainStatus::SERVER_TRANSFER_PROHIBITED
+ self.locked_by_registrant_at = Time.zone.now
+ alert_registrar_lock_changes!(lock: true)
- save!
- end
- end
-
- def registry_lockable?
- (statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
- DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
- DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
- DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty?
- end
-
- def locked_by_registrant?
- return false unless locked_by_registrant_at
-
- lock_statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED,
- DomainStatus::SERVER_DELETE_PROHIBITED,
- DomainStatus::SERVER_TRANSFER_PROHIBITED]
-
- (statuses & lock_statuses).count == 3
- end
-
- def remove_registry_lock
- return unless locked_by_registrant?
-
- transaction do
- statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
- statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
- statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
- self.locked_by_registrant_at = nil
- alert_registrar_lock_changes!(lock: false)
-
- save!
- end
- end
-
- def alert_registrar_lock_changes!(lock: true)
- translation = lock ? 'locked' : 'unlocked'
- registrar.notifications.create!(
- text: I18n.t("notifications.texts.registrar_#{translation}",
- domain_name: name),
- attached_obj_id: name,
- attached_obj_type: self.class.name
- )
- end
+ save!
end
end
+
+ def registry_lockable?
+ (statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
+ DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
+ DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
+ DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty?
+ end
+
+ def locked_by_registrant?
+ return false unless locked_by_registrant_at
+
+ lock_statuses = [DomainStatus::SERVER_UPDATE_PROHIBITED,
+ DomainStatus::SERVER_DELETE_PROHIBITED,
+ DomainStatus::SERVER_TRANSFER_PROHIBITED]
+
+ (statuses & lock_statuses).count == 3
+ end
+
+ def remove_registry_lock
+ return unless locked_by_registrant?
+
+ transaction do
+ statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
+ statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
+ statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
+ self.locked_by_registrant_at = nil
+ alert_registrar_lock_changes!(lock: false)
+
+ save!
+ end
+ end
+
+ def alert_registrar_lock_changes!(lock: true)
+ translation = lock ? 'locked' : 'unlocked'
+ registrar.notifications.create!(
+ text: I18n.t("notifications.texts.registrar_#{translation}",
+ domain_name: name),
+ attached_obj_id: name,
+ attached_obj_type: self.class.name
+ )
+ end
end
diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb
index 0a17b062a..81410329b 100644
--- a/app/models/concerns/domain/releasable.rb
+++ b/app/models/concerns/domain/releasable.rb
@@ -1,57 +1,53 @@
-module Concerns
- module Domain
- module Releasable
- extend ActiveSupport::Concern
+module Domain::Releasable
+ extend ActiveSupport::Concern
- class_methods do
- def release_domains
- releasable_domains.each do |domain|
- domain.release
- yield domain if block_given?
- end
- end
-
- private
-
- def releasable_domains
- if release_to_auction
- where('(delete_date <= ? OR force_delete_date <= ?)' \
- ' AND ? != ALL(coalesce(statuses, array[]::varchar[]))',
- Time.zone.today,
- Time.zone.today,
- DomainStatus::SERVER_DELETE_PROHIBITED)
- else
- where('(delete_date <= ? OR force_delete_date <= ?)' \
- ' AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
- ' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
- Time.zone.today,
- Time.zone.today,
- DomainStatus::SERVER_DELETE_PROHIBITED,
- DomainStatus::DELETE_CANDIDATE)
- end
- end
+ class_methods do
+ def release_domains
+ releasable_domains.each do |domain|
+ domain.release
+ yield domain if block_given?
end
+ end
- included do
- class_attribute :release_to_auction
- self.release_to_auction = ENV['release_domains_to_auction'] == 'true'
- end
+ private
- def release
- if release_to_auction
- ToStdout.msg 'Destroying domain'
- destroy!
- ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
- domain_name.sell_at_auction if domain_name.auctionable?
-
- ToStdout.msg 'Sending registrar notification'
- registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
- attached_obj_id: id,
- attached_obj_type: self.class)
- else
- discard
- end
+ def releasable_domains
+ if release_to_auction
+ where('(delete_date <= ? OR force_delete_date <= ?)' \
+ ' AND ? != ALL(coalesce(statuses, array[]::varchar[]))',
+ Time.zone.today,
+ Time.zone.today,
+ DomainStatus::SERVER_DELETE_PROHIBITED)
+ else
+ where('(delete_date <= ? OR force_delete_date <= ?)' \
+ ' AND ? != ALL(coalesce(statuses, array[]::varchar[])) AND' \
+ ' ? != ALL(COALESCE(statuses, array[]::varchar[]))',
+ Time.zone.today,
+ Time.zone.today,
+ DomainStatus::SERVER_DELETE_PROHIBITED,
+ DomainStatus::DELETE_CANDIDATE)
end
end
end
+
+ included do
+ class_attribute :release_to_auction
+ self.release_to_auction = ENV['release_domains_to_auction'] == 'true'
+ end
+
+ def release
+ if release_to_auction
+ ToStdout.msg 'Destroying domain'
+ destroy!
+ ToStdout.msg "Checking if domain_name is auctionable: #{domain_name.auctionable?}"
+ domain_name.sell_at_auction if domain_name.auctionable?
+
+ ToStdout.msg 'Sending registrar notification'
+ registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}",
+ attached_obj_id: id,
+ attached_obj_type: self.class)
+ else
+ discard
+ end
+ end
end
diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb
index 5400e9409..d280f6d67 100644
--- a/app/models/concerns/domain/transferable.rb
+++ b/app/models/concerns/domain/transferable.rb
@@ -1,4 +1,4 @@
-module Concerns::Domain::Transferable
+module Domain::Transferable
extend ActiveSupport::Concern
included do
@@ -31,7 +31,9 @@ module Concerns::Domain::Transferable
DomainStatus::PENDING_TRANSFER,
DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_TRANSFER_PROHIBITED,
- DomainStatus::CLIENT_TRANSFER_PROHIBITED
+ DomainStatus::CLIENT_TRANSFER_PROHIBITED,
+ DomainStatus::SERVER_UPDATE_PROHIBITED,
+ DomainStatus::CLIENT_UPDATE_PROHIBITED,
]).empty?
end
diff --git a/app/models/concerns/email_verifable.rb b/app/models/concerns/email_verifable.rb
index d0bb6aecb..457555b44 100644
--- a/app/models/concerns/email_verifable.rb
+++ b/app/models/concerns/email_verifable.rb
@@ -1,95 +1,93 @@
-module Concerns
- module EmailVerifable
- extend ActiveSupport::Concern
+module EmailVerifable
+ extend ActiveSupport::Concern
- def email_verification
- @email_verification ||= EmailAddressVerification.find_or_create_by(email: unicode_email,
- domain: domain(email))
- end
+ def email_verification
+ @email_verification ||= EmailAddressVerification.find_or_create_by(email: unicode_email,
+ domain: domain(email))
+ end
- def billing_email_verification
- return unless attribute_names.include?('billing_email')
+ def billing_email_verification
+ return unless attribute_names.include?('billing_email')
- @billing_email_verification ||= EmailAddressVerification
- .find_or_create_by(email: unicode_billing_email,
- domain: domain(billing_email))
- end
+ @billing_email_verification ||= EmailAddressVerification
+ .find_or_create_by(email: unicode_billing_email,
+ domain: domain(billing_email))
+ end
- def email_verification_failed?
- email_verification&.failed?
- end
-
- class_methods do
- def domain(email)
- Mail::Address.new(email).domain&.downcase || 'not_found'
- rescue Mail::Field::IncompleteParseError
- 'not_found'
- end
-
- def local(email)
- Mail::Address.new(email).local&.downcase || email
- rescue Mail::Field::IncompleteParseError
- email
- end
-
- def punycode_to_unicode(email)
- return email if domain(email) == 'not_found'
-
- local = local(email)
- domain = SimpleIDN.to_unicode(domain(email))
- "#{local}@#{domain}"&.downcase
- end
-
- def unicode_to_punycode(email)
- return email if domain(email) == 'not_found'
-
- local = local(email)
- domain = SimpleIDN.to_ascii(domain(email))
- "#{local}@#{domain}"&.downcase
- end
- end
-
- def unicode_billing_email
- self.class.punycode_to_unicode(billing_email)
- end
-
- def unicode_email
- self.class.punycode_to_unicode(email)
- end
+ def email_verification_failed?
+ email_verification&.failed?
+ end
+ class_methods do
def domain(email)
- SimpleIDN.to_unicode(self.class.domain(email))
+ Mail::Address.new(email).domain&.downcase || 'not_found'
+ rescue Mail::Field::IncompleteParseError
+ 'not_found'
+ end
+
+ def local(email)
+ Mail::Address.new(email).local&.downcase || email
+ rescue Mail::Field::IncompleteParseError
+ email
end
def punycode_to_unicode(email)
- self.class.punycode_to_unicode(email)
+ return email if domain(email) == 'not_found'
+
+ local = local(email)
+ domain = SimpleIDN.to_unicode(domain(email))
+ "#{local}@#{domain}"&.downcase
end
- def correct_email_format
- return if email.blank?
+ def unicode_to_punycode(email)
+ return email if domain(email) == 'not_found'
- result = email_verification.verify
- process_result(result: result, field: :email)
+ local = local(email)
+ domain = SimpleIDN.to_ascii(domain(email))
+ "#{local}@#{domain}"&.downcase
end
-
- def correct_billing_email_format
- return if email.blank?
-
- result = billing_email_verification.verify
- process_result(result: result, field: :billing_email)
- end
-
- # rubocop:disable Metrics/LineLength
- def process_result(result:, field:)
- case result[:errors].keys.first
- when :smtp
- errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_smtp_check_error'))
- when :mx
- errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_mx_check_error'))
- when :regex
- errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'))
- end
- end
- # rubocop:enable Metrics/LineLength
end
+
+ def unicode_billing_email
+ self.class.punycode_to_unicode(billing_email)
+ end
+
+ def unicode_email
+ self.class.punycode_to_unicode(email)
+ end
+
+ def domain(email)
+ SimpleIDN.to_unicode(self.class.domain(email))
+ end
+
+ def punycode_to_unicode(email)
+ self.class.punycode_to_unicode(email)
+ end
+
+ def correct_email_format
+ return if email.blank?
+
+ result = email_verification.verify
+ process_result(result: result, field: :email)
+ end
+
+ def correct_billing_email_format
+ return if email.blank?
+
+ result = billing_email_verification.verify
+ process_result(result: result, field: :billing_email)
+ end
+
+ # rubocop:disable Metrics/LineLength
+ def process_result(result:, field:)
+ case result[:errors].keys.first
+ when :smtp
+ errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_smtp_check_error'))
+ when :mx
+ errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_mx_check_error'))
+ when :regex
+ errors.add(field, I18n.t('activerecord.errors.models.contact.attributes.email.email_regex_check_error'))
+ end
+ end
+ # rubocop:enable Metrics/LineLength
end
diff --git a/app/models/concerns/invoice/book_keeping.rb b/app/models/concerns/invoice/book_keeping.rb
index 82e6506c9..03998cc50 100644
--- a/app/models/concerns/invoice/book_keeping.rb
+++ b/app/models/concerns/invoice/book_keeping.rb
@@ -1,34 +1,30 @@
-module Concerns
- module Invoice
- module BookKeeping
- extend ActiveSupport::Concern
+module Invoice::BookKeeping
+ extend ActiveSupport::Concern
- def as_directo_json
- invoice = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self))
- invoice['customer'] = compose_directo_customer
- invoice['issue_date'] = issue_date.strftime('%Y-%m-%d')
- invoice['transaction_date'] = account_activity
- .bank_transaction&.paid_at&.strftime('%Y-%m-%d')
- invoice['language'] = buyer.language == 'en' ? 'ENG' : ''
- invoice['invoice_lines'] = compose_directo_product
+ def as_directo_json
+ invoice = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self))
+ invoice['customer'] = compose_directo_customer
+ invoice['issue_date'] = issue_date.strftime('%Y-%m-%d')
+ invoice['transaction_date'] = account_activity
+ .bank_transaction&.paid_at&.strftime('%Y-%m-%d')
+ invoice['language'] = buyer.language == 'en' ? 'ENG' : ''
+ invoice['invoice_lines'] = compose_directo_product
- invoice
- end
+ invoice
+ end
- def compose_directo_product
- [{ 'product_id': Setting.directo_receipt_product_name, 'description': order,
- 'quantity': 1, 'price': ActionController::Base.helpers.number_with_precision(
- subtotal, precision: 2, separator: '.'
- ) }].as_json
- end
+ def compose_directo_product
+ [{ 'product_id': Setting.directo_receipt_product_name, 'description': order,
+ 'quantity': 1, 'price': ActionController::Base.helpers.number_with_precision(
+ subtotal, precision: 2, separator: '.'
+ ) }].as_json
+ end
- def compose_directo_customer
- {
- 'code': buyer.accounting_customer_code,
- 'destination': buyer_country_code,
- 'vat_reg_no': buyer_vat_no,
- }.as_json
- end
- end
+ def compose_directo_customer
+ {
+ 'code': buyer.accounting_customer_code,
+ 'destination': buyer_country_code,
+ 'vat_reg_no': buyer_vat_no,
+ }.as_json
end
end
diff --git a/app/models/concerns/invoice/cancellable.rb b/app/models/concerns/invoice/cancellable.rb
index 2eb0f8e2e..0374c9d2a 100644
--- a/app/models/concerns/invoice/cancellable.rb
+++ b/app/models/concerns/invoice/cancellable.rb
@@ -1,28 +1,24 @@
-module Concerns
- module Invoice
- module Cancellable
- extend ActiveSupport::Concern
+module Invoice::Cancellable
+ extend ActiveSupport::Concern
- included do
- scope :non_cancelled, -> { where(cancelled_at: nil) }
- end
+ included do
+ scope :non_cancelled, -> { where(cancelled_at: nil) }
+ end
- def cancellable?
- unpaid? && not_cancelled?
- end
+ def cancellable?
+ unpaid? && not_cancelled?
+ end
- def cancel
- raise 'Invoice cannot be cancelled' unless cancellable?
- update!(cancelled_at: Time.zone.now)
- end
+ def cancel
+ raise 'Invoice cannot be cancelled' unless cancellable?
+ update!(cancelled_at: Time.zone.now)
+ end
- def cancelled?
- cancelled_at
- end
+ def cancelled?
+ cancelled_at
+ end
- def not_cancelled?
- !cancelled?
- end
- end
+ def not_cancelled?
+ !cancelled?
end
end
diff --git a/app/models/concerns/invoice/payable.rb b/app/models/concerns/invoice/payable.rb
index 1a1c3e269..ad91b886e 100644
--- a/app/models/concerns/invoice/payable.rb
+++ b/app/models/concerns/invoice/payable.rb
@@ -1,28 +1,24 @@
-module Concerns
- module Invoice
- module Payable
- extend ActiveSupport::Concern
+module Invoice::Payable
+ extend ActiveSupport::Concern
- included do
- scope :unpaid, -> { where('id NOT IN (SELECT invoice_id FROM account_activities WHERE' \
- ' invoice_id IS NOT NULL)') }
- end
+ included do
+ scope :unpaid, -> { where('id NOT IN (SELECT invoice_id FROM account_activities WHERE' \
+ ' invoice_id IS NOT NULL)') }
+ end
- def payable?
- unpaid? && not_cancelled?
- end
+ def payable?
+ unpaid? && not_cancelled?
+ end
- def paid?
- account_activity
- end
+ def paid?
+ account_activity
+ end
- def receipt_date
- account_activity.created_at.to_date
- end
+ def receipt_date
+ account_activity.created_at.to_date
+ end
- def unpaid?
- !paid?
- end
- end
+ def unpaid?
+ !paid?
end
end
diff --git a/app/models/concerns/registrar/book_keeping.rb b/app/models/concerns/registrar/book_keeping.rb
index 60b9c2b1a..d8a7c2e72 100644
--- a/app/models/concerns/registrar/book_keeping.rb
+++ b/app/models/concerns/registrar/book_keeping.rb
@@ -1,128 +1,124 @@
-module Concerns
- module Registrar
- module BookKeeping
- extend ActiveSupport::Concern
+module Registrar::BookKeeping
+ extend ActiveSupport::Concern
- DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
- 'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
+ DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
+ 'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
- def monthly_summary(month:)
- activities = monthly_activites(month)
- return unless activities.any?
+ def monthly_summary(month:)
+ activities = monthly_activites(month)
+ return unless activities.any?
- invoice = {
- 'number': 1,
- 'customer': compose_directo_customer,
- 'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
- 'date': month.end_of_month.strftime('%Y-%m-%d')
- }.as_json
+ invoice = {
+ 'number': 1,
+ 'customer': compose_directo_customer,
+ 'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
+ 'date': month.end_of_month.strftime('%Y-%m-%d')
+ }.as_json
- invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
+ invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
- invoice
- end
+ invoice
+ end
- def prepare_invoice_lines(month:, activities:)
- lines = []
+ def prepare_invoice_lines(month:, activities:)
+ lines = []
- lines << { 'description': title_for_summary(month) }
- activities.each do |activity|
- fetch_invoice_lines(activity, lines)
- end
- lines << prepayment_for_all(lines)
+ lines << { 'description': title_for_summary(month) }
+ activities.each do |activity|
+ fetch_invoice_lines(activity, lines)
+ end
+ lines << prepayment_for_all(lines)
- lines.as_json
- end
+ lines.as_json
+ end
- def title_for_summary(date)
- I18n.with_locale(language == 'en' ? 'en' : 'et') do
- I18n.t('registrar.monthly_summary_title', date: I18n.l(date, format: '%B %Y'))
- end
- end
-
- def fetch_invoice_lines(activity, lines)
- price = load_price(activity)
- if price.duration.include? 'year'
- price.duration.to_i.times do |duration|
- lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
- end
- else
- lines << new_monthly_invoice_line(activity: activity).as_json
- end
- end
-
- def monthly_activites(month)
- AccountActivity.where(account_id: account_ids)
- .where(created_at: month.beginning_of_month..month.end_of_month)
- .where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
- end
-
- def new_monthly_invoice_line(activity:, duration: nil)
- price = load_price(activity)
- line = {
- 'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
- 'quantity': 1,
- 'unit': language == 'en' ? 'pc' : 'tk',
- }
-
- finalize_invoice_line(line, price: price, duration: duration, activity: activity)
- end
-
- def finalize_invoice_line(line, price:, activity:, duration:)
- yearly = price.duration.include?('year')
-
- line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount
- line['description'] = description_in_language(price: price, yearly: yearly)
-
- if duration.present?
- add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
- end
-
- line
- end
-
- def add_product_timeframe(line:, activity:, duration:)
- create_time = activity.created_at
- line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
- line['end_date'] = (create_time + (duration - 1).year + 1).end_of_month.strftime('%Y-%m-%d')
- end
-
- def description_in_language(price:, yearly:)
- timeframe_string = yearly ? 'yearly' : 'monthly'
- locale_string = "registrar.invoice_#{timeframe_string}_product_description"
-
- I18n.with_locale(language == 'en' ? 'en' : 'et') do
- I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
- end
- end
-
- def prepayment_for_all(lines)
- total = 0
- en = language == 'en'
- lines.each { |l| total += l['quantity'].to_f * l['price'].to_f }
- {
- 'product_id': Setting.directo_receipt_product_name,
- 'description': en ? 'Domains prepayment' : 'Domeenide ettemaks',
- 'quantity': -1,
- 'price': total,
- 'unit': en ? 'pc' : 'tk',
- }
- end
-
- def compose_directo_customer
- {
- 'code': accounting_customer_code,
- 'destination': address_country_code,
- 'vat_reg_no': vat_no,
- }.as_json
- end
-
- def load_price(account_activity)
- @pricelists ||= {}
- return @pricelists[account_activity.price_id] if @pricelists.key? account_activity.price_id
-
- @pricelists[account_activity.price_id] = account_activity.price
- end
+ def title_for_summary(date)
+ I18n.with_locale(language == 'en' ? 'en' : 'et') do
+ I18n.t('registrar.monthly_summary_title', date: I18n.l(date, format: '%B %Y'))
end
end
+
+ def fetch_invoice_lines(activity, lines)
+ price = load_price(activity)
+ if price.duration.include? 'year'
+ price.duration.to_i.times do |duration|
+ lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
+ end
+ else
+ lines << new_monthly_invoice_line(activity: activity).as_json
+ end
+ end
+
+ def monthly_activites(month)
+ AccountActivity.where(account_id: account_ids)
+ .where(created_at: month.beginning_of_month..month.end_of_month)
+ .where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
+ end
+
+ def new_monthly_invoice_line(activity:, duration: nil)
+ price = load_price(activity)
+ line = {
+ 'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
+ 'quantity': 1,
+ 'unit': language == 'en' ? 'pc' : 'tk',
+ }
+
+ finalize_invoice_line(line, price: price, duration: duration, activity: activity)
+ end
+
+ def finalize_invoice_line(line, price:, activity:, duration:)
+ yearly = price.duration.include?('year')
+
+ line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount
+ line['description'] = description_in_language(price: price, yearly: yearly)
+
+ if duration.present?
+ add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1
+ end
+
+ line
+ end
+
+ def add_product_timeframe(line:, activity:, duration:)
+ create_time = activity.created_at
+ line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
+ line['end_date'] = (create_time + (duration - 1).year + 1).end_of_month.strftime('%Y-%m-%d')
+ end
+
+ def description_in_language(price:, yearly:)
+ timeframe_string = yearly ? 'yearly' : 'monthly'
+ locale_string = "registrar.invoice_#{timeframe_string}_product_description"
+
+ I18n.with_locale(language == 'en' ? 'en' : 'et') do
+ I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i)
+ end
+ end
+
+ def prepayment_for_all(lines)
+ total = 0
+ en = language == 'en'
+ lines.each { |l| total += l['quantity'].to_f * l['price'].to_f }
+ {
+ 'product_id': Setting.directo_receipt_product_name,
+ 'description': en ? 'Domains prepayment' : 'Domeenide ettemaks',
+ 'quantity': -1,
+ 'price': total,
+ 'unit': en ? 'pc' : 'tk',
+ }
+ end
+
+ def compose_directo_customer
+ {
+ 'code': accounting_customer_code,
+ 'destination': address_country_code,
+ 'vat_reg_no': vat_no,
+ }.as_json
+ end
+
+ def load_price(account_activity)
+ @pricelists ||= {}
+ return @pricelists[account_activity.price_id] if @pricelists.key? account_activity.price_id
+
+ @pricelists[account_activity.price_id] = account_activity.price
+ end
end
diff --git a/app/models/concerns/registrar/legal_doc.rb b/app/models/concerns/registrar/legal_doc.rb
index 2f21f6637..294c9487d 100644
--- a/app/models/concerns/registrar/legal_doc.rb
+++ b/app/models/concerns/registrar/legal_doc.rb
@@ -1,16 +1,12 @@
-module Concerns
- module Registrar
- module LegalDoc
- extend ActiveSupport::Concern
+module Registrar::LegalDoc
+ extend ActiveSupport::Concern
- def legaldoc_mandatory?
- !legaldoc_not_mandatory?
- end
+ def legaldoc_mandatory?
+ !legaldoc_not_mandatory?
+ end
- def legaldoc_not_mandatory?
- setting = Setting.legal_document_is_mandatory
- legaldoc_optout || !setting
- end
- end
+ def legaldoc_not_mandatory?
+ setting = Setting.legal_document_is_mandatory
+ legaldoc_optout || !setting
end
end
diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb
index 033ebe52a..a1c872b56 100644
--- a/app/models/concerns/versions.rb
+++ b/app/models/concerns/versions.rb
@@ -7,10 +7,10 @@ module Versions
attr_accessor :version_loader
if WITH_CHILDREN.include?(model_name.name)
- has_paper_trail versions: { class_name: "#{model_name}Version" },
+ has_paper_trail versions: { class_name: "Version::#{model_name}Version" },
meta: { children: :children_log }
else
- has_paper_trail versions: { class_name: "#{model_name}Version" }
+ has_paper_trail versions: { class_name: "Version::#{model_name}Version" }
end
# add creator and updator
diff --git a/app/models/concerns/zone/whois_queryable.rb b/app/models/concerns/zone/whois_queryable.rb
index c79700582..e4a6c1314 100644
--- a/app/models/concerns/zone/whois_queryable.rb
+++ b/app/models/concerns/zone/whois_queryable.rb
@@ -1,74 +1,70 @@
-module Concerns
- module Zone
- module WhoisQueryable
- extend ActiveSupport::Concern
+module Zone::WhoisQueryable
+ extend ActiveSupport::Concern
- included do
- after_save :update_whois_record, if: :subzone?
- after_destroy :update_whois_record
- end
+ included do
+ after_save :update_whois_record, if: :subzone?
+ after_destroy :update_whois_record
+ end
- def subzone?
- origin.include? '.'
- end
+ def subzone?
+ origin.include? '.'
+ end
- def update_whois_record
- UpdateWhoisRecordJob.enqueue origin, 'zone'
- end
+ def update_whois_record
+ UpdateWhoisRecordJob.enqueue origin, 'zone'
+ end
- def generate_data
- wr = Whois::Record.find_or_initialize_by(name: origin)
- wr.json = generate_json
- wr.save
- end
+ def generate_data
+ wr = Whois::Record.find_or_initialize_by(name: origin)
+ wr.json = generate_json
+ wr.save
+ end
- def generate_json
- data = {}.with_indifferent_access
- [domain_vars, registrar_vars, registrant_vars].each do |h|
- data.merge!(h)
- end
-
- data
- end
-
- # Take note - since this concern only used to zone whois queries, dnssec keys are set to
- # empty array
- def domain_vars
- { disclaimer: Setting.registry_whois_disclaimer, name: origin,
- registered: created_at.try(:to_s, :iso8601), status: ['ok (paid and in zone)'],
- changed: updated_at.try(:to_s, :iso8601), email: Setting.registry_email,
- admin_contacts: [contact_vars], tech_contacts: [contact_vars],
- nameservers: nameserver_vars, dnssec_keys: [], dnssec_changed: nil }
- end
-
- def registrar_vars
- { registrar: Setting.registry_juridical_name, registrar_website: Setting.registry_url,
- registrar_phone: Setting.registry_phone }
- end
-
- def registrant_vars
- { registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
- registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
- registrant_disclosed_attributes: %w[name email] }
- end
-
- def contact_vars
- { name: Setting.registry_invoice_contact, email: Setting.registry_email,
- disclosed_attributes: %w[name email] }
- end
-
- def nameserver_vars
- vars = []
- return vars unless ns_records
-
- parsed_ns = ns_records.gsub("\r", '').gsub("\n", '')
- parsed_ns.split("#{origin}. IN NS ").each do |ns|
- ns.delete_suffix! '.'
- vars << ns if ns.match? Nameserver::HOSTNAME_REGEXP
- end
-
- vars
- end
+ def generate_json
+ data = {}.with_indifferent_access
+ [domain_vars, registrar_vars, registrant_vars].each do |h|
+ data.merge!(h)
end
+
+ data
+ end
+
+ # Take note - since this concern only used to zone whois queries, dnssec keys are set to
+ # empty array
+ def domain_vars
+ { disclaimer: Setting.registry_whois_disclaimer, name: origin,
+ registered: created_at.try(:to_s, :iso8601), status: ['ok (paid and in zone)'],
+ changed: updated_at.try(:to_s, :iso8601), email: Setting.registry_email,
+ admin_contacts: [contact_vars], tech_contacts: [contact_vars],
+ nameservers: nameserver_vars, dnssec_keys: [], dnssec_changed: nil }
+ end
+
+ def registrar_vars
+ { registrar: Setting.registry_juridical_name, registrar_website: Setting.registry_url,
+ registrar_phone: Setting.registry_phone }
+ end
+
+ def registrant_vars
+ { registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
+ registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
+ registrant_disclosed_attributes: %w[name email] }
+ end
+
+ def contact_vars
+ { name: Setting.registry_invoice_contact, email: Setting.registry_email,
+ disclosed_attributes: %w[name email] }
+ end
+
+ def nameserver_vars
+ vars = []
+ return vars unless ns_records
+
+ parsed_ns = ns_records.gsub("\r", '').gsub("\n", '')
+ parsed_ns.split("#{origin}. IN NS ").each do |ns|
+ ns.delete_suffix! '.'
+ vars << ns if ns.match? Nameserver::HOSTNAME_REGEXP
+ end
+
+ vars
end
end
diff --git a/app/models/contact.rb b/app/models/contact.rb
index 7ae51992d..61d49c10c 100644
--- a/app/models/contact.rb
+++ b/app/models/contact.rb
@@ -4,11 +4,11 @@ class Contact < ApplicationRecord
include Versions # version/contact_version.rb
include EppErrors
include UserEvents
- include Concerns::Contact::Transferable
- include Concerns::Contact::Identical
- include Concerns::Contact::Disclosable
- include Concerns::Contact::Archivable
- include Concerns::EmailVerifable
+ include Contact::Transferable
+ include Contact::Identical
+ include Contact::Disclosable
+ include Contact::Archivable
+ include EmailVerifable
belongs_to :original, class_name: self.name
belongs_to :registrar, required: true
diff --git a/app/models/concerns/contact/transferable.rb b/app/models/contact/transferable.rb
similarity index 91%
rename from app/models/concerns/contact/transferable.rb
rename to app/models/contact/transferable.rb
index 987933a8d..b10a3acfc 100644
--- a/app/models/concerns/contact/transferable.rb
+++ b/app/models/contact/transferable.rb
@@ -1,4 +1,4 @@
-module Concerns::Contact::Transferable
+module Contact::Transferable
extend ActiveSupport::Concern
included do
@@ -9,7 +9,7 @@ module Concerns::Contact::Transferable
def transfer(new_registrar)
return identical(new_registrar) if identical(new_registrar)
- new_contact = self.dup
+ new_contact = dup
new_contact.registrar = new_registrar
new_contact.original = self
new_contact.code = nil
diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb
index e6a5e9f7d..f4c6db716 100644
--- a/app/models/contact_request.rb
+++ b/app/models/contact_request.rb
@@ -24,9 +24,10 @@ class ContactRequest < ApplicationRecord
contact_request
end
- def update_status(params)
- self.status = params['status']
- self.ip_address = params['ip']
+ def update_record(params)
+ self.status = params['status'] if params['status']
+ self.ip_address = params['ip'] if params['ip']
+ self.message_id = params['ip'] if params['message_id']
save!
end
diff --git a/app/models/dns/zone.rb b/app/models/dns/zone.rb
index 31749d952..6e18b84bb 100644
--- a/app/models/dns/zone.rb
+++ b/app/models/dns/zone.rb
@@ -5,7 +5,7 @@ module DNS
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, :master_nameserver, presence: true
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
validates :origin, uniqueness: true
- include Concerns::Zone::WhoisQueryable
+ include ::Zone::WhoisQueryable
before_destroy do
throw(:abort) if used?
diff --git a/app/models/domain.rb b/app/models/domain.rb
index a11f50f40..48c1638c0 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -1,16 +1,16 @@
class Domain < ApplicationRecord
include UserEvents
include Versions # version/domain_version.rb
- include Concerns::Domain::Expirable
- include Concerns::Domain::Activatable
- include Concerns::Domain::ForceDelete
- include Concerns::Domain::Discardable
- include Concerns::Domain::Deletable
- include Concerns::Domain::Transferable
- include Concerns::Domain::RegistryLockable
- include Concerns::Domain::Releasable
- include Concerns::Domain::Disputable
- include Concerns::Domain::BulkUpdatable
+ include Domain::Expirable
+ include Domain::Activatable
+ include Domain::ForceDelete
+ include Domain::Discardable
+ include Domain::Deletable
+ include Domain::Transferable
+ include Domain::RegistryLockable
+ include Domain::Releasable
+ include Domain::Disputable
+ include Domain::BulkUpdatable
attr_accessor :roles
@@ -107,13 +107,13 @@ class Domain < ApplicationRecord
validate :status_is_consistant
def status_is_consistant
- has_error = (statuses.include?(DomainStatus::SERVER_HOLD) && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
- unless has_error
- if (statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION, DomainStatus::PENDING_DELETE, DomainStatus::FORCE_DELETE]).any?
- has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
- end
+ has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
+ unless has_error
+ if (statuses & DELETE_STATUSES).any?
+ has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
end
- errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
+ end
+ errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
end
attr_accessor :is_admin
@@ -198,6 +198,23 @@ class Domain < ApplicationRecord
Setting.nameserver_required
end
+ def registrant_user_admin_registrant_domains(registrant_user)
+ companies = Contact.registrant_user_company_contacts(registrant_user)
+ from(
+ "(#{registrant_user_administered_domains(registrant_user).to_sql} UNION " \
+ "#{registrant_user_company_registrant(companies).to_sql} UNION " \
+ "#{registrant_user_domains_company(companies, except_tech: true).to_sql}) AS domains"
+ )
+ end
+
+ def registrant_user_direct_admin_registrant_domains(registrant_user)
+ from(
+ "(#{registrant_user_direct_domains_by_registrant(registrant_user).to_sql} UNION " \
+ "#{registrant_user_direct_domains_by_contact(registrant_user,
+ except_tech: true).to_sql}) AS domains"
+ )
+ end
+
def registrant_user_domains(registrant_user)
from(
"(#{registrant_user_domains_by_registrant(registrant_user).to_sql} UNION " \
@@ -247,16 +264,20 @@ class Domain < ApplicationRecord
where(registrant: registrant_user.direct_contacts)
end
- def registrant_user_direct_domains_by_contact(registrant_user)
- joins(:domain_contacts).where(domain_contacts: { contact_id: registrant_user.direct_contacts })
+ def registrant_user_direct_domains_by_contact(registrant_user, except_tech: false)
+ request = { contact_id: registrant_user.direct_contacts }
+ request[:type] = [AdminDomainContact.name] if except_tech
+ joins(:domain_contacts).where(domain_contacts: request)
end
def registrant_user_company_registrant(companies)
where(registrant: companies)
end
- def registrant_user_domains_company(companies)
- joins(:domain_contacts).where(domain_contacts: { contact: companies })
+ def registrant_user_domains_company(companies, except_tech: false)
+ request = { contact: companies }
+ request[:type] = [AdminDomainContact.name] if except_tech
+ joins(:domain_contacts).where(domain_contacts: request)
end
end
diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb
index bf0ae2a51..30161c076 100644
--- a/app/models/domain_status.rb
+++ b/app/models/domain_status.rb
@@ -109,14 +109,12 @@ class DomainStatus < ApplicationRecord
DELETE_PROHIBIT_STATES = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
- DomainStatus::CLIENT_UPDATE_PROHIBITED,
- DomainStatus::SERVER_UPDATE_PROHIBITED,
DomainStatus::PENDING_CREATE,
DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_TRANSFER,
DomainStatus::PENDING_UPDATE,
DomainStatus::PENDING_DELETE
- ]
+ ].freeze
def epp_code_map
{
diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb
index 0c0ed3d5f..4cd876d5f 100644
--- a/app/models/epp/contact.rb
+++ b/app/models/epp/contact.rb
@@ -82,8 +82,11 @@ class Epp::Contact < Contact
'2302' => [ # Object exists
[:code, :epp_id_taken]
],
+ '2304' => [ # Status prohibits operation
+ [:statuses, :delete_prohibited],
+ ],
'2305' => [ # Association exists
- [:domains, :exist]
+ [:domains, :exist],
]
}
end
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index 143cfcc99..c5ce69776 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -201,7 +201,6 @@ class Epp::Domain < Domain
statuses.delete(DomainStatus::SERVER_HOLD)
statuses.delete(DomainStatus::EXPIRED)
- statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED)
cancel_pending_delete
save
@@ -387,4 +386,13 @@ class Epp::Domain < Domain
result
end
end
+
+ private
+
+ def verification_needed?(code:)
+ new_registrant = Registrant.find_by(code: code)
+ return false if new_registrant.try(:identical_to?, registrant)
+
+ registrant.code != code
+ end
end
diff --git a/app/models/invoice.rb b/app/models/invoice.rb
index fb625f7b9..73ed88567 100644
--- a/app/models/invoice.rb
+++ b/app/models/invoice.rb
@@ -1,8 +1,8 @@
class Invoice < ApplicationRecord
include Versions
- include Concerns::Invoice::Cancellable
- include Concerns::Invoice::Payable
- include Concerns::Invoice::BookKeeping
+ include Invoice::Cancellable
+ include Invoice::Payable
+ include Invoice::BookKeeping
belongs_to :buyer, class_name: 'Registrar'
has_one :account_activity
@@ -34,7 +34,7 @@ class Invoice < ApplicationRecord
before_create :calculate_total, unless: :total?
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
- attribute :vat_rate, ::Type::VATRate.new
+ attribute :vat_rate, ::Type::VatRate.new
def set_invoice_number
last_no = Invoice.order(number: :desc).limit(1).pluck(:number).first
diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb
index e4aab5869..377a9fdde 100644
--- a/app/models/legal_document.rb
+++ b/app/models/legal_document.rb
@@ -82,7 +82,7 @@ class LegalDocument < ApplicationRecord
end
end
- contact_ids = DomainVersion.where(item_id: orig_legal.documentable_id).distinct.
+ contact_ids = Version::DomainVersion.where(item_id: orig_legal.documentable_id).distinct.
pluck("object->>'registrant_id'", "object_changes->>'registrant_id'",
"children->>'tech_contacts'", "children->>'admin_contacts'").flatten.uniq
contact_ids = contact_ids.map{|id|
diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb
index aa41ccff8..f7e85c5af 100644
--- a/app/models/registrant_user.rb
+++ b/app/models/registrant_user.rb
@@ -9,7 +9,7 @@ class RegistrantUser < User
delegate :can?, :cannot?, to: :ability
def ident
- registrant_ident.to_s.split('-').last
+ registrant_ident.to_s[3..]
end
def country
@@ -18,6 +18,8 @@ class RegistrantUser < User
end
def companies(company_register = CompanyRegister::Client.new)
+ return [] if ident.include?('-')
+
company_register.representation_rights(citizen_personal_code: ident,
citizen_country_code: country.alpha3)
end
@@ -30,11 +32,15 @@ class RegistrantUser < User
Contact.registrant_user_direct_contacts(self)
end
- def domains
+ def domains(admin: false)
+ return Domain.registrant_user_admin_registrant_domains(self) if admin
+
Domain.registrant_user_domains(self)
end
- def direct_domains
+ def direct_domains(admin: false)
+ return Domain.registrant_user_direct_admin_registrant_domains(self) if admin
+
Domain.registrant_user_direct_domains(self)
end
@@ -72,7 +78,7 @@ class RegistrantUser < User
return false unless user_data[:last_name]
user_data[:country_code] ||= 'EE'
- %i[ident country_code].each { |f| user_data[f].upcase! if user_data[f].is_a?(String) }
+ user_data[:country_code].upcase! if user_data[:country_code].is_a?(String)
find_or_create_by_user_data(user_data)
end
diff --git a/app/models/registrar.rb b/app/models/registrar.rb
index 168dfdca7..335fb9115 100644
--- a/app/models/registrar.rb
+++ b/app/models/registrar.rb
@@ -1,8 +1,8 @@
class Registrar < ApplicationRecord
include Versions # version/registrar_version.rb
- include Concerns::Registrar::BookKeeping
- include Concerns::EmailVerifable
- include Concerns::Registrar::LegalDoc
+ include Registrar::BookKeeping
+ include EmailVerifable
+ include Registrar::LegalDoc
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
@@ -30,7 +30,7 @@ class Registrar < ApplicationRecord
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
allow_nil: true
- attribute :vat_rate, ::Type::VATRate.new
+ attribute :vat_rate, ::Type::VatRate.new
after_initialize :set_defaults
validate :correct_email_format, if: proc { |c| c.will_save_change_to_email? }
@@ -153,7 +153,7 @@ class Registrar < ApplicationRecord
puny = origin.domain.name_puny
next unless domains.include?(idn) || domains.include?(puny) || domains.empty?
- if origin.domain.nameservers.where(hostname: new_attributes[:hostname]).any?
+ if domain_not_updatable?(hostname: new_attributes[:hostname], domain: origin.domain)
failed_list << idn
next
end
@@ -202,6 +202,10 @@ class Registrar < ApplicationRecord
private
+ def domain_not_updatable?(hostname:, domain:)
+ domain.nameservers.where(hostname: hostname).any? || domain.bulk_update_prohibited?
+ end
+
def set_defaults
self.language = Setting.default_language unless language
end
diff --git a/app/models/type/vat_rate.rb b/app/models/type/vat_rate.rb
index 6a31e389b..142ae0559 100644
--- a/app/models/type/vat_rate.rb
+++ b/app/models/type/vat_rate.rb
@@ -1,5 +1,5 @@
module Type
- class VATRate < ActiveRecord::Type::Decimal
+ class VatRate < ActiveRecord::Type::Decimal
def deserialize(value)
super * 100 if value
end
diff --git a/app/models/version.rb b/app/models/version.rb
new file mode 100644
index 000000000..68770a5a1
--- /dev/null
+++ b/app/models/version.rb
@@ -0,0 +1 @@
+class Version; end
diff --git a/app/models/version/account_activity_version.rb b/app/models/version/account_activity_version.rb
index b742f7a63..17d8bc8a7 100644
--- a/app/models/version/account_activity_version.rb
+++ b/app/models/version/account_activity_version.rb
@@ -1,4 +1,4 @@
-class AccountActivityVersion < PaperTrail::Version
+class Version::AccountActivityVersion < PaperTrail::Version
self.table_name = :log_account_activities
self.sequence_name = :log_account_activities_id_seq
end
diff --git a/app/models/version/account_version.rb b/app/models/version/account_version.rb
index b68edd4a5..aca10d41f 100644
--- a/app/models/version/account_version.rb
+++ b/app/models/version/account_version.rb
@@ -1,4 +1,4 @@
-class AccountVersion < PaperTrail::Version
+class Version::AccountVersion < PaperTrail::Version
self.table_name = :log_accounts
self.sequence_name = :log_accounts_id_seq
end
diff --git a/app/models/version/action_version.rb b/app/models/version/action_version.rb
index bd23d7697..5ca6220b1 100644
--- a/app/models/version/action_version.rb
+++ b/app/models/version/action_version.rb
@@ -1,4 +1,4 @@
-class ActionVersion < PaperTrail::Version
+class Version::ActionVersion < PaperTrail::Version
self.table_name = :log_actions
self.sequence_name = :log_actions_id_seq
end
diff --git a/app/models/version/bank_statement_version.rb b/app/models/version/bank_statement_version.rb
index ae66f4efe..5a61da3af 100644
--- a/app/models/version/bank_statement_version.rb
+++ b/app/models/version/bank_statement_version.rb
@@ -1,4 +1,4 @@
-class BankStatementVersion < PaperTrail::Version
+class Version::BankStatementVersion < PaperTrail::Version
self.table_name = :log_bank_statements
self.sequence_name = :log_bank_statements_id_seq
end
diff --git a/app/models/version/bank_transaction_version.rb b/app/models/version/bank_transaction_version.rb
index 93e13be74..63c65e2b8 100644
--- a/app/models/version/bank_transaction_version.rb
+++ b/app/models/version/bank_transaction_version.rb
@@ -1,4 +1,4 @@
-class BankTransactionVersion < PaperTrail::Version
+class Version::BankTransactionVersion < PaperTrail::Version
self.table_name = :log_bank_transactions
self.sequence_name = :log_bank_transactions_id_seq
end
diff --git a/app/models/version/billing/price_version.rb b/app/models/version/billing/price_version.rb
index 7502c18e2..611405142 100644
--- a/app/models/version/billing/price_version.rb
+++ b/app/models/version/billing/price_version.rb
@@ -1,7 +1,4 @@
-module Billing
- class PriceVersion < PaperTrail::Version
- self.table_name = :log_prices
- self.sequence_name = :log_prices_id_seq
- end
+class Version::Billing::PriceVersion < PaperTrail::Version
+ self.table_name = :log_prices
+ self.sequence_name = :log_prices_id_seq
end
-
diff --git a/app/models/version/blocked_domain_version.rb b/app/models/version/blocked_domain_version.rb
index 82e6b30da..b511445c0 100644
--- a/app/models/version/blocked_domain_version.rb
+++ b/app/models/version/blocked_domain_version.rb
@@ -1,4 +1,4 @@
-class BlockedDomainVersion < PaperTrail::Version
+class Version::BlockedDomainVersion < PaperTrail::Version
self.table_name = :log_blocked_domains
self.sequence_name = :log_blocked_domains_id_seq
end
diff --git a/app/models/version/certificate_version.rb b/app/models/version/certificate_version.rb
index bcc89e62a..1edd03204 100644
--- a/app/models/version/certificate_version.rb
+++ b/app/models/version/certificate_version.rb
@@ -1,4 +1,4 @@
-class CertificateVersion < PaperTrail::Version
+class Version::CertificateVersion < PaperTrail::Version
self.table_name = :log_certificates
self.sequence_name = :log_certificates_id_seq
end
diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb
index 781813302..6c5c70a99 100644
--- a/app/models/version/contact_version.rb
+++ b/app/models/version/contact_version.rb
@@ -1,7 +1,7 @@
-class ContactVersion < PaperTrail::Version
+class Version::ContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_contacts
self.sequence_name = :log_contacts_id_seq
-
+
# scope :deleted, -> { where(event: 'destroy') }
end
diff --git a/app/models/version/dnskey_version.rb b/app/models/version/dnskey_version.rb
index c50528e42..ea468194e 100644
--- a/app/models/version/dnskey_version.rb
+++ b/app/models/version/dnskey_version.rb
@@ -1,4 +1,4 @@
-class DnskeyVersion < PaperTrail::Version
+class Version::DnskeyVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_dnskeys
self.sequence_name = :log_dnskeys_id_seq
diff --git a/app/models/version/domain_contact_version.rb b/app/models/version/domain_contact_version.rb
index 234ff8d9e..d0e1954be 100644
--- a/app/models/version/domain_contact_version.rb
+++ b/app/models/version/domain_contact_version.rb
@@ -1,4 +1,4 @@
-class DomainContactVersion < PaperTrail::Version
+class Version::DomainContactVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domain_contacts
self.sequence_name = :log_domain_contacts_id_seq
diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb
index 27753960a..b2962d1ee 100644
--- a/app/models/version/domain_version.rb
+++ b/app/models/version/domain_version.rb
@@ -1,4 +1,4 @@
-class DomainVersion < PaperTrail::Version
+class Version::DomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_domains
diff --git a/app/models/version/invoice_item_version.rb b/app/models/version/invoice_item_version.rb
index ffdef5d3e..59a9db6ea 100644
--- a/app/models/version/invoice_item_version.rb
+++ b/app/models/version/invoice_item_version.rb
@@ -1,4 +1,4 @@
-class InvoiceItemVersion < PaperTrail::Version
+class Version::InvoiceItemVersion < PaperTrail::Version
self.table_name = :log_invoice_items
self.sequence_name = :log_invoice_items_id_seq
end
diff --git a/app/models/version/invoice_version.rb b/app/models/version/invoice_version.rb
index 0b98c873f..037ce7237 100644
--- a/app/models/version/invoice_version.rb
+++ b/app/models/version/invoice_version.rb
@@ -1,4 +1,4 @@
-class InvoiceVersion < PaperTrail::Version
+class Version::InvoiceVersion < PaperTrail::Version
self.table_name = :log_invoices
self.sequence_name = :log_invoices_id_seq
end
diff --git a/app/models/version/nameserver_version.rb b/app/models/version/nameserver_version.rb
index 01a02c93a..e4d3a8a0f 100644
--- a/app/models/version/nameserver_version.rb
+++ b/app/models/version/nameserver_version.rb
@@ -1,4 +1,4 @@
-class NameserverVersion < PaperTrail::Version
+class Version::NameserverVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_nameservers
self.sequence_name = :log_nameservers_id_seq
diff --git a/app/models/version/notification_version.rb b/app/models/version/notification_version.rb
index 0b66aabe5..a7eb31ee5 100644
--- a/app/models/version/notification_version.rb
+++ b/app/models/version/notification_version.rb
@@ -1,4 +1,4 @@
-class NotificationVersion < PaperTrail::Version
+class Version::NotificationVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_notifications
self.sequence_name = :log_notifications_id_seq
diff --git a/app/models/version/payment_order_version.rb b/app/models/version/payment_order_version.rb
index e556f1021..8d0a6d083 100644
--- a/app/models/version/payment_order_version.rb
+++ b/app/models/version/payment_order_version.rb
@@ -1,4 +1,4 @@
-class PaymentOrderVersion < PaperTrail::Version
+class Version::PaymentOrderVersion < PaperTrail::Version
self.table_name = :log_payment_orders
self.sequence_name = :log_payment_orders_id_seq
end
diff --git a/app/models/version/registrant_verification_version.rb b/app/models/version/registrant_verification_version.rb
index b7dbb8852..4f1d38601 100644
--- a/app/models/version/registrant_verification_version.rb
+++ b/app/models/version/registrant_verification_version.rb
@@ -1,4 +1,4 @@
-class RegistrantVerificationVersion < PaperTrail::Version
+class Version::RegistrantVerificationVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_registrant_verifications
self.sequence_name = :log_registrant_verifications_id_seq
diff --git a/app/models/version/registrar_version.rb b/app/models/version/registrar_version.rb
index 1e9c9584f..2a55ed212 100644
--- a/app/models/version/registrar_version.rb
+++ b/app/models/version/registrar_version.rb
@@ -1,4 +1,4 @@
-class RegistrarVersion < PaperTrail::Version
+class Version::RegistrarVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_registrars
self.sequence_name = :log_registrars_id_seq
diff --git a/app/models/version/reserved_domain_version.rb b/app/models/version/reserved_domain_version.rb
index 1f3289b79..db68441ab 100644
--- a/app/models/version/reserved_domain_version.rb
+++ b/app/models/version/reserved_domain_version.rb
@@ -1,4 +1,4 @@
-class ReservedDomainVersion < PaperTrail::Version
+class Version::ReservedDomainVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_reserved_domains
self.sequence_name = :log_reserved_domains_id_seq
diff --git a/app/models/version/setting_entry_version.rb b/app/models/version/setting_entry_version.rb
index de1e4d1ca..97840771a 100644
--- a/app/models/version/setting_entry_version.rb
+++ b/app/models/version/setting_entry_version.rb
@@ -1,4 +1,4 @@
-class SettingEntryVersion < PaperTrail::Version
+class Version::SettingEntryVersion < PaperTrail::Version
self.table_name = :log_setting_entries
self.sequence_name = :log_setting_entries
end
diff --git a/app/models/version/setting_version.rb b/app/models/version/setting_version.rb
index d532f8ef4..f93e576a3 100644
--- a/app/models/version/setting_version.rb
+++ b/app/models/version/setting_version.rb
@@ -1,4 +1,4 @@
-class SettingVersion < PaperTrail::Version
+class Version::SettingVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_settings
self.sequence_name = :log_settings_id_seq
diff --git a/app/models/version/user_version.rb b/app/models/version/user_version.rb
index 13453713b..6737ece7b 100644
--- a/app/models/version/user_version.rb
+++ b/app/models/version/user_version.rb
@@ -1,4 +1,4 @@
-class UserVersion < PaperTrail::Version
+class Version::UserVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_users
self.sequence_name = :log_users_id_seq
diff --git a/app/models/version/white_ip_version.rb b/app/models/version/white_ip_version.rb
index 0f2ee8a53..44d851628 100644
--- a/app/models/version/white_ip_version.rb
+++ b/app/models/version/white_ip_version.rb
@@ -1,4 +1,4 @@
-class WhiteIpVersion < PaperTrail::Version
+class Version::WhiteIpVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_white_ips
self.sequence_name = :log_white_ips_id_seq
diff --git a/app/presenters/registrar/domain_list_csv_presenter.rb b/app/presenters/registrar/domain_list_csv_presenter.rb
index 46b11f80b..5f32bd022 100644
--- a/app/presenters/registrar/domain_list_csv_presenter.rb
+++ b/app/presenters/registrar/domain_list_csv_presenter.rb
@@ -1,4 +1,4 @@
-class Registrar::DomainListCSVPresenter
+class Registrar::DomainListCsvPresenter
def initialize(domains:, view:)
@domains = domains
@view = view
diff --git a/app/views/admin/domain_versions/archive.haml b/app/views/admin/domain_versions/archive.haml
index f813f5eb3..46a79190b 100644
--- a/app/views/admin/domain_versions/archive.haml
+++ b/app/views/admin/domain_versions/archive.haml
@@ -66,7 +66,7 @@
= domain.registrant.name
- else
- contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first
- - if contact.nil? && ver = ContactVersion.where(item_id: domain.registrant_id).last
+ - if contact.nil? && ver = Version::ContactVersion.where(item_id: domain.registrant_id).last
- contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}) {|(k,v), o| o[k] = v.last }))
= contact.try(:name)
= " ".html_safe
diff --git a/app/views/admin/domains/partials/_version.haml b/app/views/admin/domains/partials/_version.haml
index da0a0ece1..4533c9293 100644
--- a/app/views/admin/domains/partials/_version.haml
+++ b/app/views/admin/domains/partials/_version.haml
@@ -23,7 +23,7 @@
- admin_contacts = domain.admin_contacts
- registrant = domain.registrant
- unless registrant
- - ver = ContactVersion.where(item_id: domain.registrant_id).where(event: :destroy).last
+ - ver = Version::ContactVersion.where(item_id: domain.registrant_id).where(event: :destroy).last
- registrant = ver.reify
- registrant.version_loader = ver
- registrant = [registrant]
diff --git a/app/views/registrant/contacts/_api_errors.html.erb b/app/views/registrant/contacts/_api_errors.html.erb
deleted file mode 100644
index 35617fa99..000000000
--- a/app/views/registrant/contacts/_api_errors.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- <% errors.each_value do |errors| %>
- <%= errors.join(' ') %>
- <% end %>
-
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/_form.html.erb b/app/views/registrant/contacts/_form.html.erb
deleted file mode 100644
index f203f39e8..000000000
--- a/app/views/registrant/contacts/_form.html.erb
+++ /dev/null
@@ -1,64 +0,0 @@
-<%= form_for [:registrant, domain, @contact], html: { class: 'form-horizontal' } do |f| %>
- <% if @errors.present? %>
- <%= render 'api_errors', errors: @errors %>
- <% end %>
-
-
-
-
-
-
-
- <% if Contact.address_processing? %>
-
-
<%= t '.address' %>
-
- <%= render 'registrant/contacts/form/address', f: f %>
-
-
- <% end %>
-
- <% if fax_enabled? %>
-
- <% end %>
-
-
-
-
-
- <%= button_tag t('.submit_btn'), class: 'btn btn-success' %>
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrant/contacts/edit.html.erb b/app/views/registrant/contacts/edit.html.erb
deleted file mode 100644
index 0a453ded1..000000000
--- a/app/views/registrant/contacts/edit.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-
- <%= link_to t('registrant.domains.index.header'), registrant_domains_path %>
- <%= link_to domain, registrant_domain_path(domain) %>
- <%= t 'registrant.contacts.contact_index' %>
- <%= link_to @contact, registrant_domain_contact_path(domain, @contact) %>
-
-
-
-
-<%= render 'form' %>
\ No newline at end of file
diff --git a/app/views/registrant/contacts/form/_address.html.erb b/app/views/registrant/contacts/form/_address.html.erb
deleted file mode 100644
index a43784d3f..000000000
--- a/app/views/registrant/contacts/form/_address.html.erb
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show.html.erb b/app/views/registrant/contacts/show.html.erb
deleted file mode 100644
index 1f0a87b5f..000000000
--- a/app/views/registrant/contacts/show.html.erb
+++ /dev/null
@@ -1,42 +0,0 @@
-
- <%= link_to t('registrant.domains.index.header'), registrant_domains_path %>
- <%= link_to domain, registrant_domain_path(domain) %>
- <%= t 'registrant.contacts.contact_index' %>
-
-
-
-
-
-
- <%= render 'registrant/contacts/show/general' %>
-
-
-
- <%= render 'registrant/contacts/show/address' %>
-
-
-
-
-
- <%= render 'registrant/contacts/show/statuses', contact: @contact %>
-
-
-
-
-
- <%= render 'registrant/contacts/show/domains', contact: @contact %>
-
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show/_address.html.erb b/app/views/registrant/contacts/show/_address.html.erb
deleted file mode 100644
index c9bc80150..000000000
--- a/app/views/registrant/contacts/show/_address.html.erb
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- <%= t '.header' %>
-
-
-
-
-
- <% if @contact.org_name.present? %>
- <%= Contact.human_attribute_name :org_name %>
- <%= @contact.org_name %>
- <% end %>
-
- <%= Contact.human_attribute_name :street %>
- <%= @contact.street %>
-
- <%= Contact.human_attribute_name :city %>
- <%= @contact.city %>
-
- <%= Contact.human_attribute_name :zip %>
- <%= @contact.zip %>
-
- <%= Contact.human_attribute_name :state %>
- <%= @contact.state %>
-
- <%= Contact.human_attribute_name :country %>
- <%= @contact.country %>
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show/_domain.html.erb b/app/views/registrant/contacts/show/_domain.html.erb
deleted file mode 100644
index 83b7f49d5..000000000
--- a/app/views/registrant/contacts/show/_domain.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-
- <%= link_to domain.name, registrant_domain_path(domain) %>
- <%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %>
- <%= l domain.valid_to %>
- <%= domain.roles.join(", ") %>
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show/_domains.html.erb b/app/views/registrant/contacts/show/_domains.html.erb
deleted file mode 100644
index d783b55b2..000000000
--- a/app/views/registrant/contacts/show/_domains.html.erb
+++ /dev/null
@@ -1,54 +0,0 @@
-<% domains = contact.all_domains(page: params[:domain_page], per: 20,
- params: domain_filter_params.to_h, requester: @requester_contact) %>
-
-
-
-
-
- <%= t '.header' %>
-
-
-
- <%= form_tag request.path, method: :get, class: 'form-inline' do %>
- <%= select_tag :domain_filter,
- options_for_select(%w(Registrant AdminDomainContact TechDomainContact),
- selected: params[:domain_filter]),
- include_blank: t('.all'),
- class: 'form-control' %>
-
-
-
- <% end %>
-
-
-
-
-
-
-
-
-
- <%= custom_sort_link Domain.human_attribute_name(:name), :name %>
-
-
- <%= custom_sort_link Registrar.model_name.human, :registrar_name %>
-
-
- <%= custom_sort_link Domain.human_attribute_name(:valid_to), :valid_to %>
-
-
- <%= custom_sort_link Domain.human_attribute_name(:roles), :roles %>
-
-
-
-
-
- <%= render partial: 'registrant/contacts/show/domain', collection: domains %>
-
-
-
-
-
-
diff --git a/app/views/registrant/contacts/show/_general.html.erb b/app/views/registrant/contacts/show/_general.html.erb
deleted file mode 100644
index b61d2f50e..000000000
--- a/app/views/registrant/contacts/show/_general.html.erb
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
- <%= t '.header' %>
-
-
-
-
-
- <%= Contact.human_attribute_name :code %>
- <%= @contact.code %>
-
- <%= Contact.human_attribute_name :name %>
- <%= @contact.name %>
-
- <%= Contact.human_attribute_name :auth_info %>
-
- <%= tag :input, type: 'text', value: @contact.auth_info, readonly: true,
- class: 'form-control input-sm' %>
-
-
- <%= Contact.human_attribute_name :ident %>
- <%= ident_for(@contact) %>
-
- <%= Contact.human_attribute_name :email %>
- <%= @contact.email %>
-
- <%= Contact.human_attribute_name :phone %>
- <%= @contact.phone %>
-
- <% if @contact.fax %>
- <%= Contact.human_attribute_name :fax %>
- <%= @contact.fax %>
- <% end %>
-
- <%= Contact.human_attribute_name :created_at %>
- <%= l @contact.created_at %>
-
- <%= Contact.human_attribute_name :updated_at %>
- <%= l @contact.updated_at %>
-
- <%= Registrar.model_name.human %>
-
- <%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show/_search.html.erb b/app/views/registrant/contacts/show/_search.html.erb
deleted file mode 100644
index f44fa322f..000000000
--- a/app/views/registrant/contacts/show/_search.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<%= search_form_for [:registrant, @q] do |f| %>
- <%= f.search_field :name_cont %>
- <%= f.submit do %>
-
- <% end %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrant/contacts/show/_statuses.html.erb b/app/views/registrant/contacts/show/_statuses.html.erb
deleted file mode 100644
index 07db6bc87..000000000
--- a/app/views/registrant/contacts/show/_statuses.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- <%= t '.header' %>
-
-
-
-
-
-
- <%= t '.status' %>
- <%= t '.notes' %>
-
-
-
-
- <% contact.statuses.each do |status| %>
-
- <%= status %>
- <%= contact.status_notes[status] %>
-
- <% end %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/domain_delete_confirms/show.haml b/app/views/registrant/domain_delete_confirms/show.haml
deleted file mode 100644
index fffc03219..000000000
--- a/app/views/registrant/domain_delete_confirms/show.haml
+++ /dev/null
@@ -1,44 +0,0 @@
-- if params[:confirmed].present?
- .row
- .col-md-12
- %h1= t(:domain_delete_confirmed_title)
- .row
- .col-md-12
- %p= t(:domain_delete_confirmed_body)
-- elsif params[:rejected].present?
- .row
- .col-md-12
- %h1= t(:domain_delete_rejected_title)
- .row
- .col-md-12
- %p= t(:domain_delete_rejected_body)
-- else
- - if @domain.present?
- .row
- .col-md-12
- %h1= t(:domain_delete_title)
- .row
- .col-md-12
- %p= t(:domain_delete_body)
-
- %hr
- .row
- .col-md-12.text-center.confirmation
- .column-keys
- %p= t(:domain_name) + ':'
- %p= t('.registrant') + ':'
- .column-values
- %p= @domain.name
- %p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
-
- .row
- .col-md-12.text-center
- .confirmation
- = form_for registrant_domain_delete_confirm_path(@domain.id), method: :patch do |f|
- = hidden_field_tag :token, params[:token]
- = f.button t(:confirm_domain_delete), name: 'confirmed', class: 'btn btn-primary'
- = f.button t(:reject_domain_delete), name: 'rejected', class: 'btn btn-warning'
- %hr
- - else
- %h1= t(:not_valid_domain_verification_title).html_safe
- %p= t(:not_valid_domain_verification_body).html_safe
diff --git a/app/views/registrant/domain_update_confirms/show.haml b/app/views/registrant/domain_update_confirms/show.haml
deleted file mode 100644
index 5f7a978ce..000000000
--- a/app/views/registrant/domain_update_confirms/show.haml
+++ /dev/null
@@ -1,46 +0,0 @@
-- if params[:confirmed].present?
- .row
- .col-md-12
- %h1= t(:domain_registrant_change_confirmed_title)
- .row
- .col-md-12
- %p= t(:domain_registrant_change_confirmed_body)
-- elsif params[:rejected].present?
- .row
- .col-md-12
- %h1= t(:domain_registrant_change_rejected_title)
- .row
- .col-md-12
- %p= t(:domain_registrant_change_rejected_body)
-- else
- - if @domain.present?
- .row
- .col-md-12
- %h1= t(:domain_registrant_change_title)
- .row
- .col-md-12
- %p= t(:domain_registrant_change_body)
-
- %hr
- .row
- .col-md-12.text-center.confirmation
- .column-keys
- %p= t(:domain_name) + ':'
- %p= t(:current_registrant) + ':'
- %p= t(:new_pending_registrant) + ':'
- .column-values
- %p= @domain.name
- %p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
- %p= "#{@domain.pending_registrant.try(:name)} (#{@domain.pending_registrant.try(:ident)})"
-
- .row
- .col-md-12.text-center
- .confirmation
- = form_for registrant_domain_update_confirm_path(@domain.id), method: :patch do |f|
- = hidden_field_tag :token, params[:token]
- = f.button t(:confirm_domain_registrant_update), name: 'confirmed', class: 'btn btn-primary'
- = f.button t(:reject_domain_registrant_update), name: 'rejected', class: 'btn btn-warning'
- %hr
- - else
- %h1= t(:not_valid_domain_verification_title).html_safe
- %p= t(:not_valid_domain_verification_body).html_safe
diff --git a/app/views/registrant/domains/_domain.html.erb b/app/views/registrant/domains/_domain.html.erb
deleted file mode 100644
index 8cc8a490b..000000000
--- a/app/views/registrant/domains/_domain.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-
- <%= link_to domain, registrant_domain_path(domain) %>
-
- <%= link_to domain.registrant.name,
- registrant_domain_contact_path(domain, domain.registrant) %>
-
- <%= l domain.expire_time %>
- <%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %>
-
diff --git a/app/views/registrant/domains/confirmation.haml b/app/views/registrant/domains/confirmation.haml
deleted file mode 100644
index b1bc0cb2f..000000000
--- a/app/views/registrant/domains/confirmation.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-- content_for :actions do
- = render 'shared/title', name: @domain.name
-
-.row
- .col-md-12
- .panel.panel-default
- .panel-heading
- %h3.panel-title= t('.header')
- .panel-body
- .input-group.input-group-lg
- %span#sizing-addon1.input-group-addon.glyphicon.glyphicon-link
- %input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @confirmation_url}
-
diff --git a/app/views/registrant/domains/index.html.erb b/app/views/registrant/domains/index.html.erb
deleted file mode 100644
index 1254bfbc8..000000000
--- a/app/views/registrant/domains/index.html.erb
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
- <%= search_form_for [:registrant, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
-
-
-
- <%= f.label :name, for: nil %>
- <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
-
-
-
-
- <%= f.label t(:registrant_ident), for: nil %>
- <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
-
-
-
-
-
- <%= label_tag t(:results_per_page) %>
- <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
-
-
-
-
-
-
- <%= f.label t(:valid_to_from), for: nil %>
- <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
-
-
-
-
- <%= f.label t(:valid_to_until), for: nil %>
- <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
-
-
-
-
-
-
-
-
-
-
-
- <%= button_tag t('.download_pdf_btn'),
- formaction: registrant_domains_path(format: :pdf),
- name: nil,
- class: 'btn btn-default' %>
- <%= button_tag t('.download_csv_btn'),
- formaction: registrant_domains_path(format: :csv),
- name: nil,
- class: 'btn btn-default' %>
- <%= link_to t('.reset_btn'), registrant_domains_path,
- class: 'btn btn-default' %>
-
-
- <% end %>
-
-
-
-
-
-
-
-
-
-
- <%= sort_link(@q, 'name') %>
-
-
- <%= sort_link(@q, 'registrant_name', t('.registrant')) %>
-
-
- <%= sort_link(@q, 'valid_to', t(:valid_to)) %>
-
-
- <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %>
-
-
-
-
-
- <%= render @domains %>
-
-
-
-
-
- <%= paginate @domains %>
-
-
-
-
-
diff --git a/app/views/registrant/domains/list_pdf.html.erb b/app/views/registrant/domains/list_pdf.html.erb
deleted file mode 100644
index 4ce4f5ed0..000000000
--- a/app/views/registrant/domains/list_pdf.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
- <%= Domain.human_attribute_name :name %>
- <%= Registrant.model_name.human %>
- <%= Domain.human_attribute_name :valid_to %>
- <%= Registrar.model_name.human %>
-
-
-
-
- <% @domains.each do |domain| %>
-
- <%= domain.name %>
- <%= domain.registrant %>
- <%= l(domain.valid_to, format: :short) %>
- <%= domain.registrar %>
-
- <% end %>
-
-
-
-
-
-
-
diff --git a/app/views/registrant/domains/partials/_dnskeys.haml b/app/views/registrant/domains/partials/_dnskeys.haml
deleted file mode 100644
index ddd95e952..000000000
--- a/app/views/registrant/domains/partials/_dnskeys.haml
+++ /dev/null
@@ -1,18 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- = t(:dnskeys)
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-1'}= t(:flag)
- %th{class: 'col-xs-1'}= t(:protocol)
- %th{class: 'col-xs-1'}= t(:algorithm)
- %th{class: 'col-xs-9'}= t(:public_key)
- %tbody
- - @domain.dnskeys.each do |x|
- %tr
- %td= x.flags
- %td= x.protocol
- %td= x.alg
- %td= x.public_key
diff --git a/app/views/registrant/domains/partials/_domain_contact.html.erb b/app/views/registrant/domains/partials/_domain_contact.html.erb
deleted file mode 100644
index e4eaf7115..000000000
--- a/app/views/registrant/domains/partials/_domain_contact.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<% contact = domain_contact.contact %>
-
-
- <%= link_to contact, registrant_domain_contact_path(domain, contact) %>
- <%= contact.code %>
- <%= contact.email %>
-
\ No newline at end of file
diff --git a/app/views/registrant/domains/partials/_domain_contacts.html.erb b/app/views/registrant/domains/partials/_domain_contacts.html.erb
deleted file mode 100644
index 3876e2546..000000000
--- a/app/views/registrant/domains/partials/_domain_contacts.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
- <%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
-
-
-
-
-
-
- <%= Contact.human_attribute_name :name %>
- <%= Contact.human_attribute_name :code %>
- <%= Contact.human_attribute_name :email %>
-
-
-
-
- <%= render partial: 'registrant/domains/partials/domain_contact',
- collection: domain_contacts,
- locals: { domain: domain } %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb
deleted file mode 100644
index 38995be01..000000000
--- a/app/views/registrant/domains/partials/_general.html.erb
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
- <%= t(:general) %>
-
-
-
-
-
- <%= t(:name) %>
- <%= @domain.name %>
-
- <%= Domain.human_attribute_name :registered_at %>
- <%= l(@domain.registered_at) %>
-
- <%= Registrar.model_name.human %>
- <%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %>
-
- <%= Domain.human_attribute_name :transfer_code %>
-
- <%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
- class: 'form-control input-sm' %>
-
-
- <%= t(:valid_to) %>
- <%= l(@domain.valid_to) %>
-
- <%= Domain.human_attribute_name :outzone_at %>
- <%= l(@domain.outzone_at) %>
-
- <%= Domain.human_attribute_name :delete_date %>
- <%= l @domain.delete_date %>
-
- <%= Domain.human_attribute_name :force_delete_date %>
- <%= l @domain.force_delete_date %>
-
-
-
diff --git a/app/views/registrant/domains/partials/_legal_documents.haml b/app/views/registrant/domains/partials/_legal_documents.haml
deleted file mode 100644
index 7d740977b..000000000
--- a/app/views/registrant/domains/partials/_legal_documents.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- = t(:legal_documents)
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-8'}= t(:created_at)
- %th{class: 'col-xs-4'}= t(:type)
- %tbody
- - legal_documents.each do |x|
- %tr
- %td= link_to(x.created_at, [:registrar, x])
- %td= x.document_type
diff --git a/app/views/registrant/domains/partials/_nameservers.haml b/app/views/registrant/domains/partials/_nameservers.haml
deleted file mode 100644
index 0bc22732d..000000000
--- a/app/views/registrant/domains/partials/_nameservers.haml
+++ /dev/null
@@ -1,16 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- = t(:nameservers)
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-4'}= t(:hostname)
- %th{class: 'col-xs-4'}= t(:ipv4)
- %th{class: 'col-xs-4'}= t(:ipv6)
- %tbody
- - @domain.nameservers.each do |x|
- %tr
- %td= x
- %td= x.ipv4
- %td= x.ipv6
diff --git a/app/views/registrant/domains/partials/_registrant.html.erb b/app/views/registrant/domains/partials/_registrant.html.erb
deleted file mode 100644
index f02a2eb4e..000000000
--- a/app/views/registrant/domains/partials/_registrant.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- <%= t '.header' %>
-
-
-
-
- <%= Registrant.human_attribute_name :name %>
-
- <%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %>
-
-
- <%= Registrant.human_attribute_name :code %>
- <%= registrant.code %>
-
- <%= Registrant.human_attribute_name :ident %>
- <%= registrant.ident %>
-
- <%= Registrant.human_attribute_name :email %>
- <%= registrant.email %>
-
- <%= Registrant.human_attribute_name :phone %>
- <%= registrant.phone %>
-
-
-
\ No newline at end of file
diff --git a/app/views/registrant/domains/partials/_statuses.haml b/app/views/registrant/domains/partials/_statuses.haml
deleted file mode 100644
index 10fc795eb..000000000
--- a/app/views/registrant/domains/partials/_statuses.haml
+++ /dev/null
@@ -1,18 +0,0 @@
-#domain_statuses.panel.panel-default
- .panel-heading.clearfix
- = t(:statuses)
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-6'}= t(:status)
- %th{class: 'col-xs-6'}= t(:notes)
- %tbody
- - @domain.statuses.each do |status|
- %tr
- %td
- - if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION].include?(status) && @domain.pending_json.present?
- = link_to(status, confirmation_registrant_domain_path(@domain))
- - else
- = status
- %td= @domain.status_notes[status]
diff --git a/app/views/registrant/domains/show.html.erb b/app/views/registrant/domains/show.html.erb
deleted file mode 100644
index 81ca04b51..000000000
--- a/app/views/registrant/domains/show.html.erb
+++ /dev/null
@@ -1,52 +0,0 @@
-
- <%= link_to t('registrant.domains.index.header'), registrant_domains_path %>
-
-
-
-
-
-
- <%= render 'registrant/domains/partials/general' %>
-
-
-
- <%= render partial: 'registrant/domains/partials/registrant',
- locals: { registrant: @domain.registrant, domain: @domain } %>
-
-
-
-
-
- <%= render 'registrant/domains/partials/domain_contacts',
- domain: @domain,
- domain_contacts: @domain.tech_domain_contacts %>
-
-
-
-
-
- <%= render 'registrant/domains/partials/domain_contacts',
- domain: @domain,
- domain_contacts: @domain.admin_domain_contacts %>
-
-
-
-
-
- <%= render 'registrant/domains/partials/statuses' %>
-
-
-
-
-
- <%= render 'registrant/domains/partials/nameservers' %>
-
-
-
-
-
- <%= render 'registrant/domains/partials/dnskeys' %>
-
-
diff --git a/app/views/registrant/registrars/show.haml b/app/views/registrant/registrars/show.haml
deleted file mode 100644
index f5e0f40f4..000000000
--- a/app/views/registrant/registrars/show.haml
+++ /dev/null
@@ -1,44 +0,0 @@
-= render 'shared/title', name: @registrar.name
-
-- if @registrar.errors.any?
- - @registrar.errors.each do |attr, err|
- = err
- %br
-- if @registrar.errors.any?
- %hr
-.row
- .col-md-6
- .panel.panel-default
- .panel-heading
- %h3.panel-title= t(:general)
- .panel-body
- %dl.dl-horizontal
- %dt= Registrar.human_attribute_name :name
- %dd= @registrar.name
-
- %dt= Registrar.human_attribute_name :reg_no
- %dd= @registrar.reg_no
-
- %dt= Registrar.human_attribute_name :vat_no
- %dd= @registrar.vat_no
-
- %dt= Registrar.human_attribute_name :code
- %dd= @registrar.code
-
- .col-md-6
- .panel.panel-default
- .panel-heading
- %h3.panel-title= t(:contact)
- .panel-body
- %dl.dl-horizontal
- %dt= Registrar.human_attribute_name :country
- %dd= @registrar.country
-
- %dt= Registrar.human_attribute_name :address
- %dd= @registrar.address
-
- %dt= Registrar.human_attribute_name :phone
- %dd= @registrar.phone
-
- %dt= Registrar.human_attribute_name :email
- %dd= @registrar.email
diff --git a/app/views/registrant/sessions/new.html.erb b/app/views/registrant/sessions/new.html.erb
deleted file mode 100644
index 9f7af3254..000000000
--- a/app/views/registrant/sessions/new.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- <%= t '.header' %>
-
-
-
- <%= t '.hint' %>
-
-
- <%= link_to t(:sign_in), "/auth/rant_tara", method: :post, class: 'btn btn-lg btn-primary btn-block' %>
-
-
diff --git a/app/views/registrant/whois/index.haml b/app/views/registrant/whois/index.haml
deleted file mode 100644
index 5b1e64efa..000000000
--- a/app/views/registrant/whois/index.haml
+++ /dev/null
@@ -1,17 +0,0 @@
-= render 'shared/title', name: t(:whois)
-
-.row
- .col-md-12{style: 'margin-bottom: -15px;'}
- = form_tag registrant_whois_path, class: 'form-horizontal', method: :get do
- .col-md-11
- .form-group
- = text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', autofocus: true
- .col-md-1.text-right.text-center-xs
- .form-group
- %button.btn.btn-default
-
- %span.glyphicon.glyphicon-search
-
-%hr
-- if @domain
- %pre= @domain.body
diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb
index c5eaf2063..aefcdd47f 100644
--- a/app/views/registrar/account_activities/index.html.erb
+++ b/app/views/registrar/account_activities/index.html.erb
@@ -14,7 +14,7 @@
-
+
<%= sort_link(@q, 'description') %>
@@ -26,6 +26,9 @@
<%= sort_link(@q, 'sum') %>
+
+ <%= sort_link(@q, 'new_balance', 'New balance') %>
+
@@ -45,6 +48,9 @@
<%= s %>
+
+ <%= x.new_balance.present? ? "#{currency(x.new_balance)} EUR" : 'N/A' %>
+
<% end %>
diff --git a/config/application.rb b/config/application.rb
index 22c2c4df9..0ab5aa8bb 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -17,7 +17,7 @@ end
module DomainNameRegistry
class Application < Rails::Application
config.load_defaults 6.0
- config.autoloader = :classic # Do not use zeitwerk for now
+ config.autoloader = :zeitwerk # Do not use zeitwerk for now
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@@ -35,10 +35,9 @@ module DomainNameRegistry
# config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
# Autoload all model subdirs
- config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
- config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')]
- config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
- config.autoload_paths += Dir[Rails.root.join('app', 'actions', '**/')]
+ # config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
+ # config.autoload_paths += Dir[Rails.root.join('app', 'lib', '**/')]
+ # config.autoload_paths += Dir[Rails.root.join('app', 'interactions', '**/')]
config.eager_load_paths << config.root.join('lib', 'validators')
config.eager_load_paths << config.root.join('app', 'lib')
config.watchable_dirs['lib'] = %i[rb]
@@ -73,8 +72,7 @@ module DomainNameRegistry
}
config.action_mailer.default_options = { from: ENV['action_mailer_default_from'] }
- require "#{Rails.root}/app/mailers/interceptors/punycode_interceptor"
- ActionMailer::Base.register_interceptor(PunycodeInterceptor)
+ config.action_mailer.interceptors = ["Interceptors::PunycodeInterceptor"]
config.action_view.default_form_builder = 'DefaultFormBuilder'
config.secret_key_base = Figaro.env.secret_key_base
diff --git a/config/application.yml.sample b/config/application.yml.sample
index dd38e206c..88fc28a0d 100644
--- a/config/application.yml.sample
+++ b/config/application.yml.sample
@@ -170,7 +170,7 @@ tara_issuer: 'https://tara-test.ria.ee'
tara_identifier: 'identifier'
tara_secret: 'secret'
tara_redirect_uri: 'redirect_url'
-tara_keys: "{\"kty\":\"RSA\",\"kid\":\"de6cc4\",\"n\":\"jWwAjT_03ypme9ZWeSe7c-jY26NO50Wo5I1LBnPW2JLc0dPMj8v7y4ehiRpClYNTaSWcLd4DJmlKXDXXudEUWwXa7TtjBFJfzlZ-1u0tDvJ-H9zv9MzO7UhUFytztUEMTrtStdhGbzkzdEZZCgFYeo2i33eXxzIR1nGvI05d9Y-e_LHnNE2ZKTa89BC7ZiCXq5nfAaCgQna_knh4kFAX-KgiPRAtsiDHcAWKcBY3qUVcb-5XAX8p668MlGLukzsh5tFkQCbJVyNtmlbIHdbGvVHPb8C0H3oLYciv1Fjy_tS1lO7OT_cb3GVp6Ql-CG0uED_8pkpVtfsGRviub4_ElQ\",\"e\":\"AQAB\"}"
+tara_keys: "{\"kty\":\"RSA\",\"kid\":\"public:xWbbVoYq9EwMqphp\",\"n\":\"2vlgaxaUJYUWjkNM_b-ruADW3gyGnkPvxDyEXWeLyP668vn5aTrSdZ42psr6Vpu6V1MEjMr27bnE7swqndfmspqJHKlp47fO9orWWNGmrHFtClxU36wqFiIg9V39hbHdoXqZVdLywwjx6KLgsuYff95KvwfDqUK9IxxADm91ckD9m9aoQaPTrn8KsB9uhkyEchejNHRg7EGZDvWHF-aiQHCMnieSowiapPd7kTYGemPMheVyY_Zwvyya8DkvjnVa8HlrmbzjMjGdSRq5dVL0lCxb4-OlZ-QZuORUBqZ5xEAhWg2Jl6oG0slj3z8l_fd7l2oj7THNoepYWTnzUDxsN1hvRLzFnJh8MNUklYHWf8CFrwmPdqGDs0jeLP2v7X8LJeQ-Ly3GHsUBai1aVORZXCHq1Tzt2XyQhvPVt_3WoaVKJBi4hjz0CLKlSE0eUv9TWL58CU76tU98dxOwSb6hhqEu3xn6mLApyyEZzeUdYdJutDFQuTYz2pb1yqMFqlp2LHa49p7Q5TvBp4pKOxwjrqnlKTsasL8BU2vA9xHuEEYttVzAPWjH_5-BfoJ8GKQTLaXc6LOmWIZcMDVM8QEOkLXQdUtlaPVz-2wl9Q_FwhoBzXSZujEYQVcSZznxIdNyV4nvn2mo56isITX18PTcdyZ4V-wWlS5PuUNVVRQHWE0\",\"e\":\"AQAB\"}"
tara_rant_identifier: 'identifier'
tara_rant_secret: 'secret'
diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml
index 906bde193..4b4d099d7 100644
--- a/config/locales/contacts.en.yml
+++ b/config/locales/contacts.en.yml
@@ -25,8 +25,10 @@ en:
email_regex_check_error: Invalid format
domains:
exist: 'Object association prohibits operation'
+ delete_prohibited: Contact delete prohibited by status
statuses:
not_uniq: 'not uniq'
+ delete_prohibited: Contact delete prohibited by status
country_code:
invalid: Country code is not valid, should be in ISO_3166-1 alpha 2 format (%{value})
disclosed_attributes:
diff --git a/config/routes.rb b/config/routes.rb
index 4ac50908d..580747ab1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -200,35 +200,8 @@ Rails.application.routes.draw do
end
end
- scope :registrant do
- devise_scope :registrant_user do
- get 'sign_in', to: 'registrant/sessions#new', as: :new_registrant_user_session
- post 'sessions', to: 'registrant/sessions#create', as: :registrant_user_session
- delete 'sign_out', to: 'registrant/sessions#destroy', as: :destroy_registrant_user_session
-
- # TARA
- match '/open_id/callback', via: %i[get post], to: 'sso/tara#registrant_callback'
- match '/open_id/cancel', via: %i[get post delete], to: 'sso/tara#cancel'
- end
- end
-
namespace :registrant do
- root 'domains#index'
-
- # POST /registrant/sign_in is not used
devise_for :users, path: '', class_name: 'RegistrantUser'
-
- resources :registrars, only: :show
- # resources :companies, only: :index
- resources :domains, only: %i[index show] do
- resources :contacts, only: %i[show edit update]
- member do
- get 'confirmation'
- end
- end
-
- resources :domain_update_confirms, only: %i[show update]
- resources :domain_delete_confirms, only: %i[show update]
end
# ADMIN ROUTES
@@ -283,12 +256,24 @@ Rails.application.routes.draw do
end
end
+ resources :version_domain_versions, path: '/domain_versions' do
+ collection do
+ get 'search' => 'domain_versions#search', via: [:get, :post], as: :search
+ end
+ end
+
resources :contact_versions do
collection do
get 'search'
end
end
+ resources :version_contact_versions, path: '/contact_versions' do
+ collection do
+ get 'search' => 'contact_versions#search', via: [:get, :post], as: :search
+ end
+ end
+
resources :settings, only: %i[index create]
resources :blocked_domains do
diff --git a/db/migrate/20210215101019_add_new_balance_to_account_activity.rb b/db/migrate/20210215101019_add_new_balance_to_account_activity.rb
new file mode 100644
index 000000000..64c829833
--- /dev/null
+++ b/db/migrate/20210215101019_add_new_balance_to_account_activity.rb
@@ -0,0 +1,5 @@
+class AddNewBalanceToAccountActivity < ActiveRecord::Migration[6.0]
+ def change
+ add_column :account_activities, :new_balance, :decimal, precision: 10, scale: 2, null: true
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index acf134a55..de2243597 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -226,7 +226,8 @@ CREATE TABLE public.account_activities (
creator_str character varying,
updator_str character varying,
activity_type character varying,
- price_id integer
+ price_id integer,
+ new_balance numeric(10,2)
);
@@ -4959,6 +4960,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200908131554'),
('20200910085157'),
('20200910102028'),
-('20200916125326');
+('20200916125326'),
+('20210215101019');
diff --git a/lib/serializers/registrant_api/domain.rb b/lib/serializers/registrant_api/domain.rb
index 64913a7fb..b087a3a88 100644
--- a/lib/serializers/registrant_api/domain.rb
+++ b/lib/serializers/registrant_api/domain.rb
@@ -25,6 +25,12 @@ module Serializers
registrant: {
name: domain.registrant.name,
id: domain.registrant.uuid,
+ ident: domain.registrant.ident,
+ ident_type: domain.registrant.ident_type,
+ ident_country_code: domain.registrant.ident_country_code,
+ phone: domain.registrant.phone,
+ email: domain.registrant.email,
+ org: domain.registrant.org?,
},
tech_contacts: contacts(:tech),
admin_contacts: contacts(:admin),
@@ -60,7 +66,7 @@ module Serializers
registrar: { name: domain.registrar.name, website: domain.registrar.website },
registrant: { name: domain.registrant.name, id: domain.registrant.uuid,
phone: domain.registrant.phone, email: domain.registrant.email,
- ident: domain.registrant.ident }
+ ident: domain.registrant.ident, org: domain.registrant.org? }
}
end
diff --git a/lib/tasks/documents.rake b/lib/tasks/documents.rake
index 5ae8fb4df..39c32a3bd 100644
--- a/lib/tasks/documents.rake
+++ b/lib/tasks/documents.rake
@@ -16,8 +16,8 @@ namespace :documents do
next if x.documentable_id.blank?
document_type = case x.documentable_type
- when 'Domain' then DomainVersion
- when 'Contact'then ContactVersion
+ when 'Domain' then Version::DomainVersion
+ when 'Contact'then Version::ContactVersion
end
dc = document_type.where(item_id: x.documentable_id)
diff --git a/test/helpers/form_helper_test.rb b/test/helpers/form_helper_test.rb
new file mode 100644
index 000000000..199384170
--- /dev/null
+++ b/test/helpers/form_helper_test.rb
@@ -0,0 +1,11 @@
+require 'test_helper'
+
+class FormHelperTest < ActionView::TestCase
+ def test_legal_document_field
+ meth = MiniTest::Mock.new
+ returned_legal_document_field = ApplicationController.helpers.legal_document_field('Hello', meth)
+
+ assert returned_legal_document_field.include? 'data-legal-document="true"'
+ assert returned_legal_document_field.include? 'accept=".pdf,.asice,.asics,.sce,.scs,.adoc,.edoc,.bdoc,.zip,.rar,.gz,.tar,.7z,.odt,.doc,.docx"'
+ end
+end
\ No newline at end of file
diff --git a/test/helpers/form_tag_helper_test.rb b/test/helpers/form_tag_helper_test.rb
new file mode 100644
index 000000000..f664957fc
--- /dev/null
+++ b/test/helpers/form_tag_helper_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class FormTagHelperTest < ActionView::TestCase
+ def test_legal_document_field
+ returned_legal_document_field = ApplicationController.helpers.legal_document_field_tag('Hello')
+ assert returned_legal_document_field.include? 'data-legal-document="true"'
+ assert returned_legal_document_field.include? 'accept=".pdf,.asice,.asics,.sce,.scs,.adoc,.edoc,.bdoc,.zip,.rar,.gz,.tar,.7z,.odt,.doc,.docx"'
+ end
+end
\ No newline at end of file
diff --git a/test/integration/api/domain_transfers_test.rb b/test/integration/api/domain_transfers_test.rb
index 3e9c10100..3ed5b0fc6 100644
--- a/test/integration/api/domain_transfers_test.rb
+++ b/test/integration/api/domain_transfers_test.rb
@@ -63,6 +63,23 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
end
+ def test_bulk_transfer_if_domain_has_update_prohibited_status
+ domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
+
+ post '/repp/v1/domains/transfer', params: request_params, as: :json,
+ headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
+
+ assert_response :ok
+ assert_equal ({ code: 1000,
+ message: 'Command completed successfully',
+ data: { success: [],
+ failed: [{ type: "domain_transfer",
+ domain_name: "shop.test",
+ errors: [{:code=>"2304", :msg=>"Object status prohibits operation"}] }],
+ }}),
+ JSON.parse(response.body, symbolize_names: true)
+ end
+
private
def request_params
diff --git a/test/integration/api/nameservers/put_test.rb b/test/integration/api/nameservers/put_test.rb
index 77b01a9b1..a55014709 100644
--- a/test/integration/api/nameservers/put_test.rb
+++ b/test/integration/api/nameservers/put_test.rb
@@ -104,6 +104,25 @@ class APINameserversPutTest < ApplicationIntegrationTest
JSON.parse(response.body, symbolize_names: true)
end
+ def test_bulk_namesaervers_if_domain_update_prohibited
+ domains(:shop).update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
+
+ params = { data: { type: 'nameserver', id: domains(:shop).nameservers.hostnames[0],
+ attributes: { hostname: 'ns55.bestnames.test' } } }
+ put '/repp/v1/registrar/nameservers', params: params, as: :json,
+ headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
+
+ assert_response :ok
+ assert_equal ({ code: 1000,
+ message: 'Command completed successfully',
+ data: { type: "nameserver",
+ id: "ns55.bestnames.test",
+ attributes: {hostname: "ns55.bestnames.test"},
+ affected_domains: ["airport.test"],
+ skipped_domains: ["shop.test"]}}),
+ JSON.parse(response.body, symbolize_names: true)
+ end
+
def test_unauthenticated
put '/repp/v1/registrar/nameservers'
assert_response 401
diff --git a/test/integration/api/registrant/registrant_api_domains_test.rb b/test/integration/api/registrant/registrant_api_domains_test.rb
index 61d635e5f..a8801f1b4 100644
--- a/test/integration/api/registrant/registrant_api_domains_test.rb
+++ b/test/integration/api/registrant/registrant_api_domains_test.rb
@@ -5,9 +5,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
def setup
super
- @domain = domains(:hospital)
+ @domain = domains(:airport)
@registrant = @domain.registrant
@user = users(:registrant)
+ domains(:metro).tech_domain_contacts.update(contact_id: @registrant.id)
@auth_headers = { 'HTTP_AUTHORIZATION' => auth_token }
end
@@ -19,7 +20,14 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
assert_equal('hospital.test', domain[:name])
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
- assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, domain[:registrant])
+ assert_equal({:name=>"John",
+ :id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
+ :ident=>"1234", :ident_type=>"priv",
+ :ident_country_code=>"US",
+ :phone=>"+555.555",
+ :email=>"john@inbox.test",
+ :org=>false},
+ domain[:registrant])
assert_equal([{name: 'John',
id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957',
email: 'john@inbox.test'}],
@@ -57,6 +65,46 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
end
+ def test_return_domain_list_with_registrants_and_admins
+ domains(:hospital).admin_domain_contacts.update(contact_id: contacts(:william).id)
+ domains(:hospital).update(registrant: contacts(:william).becomes(Registrant))
+
+ get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
+ assert_equal(200, response.status)
+
+ response_json = JSON.parse(response.body, symbolize_names: true)
+ response_json[:domains].each do |x|
+ if x[:registrant][:org] == false
+ x[:tech_contacts].each do |s|
+ assert_not s[:name].include?(@registrant.name)
+ end
+ end
+ end
+ end
+
+ def test_return_domain_list_with_registrants_and_admins_tech
+ get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0, 'tech' => true }
+ assert_equal(200, response.status)
+
+ response_json = JSON.parse(response.body, symbolize_names: true)
+ response_json[:domains].each do |x|
+ if x[:name] == 'metro.test'
+ x[:tech_contacts].each do |s|
+ assert s[:name].include?(@registrant.name)
+ end
+ end
+ end
+ end
+
+ def test_domains_total_if_an_incomplete_list_is_returned
+ get '/api/v1/registrant/domains', headers: @auth_headers, params: { 'offset' => 0 }
+ assert_equal(200, response.status)
+
+ response_json = JSON.parse(response.body, symbolize_names: true)
+ assert_equal response_json[:domains].length, response_json[:count]
+ assert_equal response_json[:total], 5
+ end
+
def test_root_accepts_limit_and_offset_parameters
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
headers: @auth_headers
diff --git a/test/integration/api/registrant/registrant_api_registry_locks_test.rb b/test/integration/api/registrant/registrant_api_registry_locks_test.rb
index fb6d13aca..0de47dbc9 100644
--- a/test/integration/api/registrant/registrant_api_registry_locks_test.rb
+++ b/test/integration/api/registrant/registrant_api_registry_locks_test.rb
@@ -130,7 +130,15 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ name: 'Best Names', website: 'https://bestnames.test' }, response_json[:registrar])
- assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, response_json[:registrant])
+ assert_equal({:name=>"John",
+ :id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
+ :ident=>"1234",
+ :ident_type=>"priv",
+ :ident_country_code=>"US",
+ :phone=>"+555.555",
+ :email=>"john@inbox.test",
+ :org=>false},
+ response_json[:registrant])
assert_equal([{name: 'Jane',
id: '9db3de62-2414-4487-bee2-d5c155567768',
email: 'jane@mail.test'
diff --git a/test/integration/epp/contact/delete/base_test.rb b/test/integration/epp/contact/delete/base_test.rb
index 26ba63897..e86bea9dd 100644
--- a/test/integration/epp/contact/delete/base_test.rb
+++ b/test/integration/epp/contact/delete/base_test.rb
@@ -27,6 +27,60 @@ class EppContactDeleteBaseTest < EppTestCase
assert_epp_response :completed_successfully
end
+ def test_delete_contact_with_server_delete_prohibited
+ contact = deletable_contact
+ contact.update(statuses: Contact::SERVER_DELETE_PROHIBITED)
+ assert contact.statuses.include? Contact::SERVER_DELETE_PROHIBITED
+
+ contact.update_columns(code: contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{contact.code.upcase}
+
+
+
+
+ XML
+
+ post epp_delete_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ assert Contact.exists?(id: contact.id)
+ assert_epp_response :object_status_prohibits_operation
+ end
+
+ def test_delete_contact_with_client_delete_prohibited
+ contact = deletable_contact
+ contact.update(statuses: Contact::CLIENT_DELETE_PROHIBITED)
+ assert contact.statuses.include? Contact::CLIENT_DELETE_PROHIBITED
+
+ contact.update_columns(code: contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{contact.code.upcase}
+
+
+
+
+ XML
+
+ post epp_delete_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ assert Contact.exists?(id: contact.id)
+ assert_epp_response :object_status_prohibits_operation
+ end
+
def test_undeletable_cannot_be_deleted
contact = contacts(:john)
assert_not contact.deletable?
@@ -61,4 +115,4 @@ class EppContactDeleteBaseTest < EppTestCase
DomainContact.delete_all
contacts(:john)
end
-end
\ No newline at end of file
+end
diff --git a/test/integration/epp/contact/update/base_test.rb b/test/integration/epp/contact/update/base_test.rb
index 98c0e4462..ff43905de 100644
--- a/test/integration/epp/contact/update/base_test.rb
+++ b/test/integration/epp/contact/update/base_test.rb
@@ -325,6 +325,104 @@ class EppContactUpdateBaseTest < EppTestCase
assert_nil @contact.state
end
+ def test_update_contact_with_update_prohibited
+ @contact.update(statuses: [Contact::CLIENT_UPDATE_PROHIBITED])
+ @contact.update_columns(code: @contact.code.upcase)
+
+ street = '123 Example'
+ city = 'Tallinn'
+ state = 'Harjumaa'
+ zip = '123456'
+ country_code = 'EE'
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{@contact.code}
+
+
+
+ #{street}
+ #{city}
+ #{state}
+ #{zip}
+ #{country_code}
+
+
+
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ @contact.reload
+
+ assert_not_equal city, @contact.city
+ assert_not_equal street, @contact.street
+ assert_not_equal zip, @contact.zip
+ assert_not_equal country_code, @contact.country_code
+ assert_not_equal state, @contact.state
+
+ assert_epp_response :object_status_prohibits_operation
+ end
+
+ def test_legal_document
+ assert_equal 'john-001', @contact.code
+ assert_not_equal 'new name', @contact.name
+ assert_not_equal 'new-email@inbox.test', @contact.email
+ assert_not_equal '+123.4', @contact.phone
+
+ Setting.request_confirmation_on_domain_deletion_enabled = false
+
+ # https://github.com/internetee/registry/issues/415
+ @contact.update_columns(code: @contact.code.upcase)
+
+ assert_not @contact.legal_documents.present?
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+ new name
+
+ +123.4
+ new-email@inbox.test
+
+
+
+
+
+ #{'test' * 2000}
+
+
+
+
+ XML
+
+ assert_difference -> { @contact.legal_documents.reload.size } do
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ @contact.reload
+ end
+
+ assert_epp_response :completed_successfully
+ assert_equal 'new name', @contact.name
+ assert_equal 'new-email@inbox.test', @contact.email
+ assert_equal '+123.4', @contact.phone
+ end
+
private
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
diff --git a/test/integration/epp/domain/delete/base_test.rb b/test/integration/epp/domain/delete/base_test.rb
index 56a3cc31e..d32a89f63 100644
--- a/test/integration/epp/domain/delete/base_test.rb
+++ b/test/integration/epp/domain/delete/base_test.rb
@@ -133,6 +133,40 @@ class EppDomainDeleteBaseTest < EppTestCase
assert_epp_response :completed_successfully
end
+ def test_deletes_on_update_prohibited
+ assert_equal 'shop.test', @domain.name
+ @domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
+ Setting.request_confirmation_on_domain_deletion_enabled = false
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+
+ #{'test' * 2000}
+
+
+
+
+ XML
+
+ perform_enqueued_jobs do
+ post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ end
+ @domain.reload
+
+ assert_not @domain.registrant_verification_asked?
+ assert_not @domain.pending_delete_confirmation?
+ assert_no_emails
+ assert_epp_response :completed_successfully
+ end
+
def test_skips_registrant_confirmation_when_required_but_already_verified_by_registrar
assert_equal 'shop.test', @domain.name
Setting.request_confirmation_on_domain_deletion_enabled = true
diff --git a/test/integration/epp/domain/renew/base_test.rb b/test/integration/epp/domain/renew/base_test.rb
index 9a61e1470..7c58d325d 100644
--- a/test/integration/epp/domain/renew/base_test.rb
+++ b/test/integration/epp/domain/renew/base_test.rb
@@ -32,6 +32,38 @@ class EppDomainRenewBaseTest < EppTestCase
assert_equal original_valid_to + default_renewal_period, domain.valid_to
end
+ def test_renews_domain_if_update_prohibited
+ travel_to Time.zone.parse('2010-07-05')
+ domain = domains(:shop)
+ original_valid_to = domain.valid_to
+ default_renewal_period = 1.year
+ domain.statuses << DomainStatus::SERVER_UPDATE_PROHIBITED
+ domain.save
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{domain.name}
+ #{domain.expire_time.to_date}
+ 1
+
+
+
+
+ XML
+
+ post epp_renew_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ domain.reload
+
+ assert_epp_response :completed_successfully
+ assert_equal original_valid_to + default_renewal_period, domain.valid_to
+ assert domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
+ end
+
def test_domain_cannot_be_renewed_when_invalid
domain = domains(:invalid)
diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb
index 14e806fca..83ba65478 100644
--- a/test/integration/epp/domain/update/base_test.rb
+++ b/test/integration/epp/domain/update/base_test.rb
@@ -5,6 +5,7 @@ class EppDomainUpdateBaseTest < EppTestCase
setup do
@domain = domains(:shop)
+ @contact = contacts(:john)
@original_registrant_change_verification =
Setting.request_confirmation_on_registrant_change_enabled
ActionMailer::Base.deliveries.clear
@@ -62,6 +63,27 @@ class EppDomainUpdateBaseTest < EppTestCase
assert_epp_response :object_status_prohibits_operation
end
+ def test_prohibited_domain_cannot_be_updated
+ @domain.update!(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ assert_epp_response :object_status_prohibits_operation
+ end
+
def test_does_not_return_server_delete_prohibited_status_when_pending_update_status_is_set
@domain.update!(statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::PENDING_UPDATE])
@@ -123,6 +145,46 @@ class EppDomainUpdateBaseTest < EppTestCase
assert_verification_and_notification_emails
end
+ def test_domain_should_doesnt_have_pending_update_when_updated_registrant_with_same_idents_data
+ assert_not @domain.statuses.include? "pendingUpdate"
+
+ old_registrant = @domain.registrant
+ new_registrant = contacts(:william).becomes(Registrant)
+
+ new_registrant.update(ident: old_registrant.ident)
+ new_registrant.update(ident_country_code: old_registrant.ident_country_code)
+ new_registrant.update(ident_type: old_registrant.ident_type)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{@domain.name}
+
+ #{new_registrant.code}
+
+
+
+
+
+ #{'test' * 2000}
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ @domain.reload
+ assert_epp_response :completed_successfully
+
+ assert_equal @domain.registrant, new_registrant
+ assert_not @domain.statuses.include? "pendingUpdate"
+ end
+
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
Setting.request_confirmation_on_registrant_change_enabled = true
new_registrant = contacts(:william)
@@ -225,6 +287,49 @@ class EppDomainUpdateBaseTest < EppTestCase
Setting.legal_document_is_mandatory = old_value
end
+ # ================================================================
+ def test_domain_should_not_padding_if_registrant_update_with_same_ident
+ Setting.request_confirmation_on_registrant_change_enabled = true
+
+ current = @domain.registrant
+ new_registrant = contacts(:william)
+ new_registrant.update(
+ ident: current.ident,
+ ident_type: current.ident_type,
+ ident_country_code: current.ident_country_code
+ )
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{@domain.name}
+
+ #{new_registrant.code}
+
+
+
+
+
+ #{'test' * 2000}
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ @domain.reload
+
+ # NOTE: completed_successfully_action_pending
+ assert_epp_response :completed_successfully
+ refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
+
+ end
+
def test_skips_verification_when_provided_registrant_is_the_same_as_current_one
Setting.request_confirmation_on_registrant_change_enabled = true
diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb
index 6d3ec467e..a18fdbe4e 100644
--- a/test/integration/epp/poll_test.rb
+++ b/test/integration/epp/poll_test.rb
@@ -26,6 +26,31 @@ class EppPollTest < EppTestCase
assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
end
+ def test_does_not_drop_error_if_old_version
+ version = Version::DomainVersion.last
+ @notification.update(attached_obj_type: 'DomainVersion', attached_obj_id: version.id)
+
+ request_xml = <<-XML
+
+
+
+
+
+
+ XML
+ assert_nothing_raised do
+ post epp_poll_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+ end
+
+ xml_doc = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully_ack_to_dequeue
+ assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count]
+ assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id]
+ assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text
+ assert_equal 'Your domain has been updated', xml_doc.at_css('msgQ msg').text
+ end
+
def test_return_action_data_when_present
@notification.update!(action: actions(:contact_update))
diff --git a/test/integration/registrant_area/application_helper_test.rb b/test/integration/registrant_area/application_helper_test.rb
new file mode 100644
index 000000000..d915baf61
--- /dev/null
+++ b/test/integration/registrant_area/application_helper_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class ApplicationHelperTest < ActionView::TestCase
+ def test_env_style_when_pic_present
+ assert_dom_equal %{},
+ %{}
+ end
+
+ def test_env_style_return_nil
+ env_style = ''
+ assert_dom_equal %{},
+ %{}
+ end
+end
diff --git a/test/integration/registrant_area/contacts_test.rb b/test/integration/registrant_area/contacts_test.rb
deleted file mode 100644
index c906cd026..000000000
--- a/test/integration/registrant_area/contacts_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'test_helper'
-
-class RegistrantAreaContactsIntegrationTest < ApplicationIntegrationTest
- setup do
- @domain = domains(:shop)
- @registrant = users(:registrant)
- sign_in @registrant
- end
-
- def test_can_view_other_domain_contacts
- secondary_contact = contacts(:jane)
-
- visit registrant_domain_path(@domain)
- assert_text secondary_contact.name
- click_link secondary_contact.name
- assert_text @domain.name
- assert_text secondary_contact.email
- end
-end
diff --git a/test/integration/registrant_area/domain_delete_confirmations.rb b/test/integration/registrant_area/domain_delete_confirmations.rb
deleted file mode 100644
index 29bca7ed9..000000000
--- a/test/integration/registrant_area/domain_delete_confirmations.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require 'test_helper'
-
-class RegistrantAreaDomainDeleteConfirmationIntegrationTest < ActionDispatch::IntegrationTest
- include ActionMailer::TestHelper
-
- setup do
- @domain = domains(:shop)
- ActionMailer::Base.deliveries.clear
- end
-
- def test_notifies_registrant_by_email_when_accepted
- @domain.update!(registrant_verification_asked_at: Time.zone.now,
- registrant_verification_token: 'test',
- statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
-
- patch registrant_domain_delete_confirm_path(@domain, token: 'test', confirmed: true)
-
- assert_emails 1
- end
-
- def test_notifies_registrant_by_email_when_rejected
- @domain.update!(registrant_verification_asked_at: Time.zone.now,
- registrant_verification_token: 'test',
- statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
-
- patch registrant_domain_delete_confirm_path(@domain, token: 'test', rejected: true)
-
- assert_emails 1
- end
-end
\ No newline at end of file
diff --git a/test/integration/registrant_area/domains_test.rb b/test/integration/registrant_area/domains_test.rb
deleted file mode 100644
index d2ca1c775..000000000
--- a/test/integration/registrant_area/domains_test.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'test_helper'
-
-class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
- setup do
- sign_in users(:registrant)
- end
-
- def test_downloads_list_as_csv
- get registrant_domains_path(format: :csv)
-
- assert_response :ok
- assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
- assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-
- def test_downloads_list_as_pdf
- get registrant_domains_path(format: :pdf)
-
- assert_response :ok
- assert_equal Mime[:pdf], response.headers['Content-Type']
- assert_equal "attachment; filename=\"domains.pdf\"; filename*=UTF-8''domains.pdf", response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-end
diff --git a/test/integration/registrar_area/domains_test.rb b/test/integration/registrar_area/domains_test.rb
index 1a4e0534c..307bcae5e 100644
--- a/test/integration/registrar_area/domains_test.rb
+++ b/test/integration/registrar_area/domains_test.rb
@@ -1,6 +1,8 @@
require 'test_helper'
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
+ include FormTagHelper
+
setup do
sign_in users(:api_bestnames)
end
diff --git a/test/integration/repp/v1/accounts/balance_test.rb b/test/integration/repp/v1/accounts/balance_test.rb
index 785e0aee8..4b711bd05 100644
--- a/test/integration/repp/v1/accounts/balance_test.rb
+++ b/test/integration/repp/v1/accounts/balance_test.rb
@@ -2,6 +2,7 @@ require 'test_helper'
class ReppV1BalanceTest < ActionDispatch::IntegrationTest
def setup
+ travel_to Time.zone.parse('2010-07-05')
@registrar = users(:api_bestnames)
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
token = "Basic #{token}"
@@ -19,4 +20,32 @@ class ReppV1BalanceTest < ActionDispatch::IntegrationTest
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
end
+
+ def test_can_query_balance_with_details
+ # Create new billable action to get activity
+ post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: { domains: ['shop.test'], renew_period: '1y' }
+
+ started_from = "2010-07-05"
+ end_to = DateTime.current.to_date.to_s(:db)
+
+ get "/repp/v1/accounts/balance?detailed=true", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :ok
+ assert_equal 1000, json[:code]
+ assert_equal 'Command completed successfully', json[:message]
+ assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
+ assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
+ entry = json[:data][:transactions].last
+ assert_equal @registrar.registrar.cash_account.account_activities.last.created_at, entry[:created_at]
+ assert_equal @registrar.registrar.cash_account.account_activities.last.description, entry[:description]
+ assert_equal 'debit', entry[:type]
+ assert_equal @registrar.registrar.cash_account.account_activities.last.sum.to_s, entry[:sum]
+ assert_equal @registrar.registrar.cash_account.account_activities.last.new_balance.to_s, entry[:balance]
+
+ json[:data][:transactions].map do |trans|
+ assert trans[:created_at].to_date.to_s(:db) >= started_from
+ assert trans[:created_at].to_date.to_s(:db) >= end_to
+ end
+ end
end
diff --git a/test/integration/repp/v1/domains/bulk_renew_test.rb b/test/integration/repp/v1/domains/bulk_renew_test.rb
index 26a34dd39..19a3e34fc 100644
--- a/test/integration/repp/v1/domains/bulk_renew_test.rb
+++ b/test/integration/repp/v1/domains/bulk_renew_test.rb
@@ -37,6 +37,43 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
end
end
+ def test_keeps_update_prohibited_status
+ domain = domains(:shop)
+ domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED])
+ payload = {
+ "domains": [
+ 'shop.test'
+ ],
+ "renew_period": "1y"
+ }
+
+ assert_changes -> { Domain.find_by(name: 'shop.test').valid_to } do
+ post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :ok
+ assert_equal 1000, json[:code]
+ assert_equal 'Command completed successfully', json[:message]
+ assert json[:data][:updated_domains].include? 'shop.test'
+ end
+ domain.reload
+ assert_equal domain.statuses, [DomainStatus::CLIENT_UPDATE_PROHIBITED, DomainStatus::SERVER_UPDATE_PROHIBITED]
+ end
+
+ def test_multi_domains_сannot_be_renewed_with_renew_prohibited_status
+ array_domains = [domains(:shop), domains(:airport)]
+ payload = {
+ "domains": array_domains.pluck(:name),
+ "renew_period": "1y"
+ }
+
+ array_domains.each do |domain|
+ set_status_for_domain(domain, [DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::SERVER_RENEW_PROHIBITED])
+ end
+
+ assert_renew_prohibited_domains(array_domains, payload)
+ end
+
def test_throws_error_when_domain_not_renewable
payload = {
"domains": [
@@ -88,4 +125,36 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
assert_equal 2005, json[:code]
assert_equal 'Invalid renew period', json[:message]
end
+
+ private
+
+ def set_status_for_domain(domain, statuses)
+ domain.update(statuses: statuses)
+
+ if statuses.size > 1
+ statuses.each do |status|
+ assert domain.statuses.include? status
+ end
+ else
+ assert domain.statuses.include? statuses
+ end
+ end
+
+ def bulk_renew(payload)
+ post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
+ JSON.parse(response.body, symbolize_names: true)
+ end
+
+ def assert_renew_prohibited_domains(domains, payload)
+ assert_no_changes -> { Domain.where(name: domains).pluck(:valid_to) } do
+ json = bulk_renew(payload)
+
+ assert_response :bad_request
+ assert_equal 2002, json[:code]
+ assert domains.all? do |domain|
+ json[:message].include? "Domain renew error for #{domain.name}"
+ end
+ assert json[:data].empty?
+ end
+ end
end
diff --git a/test/integration/repp/v1/registrar/nameservers_test.rb b/test/integration/repp/v1/registrar/nameservers_test.rb
index 102649637..01f30c813 100644
--- a/test/integration/repp/v1/registrar/nameservers_test.rb
+++ b/test/integration/repp/v1/registrar/nameservers_test.rb
@@ -34,6 +34,33 @@ class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
assert json[:data][:affected_domains].include? 'shop.test'
end
+ def test_fails_to_update_if_prohibited
+ domain = domains(:shop)
+ domain.update(statuses: [DomainStatus::CLIENT_UPDATE_PROHIBITED])
+ nameserver = nameservers(:shop_ns1)
+ payload = {
+ "data": {
+ "id": nameserver.hostname,
+ "type": "nameserver",
+ "attributes": {
+ "hostname": "#{nameserver.hostname}.test",
+ "ipv4": ["1.1.1.1"]
+ }
+ }
+ }
+
+ put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :ok
+ assert_equal 1000, json[:code]
+ assert_equal 'Command completed successfully', json[:message]
+ assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
+ assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
+ assert json[:data][:affected_domains].include? 'airport.test'
+ assert json[:data][:skipped_domains].include? 'shop.test'
+ end
+
def test_nameserver_with_hostname_must_exist
payload = {
"data": {
diff --git a/test/integration/repp/v1/retained_domains_test.rb b/test/integration/repp/v1/retained_domains_test.rb
index 73b32d381..814eabfc1 100644
--- a/test/integration/repp/v1/retained_domains_test.rb
+++ b/test/integration/repp/v1/retained_domains_test.rb
@@ -21,7 +21,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
status: 'reserved',
punycode_name: 'reserved.test' }]
- assert_equal response_json[:domains], expected_objects
+ assert_empty response_json[:domains] - expected_objects
end
def test_get_index_with_type_parameter
diff --git a/test/interactions/domain_delete_interaction/domain_delete_test.rb b/test/interactions/domain_delete_interaction/domain_delete_test.rb
index 9582fae03..7716ddb63 100644
--- a/test/interactions/domain_delete_interaction/domain_delete_test.rb
+++ b/test/interactions/domain_delete_interaction/domain_delete_test.rb
@@ -22,4 +22,43 @@ class DomainDeleteTest < ActiveSupport::TestCase
Domains::Delete::DoDelete.run(domain: @domain)
end
end
+
+ def test_preclean_pendings
+ @domain.registrant_verification_token = "123"
+ @domain.registrant_verification_asked_at = "123"
+ @domain.preclean_pendings
+
+ assert_nil @domain.registrant_verification_token
+ assert_nil @domain.registrant_verification_asked_at
+ end
+
+ def test_clean_pendings
+ @domain.is_admin = true
+ @domain.registrant_verification_token = "123"
+ @domain.registrant_verification_asked_at = "123"
+ @domain.pending_json = { delete: DomainStatus::PENDING_DELETE}
+ @domain.update(statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION,
+ DomainStatus::PENDING_UPDATE,
+ DomainStatus::PENDING_DELETE,
+ ])
+ @domain.status_notes[DomainStatus::PENDING_UPDATE] = '123'
+ @domain.status_notes[DomainStatus::PENDING_DELETE] = '234'
+ @domain.reload
+
+
+ @domain.clean_pendings!
+ @domain.reload
+
+ assert @domain.is_admin
+ assert_nil @domain.registrant_verification_token
+ assert_nil @domain.registrant_verification_asked_at
+ assert_equal @domain.pending_json, {}
+
+ assert (not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION)
+ assert (not @domain.statuses.include? DomainStatus::PENDING_UPDATE)
+ assert (not @domain.statuses.include? DomainStatus::PENDING_DELETE)
+
+ assert_equal @domain.status_notes[DomainStatus::PENDING_UPDATE], ''
+ assert_equal @domain.status_notes[DomainStatus::PENDING_DELETE], ''
+ end
end
diff --git a/test/jobs/domain_delete_job_test.rb b/test/jobs/domain_delete_job_test.rb
new file mode 100644
index 000000000..a6f7d9065
--- /dev/null
+++ b/test/jobs/domain_delete_job_test.rb
@@ -0,0 +1,20 @@
+require "test_helper"
+
+class DomainDeleteJobTest < ActiveSupport::TestCase
+ setup do
+ travel_to Time.zone.parse('2010-07-05')
+ @domain = domains(:shop)
+ @domain.update!(delete_date:'2010-07-05')
+ @domain.reload
+ end
+
+ def test_delete_domain
+ dom = Domain.find_by(id: @domain.id)
+ assert dom
+
+ DomainDeleteJob.run(@domain.id)
+
+ dom = Domain.find_by(id: @domain.id)
+ assert_nil dom
+ end
+end
\ No newline at end of file
diff --git a/test/jobs/domain_expire_email_job_test.rb b/test/jobs/domain_expire_email_job_test.rb
new file mode 100644
index 000000000..f57de2686
--- /dev/null
+++ b/test/jobs/domain_expire_email_job_test.rb
@@ -0,0 +1,29 @@
+require "test_helper"
+
+class DomainExpireEmailJobTest < ActiveSupport::TestCase
+ setup do
+ @domain = domains(:shop)
+ travel_to Time.zone.parse('2010-08-06')
+ @domain.update(valid_to: Time.now - 1.day)
+ @domain.reload
+ end
+
+ def test_domain_expire
+ success = DomainExpireEmailJob.run(@domain.id)
+ assert success
+ end
+
+ def test_domain_expire_with_force_delete
+ @domain.update(statuses: [DomainStatus::FORCE_DELETE])
+ @domain.reload
+ assert_equal ['serverForceDelete'], @domain.statuses
+
+ success = DomainExpireEmailJob.run(@domain.id)
+ assert success
+
+ statuses = @domain.statuses
+ statuses.delete(DomainStatus::FORCE_DELETE)
+ @domain.update(statuses: statuses)
+ assert_equal ['ok'], @domain.statuses
+ end
+end
\ No newline at end of file
diff --git a/test/jobs/regenerate_registrar_whoises_job_test.rb b/test/jobs/regenerate_registrar_whoises_job_test.rb
new file mode 100644
index 000000000..3fe94612b
--- /dev/null
+++ b/test/jobs/regenerate_registrar_whoises_job_test.rb
@@ -0,0 +1,13 @@
+require "test_helper"
+
+class RegenerateRegistrarWhoisesJobTest < ActiveSupport::TestCase
+ setup do
+ travel_to Time.zone.parse('2010-07-05 10:00')
+ @registrar = registrars(:bestnames)
+ end
+
+ def test_job_return_true
+ # if return false, then job was failes
+ assert RegenerateRegistrarWhoisesJob.run(@registrar.id)
+ end
+end
\ No newline at end of file
diff --git a/test/lib/serializers/registrant_api/domain_test.rb b/test/lib/serializers/registrant_api/domain_test.rb
index f2623741f..2e68e4293 100644
--- a/test/lib/serializers/registrant_api/domain_test.rb
+++ b/test/lib/serializers/registrant_api/domain_test.rb
@@ -30,8 +30,15 @@ class SerializersRegistrantApiDomainTest < ActiveSupport::TestCase
assert_equal({name: 'Best Names', website: 'https://bestnames.test' }, @json[:registrar])
end
- def test_returns_registrant_name_and_uuid
- assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'},
+ def test_returns_registrant_name_uuid_and_org
+ assert_equal({:name=>"John",
+ :id=>"eb2f2766-b44c-4e14-9f16-32ab1a7cb957",
+ :ident=>"1234",
+ :ident_type=>"priv",
+ :ident_country_code=>"US",
+ :phone=>"+555.555",
+ :email=>"john@inbox.test",
+ :org=>false},
@json[:registrant])
end
diff --git a/test/lib/validators/date_time_iso8601_validator_test.rb b/test/lib/validators/date_time_iso8601_validator_test.rb
new file mode 100644
index 000000000..ca397c6e5
--- /dev/null
+++ b/test/lib/validators/date_time_iso8601_validator_test.rb
@@ -0,0 +1,62 @@
+require 'test_helper'
+
+class DateTimeIso8601Validatable
+ include ActiveModel::Validations
+ validates_with DateTimeIso8601Validator, :attributes=>[:errors]
+ attr_accessor :code, :type
+ validates :code, iso8601: { date_only: true }, if: :birthday?
+
+ def birthday?
+ type == "birthday"
+ end
+
+ def empty?
+ code.empty?
+ end
+end
+
+class DateTimeIso8601ValidatorTest < ActiveSupport::TestCase
+ def test_check_invalid_reverse_date
+ obj = DateTimeIso8601Validatable.new
+ obj.type = "birthday"
+ obj.code = "22-12-2020"
+ assert_not obj.valid?
+ end
+
+ def test_check_date_without_separate_symbols
+ obj = DateTimeIso8601Validatable.new
+ obj.type = "birthday"
+ obj.code = "24521012"
+ assert_not obj.valid?
+ end
+
+ def test_check_empty_date
+ obj = DateTimeIso8601Validatable.new
+ obj.type = "birthday"
+ obj.code = ""
+ assert_not obj.valid?
+ end
+
+ def test_check_valid_date
+ obj = DateTimeIso8601Validatable.new
+ obj.code = Date.new(2000,5,25).iso8601
+ obj.type = "birthday"
+ assert obj.valid?
+ end
+
+ def test_return_code_2005_in_epp_validate
+ obj = DateTimeIso8601Validatable.new
+ obj.code = Date.new(2000,5,25).iso8601
+ obj.type = "birthday"
+ epp_resp = DateTimeIso8601Validator.validate_epp(obj, obj.code)
+ assert_equal epp_resp[:msg], "Expiry absolute must be compatible to ISO 8601"
+ end
+
+ def test_epp_request_with_empty_data
+ obj = DateTimeIso8601Validatable.new
+ obj.code = ""
+ obj.type = "birthday"
+ epp_resp = DateTimeIso8601Validator.validate_epp(obj, obj.code)
+ assert_nil epp_resp
+ end
+end
\ No newline at end of file
diff --git a/test/lib/validators/duration_iso8601_validator_test.rb b/test/lib/validators/duration_iso8601_validator_test.rb
new file mode 100644
index 000000000..a4acaad60
--- /dev/null
+++ b/test/lib/validators/duration_iso8601_validator_test.rb
@@ -0,0 +1,57 @@
+require 'test_helper'
+
+class DurationIso8601Validatable
+ include ActiveModel::Validations
+ validates_with DurationIso8601Validator, :attributes=>[:errors]
+ attr_accessor :duration
+ validates :duration, inclusion: { in: Proc.new { |price| price.class.durations } }
+
+ def self.durations
+ [
+ '3 mons',
+ '6 mons',
+ '9 mons',
+ '1 year',
+ '2 years',
+ '3 years',
+ '4 years',
+ '5 years',
+ '6 years',
+ '7 years',
+ '8 years',
+ '9 years',
+ '10 years',
+ ]
+ end
+
+ def empty?
+ duration.empty?
+ end
+end
+
+class DurationIso8601ValidatorTest < ActiveSupport::TestCase
+ def test_valid_duration
+ dura = DurationIso8601Validatable.new
+ dura.duration = '1 year'
+ assert dura.valid?
+ end
+
+ def test_invalid_duration
+ dura = DurationIso8601Validatable.new
+ dura.duration = 'one millinons years'
+ assert_not dura.valid?
+ end
+
+ def test_empty_duration
+ dura = DurationIso8601Validatable.new
+ dura.duration = ''
+ assert_not dura.valid?
+ end
+
+ def test_return_epp_response_code_2005
+ dura = DurationIso8601Validatable.new
+ dura.duration = '1 year'
+ epp_resp = DurationIso8601Validator.validate_epp(dura, dura.duration)
+ assert_equal epp_resp[:msg], "Expiry relative must be compatible to ISO 8601"
+ end
+end
diff --git a/test/mailers/registrant_change_mailer_test.rb b/test/mailers/registrant_change_mailer_test.rb
index 5d14972e3..5ddfc76db 100644
--- a/test/mailers/registrant_change_mailer_test.rb
+++ b/test/mailers/registrant_change_mailer_test.rb
@@ -72,11 +72,14 @@ class RegistrantChangeMailerTest < ActionMailer::TestCase
email = RegistrantChangeMailer.expired(domain: @domain,
registrar: @domain.registrar,
- registrant: @domain.registrant).deliver_now
+ registrant: @domain.registrant,
+ send_to: [@domain.new_registrant_email,
+ @domain.registrant.email],
+ ).deliver_now
assert_emails 1
- assert_equal ['william@inbox.test'], email.to
+ assert_equal ['william@inbox.test', @domain.registrant.email], email.to
assert_equal 'Domeeni shop.test registreerija vahetuse taotlus on tühistatud' \
' / shop.test registrant change cancelled', email.subject
end
-end
\ No newline at end of file
+end
diff --git a/test/models/admin_user_test.rb b/test/models/admin_user_test.rb
index aedc911bd..e737f8a3c 100644
--- a/test/models/admin_user_test.rb
+++ b/test/models/admin_user_test.rb
@@ -123,6 +123,15 @@ class AdminUserTest < ActiveSupport::TestCase
assert user.valid?
end
+ def test_min_password_length
+ assert_equal AdminUser.min_password_length, 8
+ end
+
+ def test_country_instance
+ user = valid_user
+ assert user.country.present?
+ end
+
private
def valid_user
diff --git a/test/models/certificate_test.rb b/test/models/certificate_test.rb
new file mode 100644
index 000000000..a48c6081f
--- /dev/null
+++ b/test/models/certificate_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class CertificateTest < ActiveSupport::TestCase
+ setup do
+ @certificate = certificates(:api)
+ @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n")
+ end
+
+ def test_does_metadata_is_api
+ api = @certificate.assign_metadata
+ assert api, 'api'
+ end
+
+ def test_certificate_sign_returns_false
+ assert_not @certificate.sign!, 'false'
+ end
+end
\ No newline at end of file
diff --git a/test/models/concerns/versions_test.rb b/test/models/concerns/versions_test.rb
index 2a54b4476..bc823d51c 100644
--- a/test/models/concerns/versions_test.rb
+++ b/test/models/concerns/versions_test.rb
@@ -7,7 +7,7 @@ class VersionsTest < ActiveSupport::TestCase
@nameserver.update(hostname: 'ns99.bestnames.test')
@ignored_column_title = Nameserver.ignored_columns.first
- version = NameserverVersion.last
+ version = Version::NameserverVersion.last
hash = version.object
hash[@ignored_column_title] = 123456
version.update(object: hash)
diff --git a/test/models/contact/archivable_test.rb b/test/models/contact/archivable_test.rb
index 340ca54e0..cd07d3894 100644
--- a/test/models/contact/archivable_test.rb
+++ b/test/models/contact/archivable_test.rb
@@ -6,8 +6,8 @@ class ArchivableContactTest < ActiveSupport::TestCase
end
def test_contact_is_archivable_when_it_was_linked_and_inactivity_period_has_passed
- DomainVersion.stub(:was_contact_linked?, true) do
- DomainVersion.stub(:contact_unlinked_more_than?, true) do
+ Version::DomainVersion.stub(:was_contact_linked?, true) do
+ Version::DomainVersion.stub(:contact_unlinked_more_than?, true) do
assert @contact.archivable?
end
end
@@ -18,7 +18,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
@contact.created_at = Time.zone.parse('2010-07-05 00:00:00')
travel_to Time.zone.parse('2010-07-05 00:00:01')
- DomainVersion.stub(:was_contact_linked?, false) do
+ Version::DomainVersion.stub(:was_contact_linked?, false) do
assert @contact.archivable?
end
end
@@ -28,14 +28,14 @@ class ArchivableContactTest < ActiveSupport::TestCase
@contact.created_at = Time.zone.parse('2010-07-05')
travel_to Time.zone.parse('2010-07-05')
- DomainVersion.stub(:contact_unlinked_more_than?, false) do
+ Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
assert_not @contact.archivable?
end
end
def test_contact_is_not_archivable_when_it_was_ever_linked_but_linked_within_inactivity_period
- DomainVersion.stub(:was_contact_linked?, true) do
- DomainVersion.stub(:contact_unlinked_more_than?, false) do
+ Version::DomainVersion.stub(:was_contact_linked?, true) do
+ Version::DomainVersion.stub(:contact_unlinked_more_than?, false) do
assert_not @contact.archivable?
end
end
@@ -73,7 +73,7 @@ class ArchivableContactTest < ActiveSupport::TestCase
def archivable_contact
contact = contacts(:john)
Setting.orphans_contacts_in_months = 0
- DomainVersion.delete_all
+ Version::DomainVersion.delete_all
other_contact = contacts(:william)
assert_not_equal other_contact, contact
diff --git a/test/models/disputed_domain_test.rb b/test/models/disputed_domain_test.rb
index 01897e19b..a37a61c37 100644
--- a/test/models/disputed_domain_test.rb
+++ b/test/models/disputed_domain_test.rb
@@ -16,6 +16,20 @@ class DisputedDomainTest < ActiveSupport::TestCase
@dispute.reload
assert @dispute.closed
+ assert @dispute.forward_to_auction_if_possible
+
+ n = Whois::Record.find_by(name: @dispute.domain_name)
+ assert @dispute.remove_whois_data(n)
+ end
+
+ def test_invalid_auth
+ travel_to Time.zone.parse('2010-10-05')
+ assert_not Dispute.valid_auth?(nil, nil)
+ end
+
+ def test_valid_auth
+ travel_to Time.zone.parse('2010-10-05')
+ assert Dispute.valid_auth?(@dispute.domain_name, @dispute.password)
end
def test_syncs_password_to_reserved
diff --git a/test/models/dnskey_test.rb b/test/models/dnskey_test.rb
new file mode 100644
index 000000000..2f4eff3af
--- /dev/null
+++ b/test/models/dnskey_test.rb
@@ -0,0 +1,58 @@
+require 'test_helper'
+
+class DnskeyTest < ActiveSupport::TestCase
+ include EppErrors
+
+ setup do
+ @dnskey = 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
+ @domain = domains(:shop)
+ end
+
+ def test_valid_dns_key
+ dns = Dnskey.new
+ dns.domain_id = @domain.id
+ dns.flags = 257
+ dns.protocol = 3
+ dns.alg = 8
+ dns.public_key = @dnskey
+
+ assert dns.save
+ end
+
+ def test_invalid_algrorithm
+ dns = Dnskey.new
+ dns.alg = 666
+ errors = dns.validate_algorithm
+ assert_equal errors, ['Valid algorithms are: 3, 5, 6, 7, 8, 10, 13, 14']
+ end
+
+ def test_invalid_protocol
+ dns = Dnskey.new
+ dns.protocol = 666
+ errors = dns.validate_protocol
+ assert_equal errors, ['Valid protocols are: 3']
+ end
+
+ def test_invalid_flags
+ dns = Dnskey.new
+ dns.flags = 666
+ errors = dns.validate_flags
+ assert_equal errors, ['Valid flags are: 0, 256, 257']
+ end
+
+ def test_ds_digest_type_one
+ Setting.ds_digest_type = 1
+
+ dns = Dnskey.new
+ dns.domain_id = @domain.id
+ dns.flags = 257
+ dns.protocol = 3
+ dns.alg = 8
+ dns.public_key = @dnskey
+
+ assert dns.save
+
+ assert_equal dns.ds_digest_type, 1
+ assert_equal dns.ds_digest, '640D173A44D9AF2856FBE282EE64CE11A76DBB84'
+ end
+end
\ No newline at end of file
diff --git a/test/models/domain/force_delete_test.rb b/test/models/domain/force_delete_test.rb
index 2bb1b5b8f..19338f495 100644
--- a/test/models/domain/force_delete_test.rb
+++ b/test/models/domain/force_delete_test.rb
@@ -234,6 +234,19 @@ class ForceDeleteTest < ActionMailer::TestCase
assert_includes(@domain.statuses, asserted_status)
end
+ def test_client_hold_prohibits_manual_inzone
+ @domain.update(valid_to: Time.zone.parse('2012-08-05'))
+ @domain.update(template_name: 'legal_person')
+ travel_to Time.zone.parse('2010-07-05')
+ @domain.schedule_force_delete(type: :soft)
+ travel_to Time.zone.parse('2010-08-21')
+ Domains::ClientHold::SetClientHold.run!
+ @domain.reload
+
+ @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE
+ assert_not @domain.valid?
+ end
+
def test_force_delete_soft_year_ahead_not_sets_client_hold_before_threshold
asserted_status = DomainStatus::CLIENT_HOLD
diff --git a/test/models/domain_contact_test.rb b/test/models/domain_contact_test.rb
new file mode 100644
index 000000000..4bfefb7f1
--- /dev/null
+++ b/test/models/domain_contact_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class DomainContactTest < ActiveSupport::TestCase
+ setup do
+ @domain_contact = domain_contacts(:shop_jane)
+ end
+
+ def test_if_domain_contact_type_invalid
+ @domain_contact.update(type: "Some")
+ assert @domain_contact.name, ''
+ end
+
+ def test_value_typeahead
+ assert @domain_contact.value_typeahead, 'Jane'
+ end
+
+end
\ No newline at end of file
diff --git a/test/models/legal_document_test.rb b/test/models/legal_document_test.rb
index f09c52047..e187f6fc3 100644
--- a/test/models/legal_document_test.rb
+++ b/test/models/legal_document_test.rb
@@ -5,6 +5,10 @@ class LegalDocumentTest < ActiveSupport::TestCase
assert valid_legal_document.valid?, proc { valid_legal_document.errors.full_messages }
end
+ def test_duplicate_legal_docs
+ assert LegalDocument.remove_duplicates
+ end
+
private
def valid_legal_document
diff --git a/test/models/mass_action_test.rb b/test/models/mass_action_test.rb
new file mode 100644
index 000000000..8c730a5e6
--- /dev/null
+++ b/test/models/mass_action_test.rb
@@ -0,0 +1,20 @@
+require 'test_helper'
+
+class MassActionTest < ActiveSupport::TestCase
+ setup do
+ @csv_valid = Rails.root.join('test', 'fixtures', 'files', 'mass_actions', 'valid_mass_force_delete_list.csv').to_s
+ @csv_invalid = Rails.root.join('test', 'fixtures', 'files', 'mass_actions', 'invalid_mass_force_delete_list.csv').to_s
+ end
+
+ def test_mass_action_procces_with_valid_data
+ assert MassAction.process("force_delete", @csv_valid)
+ end
+
+ def test_mass_action_proccess_with_invalid_data
+ assert_not MassAction.process("force_delete", @csv_invalid)
+ end
+
+ def test_mass_action_invalid_attributes
+ assert_not MassAction.process("force_restart", @csv_valid)
+ end
+end
\ No newline at end of file
diff --git a/test/models/registrant_verification_test.rb b/test/models/registrant_verification_test.rb
index ef4038784..a8707fd85 100644
--- a/test/models/registrant_verification_test.rb
+++ b/test/models/registrant_verification_test.rb
@@ -15,7 +15,7 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
registrant_verification = registrant_verifications(:one)
random_action = "random#{rand(100)}"
- assert_difference -> { RegistrantVerificationVersion.count } do
+ assert_difference -> { Version::RegistrantVerificationVersion.count } do
registrant_verification.update_attributes!(action: random_action)
end
end
@@ -23,11 +23,11 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
def test_reject_changes
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
verification_token: @token)
- start_versions_count = RegistrantVerificationVersion.count
+ start_versions_count = Version::RegistrantVerificationVersion.count
assert_nothing_raised do
@registrant_verification.domain_registrant_change_reject!("email link, #{@initiator}")
end
- assert_equal RegistrantVerificationVersion.count, start_versions_count + 1
+ assert_equal Version::RegistrantVerificationVersion.count, start_versions_count + 1
end
end
diff --git a/test/models/version/domain_version_test.rb b/test/models/version/domain_version_test.rb
index 719fcf3ba..be8b020c4 100644
--- a/test/models/version/domain_version_test.rb
+++ b/test/models/version/domain_version_test.rb
@@ -11,7 +11,7 @@ class DomainVersionTest < ActiveSupport::TestCase
tech_contacts: [],
registrant: [@contact.id] })
- assert DomainVersion.was_contact_linked?(@contact.id)
+ assert Version::DomainVersion.was_contact_linked?(@contact.id)
end
def test_was_contact_linked_returns_true_when_contact_was_used_as_admin_contact
@@ -19,7 +19,7 @@ class DomainVersionTest < ActiveSupport::TestCase
tech_contacts: [],
registrant: [] })
- assert DomainVersion.was_contact_linked?(@contact.id)
+ assert Version::DomainVersion.was_contact_linked?(@contact.id)
end
def test_was_contact_linked_returns_true_when_contact_was_used_as_tech_contact
@@ -27,7 +27,7 @@ class DomainVersionTest < ActiveSupport::TestCase
tech_contacts: [@contact.id],
registrant: [] })
- assert DomainVersion.was_contact_linked?(@contact.id)
+ assert Version::DomainVersion.was_contact_linked?(@contact.id)
end
def test_was_contact_linked_returns_false_when_contact_was_not_used
@@ -35,7 +35,7 @@ class DomainVersionTest < ActiveSupport::TestCase
tech_contacts: [],
registrant: [] })
- assert_not DomainVersion.was_contact_linked?(@contact.id)
+ assert_not Version::DomainVersion.was_contact_linked?(@contact.id)
end
def test_contact_unlinked_more_than_returns_true_when_contact_was_linked_as_registrant_more_than_given_period
@@ -45,7 +45,7 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [@contact.id] })
travel_to Time.zone.parse('2010-07-05 00:00:01')
- assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_unlinked_more_than_given_period_as_admin_contact
@@ -55,7 +55,7 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [] })
travel_to Time.zone.parse('2010-07-05 00:00:01')
- assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_unlinked_more_than_given_period_as_tech_contact
@@ -65,7 +65,7 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [] })
travel_to Time.zone.parse('2010-07-05 00:00:01')
- assert DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_linked_within_given_period_as_registrant
@@ -75,7 +75,7 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [@contact.id] })
travel_to Time.zone.parse('2010-07-05')
- assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_linked_within_given_period_as_admin_contact
@@ -85,7 +85,7 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [] })
travel_to Time.zone.parse('2010-07-05')
- assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_linked_within_given_period_as_tech_contact
@@ -95,11 +95,11 @@ class DomainVersionTest < ActiveSupport::TestCase
registrant: [] })
travel_to Time.zone.parse('2010-07-05')
- assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
def test_contact_was_never_linked
- DomainVersion.delete_all
- assert_not DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
+ Version::DomainVersion.delete_all
+ assert_not Version::DomainVersion.contact_unlinked_more_than?(contact_id: @contact.id, period: 1.day)
end
end
diff --git a/test/models/whois/record_test.rb b/test/models/whois/record_test.rb
index d06b23cae..eceba9205 100644
--- a/test/models/whois/record_test.rb
+++ b/test/models/whois/record_test.rb
@@ -15,6 +15,11 @@ class Whois::RecordTest < ActiveSupport::TestCase
Setting.registry_whois_disclaimer = @original_disclaimer
end
+ def test_whois_records_without_auction
+ domain = Whois::Record.without_auctions
+ assert_equal domain[0].name, 'shop.test'
+ end
+
def test_reads_disclaimer_setting
Setting.registry_whois_disclaimer = JSON.generate({en: 'test_disclaimer'})
assert_equal Setting.registry_whois_disclaimer, Whois::Record.disclaimer
diff --git a/test/system/admin_area/contacts_test.rb b/test/system/admin_area/contacts_test.rb
index 19b15c8a5..92b0a064b 100644
--- a/test/system/admin_area/contacts_test.rb
+++ b/test/system/admin_area/contacts_test.rb
@@ -9,7 +9,7 @@ class AdminContactsTest < ApplicationSystemTestCase
end
def test_update_contact
- visit admin_contact_path(id: @contact.id)
+ visit admin_contact_path(@contact.id)
assert_text "#{@contact.name}"
click_on 'Edit statuses'
diff --git a/test/system/admin_area/domain_versions_test.rb b/test/system/admin_area/domain_versions_test.rb
index 8ff90a562..833398c61 100644
--- a/test/system/admin_area/domain_versions_test.rb
+++ b/test/system/admin_area/domain_versions_test.rb
@@ -5,6 +5,7 @@ class DomainVersionsTest < ApplicationSystemTestCase
super
@registrar = registrars(:bestnames)
+ @domain = domains(:shop)
create_domain_with_history
sign_in users(:admin)
@@ -59,4 +60,35 @@ class DomainVersionsTest < ApplicationSystemTestCase
assert_text 'Best Names'
assert_text '23.04.18, 18:50 update 1-AdminUser'
end
+
+ def test_search_registrant_param
+ visit admin_domain_versions_path
+ fill_in 'Registrant', with: @domain.registrant, match: :first
+ find('.btn.btn-primary').click
+
+ assert_equal current_url,
+ 'http://www.example.com/admin/domain_versions?q[name]=&q[registrant]=John&q[registrar]=&q[event]=&results_per_page='
+ end
+
+ def test_search_registrar_param
+ visit admin_domain_versions_path
+ find('#q_registrar').set(@domain.registrar)
+ find('.btn.btn-primary').click
+
+ assert_equal current_url,
+ 'http://www.example.com/admin/domain_versions?q[name]=&q[registrant]=&q[registrar]=Best+Names&q[event]=&results_per_page='
+ end
+
+ def test_search_name_param
+ visit admin_domain_versions_path
+ fill_in 'Name', with: @domain.name, match: :first
+ find('.btn.btn-primary').click
+
+ assert_equal current_url,
+ 'http://www.example.com/admin/domain_versions?q[name]=shop.test&q[registrant]=&q[registrar]=&q[event]=&results_per_page='
+ end
+
+ def test_search_event_param
+ # TODO
+ end
end
diff --git a/test/system/registrant_area/contacts/details_test.rb b/test/system/registrant_area/contacts/details_test.rb
deleted file mode 100644
index bf96046a6..000000000
--- a/test/system/registrant_area/contacts/details_test.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase
- setup do
- sign_in users(:registrant)
- @domain = domains(:shop)
- @contact = contacts(:john)
- end
-
- def test_general_data
- visit registrant_domain_contact_url(@domain, @contact)
- assert_text 'Code john-001'
- assert_text 'Name John'
-
- assert_text 'Auth info'
- assert_css('[value="cacb5b"]')
-
- assert_text 'Ident 1234'
- assert_text 'Email john@inbox.test'
- assert_text 'Phone +555.555'
-
- assert_text "Created at #{l Time.zone.parse('2010-07-05')}"
- assert_text "Updated at #{l Time.zone.parse('2010-07-06')}"
- end
-
- def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user
- suppress(ActiveRecord::RecordNotFound) do
- visit registrant_domain_contact_url(domains(:metro), @contact)
- assert_response :not_found
- assert_no_text 'Name John'
- end
- end
-end
diff --git a/test/system/registrant_area/contacts/update_test.rb b/test/system/registrant_area/contacts/update_test.rb
deleted file mode 100644
index 07115579b..000000000
--- a/test/system/registrant_area/contacts/update_test.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantAreaContactUpdateTest < ApplicationIntegrationTest
- setup do
- @domain = domains(:shop)
- @contact = contacts(:john)
- sign_in users(:registrant)
-
- @original_address_processing = Setting.address_processing
- @original_fax_enabled_setting = ENV['fax_enabled']
- @original_registrant_api_base_url_setting = ENV['registrant_api_base_url']
-
- ENV['registrant_api_base_url'] = 'https://api.test'
- end
-
- teardown do
- Setting.address_processing = @original_address_processing
- ENV['fax_enabled'] = @original_fax_enabled_setting
- ENV['registrant_api_base_url'] = @original_registrant_api_base_url_setting
- end
-
- def test_form_is_pre_populated_with_contact_data
- visit edit_registrant_domain_contact_url(@domain, @contact)
-
- assert_field 'Name', with: 'John'
- assert_field 'Email', with: 'john@inbox.test'
- assert_field 'Phone', with: '+555.555'
- end
-
- def test_update_contact
- stub_auth_request
-
- request_body = { name: 'new name', email: 'new@inbox.test', phone: '+666.6' }.to_json
- headers = { 'Content-Type' => Mime[:json],
- 'Authorization' => 'Bearer test-access-token' }
- url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
- update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
- .to_return(body: '{}', status: 200)
-
- visit registrant_domain_contact_url(@domain, @contact)
- click_link_or_button 'Edit'
-
- fill_in 'Name', with: 'new name'
- fill_in 'Email', with: 'new@inbox.test'
- fill_in 'Phone', with: '+666.6'
-
- click_link_or_button 'Update contact'
-
- assert_requested update_request_stub
- assert_current_path registrant_domain_contact_path(@domain, @contact)
- assert_text 'Contact has been successfully updated'
- end
-
- def test_form_is_pre_populated_with_fax_when_enabled
- ENV['fax_enabled'] = 'true'
- @contact.update!(fax: '+111.1')
-
- visit edit_registrant_domain_contact_url(@domain, @contact)
- assert_field 'Fax', with: '+111.1'
- end
-
- def test_update_fax_when_enabled
- ENV['fax_enabled'] = 'true'
- stub_auth_request
-
- request_body = { email: 'john@inbox.test', name: 'John', phone: '+555.555', fax: '+222.2' }
- headers = { 'Authorization' => 'Bearer test-access-token' }
- url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
- update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
- .to_return(body: '{}', status: 200)
-
- visit edit_registrant_domain_contact_url(@domain, @contact)
-
- fill_in 'Fax', with: '+222.2'
- click_link_or_button 'Update contact'
-
- assert_requested update_request_stub
- assert_current_path registrant_domain_contact_path(@domain, @contact)
- assert_text 'Contact has been successfully updated'
- end
-
- def test_hide_fax_field_when_disabled
- visit edit_registrant_domain_contact_url(@domain, @contact)
- assert_no_field 'Fax'
- end
-
- def test_form_is_pre_populated_with_address_when_enabled
- Setting.address_processing = true
- @contact.update!(street: 'Main Street',
- zip: '12345',
- city: 'New York',
- state: 'New York State',
- country_code: 'US')
-
- visit edit_registrant_domain_contact_url(@domain, @contact)
-
- assert_field 'Street', with: 'Main Street'
- assert_field 'Zip', with: '12345'
- assert_field 'City', with: 'New York'
- assert_field 'State', with: 'New York State'
- assert_select 'Country', selected: 'United States'
- end
-
- def test_update_address_when_enabled
- Setting.address_processing = true
- stub_auth_request
-
- request_body = { name: 'John',
- email: 'john@inbox.test',
- phone: '+555.555',
- address: {
- city: 'new city',
- street: 'new street',
- zip: '93742',
- country_code: 'AT',
- state: 'new state',
- } }.to_json
- headers = { 'Content-type' => Mime[:json],
- 'Authorization' => 'Bearer test-access-token' }
- url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
- update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
- .to_return(body: '{}', status: 200)
-
- visit edit_registrant_domain_contact_url(@domain, @contact)
-
- fill_in 'Street', with: 'new street'
- fill_in 'City', with: 'new city'
- fill_in 'State', with: 'new state'
- fill_in 'Zip', with: '93742'
- select 'Austria', from: 'Country'
- click_link_or_button 'Update contact'
-
- assert_requested update_request_stub
- assert_current_path registrant_domain_contact_path(@domain, @contact)
- assert_text 'Contact has been successfully updated'
- end
-
- def test_hide_address_field_when_disabled
- visit edit_registrant_domain_contact_url(@domain, @contact)
- assert_no_field 'Address'
- assert_no_field 'Street'
- end
-
- def test_fail_gracefully
- stub_auth_request
-
- response_body = { errors: { name: ['Name is invalid'] } }.to_json
- headers = { 'Authorization' => 'Bearer test-access-token' }
- stub_request(:patch, "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}")
- .with(headers: headers)
- .to_return(body: response_body, status: 400)
-
- visit edit_registrant_domain_contact_url(@domain, @contact)
- fill_in 'Name', with: 'invalid name'
- click_link_or_button 'Update contact'
-
- assert_current_path registrant_domain_contact_path(@domain, @contact)
- assert_text 'Name is invalid'
- assert_field 'Name', with: 'invalid name'
- assert_no_text 'Contact has been successfully updated'
- end
-
- private
-
- def stub_auth_request
- body = { ident: '1234', first_name: 'Registrant', last_name: 'User' }
- stub_request(:post, 'https://api.test/api/v1/registrant/auth/eid').with(body: body)
- .to_return(body: { access_token: 'test-access-token' }.to_json,
- headers: { 'Content-type' => Mime[:json] },
- status: 200)
- end
-end
diff --git a/test/system/registrant_area/domains/details_test.rb b/test/system/registrant_area/domains/details_test.rb
deleted file mode 100644
index 2f61d46be..000000000
--- a/test/system/registrant_area/domains/details_test.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
- setup do
- sign_in users(:registrant)
- @domain = domains(:shop)
- end
-
- def test_general_data
- @domain.update_columns(force_delete_date: '2010-07-08', statuses: [DomainStatus::FORCE_DELETE])
-
- visit registrant_domain_url(@domain)
-
- assert_text 'Name shop.test'
- assert_text "Registered at #{l @domain.registered_at}"
- assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
-
- assert_text 'Transfer code'
- assert_css('[value="65078d5"]')
-
- assert_text "Valid to #{l Time.zone.parse('2010-07-05')}"
- assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}"
- assert_text "Delete date #{l Date.parse('2010-07-07')}"
- assert_text "Force delete date #{l Date.parse('2010-07-08')}"
- end
-
- def test_registrant
- visit registrant_domain_url(@domain)
- assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
- assert_text 'Code john-001'
- assert_text 'Ident 1234'
- assert_text 'Email john@inbox.test'
- assert_text 'Phone +555.555'
- end
-
- def test_admin_contacts
- visit registrant_domain_url(@domain)
-
- within('.admin-domain-contacts') do
- assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane))
- assert_text 'jane-001'
- assert_text 'jane@mail.test'
- assert_css '.admin-domain-contact', count: 1
- end
- end
-
- def test_tech_contacts
- visit registrant_domain_url(@domain)
-
- within('.tech-domain-contacts') do
- assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william))
- assert_text 'william-001'
- assert_text 'william@inbox.test'
- assert_css '.tech-domain-contact', count: 2
- end
- end
-
- def test_registrant_user_cannot_access_domains_of_other_users
- suppress(ActiveRecord::RecordNotFound) do
- visit registrant_domain_url(domains(:metro))
- assert_response :not_found
- assert_no_text 'metro.test'
- end
- end
-
- def test_confirmation_url
- @domain.update!(registrant_verification_token: 'a01',
- pending_json: { new_registrant_email: 'any' },
- statuses: [DomainStatus::PENDING_UPDATE])
-
- visit registrant_domain_url(@domain)
- click_on 'pendingUpdate'
-
- assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01')
- end
-end
diff --git a/test/system/registrant_area/domains/domain_delete_confirms_test.rb b/test/system/registrant_area/domains/domain_delete_confirms_test.rb
deleted file mode 100644
index 765cd0149..000000000
--- a/test/system/registrant_area/domains/domain_delete_confirms_test.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'application_system_test_case'
-
-class DomainDeleteConfirmsTest < ApplicationSystemTestCase
- include ActionMailer::TestHelper
- setup do
- @user = users(:registrant)
- sign_in @user
-
- @domain = domains(:shop)
- @domain.registrant_verification_asked!('\n ', @user.id)
- @domain.pending_delete!
- end
-
- def test_enqueues_approve_job_after_verification
- visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
-
- perform_enqueued_jobs do
- click_on 'Confirm domain delete'
- end
- assert_text 'Domain registrant change has successfully received.'
-
- @domain.reload
- assert_includes @domain.statuses, 'serverHold'
- end
-
- def test_enqueues_reject_job_after_verification
- visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
-
- perform_enqueued_jobs do
- click_on 'Reject domain delete'
- end
- assert_text 'Domain registrant change has been rejected successfully.'
-
- @domain.reload
- assert_equal ['ok'], @domain.statuses
- end
-
- def test_saves_whodunnit_info_after_verifivation
- visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
- token = @domain.registrant_verification_token
- click_on 'Confirm domain delete'
- assert_text 'Domain registrant change has successfully received.'
-
- refute RegistrantVerification.find_by(verification_token:token).updator_str.empty?
- end
-end
diff --git a/test/system/registrant_area/domains/list_test.rb b/test/system/registrant_area/domains/list_test.rb
deleted file mode 100644
index 3cbf477da..000000000
--- a/test/system/registrant_area/domains/list_test.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require 'application_system_test_case'
-
-CompanyRegisterClientStub = Struct.new(:any_method) do
- def representation_rights(citizen_personal_code:, citizen_country_code:)
- raise CompanyRegister::NotAvailableError
- end
-end
-
-class RegistrantAreaDomainListTest < ApplicationSystemTestCase
- setup do
- @user = users(:registrant)
- sign_in @user
-
- @domain = domains(:shop)
- end
-
- def test_show_domain_list
- visit registrant_domains_url
- assert_link 'shop.test', href: registrant_domain_path(@domain)
- assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
- assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
- assert_text l(Time.zone.parse('2010-07-05'))
- assert_css '.domains .domain', count: 4
- end
-
- def test_do_not_show_domains_of_other_registrant_users
- visit registrant_domains_url
- assert_no_text 'metro.test'
- end
-
- def test_only_shows_direct_relation_and_or_company_domains
- # case https://github.com/internetee/registry/issues/1690
- tech_contact = contacts(:registrar_ltd)
-
- # All domains share the same tech contact object
- Domain.all.each do |domain|
- DomainContact.create(domain: domain, contact: tech_contact, type: TechDomainContact)
- end
-
- visit registrant_domains_url
- assert_no_text 'Company register is unavailable.'
- assert_no_text 'metro.test'
- end
-
- def test_notification_when_company_register_is_unavailable
- CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
- visit registrant_domains_url
- end
-
- assert_text 'Company register is unavailable. Domains and contacts associated via' \
- ' organizations are not shown.'
- end
-
- def test_show_direct_domains_when_company_register_is_unavailable
- assert_equal 'US-1234', @user.registrant_ident
-
- contact = contacts(:john)
- assert_equal '1234', contact.ident
- assert_equal Contact::PRIV, contact.ident_type
- assert_equal 'US', contact.ident_country_code
-
- assert_equal contact.becomes(Registrant), @domain.registrant
- assert_equal 'shop.test', @domain.name
-
- CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
- visit registrant_domains_url
- end
-
- assert_text 'shop.test'
- end
-end
diff --git a/test/system/registrant_area/domains_test.rb b/test/system/registrant_area/domains_test.rb
deleted file mode 100644
index fa151c89e..000000000
--- a/test/system/registrant_area/domains_test.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantDomainsTest < ApplicationSystemTestCase
- setup do
- sign_in users(:registrant)
- end
-
- def test_shows_domains_where_current_user_is_registrant
- visit registrant_domains_url
- assert_text 'shop.test'
- end
-
- def test_shows_domains_where_current_user_is_contact_person
- visit registrant_domains_url
- assert_text 'airport.test'
- end
-
- def test_shows_domains_where_current_user_has_associated_organizations
- visit registrant_domains_url
- assert_text 'library.test'
- end
-end
diff --git a/test/system/registrant_area/layout_test.rb b/test/system/registrant_area/layout_test.rb
deleted file mode 100644
index 9df8028e3..000000000
--- a/test/system/registrant_area/layout_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantLayoutTest < ApplicationSystemTestCase
- def setup
- super
- sign_in(users(:registrant))
- end
-
- def test_has_link_to_rest_whois_and_internet_ee
- visit registrant_domains_url
-
- assert(has_link?('Internet.ee', href: 'https://internet.ee'))
- assert(has_link?('WHOIS', href: 'https://whois.internet.ee'))
- end
-end
diff --git a/test/system/registrant_area/tara/tara_users_test.rb b/test/system/registrant_area/tara/tara_users_test.rb
deleted file mode 100644
index 5020616d4..000000000
--- a/test/system/registrant_area/tara/tara_users_test.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrantAreaTaraUsersTest < ApplicationSystemTestCase
- def setup
- super
-
- OmniAuth.config.test_mode = true
- @registrant = users(:registrant)
-
- @existing_user_hash = {
- 'provider' => 'rant_tara',
- 'uid' => "US1234",
- 'info': { 'first_name': 'Registrant', 'last_name': 'User' }
- }
-
- @new_user_hash = {
- 'provider' => 'rant_tara',
- 'uid' => 'EE51007050604',
- 'info': { 'first_name': 'New Registrant', 'last_name': 'User'}
- }
- end
-
- def teardown
- super
-
- OmniAuth.config.test_mode = false
- OmniAuth.config.mock_auth['rant_tara'] = nil
- end
-
- def test_existing_user_gets_signed_in
- OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@existing_user_hash)
-
- visit new_registrant_user_session_path
- click_link('Sign in')
-
- assert_text('Signed in successfully')
- end
-
- def test_new_user_is_created_and_signed_in
- OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@new_user_hash)
-
- assert_difference 'RegistrantUser.count' do
- visit new_registrant_user_session_path
- click_link('Sign in')
-
- assert_equal 'New Registrant User', RegistrantUser.last.username
- assert_equal 'EE-51007050604', RegistrantUser.last.registrant_ident
- assert_text('Signed in successfully')
- end
- end
-end
diff --git a/test/system/registrar_area/tara/tara_users_test.rb b/test/system/registrar_area/tara/tara_users_test.rb
index a2defd715..005504043 100644
--- a/test/system/registrar_area/tara/tara_users_test.rb
+++ b/test/system/registrar_area/tara/tara_users_test.rb
@@ -34,6 +34,18 @@ class TaraUsersTest < ApplicationSystemTestCase
assert_text('Signed in successfully')
end
+ def test_existing_user_logs_in_without_cookie_overflow
+ @existing_user_hash['credentials'] = massive_hash
+ OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@existing_user_hash)
+
+ visit new_registrar_user_session_path
+ assert_nothing_raised do
+ click_link('Sign in')
+ end
+
+ assert_text('Signed in successfully')
+ end
+
def test_nonexisting_user_gets_error_message
OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@new_user_hash)
@@ -42,4 +54,10 @@ class TaraUsersTest < ApplicationSystemTestCase
assert_text('No such user')
end
+
+ def massive_hash
+ o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
+ string = (0...5000).map { o[rand(o.length)] }.join
+ {"access_token":"AT-540-Fj5gbPvJp4jPkO-4EdgzIhIhhJapoRTM","token_type":"bearer","expires_in":600,"id_token":string}
+ end
end
diff --git a/test/tasks/contacts/archive_test.rb b/test/tasks/contacts/archive_test.rb
index eebfa7b68..f5ecff092 100644
--- a/test/tasks/contacts/archive_test.rb
+++ b/test/tasks/contacts/archive_test.rb
@@ -14,7 +14,7 @@ class ArchiveContactsTaskTest < ActiveSupport::TestCase
def archivable_contact
contact = contacts(:john)
Setting.orphans_contacts_in_months = 0
- DomainVersion.delete_all
+ Version::DomainVersion.delete_all
other_contact = contacts(:william)
assert_not_equal other_contact, contact
diff --git a/test/test_helper.rb b/test/test_helper.rb
index a1634f717..fe20f7a6e 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -42,7 +42,7 @@ EInvoice.provider = EInvoice::Providers::TestProvider.new
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
- set_fixture_class log_domains: DomainVersion
+ set_fixture_class log_domains: Version::DomainVersion
teardown do
travel_back