diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml
index f4498f4da..c742e2da1 100644
--- a/.github/workflows/ruby.yml
+++ b/.github/workflows/ruby.yml
@@ -79,7 +79,7 @@ jobs:
- name: Save coverage
run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json
- - uses: actions/upload-artifact@v3.1.0
+ - uses: actions/upload-artifact@v3.1.1
with:
name: coverage-${{ matrix.ruby }}
path: coverage/codeclimate.${{ matrix.ruby }}.json
@@ -104,7 +104,7 @@ jobs:
- name: Give test coverage reporter executable permissions
run: chmod +x cc-test-reporter
- - uses: actions/download-artifact@v3.0.0
+ - uses: actions/download-artifact@v3.0.1
with:
name: coverage-${{ matrix.ruby }}
path: coverage
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a9b96159e..207b0a08c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,86 @@
+01.12.2022
+* Fixed empty validation result reason in the logs https://github.com/internetee/registry/issues/2490
+* Reduced unnecessary logging from email validation logs https://github.com/internetee/registry/issues/2491
+
+30.11.2022
+* Validator for incoming disclosed attributes https://github.com/internetee/registry/issues/2486
+* Endpoint for registrar xml console feature https://github.com/internetee/registry/pull/2483
+
+29.11.2022
+* Fixed pantom statuse issue in REPP https://github.com/internetee/registry/issues/2470
+
+24.11.2022
+* Overwrite feature to SendMonthlyInvoicesJob https://github.com/internetee/registry/pull/2485
+
+23.11.2022
+* outzone rake task for invalid email domains by @OlegPhenomenon in https://github.com/internetee/registry/pull/2437
+* Update dependency paper_trail to v13 by @renovate in https://github.com/internetee/registry/pull/2419
+* Bump omniauth from 1.9.1 to 1.9.2 by @dependabot in https://github.com/internetee/registry/pull/2429
+* Update dependency pdfkit to v0.8.7.2 [SECURITY] by @renovate in https://github.com/internetee/registry/pull/2472
+* Bump google-protobuf from 3.19.4 to 3.21.9 by @dependabot in https://github.com/internetee/registry/pull/2477
+* Fix domain contacts repp by @maricavor in https://github.com/internetee/registry/pull/2475
+* Update dependency pg to v1.4.5 by @renovate in https://github.com/internetee/registry/pull/2481
+* Fixed dates for yearly domains in monthly invoices by @maricavor in https://github.com/internetee/registry/pull/2482
+
+02.11.2022
+* outzone rake task for invalid email domains by @OlegPhenomenon in https://github.com/internetee/registry/pull/2437
+
+28.10.2022
+* Add request throttling by @yulgolem in https://github.com/internetee/registry/pull/2028
+
+26.10.2022
+* Update actions/download-artifact action to v3.0.1 by @renovate in https://github.com/internetee/registry/pull/2464
+* Update actions/upload-artifact action to v3.1.1 by @renovate in https://github.com/internetee/registry/pull/2465
+* assign the limit of validation records by @OlegPhenomenon in https://github.com/internetee/registry/pull/2466
+
+20.10.2022
+* added exception for auctions with no-bids and registred-domains statuses by @OlegPhenomenon in https://github.com/internetee/registry/pull/2403
+* assign auction type for nil value rake task by @OlegPhenomenon in https://github.com/internetee/registry/pull/2404
+
+17.10.2022
+* Remove registrar portal by @thiagoyoussef in https://github.com/internetee/registry/pull/2434
+* Update dependency pg to v1.4.4 by @renovate in https://github.com/internetee/registry/pull/2459
+* fix check force delete lift poll messages by @thiagoyoussef in https://github.com/internetee/registry/pull/2461
+
+12.10.2022
+* Created regex only email validation domain list by @maricavor in https://github.com/internetee/registry/pull/2401
+* Fix check force delete lift bug by @thiagoyoussef in https://github.com/internetee/registry/pull/2418
+* Refactored monthly invoice generation job by @maricavor in https://github.com/internetee/registry/pull/2456
+
+07.10.2022
+* Enable trimming for dnskey and email values by @thiagoyoussef in https://github.com/internetee/registry/pull/2453
+
+06.10.2022
+* Update dependency pdfkit to v0.8.7 [SECURITY] by @renovate in https://github.com/internetee/registry/pull/2452
+* Admin: option to delete auction record by @thiagoyoussef in https://github.com/internetee/registry/pull/2449
+* Add monthly invoice email description by @thiagoyoussef in https://github.com/internetee/registry/pull/2442
+
+03.10.2022
+* fixed zeitwerk load file issue by @OlegPhenomenon in https://github.com/internetee/registry/pull/2448
+* added sidekiq link to admin view by @OlegPhenomenon in https://github.com/internetee/registry/pull/2447
+* protected public method account activity create by @OlegPhenomenon in https://github.com/internetee/registry/pull/2443
+
+29.09.2022
+* Update dependency haml to v6 by @renovate in https://github.com/internetee/registry/pull/2444
+* added endpoints to demo registry for accr results by @OlegPhenomenon in https://github.com/internetee/registry/pull/2237
+* Refactor: remove legacy que by @thiagoyoussef in https://github.com/internetee/registry/pull/2337
+* fixed type of auction for next rounds by @OlegPhenomenon in https://github.com/internetee/registry/pull/2393
+* Admin: download pdf with domain data on show by @thiagoyoussef in https://github.com/internetee/registry/pull/2396
+* Increase notification text field length on database by @thiagoyoussef in https://github.com/internetee/registry/pull/2397
+
+20.09.2022
+* Created market share chart data endpoint by @maricavor in https://github.com/internetee/registry/pull/2426
+
+16.09.2022
+* Removed 200 limit of records if nil by @maricavor in https://github.com/internetee/registry/pull/2440
+* fixed legal doc issue output by @OlegPhenomenon in https://github.com/internetee/registry/pull/2410
+* extended csv domain export by @OlegPhenomenon in https://github.com/internetee/registry/pull/2407
+* remove fixed top registrar navbar css class by @OlegPhenomenon in https://github.com/internetee/registry/pull/2406
+
+13.09.2022
+* Ignore statuses update if invoice already paid by @OlegPhenomenon in https://github.com/internetee/registry/pull/2438
+* remove eis-billing feature toggle by @OlegPhenomenon in https://github.com/internetee/registry/pull/2433
+
08.09.2022
* Fixed template error for multi-year registered domains in force delete process [#2435](https://github.com/internetee/registry/issues/2435)
diff --git a/Gemfile b/Gemfile
index 4ba187b94..df067a040 100644
--- a/Gemfile
+++ b/Gemfile
@@ -16,8 +16,8 @@ gem 'uglifier'
gem 'figaro', '~> 1.2'
# model related
-gem 'paper_trail', '~> 12.1'
-gem 'pg', '1.4.3'
+gem 'paper_trail', '~> 13.0'
+gem 'pg', '1.4.5'
# 1.8 is for Rails < 5.0
gem 'ransack', '~> 2.6.0'
gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
@@ -30,13 +30,12 @@ gem 'nokogiri', '~> 1.13.0'
# style
gem 'bootstrap-sass', '~> 3.4'
gem 'cancancan'
-gem 'coderay', '1.1.3' # xml console visualize
gem 'coffee-rails', '>= 5.0'
gem 'devise', '~> 4.8'
gem 'jquery-rails'
gem 'kaminari'
gem 'sass-rails'
-gem 'select2-rails', '4.0.13' # for autocomplete
+gem 'select2-rails', '4.0.13' # for autocomplete
gem 'selectize-rails', '0.12.6' # include selectize.js for select
# registry specfic
@@ -48,7 +47,7 @@ gem 'simpleidn', '0.2.1' # For punycode
gem 'whenever', '1.0.0', require: false
# country listing
-gem 'countries', :require => 'countries/global'
+gem 'countries', require: 'countries/global'
# id + mid login
# gem 'digidoc_client', '0.3.0'
@@ -77,7 +76,6 @@ gem 'lhv', github: 'internetee/lhv', branch: 'master'
gem 'rexml'
gem 'wkhtmltopdf-binary', '~> 0.12.5.1'
-
gem 'directo', github: 'internetee/directo', branch: 'master'
group :development, :test do
@@ -95,12 +93,12 @@ group :test do
end
gem 'aws-sdk-sesv2', '~> 1.19'
+gem 'newrelic-infinite_tracing'
+gem 'newrelic_rpm'
# profiles
gem 'pghero'
gem 'pg_query', '>= 0.9.0'
-gem 'newrelic_rpm'
-gem 'newrelic-infinite_tracing'
# token
gem 'jwt'
diff --git a/Gemfile.lock b/Gemfile.lock
index f1908d37c..9b8646c7d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -55,11 +55,11 @@ GIT
GIT
remote: https://github.com/internetee/omniauth-tara.git
- revision: cec845ec3794532144c4976104a07e206d759aa6
+ revision: 215f5e91b8c1a51b2fe9a72755585096252a2f93
specs:
- omniauth-tara (0.3.0)
+ omniauth-tara (0.4.0)
addressable (~> 2.5)
- omniauth (~> 1.3)
+ omniauth (>= 1.9, < 3)
openid_connect (~> 1.1)
GIT
@@ -139,8 +139,8 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
- addressable (2.8.0)
- public_suffix (>= 2.0.2, < 5.0)
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
airbrake (11.0.3)
airbrake-ruby (~> 5.1)
@@ -168,7 +168,7 @@ GEM
aws-sigv4 (1.2.4)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16)
- bindata (2.4.10)
+ bindata (2.4.14)
bootsnap (1.9.3)
msgpack (~> 1.0)
bootstrap-sass (3.4.1)
@@ -224,13 +224,19 @@ GEM
unf (>= 0.0.5, < 1.0.0)
erubi (1.10.0)
execjs (2.7.0)
+ faraday (2.6.0)
+ faraday-net_http (>= 2.0, < 3.1)
+ ruby2_keywords (>= 0.0.4)
+ faraday-follow_redirects (0.3.0)
+ faraday (>= 1, < 3)
+ faraday-net_http (3.0.1)
ffi (1.15.0)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
globalid (0.5.2)
activesupport (>= 5.0)
- google-protobuf (3.19.4)
- google-protobuf (3.19.4-x86_64-linux)
+ google-protobuf (3.21.9)
+ google-protobuf (3.21.9-x86_64-linux)
googleapis-common-protos-types (1.3.0)
google-protobuf (~> 3.14)
grpc (1.41.1)
@@ -246,7 +252,7 @@ GEM
thor
tilt
hashdiff (1.0.1)
- hashie (4.1.0)
+ hashie (5.0.0)
hpricot (0.8.6)
http-accept (1.7.0)
http-cookie (1.0.3)
@@ -268,10 +274,12 @@ GEM
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.5.1)
- json-jwt (1.13.0)
+ json-jwt (1.16.1)
activesupport (>= 4.2)
aes_key_wrap
bindata
+ faraday (~> 2.0)
+ faraday-follow_redirects
jwt (2.3.0)
kaminari (1.2.1)
activesupport (>= 4.1.0)
@@ -300,9 +308,9 @@ GEM
mimemagic (0.4.3)
nokogiri (~> 1)
rake
- mini_mime (1.1.1)
+ mini_mime (1.1.2)
mini_portile2 (2.8.0)
- minitest (5.15.0)
+ minitest (5.16.3)
monetize (1.9.4)
money (~> 6.12)
money (6.13.8)
@@ -313,40 +321,46 @@ GEM
money (~> 6.13.2)
railties (>= 3.0)
msgpack (1.4.2)
+ net-protocol (0.1.3)
+ timeout
+ net-smtp (0.3.3)
+ net-protocol
netrc (0.11.0)
newrelic-infinite_tracing (8.1.0)
grpc (~> 1.34)
newrelic_rpm (= 8.1.0)
newrelic_rpm (8.1.0)
nio4r (2.5.8)
- nokogiri (1.13.6)
+ nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
- nokogiri (1.13.6-x86_64-linux)
+ nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
nori (2.6.0)
- omniauth (1.9.1)
+ omniauth (2.1.0)
hashie (>= 3.4.6)
- rack (>= 1.6.2, < 3)
+ rack (>= 2.2.3)
+ rack-protection
omniauth-rails_csrf_protection (0.1.2)
actionpack (>= 4.2)
omniauth (>= 1.3.1)
- openid_connect (1.3.0)
+ openid_connect (1.4.2)
activemodel
attr_required (>= 1.0.0)
- json-jwt (>= 1.5.0)
- rack-oauth2 (>= 1.6.1)
- swd (>= 1.0.0)
+ json-jwt (>= 1.15.0)
+ net-smtp
+ rack-oauth2 (~> 1.21)
+ swd (~> 1.3)
tzinfo
validate_email
validate_url
- webfinger (>= 1.0.1)
+ webfinger (~> 1.2)
orm_adapter (0.5.0)
- paper_trail (12.1.0)
+ paper_trail (13.0.0)
activerecord (>= 5.2)
request_store (~> 1.1)
- pdfkit (0.8.7)
- pg (1.4.3)
+ pdfkit (0.8.7.2)
+ pg (1.4.5)
pg_query (2.1.2)
google-protobuf (>= 3.17.1)
pghero (2.8.1)
@@ -354,17 +368,19 @@ GEM
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
- public_suffix (4.0.6)
+ public_suffix (5.0.0)
puma (5.6.4)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.4)
- rack-oauth2 (1.16.0)
+ rack-oauth2 (1.21.3)
activesupport
attr_required
httpclient
json-jwt (>= 1.11.0)
rack (>= 2.1.0)
+ rack-protection (3.0.2)
+ rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.4.1)
@@ -401,7 +417,7 @@ GEM
rbtree3 (0.6.0)
redis (4.6.0)
regexp_parser (2.1.1)
- request_store (1.5.0)
+ request_store (1.5.1)
rack (>= 1.4)
responders (3.0.1)
actionpack (>= 5.0)
@@ -412,6 +428,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
+ ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
@@ -464,9 +481,10 @@ GEM
temple (0.8.2)
thor (1.2.1)
tilt (2.0.11)
+ timeout (0.3.0)
truemail (2.4.9)
simpleidn (~> 0.2.1)
- tzinfo (2.0.4)
+ tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
@@ -506,7 +524,7 @@ GEM
wkhtmltopdf-binary (0.12.5.4)
xpath (3.2.0)
nokogiri (~> 1.8)
- zeitwerk (2.5.4)
+ zeitwerk (2.6.6)
PLATFORMS
ruby
@@ -521,7 +539,6 @@ DEPENDENCIES
bootstrap-sass (~> 3.4)
cancancan
capybara
- coderay (= 1.1.3)
coffee-rails (>= 5.0)
company_register!
countries
@@ -553,9 +570,9 @@ DEPENDENCIES
nokogiri (~> 1.13.0)
omniauth-rails_csrf_protection
omniauth-tara!
- paper_trail (~> 12.1)
+ paper_trail (~> 13.0)
pdfkit
- pg (= 1.4.3)
+ pg (= 1.4.5)
pg_query (>= 0.9.0)
pghero
pry (= 0.14.1)
@@ -580,4 +597,4 @@ DEPENDENCIES
wkhtmltopdf-binary (~> 0.12.5.1)
BUNDLED WITH
- 2.3.21
+ 2.3.25
diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb
index 05bfc239f..645b9e0ee 100644
--- a/app/controllers/admin/auctions_controller.rb
+++ b/app/controllers/admin/auctions_controller.rb
@@ -31,7 +31,7 @@ module Admin
def create
auction = Auction.new(domain: params[:domain], status: Auction.statuses[:started], platform: 'manual')
- if domain_exists_in_blocked_disputed_and_registered?(params[:domain])
+ if Auction.domain_exists_in_blocked_disputed_and_registered?(params[:domain])
flash[:alert] = "Adding #{params[:domain]} failed - domain registered or regsitration is blocked"
redirect_to admin_auctions_path and return
end
@@ -81,7 +81,7 @@ module Admin
table.each do |row|
record = row.to_h
- if domain_exists_in_blocked_disputed_and_registered?(record['name'])
+ if Auction.domain_exists_in_blocked_disputed_and_registered?(record['name'])
failed_names << record['name']
next
@@ -119,13 +119,6 @@ module Admin
Epp::Domain.check_availability(domain_name)
end
- def domain_exists_in_blocked_disputed_and_registered?(domain_name)
- Domain.exists?(name: domain_name) ||
- BlockedDomain.exists?(name: domain_name) ||
- Dispute.exists?(domain_name: domain_name) ||
- Auction.exists?(domain: domain_name)
- end
-
def validate_table(table)
first_row = table.headers
first_row.include? 'name'
diff --git a/app/controllers/api/v1/contact_requests_controller.rb b/app/controllers/api/v1/contact_requests_controller.rb
index 1ef73e9ef..51c967bd5 100644
--- a/app/controllers/api/v1/contact_requests_controller.rb
+++ b/app/controllers/api/v1/contact_requests_controller.rb
@@ -3,7 +3,6 @@ module Api
class ContactRequestsController < BaseController
before_action :authenticate_shared_key
- # POST api/v1/contact_requests/
def create
return head(:bad_request) if contact_request_params[:email].blank?
@@ -19,6 +18,8 @@ module Api
process_id(params[:id])
end
+ private
+
def process_id(id)
record = ContactRequest.find_by(id: id)
return :not_found unless record
diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb
index b196c567a..47e036534 100644
--- a/app/controllers/api/v1/registrant/contacts_controller.rb
+++ b/app/controllers/api/v1/registrant/contacts_controller.rb
@@ -46,63 +46,36 @@ module Api
end
def update
- logger.debug 'Received update request'
- logger.debug params
- contact = current_user_contacts.find_by!(uuid: params[:uuid])
- contact.name = params[:name] if params[:name].present?
- contact.email = params[:email] if params[:email].present?
- contact.phone = params[:phone] if params[:phone].present?
+ contact = find_contact_and_update_credentials(params[:uuid], params[:name], params[:email], params[:phone])
+ reparsed_request = reparsed_request(request.body.string)
+ disclosed_attributes = reparsed_request[:disclosed_attributes]
- # Needed to support passing empty array, which otherwise gets parsed to nil
- # https://github.com/rails/rails/pull/13157
- reparsed_request_json = ActiveSupport::JSON.decode(request.body.string)
- .with_indifferent_access
- logger.debug 'Reparsed request is following'
- logger.debug reparsed_request_json.to_s
- disclosed_attributes = reparsed_request_json[:disclosed_attributes]
-
- if disclosed_attributes
- if disclosed_attributes.present? && contact.org?
- error_msg = "Legal person's data is visible by default and cannot be concealed." \
- ' Please remove this parameter.'
- render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
- return
- end
-
- contact.disclosed_attributes = disclosed_attributes
+ if disclosed_attributes.present?
+ extra_attrs = disclosed_attributes - Contact::DISCLOSE_ATTRIBUTES
+ attributes_not_exist_error(extra_attrs) and return if extra_attrs.present?
end
+ if disclosed_attributes.present? && contact.org?
+ extra_attrs = disclosed_attributes - Contact::OPEN_LEGAL_ATTRIBUTES
+ render_disclosed_attributes_error and return if extra_attrs.present?
+ end
+
+ contact.disclosed_attributes = disclosed_attributes if disclosed_attributes
+ publishable = reparsed_request[:registrant_publishable]
+ contact.registrant_publishable = publishable if publishable.in? [true, false]
+
logger.debug "Setting.address_processing is set to #{Setting.address_processing}"
-
- if Setting.address_processing && params[:address]
- address = Contact::Address.new(params[:address][:street],
- params[:address][:zip],
- params[:address][:city],
- params[:address][:state],
- params[:address][:country_code])
- contact.address = address
- end
-
- if !Setting.address_processing && params[:address]
- error_msg = 'Address processing is disabled and therefore cannot be updated'
- render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return
- end
+ contact.address = parse_address(params[:address]) if Setting.address_processing && params[:address]
+ render_address_error and return if !Setting.address_processing && params[:address]
contact.fax = params[:fax] if ENV['fax_enabled'] == 'true' && params[:fax].present?
logger.debug "ENV['fax_enabled'] is set to #{ENV['fax_enabled']}"
- if ENV['fax_enabled'] != 'true' && params[:fax]
- error_msg = 'Fax processing is disabled and therefore cannot be updated'
- render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return
- end
+ render_fax_error and return if ENV['fax_enabled'] != 'true' && params[:fax]
- contact.transaction do
- contact.save!
- action = current_registrant_user.actions.create!(contact: contact, operation: :update)
- contact.registrar.notify(action)
- end
+ contact = update_and_notify!(contact)
- render json: serialize_contact(contact, false)
+ render json: serialize_contact(contact, true)
end
private
@@ -136,6 +109,64 @@ module Api
def logger
Rails.logger
end
+
+ def render_disclosed_attributes_error
+ error_msg = "Legal person's data is visible by default and cannot be concealed." \
+ ' Please remove this parameter.'
+ render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
+ end
+
+ def parse_address(address)
+ Contact::Address.new(
+ address[:street],
+ address[:zip],
+ address[:city],
+ address[:state],
+ address[:country_code]
+ )
+ end
+
+ def attributes_not_exist_error(extra_attrs)
+ error_msg = "Request contains extra attributes: #{extra_attrs.join(', ')}"
+ render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
+ end
+
+ def render_address_error
+ error_msg = 'Address processing is disabled and therefore cannot be updated'
+ render json: { errors: [{ address: [error_msg] }] }, status: :bad_request
+ end
+
+ def render_fax_error
+ error_msg = 'Fax processing is disabled and therefore cannot be updated'
+ render json: { errors: [{ address: [error_msg] }] }, status: :bad_request
+ end
+
+ def update_and_notify!(contact)
+ contact.transaction do
+ contact.save!
+ action = current_registrant_user.actions.create!(contact: contact, operation: :update)
+ contact.registrar.notify(action)
+ end
+
+ contact
+ end
+
+ def reparsed_request(request_body)
+ reparsed_request = ActiveSupport::JSON.decode(request_body).with_indifferent_access
+ logger.debug 'Reparsed request is following'
+ logger.debug reparsed_request.to_s
+
+ reparsed_request
+ end
+
+ def find_contact_and_update_credentials(uuid, name, email, phone)
+ contact = current_user_contacts.find_by!(uuid: uuid)
+ contact.name = name if name.present?
+ contact.email = email if email.present?
+ contact.phone = phone if phone.present?
+
+ contact
+ end
end
end
end
diff --git a/app/controllers/concerns/epp_requestable.rb b/app/controllers/concerns/epp_requestable.rb
new file mode 100644
index 000000000..d290c8e38
--- /dev/null
+++ b/app/controllers/concerns/epp_requestable.rb
@@ -0,0 +1,63 @@
+module EppRequestable
+ extend ActiveSupport::Concern
+
+ included do
+ # before_action :validate_epp_user, only: :create
+ end
+
+ def create
+ result = server.request(request_params[:payload])
+ render_success(data: { xml: result.force_encoding('UTF-8') })
+ rescue StandardError
+ handle_non_epp_errors(nil, I18n.t('errors.messages.epp_conn_error'))
+ end
+
+ private
+
+ # def validate_epp_user
+ # return unless handle_hello_request
+
+ # handle_login_request
+ # server.close_connection
+ # rescue OpenSSL::SSL::SSLError => e
+ # Rails.logger.error "INVALID CERT: #{e}"
+ # Rails.logger.error "INVALID CERT DEBUG INFO: epp_hostname: #{ENV['epp_hostname']}," \
+ # "port: #{ENV['epp_port']}, cert_path: #{ENV['cert_path']}, key_path: #{ENV['key_path']}"
+ # handle_non_epp_errors(nil, I18n.t('errors.messages.invalid_cert'))
+ # end
+
+ # def handle_hello_request
+ # res = server.open_connection
+ # unless Nokogiri::XML(res).css('greeting')
+ # server.close_connection # just in case
+ # handle_non_epp_errors(nil, I18n.t('errors.messages.failed_epp_conn')) and return false
+ # end
+ # true
+ # end
+
+ # def handle_login_request
+ # tag = current_user.username
+ # ex = EppXml::Session.new(cl_trid_prefix: tag)
+ # xml = ex.login(clID: { value: tag }, pw: { value: current_user.plain_text_password })
+ # res = server.send_request(xml)
+
+ # return if Nokogiri::XML(res).css('result').first['code'] == '1000'
+
+ # handle_non_epp_errors(nil, Nokogiri::XML(res).css('result').text)
+ # end
+
+ def server
+ client_cert = File.read(ENV['cert_path'])
+ client_key = File.read(ENV['key_path'])
+ port = ENV['epp_port'] || 700
+ @server ||= Epp::Server.new({ server: ENV['epp_hostname'], tag: current_user.username,
+ password: current_user.plain_text_password,
+ port: port,
+ cert: OpenSSL::X509::Certificate.new(client_cert),
+ key: OpenSSL::PKey::RSA.new(client_key) })
+ end
+
+ def request_params
+ params.require(:xml_console).permit(:payload)
+ end
+end
diff --git a/app/controllers/eis_billing/e_invoice_response_controller.rb b/app/controllers/eis_billing/e_invoice_response_controller.rb
index 208c8864f..20a0d724a 100644
--- a/app/controllers/eis_billing/e_invoice_response_controller.rb
+++ b/app/controllers/eis_billing/e_invoice_response_controller.rb
@@ -10,6 +10,8 @@ class EisBilling::EInvoiceResponseController < EisBilling::BaseController
def mark_e_invoice_sent_at(invoice_number)
invoice = Invoice.find_by(number: invoice_number)
+ invoice = Invoice.find_by(number: invoice_number['invoice_number']) if invoice.nil?
+
invoice.update(e_invoice_sent_at: Time.zone.now)
end
end
diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb
index 12efbd1d3..1f1de8458 100644
--- a/app/controllers/epp/base_controller.rb
+++ b/app/controllers/epp/base_controller.rb
@@ -20,13 +20,23 @@ module Epp
rescue_from StandardError, with: :respond_with_command_failed_error
rescue_from AuthorizationError, with: :respond_with_authorization_error
+ rescue_from Shunter::ThrottleError, with: :respond_with_session_limit_exceeded_error
rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error
+
before_action :set_paper_trail_whodunnit
skip_before_action :validate_against_schema
protected
+ def respond_with_session_limit_exceeded_error(exception)
+ epp_errors.add(:epp_errors,
+ code: '2502',
+ msg: Shunter.default_error_message)
+ handle_errors
+ log_exception(exception) unless Rails.env.test?
+ end
+
def respond_with_command_failed_error(exception)
epp_errors.add(:epp_errors,
code: '2400',
@@ -51,6 +61,11 @@ module Epp
private
+ def throttled_user
+ authorize!(:throttled_user, @domain) unless current_user || instance_of?(Epp::SessionsController)
+ current_user
+ end
+
def wrap_exceptions
yield
rescue CanCan::AccessDenied
diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb
index 10250563c..db96a186d 100644
--- a/app/controllers/epp/contacts_controller.rb
+++ b/app/controllers/epp/contacts_controller.rb
@@ -5,6 +5,9 @@ module Epp
before_action :find_contact, only: [:info, :update, :delete]
before_action :find_password, only: [:info, :update, :delete]
+ THROTTLED_ACTIONS = %i[info check create renew update transfer delete].freeze
+ include Shunter::Integration::Throttle
+
def info
authorize! :info, @contact, @password
render_epp_response 'epp/contacts/info'
diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb
index d2e146c0a..abf360c55 100644
--- a/app/controllers/epp/domains_controller.rb
+++ b/app/controllers/epp/domains_controller.rb
@@ -6,6 +6,9 @@ module Epp
before_action :set_paper_trail_whodunnit
before_action :parse_schemas_prefix_and_version
+ THROTTLED_ACTIONS = %i[info create check renew update transfer delete].freeze
+ include Shunter::Integration::Throttle
+
def info
authorize! :info, @domain
diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb
index a674bcd45..7fe6d2636 100644
--- a/app/controllers/epp/polls_controller.rb
+++ b/app/controllers/epp/polls_controller.rb
@@ -1,5 +1,8 @@
module Epp
class PollsController < BaseController
+ THROTTLED_ACTIONS = %i[poll].freeze
+ include Shunter::Integration::Throttle
+
def poll
authorize! :manage, :poll
req_poll if params[:parsed_frame].css('poll').first['op'] == 'req'
diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb
index 8d8b56e62..0667c9adc 100644
--- a/app/controllers/epp/sessions_controller.rb
+++ b/app/controllers/epp/sessions_controller.rb
@@ -3,6 +3,9 @@ module Epp
skip_authorization_check only: [:hello, :login, :logout]
before_action :set_paper_trail_whodunnit
+ THROTTLED_ACTIONS = %i[login hello].freeze
+ include Shunter::Integration::Throttle
+
def hello
render_epp_response('greeting')
end
diff --git a/app/controllers/registrar/account_activities_controller.rb b/app/controllers/registrar/account_activities_controller.rb
deleted file mode 100644
index 0ad8c3d5a..000000000
--- a/app/controllers/registrar/account_activities_controller.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-class Registrar
- class AccountActivitiesController < BaseController
- load_and_authorize_resource
-
- def index
- params[:q] ||= {}
- account = current_registrar_user.registrar.cash_account
-
- ca_cache = params[:q][:created_at_lteq]
- begin
- end_time = params[:q][:created_at_lteq].try(:to_date)
- params[:q][:created_at_lteq] = end_time.try(:end_of_day)
- rescue
- logger.warn('Invalid date')
- end
-
- @q = account.activities.includes(:invoice).ransack(params[:q])
- @q.sorts = 'id desc' if @q.sorts.empty?
-
- respond_to do |format|
- format.html { @account_activities = @q.result.page(params[:page]) }
- format.csv do
- raw_csv = CsvGenerator.generate_csv(@q.result)
- send_data raw_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
- end
- end
-
- params[:q][:created_at_lteq] = ca_cache
- end
- end
-end
diff --git a/app/controllers/registrar/account_controller.rb b/app/controllers/registrar/account_controller.rb
deleted file mode 100644
index a7d135659..000000000
--- a/app/controllers/registrar/account_controller.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-class Registrar
- class AccountController < BaseController
- skip_authorization_check
- helper_method :iban_max_length
- helper_method :balance_auto_reload_setting
-
- def show; end
-
- def edit
- @registrar = current_registrar_user.registrar
- end
-
- def update
- @registrar = current_registrar_user.registrar
- @registrar.update!(registrar_params)
-
- redirect_to registrar_account_path, notice: t('.saved')
- end
-
- private
-
- def registrar_params
- params.require(:registrar).permit(:billing_email, :iban)
- end
-
- def iban_max_length
- Iban.max_length
- end
-
- def balance_auto_reload_setting
- current_registrar_user.registrar.settings['balance_auto_reload']
- end
- end
-end
diff --git a/app/controllers/registrar/admin_contacts_controller.rb b/app/controllers/registrar/admin_contacts_controller.rb
deleted file mode 100644
index 378f490a9..000000000
--- a/app/controllers/registrar/admin_contacts_controller.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class Registrar
- class AdminContactsController < BulkChangeController
- BASE_URL = URI.parse("#{ENV['repp_url']}domains/admin_contacts").freeze
- ACTIVE_TAB = :admin_contact
-
- def update
- authorize! :manage, :repp
- uri = BASE_URL
- request = form_request(uri)
-
- action = Actions::DoRequest.new(request, uri)
- response = action.call
-
- start_notice = t('.replaced')
-
- process_response(response: response,
- start_notice: start_notice,
- active_tab: ACTIVE_TAB)
- end
- end
-end
diff --git a/app/controllers/registrar/base_controller.rb b/app/controllers/registrar/base_controller.rb
deleted file mode 100644
index 2aad861b8..000000000
--- a/app/controllers/registrar/base_controller.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-class Registrar
- class BaseController < ApplicationController
- include Registrar::ApplicationHelper
-
- before_action :authenticate_registrar_user!
- before_action :check_ip_restriction
- helper_method :depp_controller?
- helper_method :head_title_sufix
- before_action :set_paper_trail_whodunnit
-
- protected
-
- def current_ability
- @current_ability ||= Ability.new(current_registrar_user, request.remote_ip)
- end
-
- private
-
- def check_ip_restriction
- ip_restriction = Authorization::RestrictedIp.new(request.ip)
- allowed = ip_restriction.can_access_registrar_area?(current_registrar_user.registrar)
-
- return if allowed
-
- sign_out current_registrar_user
-
- flash[:alert] = t('registrar.authorization.ip_not_allowed', ip: request.ip)
- redirect_to new_registrar_user_session_url
- end
-
- def depp_controller?
- false
- end
-
- def head_title_sufix
- t(:registrar_head_title_sufix)
- end
-
- def user_for_paper_trail
- current_registrar_user ? current_registrar_user.id_role_username : 'anonymous'
- end
- end
-end
diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb
deleted file mode 100644
index 9cd00e6cc..000000000
--- a/app/controllers/registrar/bulk_change_controller.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-class Registrar
- class BulkChangeController < DeppController
- helper_method :available_contacts
-
- def new
- authorize! :manage, :repp
- @expire_date = Time.zone.now.to_date
- render 'registrar/bulk_change/new', locals: { active_tab: default_tab }
- end
-
- def bulk_renew
- authorize! :manage, :repp
- set_form_data
-
- if ready_to_renew?
- res = ReppApi.bulk_renew(domain_ids_for_bulk_renew, params[:period],
- current_registrar_user)
-
- flash_message(JSON.parse(res))
- else
- flash[:notice] = nil
- end
-
- render 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew }
- end
-
- private
-
- def form_request(uri)
- request = Net::HTTP::Patch.new(uri)
- request.set_form_data(current_contact_id: params[:current_contact_id],
- new_contact_id: params[:new_contact_id])
- request.basic_auth(current_registrar_user.username,
- current_registrar_user.plain_text_password)
- request
- end
-
- def process_response(response:, start_notice: '', active_tab:)
- parsed_response = JSON.parse(response.body, symbolize_names: true)
-
- if response.code == '200'
- notices = success_notices(parsed_response, start_notice)
-
- flash[:notice] = notices.join(', ')
- redirect_to registrar_domains_url
- else
- @error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message]
- render 'registrar/bulk_change/new', locals: { active_tab: active_tab }
- end
- end
-
- def success_notices(parsed_response, start_notice)
- notices = [start_notice]
-
- notices << "#{t('.affected_domains')}: " \
- "#{parsed_response[:data][:affected_domains].join(', ')}"
-
- if parsed_response[:data][:skipped_domains]
- notices << "#{t('.skipped_domains')}: " \
- "#{parsed_response[:data][:skipped_domains].join(', ')}"
- end
- notices
- end
-
- def ready_to_renew?
- domain_ids_for_bulk_renew.present? && params[:renew].present?
- end
-
- def set_form_data
- @expire_date = params[:expire_date].to_date
- @domains = domains_by_date(@expire_date)
- @period = params[:period]
- end
-
- def available_contacts
- current_registrar_user.registrar.contacts.order(:name).pluck(:name, :code)
- end
-
- def default_tab
- :technical_contact
- end
-
- def domains_scope
- current_registrar_user.registrar.domains
- end
-
- def domains_by_date(date)
- domains_scope.where('valid_to <= ?', date)
- end
-
- def domain_ids_for_bulk_renew
- params['domain_ids']&.reject { |id| id.blank? }
- end
-
- def renew_task(domains)
- Domains::BulkRenew::Start.run(domains: domains,
- period_element: @period,
- registrar: current_registrar_user.registrar)
- end
-
- def flash_message(res)
- flash[:notice] = res['code'] == 1000 ? t(:bulk_renew_completed) : res['message']
- end
- end
-end
diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb
deleted file mode 100644
index 812e278e5..000000000
--- a/app/controllers/registrar/contacts_controller.rb
+++ /dev/null
@@ -1,163 +0,0 @@
-class Registrar
- class ContactsController < DeppController
- before_action :init_epp_contact
- helper_method :address_processing?
- helper_method :ident_types
- helper_method :domain_filter_params
-
- def index
- authorize! :view, Depp::Contact
-
- params[:q] ||= {}
- params[:q].delete_if { |_k, v| v.blank? }
-
- search_params = params[:q].deep_dup
-
- if search_params[:domain_contacts_type_in].is_a?(Array) &&
- search_params[:domain_contacts_type_in].delete('registrant')
- search_params[:registrant_domains_id_not_null] = 1
- end
-
- contacts = current_registrar_user.registrar.contacts.includes(:registrar)
- status_list = params[:statuses_contains]
-
- if status_list
- contacts_ids = contacts.select { |c| (c.statuses & status_list.to_a) == status_list.to_a }
- .map(&:id)
- contacts = contacts.where(id: contacts_ids)
- end
-
- normalize_search_parameters do
- @q = contacts.ransack(search_params)
- end
-
- contacts = @q.result
-
- respond_to do |format|
- format.html do
- contacts_per_page = params[:results_per_page].to_i
- @contacts = contacts.page(params[:page])
- @contacts = @contacts.per(contacts_per_page) if contacts_per_page.positive?
- end
- format.csv do
- raw_csv = CsvGenerator.generate_csv(contacts)
- send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8"
- end
- format.pdf do
- raw_html = ApplicationController.render(
- template: 'registrar/contacts/list_pdf',
- assigns: { contacts: contacts },
- formats: [:html]
- )
- raw_pdf = contacts.pdf(raw_html)
-
- send_data raw_pdf, filename: 'contacts.pdf'
- end
- end
- end
-
- def new
- authorize! :create, Depp::Contact
- @contact = Depp::Contact.new
- end
-
- def show
- authorize! :view, Depp::Contact
- @contact = Depp::Contact.find_by_id(params[:id])
- end
-
- def edit
- authorize! :edit, Depp::Contact
- @contact = Depp::Contact.find_by_id(params[:id])
- end
-
- def create
- authorize! :create, Depp::Contact
- @contact = Depp::Contact.new(contact_params)
-
- if @contact.save
- redirect_to registrar_contact_url(@contact.id)
- else
- render 'new'
- end
- end
-
- def update
- authorize! :edit, Depp::Contact
- @contact = Depp::Contact.new(contact_params)
-
- if @contact.update_attributes(contact_params)
- redirect_to registrar_contact_url(@contact.id)
- else
- render 'edit'
- end
- end
-
- def delete
- authorize! :delete, Depp::Contact
- @contact = Depp::Contact.find_by_id(params[:id])
- end
-
- def destroy
- authorize! :delete, Depp::Contact
- @contact = Depp::Contact.new(contact_params_for_delete)
-
- if @contact.delete
- redirect_to registrar_contacts_url, notice: t(:destroyed)
- else
- render 'delete'
- end
- end
-
- protected
-
- def domain_filter_params
- params.permit(:domain_filter)
- end
-
- private
-
- def init_epp_contact
- Depp::Contact.user = depp_current_user
- end
-
- 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 address_processing?
- Contact.address_processing?
- end
-
- def ident_types
- Contact::Ident.types
- end
-
- def contact_params
- params.require(:depp_contact).permit(:id,
- :name,
- :email,
- :phone,
- :org_name,
- :ident, :ident_type, :ident_country_code,
- :street, :city, :zip, :state, :country_code,
- :password,
- :legal_document,
- :code)
- end
-
- def contact_params_for_delete
- params.require(:depp_contact).permit(:id, :password, :legal_document)
- end
- end
-end
diff --git a/app/controllers/registrar/current_user_controller.rb b/app/controllers/registrar/current_user_controller.rb
deleted file mode 100644
index 3a214322c..000000000
--- a/app/controllers/registrar/current_user_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class Registrar
- class CurrentUserController < BaseController
- skip_authorization_check
-
- def switch
- raise 'Cannot switch to unlinked user' unless current_registrar_user.linked_with?(new_user)
-
- sign_in(:registrar_user, new_user)
- redirect_back(fallback_location: root_path, notice: t('.switched', new_user: new_user))
- end
-
- private
-
- def new_user
- @new_user ||= ApiUser.find(params[:new_user_id])
- end
- end
-end
diff --git a/app/controllers/registrar/deposits_controller.rb b/app/controllers/registrar/deposits_controller.rb
deleted file mode 100644
index 0dcaf6830..000000000
--- a/app/controllers/registrar/deposits_controller.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-class Registrar
- class DepositsController < BaseController
- authorize_resource class: false
-
- def new
- @deposit = Deposit.new
- end
-
- def create
- @deposit = Deposit.new(deposit_params.merge(registrar: current_registrar_user.registrar))
- @invoice = @deposit.issue_prepayment_invoice
-
- if @invoice
- flash[:notice] = t(:please_pay_the_following_invoice)
- redirect_to [:registrar, @invoice]
- else
- flash[:alert] = @deposit.errors.full_messages.join(', ')
- redirect_to new_registrar_deposit_path
- end
- end
-
- private
-
- def deposit_params
- params.require(:deposit).permit(:amount, :description)
- end
- end
-end
diff --git a/app/controllers/registrar/depp_controller.rb b/app/controllers/registrar/depp_controller.rb
deleted file mode 100644
index 70fb01c4a..000000000
--- a/app/controllers/registrar/depp_controller.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-class Registrar
- class DeppController < BaseController
- helper_method :depp_current_user
-
- rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |exception|
- logger.error 'COULD NOT CONNECT TO REGISTRY'
- logger.error exception.backtrace.join("\n")
- redirect_to new_registrar_user_session_url, alert: t(:no_connection_to_registry)
- end
-
- before_action :authenticate_user
-
- def authenticate_user
- redirect_to new_registrar_user_session_url and return unless depp_current_user
- end
-
- def depp_controller?
- true
- end
-
- def depp_current_user
- return nil unless current_registrar_user
- @depp_current_user ||= Depp::User.new(
- tag: current_registrar_user.username,
- password: current_registrar_user.plain_text_password
- )
- end
-
- def response_ok?
- @data.css('result').each do |x|
- success_codes = %(1000, 1001, 1300, 1301)
- return false unless success_codes.include?(x['code'])
- end
- true
- end
- end
-end
diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb
deleted file mode 100644
index 57e06d010..000000000
--- a/app/controllers/registrar/domain_transfers_controller.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-class Registrar
- class DomainTransfersController < BulkChangeController
- before_action do
- authorize! :transfer, Depp::Domain
- end
-
- def new
- end
-
- def create
- if params[:batch_file].present?
- csv = CSV.read(params[:batch_file].path, headers: true)
- domain_transfers = []
-
- csv.each do |row|
- domain_name = row['Domain']
- transfer_code = row['Transfer code']
- domain_transfers << { 'domain_name' => domain_name, 'transfer_code' => transfer_code }
- end
-
- uri = URI.parse("#{ENV['repp_url']}domains/transfer")
- request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
- request.body = { data: { domain_transfers: domain_transfers } }.to_json
- request.basic_auth(current_registrar_user.username,
- current_registrar_user.plain_text_password)
-
- action = Actions::DoRequest.new(request, uri)
- response = action.call
-
- parsed_response = JSON.parse(response.body, symbolize_names: true)
-
- if response.code == '200'
- failed = parsed_response[:data][:failed].pluck(:domain_name).join(', ')
- flash[:notice] = t('.transferred', count: parsed_response[:data][:success].size,
- failed: failed)
- redirect_to registrar_domains_url
- else
- @api_errors = parsed_response[:message]
- render 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer }
- end
- else
- params[:request] = true # EPP domain:transfer "op" attribute
- domain = Depp::Domain.new(current_user: depp_current_user)
- @data = domain.transfer(params)
- render :new unless response_ok?
- end
- end
- end
-end
diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb
deleted file mode 100644
index 5168d25b8..000000000
--- a/app/controllers/registrar/domains_controller.rb
+++ /dev/null
@@ -1,227 +0,0 @@
-class Registrar
- class DomainsController < DeppController
- before_action :init_domain, except: :new
- helper_method :contacts
- helper_method :search_params
-
- def index
- authorize! :view, Depp::Domain
-
- if search_params.to_h.delete_if { |_key, value| value.blank? }.length == 1 &&
- search_params[:name_matches].present?
- domain = Domain.find_by(name: search_params[:name_matches])
-
- redirect_to info_registrar_domains_url(domain_name: domain.name) and return if domain
- end
-
- domains = if params[:statuses_contains]
- current_domain_scope.where('domains.statuses @> ?::varchar[]',
- "{#{params[:statuses_contains].join(',')}}")
- else
- current_domain_scope
- end
-
- domains = domains.where(contacts: { ident: params[:contacts_ident_eq] }) if params[:contacts_ident_eq]
-
- normalize_search_parameters do
- @q = domains.ransack(search_params.except(:contacts_ident_eq))
- @domains = @q.result.page(params[:page])
-
- # if we do not get any results, add wildcards to the name field and search again
- if @domains.count == 0 && search_params[:name_matches] !~ /^%.+%$/
- new_search_params = search_params.to_h.except(:contacts_ident_eq)
- new_search_params[:name_matches] = "%#{new_search_params[:name_matches]}%"
- @q = domains.ransack(new_search_params)
- @domains = @q.result.page(params[:page])
- end
- end
-
- respond_to do |format|
- format.html
- format.csv do
- domain_presenters = []
-
- @q.result.find_each do |domain|
- domain_presenters << ::DomainPresenter.new(domain: domain, view: view_context)
- end
-
- 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"
- end
- end
- end
-
- def current_domain_scope
- current_registrar_user.registrar.domains.includes(:registrar, :registrant)
- end
-
- def info
- authorize! :info, Depp::Domain
- @data = @domain.info(params[:domain_name]) if params[:domain_name]
- @pending_delete = domain_delete_pending(@data)
- @client_holded = client_holded(@data)
- if response_ok?
- render 'info'
- else
- flash[:alert] = @data.css('msg').text
- redirect_to registrar_domains_url and return
- end
- end
-
- def check
- authorize! :check, Depp::Domain
- if params[:domain_name]
- @data = @domain.check(params[:domain_name])
- render 'check_index' and return unless response_ok?
- else
- render 'check_index'
- end
- end
-
- def new
- authorize! :create, Depp::Domain
- @domain_params = Depp::Domain.default_params
- @domain_params[:period] = Depp::Domain.default_period
- end
-
- # rubocop:disable Metrics/CognitiveComplexity
- def create
- authorize! :create, Depp::Domain
- @domain_params = domain_params.to_h
- @data = @domain.create(@domain_params)
-
- if @data && response_ok?
- redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
- else
- flash[:alert] = t('.email_error_message') unless @emails_check_result
- render 'new'
- end
- end
-
- def edit
- authorize! :update, Depp::Domain
- @data = @domain.info(params[:domain_name])
- @domain_params = Depp::Domain.construct_params_from_server_data(@data)
- @dispute = Dispute.active.find_by(domain_name: params[:domain_name])
- end
-
- def update
- authorize! :update, Depp::Domain
- @domain_params = params[:domain]
- @data = @domain.update(@domain_params)
- @dispute = Dispute.active.find_by(domain_name: @domain_params[:name])
-
- if @data && response_ok?
- redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
- else
- flash[:alert] = t('.email_error_message') unless @emails_check_result
- params[:domain_name] = @domain_params[:name]
- render 'new'
- end
- end
- # rubocop:enable Metrics/CognitiveComplexity
-
- def delete
- authorize! :delete, Depp::Domain
- end
-
- def destroy
- authorize! :delete, Depp::Domain
- @data = @domain.delete(params[:domain])
- @results = @data.css('result')
- if response_ok?
- flash[:notice] = t('.deleting_request')
- redirect_to info_registrar_domains_url(domain_name: params[:domain][:name])
- else
- params[:domain_name] = params[:domain][:name]
- render 'delete'
- end
- end
-
- def renew
- authorize! :renew, Depp::Domain
- if params[:domain_name] && params[:cur_exp_date]
- @data = @domain.renew(params)
- render 'renew_index' and return unless response_ok?
- else
- params[:period] = Depp::Domain.default_period
- render 'renew_index'
- end
- end
-
- def search_contacts
- authorize! :create, Depp::Domain
-
- scope = current_registrar_user.registrar.contacts.limit(10)
- if params[:query].present?
- escaped_str = ActiveRecord::Base.connection.quote_string params[:query]
- scope = scope.where("name ilike '%#{escaped_str}%' OR code ilike '%#{escaped_str}%' ")
- end
-
- render json: scope.pluck(:name, :code).map { |c| { display_key: "#{c.second} #{c.first}", value: c.second } }
- end
-
- def remove_hold
- authorize! :remove_hold, Depp::Domain
- return unless params[:domain_name]
-
- @data = @domain.remove_hold(params)
-
- flash[:alert] = @data.css('msg').text unless response_ok?
- redirect_to info_registrar_domains_url(domain_name: params[:domain_name])
- end
-
- private
-
- def init_domain
- @domain = Depp::Domain.new(current_user: depp_current_user)
- end
-
- def client_holded(data)
- data.css('status')&.map { |element| element.attribute('s').value }
- &.any? { |status| status == DomainStatus::CLIENT_HOLD }
- end
-
- def domain_delete_pending(data)
- data.css('status')&.map { |element| element.attribute('s').value }
- &.any? { |status| status.include?(DomainStatus::PENDING_DELETE) }
- end
-
- def contacts
- current_registrar_user.registrar.contacts
- end
-
- def normalize_search_parameters
- ca_cache = search_params[:valid_to_lteq]
- begin
- end_time = search_params[:valid_to_lteq].try(:to_date)
- search_params[:valid_to_lteq] = end_time.try(:end_of_day)
- rescue
- logger.warn('Invalid date')
- end
-
- yield
-
- search_params[:valid_to_lteq] = ca_cache
- end
-
- def search_params
- params.fetch(:q, {}).permit(:name_matches,
- :registrant_ident_eq,
- :contacts_ident_eq,
- :nameservers_hostname_eq,
- :valid_to_gteq,
- :valid_to_lteq,
- :s)
- end
-
- def domain_params
- params.require(:domain).permit(:name, :period, :registrant, :registrant_helper, :reserved_pw,
- :verified, :legal_document, contacts_attributes: {},
- nameservers_attributes: {},
- dnskeys_attributes: {})
- end
- end
-end
diff --git a/app/controllers/registrar/invoices/delivery_controller.rb b/app/controllers/registrar/invoices/delivery_controller.rb
deleted file mode 100644
index 8cdbb9196..000000000
--- a/app/controllers/registrar/invoices/delivery_controller.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class Registrar
- module Invoices
- class DeliveryController < BaseController
- include Deliverable
-
- private
-
- def redirect_url
- registrar_invoice_path(@invoice)
- end
- end
- end
-end
diff --git a/app/controllers/registrar/invoices_controller.rb b/app/controllers/registrar/invoices_controller.rb
deleted file mode 100644
index 2a17b72b0..000000000
--- a/app/controllers/registrar/invoices_controller.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-class Registrar
- class InvoicesController < BaseController
- load_and_authorize_resource
-
- def index
- params[:q] ||= {}
- invoices = current_registrar_user.registrar.invoices.includes(:items, :account_activity)
-
- normalize_search_parameters do
- @q = invoices.ransack(params[:q])
- @q.sorts = 'id desc' if @q.sorts.empty?
- @invoices = @q.result.page(params[:page])
- end
- end
-
- def show; end
-
- def cancel
- @invoice.cancel
- EisBilling::SendInvoiceStatus.send_info(invoice_number: @invoice.number, status: 'cancelled')
-
- redirect_to [:registrar, @invoice], notice: t('.cancelled')
- end
-
- def download
- filename = "invoice-#{@invoice.number}.pdf"
- send_data @invoice.as_pdf, filename: filename
- end
-
- private
-
- def normalize_search_parameters
- params[:q][:total_gteq].gsub!(',', '.') if params[:q][:total_gteq]
- params[:q][:total_lteq].gsub!(',', '.') if params[:q][:total_lteq]
- yield
- end
- end
-end
diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb
deleted file mode 100644
index 9bf31d1d7..000000000
--- a/app/controllers/registrar/nameservers_controller.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-class Registrar
- class NameserversController < BulkChangeController
- def update
- authorize! :manage, :repp
-
- ipv4 = params[:ipv4].split("\r\n")
- ipv6 = params[:ipv6].split("\r\n")
-
- uri = URI.parse("#{ENV['repp_url']}registrar/nameservers")
-
- domains = domain_list_from_csv
-
- return csv_list_empty_guard if domains == []
-
- options = {
- uri: uri,
- ipv4: ipv4,
- ipv6: ipv6,
- }
- action = Actions::BulkNameserversChange.new(params, domains, current_registrar_user, options)
- response = action.call
-
- parsed_response = JSON.parse(response.body, symbolize_names: true)
-
- if response.code == '200'
- redirect_to(registrar_domains_url,
- flash: { notice: compose_notice_message(parsed_response) })
- else
- @api_errors = parsed_response[:message]
- render 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
- end
- end
-
- def compose_notice_message(res)
- action_text = params[:old_hostname].blank? ? t('.added') : t('.replaced')
- notices = ["#{action_text}. #{t('.affected_domains')}: " \
- "#{res[:data][:affected_domains].join(', ')}"]
-
- notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" if res[:data][:skipped_domains]
-
- notices.join(', ')
- end
-
- def csv_list_empty_guard
- notice = 'CSV scoped domain list seems empty. Make sure that domains are added and ' \
- '"Domain" header is present.'
- redirect_to(registrar_domains_url, flash: { notice: notice })
- end
-
- def domain_list_from_csv
- return if params[:puny_file].blank?
-
- domains = []
- csv = CSV.read(params[:puny_file].path, headers: true)
-
- return [] if csv['Domain'].blank?
-
- csv.map { |b| domains << b['Domain'] }
-
- domains.compact
- rescue CSV::MalformedCSVError
- []
- end
- end
-end
diff --git a/app/controllers/registrar/payments_controller.rb b/app/controllers/registrar/payments_controller.rb
deleted file mode 100644
index 598d13446..000000000
--- a/app/controllers/registrar/payments_controller.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-class Registrar
- class PaymentsController < BaseController
- protect_from_forgery except: [:back, :callback]
-
- skip_authorization_check # actually anyone can pay, no problems at all
- skip_before_action :authenticate_registrar_user!, :check_ip_restriction,
- only: [:back, :callback]
-
- before_action :check_supported_payment_method, only: [:pay]
-
- def pay
- invoice = Invoice.find(params[:invoice_id])
- channel = params[:bank]
-
- @payment_order = PaymentOrder.new_with_type(type: channel, invoice: invoice)
- @payment_order.save
- @payment_order.reload
-
- @payment_order.return_url = registrar_return_payment_with_url(@payment_order)
- @payment_order.response_url = registrar_response_payment_with_url(@payment_order)
-
- @payment_order.save
- @payment_order.reload
- end
-
- def back
- @payment_order = PaymentOrder.find_by!(id: params[:payment_order])
- @payment_order.update!(response: params.to_unsafe_h)
-
- if @payment_order.payment_received?
- @payment_order.complete_transaction
-
- if @payment_order.invoice.paid?
- flash[:notice] = t('.payment_successful')
- else
- flash[:alert] = t('.successful_payment_backend_error')
- end
- else
- @payment_order.create_failure_report
- flash[:alert] = t('.payment_not_received')
- end
- redirect_to registrar_invoice_path(@payment_order.invoice)
- end
-
- def callback
- @payment_order = PaymentOrder.find_by!(id: params[:payment_order])
- @payment_order.update!(response: params.to_unsafe_h)
-
- if @payment_order.payment_received?
- @payment_order.complete_transaction
- else
- @payment_order.create_failure_report
- end
-
- render status: 200, json: { status: 'ok' }
- end
-
- private
-
- def check_supported_payment_method
- return if PaymentOrder.supported_method?(params[:bank], shortname: true)
-
- raise(StandardError, 'Not supported payment method')
- end
- end
-end
diff --git a/app/controllers/registrar/polls_controller.rb b/app/controllers/registrar/polls_controller.rb
deleted file mode 100644
index dde4bb8ea..000000000
--- a/app/controllers/registrar/polls_controller.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-class Registrar
- class PollsController < DeppController
- authorize_resource class: false
- before_action :init_epp_xml
-
- def show
- if Rails.env.test? # Stub for depp server request
- @data = Object.new
-
- def @data.css(key)
- ; [];
- end
- else
- @data = depp_current_user.request(@ex.poll)
- end
- end
-
- def destroy
- @data = depp_current_user.request(@ex.poll(poll: { value: '', attrs: { op: 'ack', msgID: params[:id] } }))
-
- @results = @data.css('result')
-
- @data = depp_current_user.request(@ex.poll)
- render 'show'
- end
-
- def confirm_transfer
- domain_params = params[:domain]
- @data = @domain.confirm_transfer(domain_params)
-
- @results = @data.css('result')
- @data = depp_current_user.request(@ex.poll)
-
- render 'show'
- end
-
- private
-
- def init_epp_xml
- @ex = EppXml::Session.new(cl_trid_prefix: depp_current_user.tag)
- @domain = Depp::Domain.new(current_user: depp_current_user)
- end
- end
-end
diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb
deleted file mode 100644
index c73ed799b..000000000
--- a/app/controllers/registrar/sessions_controller.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-class Registrar
- class SessionsController < Devise::SessionsController
- before_action :check_ip_restriction
- helper_method :depp_controller?
-
- def create
- @depp_user = Depp::User.new(depp_user_params)
-
- if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'].blank?
- @depp_user.errors.add(:base, :webserver_missing_user_name_directive)
- end
-
- if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'].blank?
- @depp_user.errors.add(:base, :webserver_missing_client_cert_directive)
- end
-
- if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'] == '(null)'
- @depp_user.errors.add(:base, :webserver_user_name_directive_should_be_required)
- end
-
- if @depp_user.pki && request.env['HTTP_SSL_CLIENT_CERT'] == '(null)'
- @depp_user.errors.add(:base, :webserver_client_cert_directive_should_be_required)
- end
-
- @api_user = ApiUser.find_by(username: sign_in_params[:username],
- plain_text_password: sign_in_params[:password])
-
- unless @api_user
- @depp_user.errors.add(:base, t(:no_such_user))
- show_error and return
- end
-
- if @depp_user.pki && !@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
- request.env['HTTP_SSL_CLIENT_S_DN_CN'], api: false)
- @depp_user.errors.add(:base, :invalid_cert)
- end
-
- show_error and return unless @depp_user.errors.none?
-
- if @api_user.active?
- sign_in_and_redirect(:registrar_user, @api_user)
- else
- @depp_user.errors.add(:base, :not_active)
- show_error
- end
- end
-
- private
-
- def depp_controller?
- false
- end
-
- def find_user_by_idc(idc)
- return User.new unless idc
- ApiUser.find_by(identity_code: idc) || User.new
- end
-
- def find_user_by_idc_and_allowed(idc)
- return User.new unless idc
-
- possible_users = ApiUser.where(identity_code: idc) || User.new
- possible_users.each do |selected_user|
- return selected_user if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip)
- end
- end
-
- def check_ip_restriction
- ip_restriction = Authorization::RestrictedIp.new(request.ip)
- allowed = ip_restriction.can_access_registrar_area_sign_in_page?
-
- return if allowed
-
- render plain: t('registrar.authorization.ip_not_allowed', ip: request.ip)
- end
-
- def current_ability
- @current_ability ||= Ability.new(current_registrar_user, request.remote_ip)
- end
-
- def after_sign_in_path_for(_resource_or_scope)
- if can?(:show, :poll)
- registrar_root_path
- else
- registrar_account_path
- end
- end
-
- def after_sign_out_path_for(_resource_or_scope)
- new_registrar_user_session_path
- end
-
- def user_for_paper_trail
- current_registrar_user ? current_registrar_user.id_role_username : 'anonymous'
- end
-
- def depp_user_params
- params = sign_in_params
- params[:tag] = params.delete(:username)
- params.merge!(pki: !(Rails.env.development? || Rails.env.test?))
- params
- end
-
- def show_error
- redirect_to new_registrar_user_session_url, alert: @depp_user.errors.full_messages.first
- end
- end
-end
diff --git a/app/controllers/registrar/settings/balance_auto_reload_controller.rb b/app/controllers/registrar/settings/balance_auto_reload_controller.rb
deleted file mode 100644
index d6ace12ef..000000000
--- a/app/controllers/registrar/settings/balance_auto_reload_controller.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-class Registrar
- module Settings
- class BalanceAutoReloadController < BaseController
- before_action :authorize
-
- def edit
- @type = if current_registrar.settings['balance_auto_reload']
- type_params = current_registrar.settings['balance_auto_reload']['type']
- .except('name')
- BalanceAutoReloadTypes::Threshold.new(type_params)
- else
- BalanceAutoReloadTypes::Threshold.new
- end
- end
-
- def update
- type = BalanceAutoReloadTypes::Threshold.new(type_params)
- current_registrar.update!(settings: { balance_auto_reload: { type: type } })
-
- redirect_to registrar_account_path, notice: t('.saved')
- end
-
- def destroy
- current_registrar.settings.delete('balance_auto_reload')
- current_registrar.save!
-
- redirect_to registrar_account_path, notice: t('.disabled')
- end
-
- private
-
- def type_params
- permitted_params = params.require(:type).permit(:amount, :threshold)
- normalize_params(permitted_params)
- end
-
- def normalize_params(params)
- params[:amount] = params[:amount].to_f
- params[:threshold] = params[:threshold].to_f
- params
- end
-
- def authorize
- authorize!(:manage, :balance_auto_reload)
- end
-
- def current_registrar
- current_registrar_user.registrar
- end
- end
- end
-end
diff --git a/app/controllers/registrar/tech_contacts_controller.rb b/app/controllers/registrar/tech_contacts_controller.rb
deleted file mode 100644
index 9a5631abf..000000000
--- a/app/controllers/registrar/tech_contacts_controller.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-class Registrar
- class TechContactsController < BulkChangeController
- BASE_URL = URI.parse("#{ENV['repp_url']}domains/contacts").freeze
- ACTIVE_TAB = :technical_contact
-
- def update
- authorize! :manage, :repp
-
- uri = BASE_URL
- request = form_request(uri)
-
- action = Actions::DoRequest.new(request, uri)
- response = action.call
-
- start_notice = t('.replaced')
-
- process_response(response: response,
- start_notice: start_notice,
- active_tab: ACTIVE_TAB)
- end
- end
-end
diff --git a/app/controllers/registrar/xml_consoles_controller.rb b/app/controllers/registrar/xml_consoles_controller.rb
deleted file mode 100644
index a27e3e3ee..000000000
--- a/app/controllers/registrar/xml_consoles_controller.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-class Registrar
- class XmlConsolesController < DeppController
- PREFS = %w[
- domain-ee
- contact-ee
- eis
- epp-ee
- ].freeze
-
- authorize_resource class: false
-
- def show; end
-
- def create
- begin
- @result = depp_current_user.server.request(params[:payload])
- rescue StandardError
- @result = 'CONNECTION ERROR - Is the EPP server running?'
- end
- render :show
- end
-
- def load_xml
- cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
- xml_dir_path = Rails.root.join('app/views/registrar/xml_consoles/epp_requests').to_s
- xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
- xml = prepare_payload(xml, cl_trid)
-
- render plain: xml
- end
-
- private
-
- def prepare_payload(xml, cl_trid)
- PREFS.map do |pref|
- xml = load_schema_by_prefix(pref, xml)
- end
-
- xml.gsub!('ABC-12345 ', "#{cl_trid} ")
- xml
- end
-
- def load_schema_by_prefix(pref, xml)
- case pref
- when 'epp-ee'
- insert_prefix_and_version(xml, pref, '1.0')
- when 'eis'
- insert_prefix_and_version(xml, pref, '1.0')
- when 'contact-ee'
- insert_prefix_and_version(xml, pref, '1.1')
- else
- insert_prefix_and_version(xml, pref, '1.2')
- end
- end
-
- def insert_prefix_and_version(xml, pref, version)
- xml.gsub!("\"#{pref}\"",
- "\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
- xml
- end
- end
-end
diff --git a/app/controllers/repp/v1/accounts_controller.rb b/app/controllers/repp/v1/accounts_controller.rb
index 8395db42c..a405646ca 100644
--- a/app/controllers/repp/v1/accounts_controller.rb
+++ b/app/controllers/repp/v1/accounts_controller.rb
@@ -3,6 +3,11 @@ module Repp
class AccountsController < BaseController # rubocop:disable Metrics/ClassLength
load_and_authorize_resource
+ THROTTLED_ACTIONS = %i[
+ index balance details update_auto_reload_balance disable_auto_reload_balance switch_user update
+ ].freeze
+ include Shunter::Integration::Throttle
+
api :get, '/repp/v1/accounts'
desc 'Get all activities'
def index
diff --git a/app/controllers/repp/v1/base_controller.rb b/app/controllers/repp/v1/base_controller.rb
index d84c8e37b..2b05df8ef 100644
--- a/app/controllers/repp/v1/base_controller.rb
+++ b/app/controllers/repp/v1/base_controller.rb
@@ -27,6 +27,10 @@ module Repp
@response = { code: 2201, message: 'Authorization error' }
logger.error e.to_s
render(json: @response, status: :unauthorized)
+ rescue Shunter::ThrottleError => e
+ @response = { code: 2502, message: Shunter.default_error_message }
+ logger.error e.to_s unless Rails.env.test?
+ render(json: @response, status: :bad_request)
ensure
create_repp_log
end
@@ -167,6 +171,11 @@ module Repp
data[:abilities] = Ability.new(current_user).permissions
data
end
+
+ def throttled_user
+ authorize!(:throttled_user, @domain) unless current_user || action_name == 'tara_callback'
+ current_user
+ end
end
end
end
diff --git a/app/controllers/repp/v1/contacts_controller.rb b/app/controllers/repp/v1/contacts_controller.rb
index 5d8f20ee0..510525ac5 100644
--- a/app/controllers/repp/v1/contacts_controller.rb
+++ b/app/controllers/repp/v1/contacts_controller.rb
@@ -5,6 +5,9 @@ module Repp
before_action :find_contact, only: %i[show update destroy]
skip_around_action :log_request, only: :search
+ THROTTLED_ACTIONS = %i[index check search create show update destroy].freeze
+ include Shunter::Integration::Throttle
+
api :get, '/repp/v1/contacts'
desc 'Get all existing contacts'
def index
diff --git a/app/controllers/repp/v1/domains/admin_contacts_controller.rb b/app/controllers/repp/v1/domains/admin_contacts_controller.rb
index 5db865199..ce06296f5 100644
--- a/app/controllers/repp/v1/domains/admin_contacts_controller.rb
+++ b/app/controllers/repp/v1/domains/admin_contacts_controller.rb
@@ -2,6 +2,9 @@ module Repp
module V1
module Domains
class AdminContactsController < BaseContactsController
+ THROTTLED_ACTIONS = %i[update].freeze
+ include Shunter::Integration::Throttle
+
def update
super
diff --git a/app/controllers/repp/v1/domains/contacts_controller.rb b/app/controllers/repp/v1/domains/contacts_controller.rb
index b41b3a378..53f8559d9 100644
--- a/app/controllers/repp/v1/domains/contacts_controller.rb
+++ b/app/controllers/repp/v1/domains/contacts_controller.rb
@@ -4,6 +4,9 @@ module Repp
class ContactsController < BaseContactsController
before_action :set_domain, only: %i[index create destroy]
+ THROTTLED_ACTIONS = %i[index create destroy update].freeze
+ include Shunter::Integration::Throttle
+
def_param_group :contacts_apidoc do
param :contacts, Array, required: true, desc: 'Array of new linked contacts' do
param :code, String, required: true, desc: 'Contact code'
@@ -38,9 +41,7 @@ module Repp
def cta(action = 'add')
params[:contacts].each { |c| c[:action] = action }
action = Actions::DomainUpdate.new(@domain, contact_create_params, false)
- # rubocop:disable Style/AndOr
handle_errors(@domain) and return unless action.call
- # rubocop:enable Style/AndOr
render_success(data: { domain: { name: @domain.name } })
end
diff --git a/app/controllers/repp/v1/domains/dnssec_controller.rb b/app/controllers/repp/v1/domains/dnssec_controller.rb
index fcfaa991a..0acf2e6e9 100644
--- a/app/controllers/repp/v1/domains/dnssec_controller.rb
+++ b/app/controllers/repp/v1/domains/dnssec_controller.rb
@@ -4,6 +4,9 @@ module Repp
class DnssecController < BaseController
before_action :set_domain, only: %i[index create destroy]
+ THROTTLED_ACTIONS = %i[index create destroy].freeze
+ include Shunter::Integration::Throttle
+
def_param_group :dns_keys_apidoc do
param :flags, String, required: true, desc: '256 (KSK) or 257 (ZSK)'
param :protocol, String, required: true, desc: 'Key protocol (3)'
diff --git a/app/controllers/repp/v1/domains/nameservers_controller.rb b/app/controllers/repp/v1/domains/nameservers_controller.rb
index 6f76f9e99..8ee1cba35 100644
--- a/app/controllers/repp/v1/domains/nameservers_controller.rb
+++ b/app/controllers/repp/v1/domains/nameservers_controller.rb
@@ -5,6 +5,9 @@ module Repp
before_action :set_domain, only: %i[index create destroy]
before_action :set_nameserver, only: %i[destroy]
+ THROTTLED_ACTIONS = %i[index create destroy].freeze
+ include Shunter::Integration::Throttle
+
api :GET, '/repp/v1/domains/:domain_name/nameservers'
desc "Get domain's nameservers"
def index
diff --git a/app/controllers/repp/v1/domains/renews_controller.rb b/app/controllers/repp/v1/domains/renews_controller.rb
index 9aba3e41b..c91130119 100644
--- a/app/controllers/repp/v1/domains/renews_controller.rb
+++ b/app/controllers/repp/v1/domains/renews_controller.rb
@@ -6,6 +6,9 @@ module Repp
before_action :select_renewable_domains, only: [:bulk_renew]
before_action :set_domain, only: [:create]
+ THROTTLED_ACTIONS = %i[create bulk_renew].freeze
+ include Shunter::Integration::Throttle
+
api :POST, 'repp/v1/domains/:domain_name/renew'
desc 'Renew domain'
param :renews, Hash, required: true, desc: 'Renew parameters' do
@@ -43,7 +46,7 @@ module Repp
def validate_renew_period
@epp_errors ||= ActiveModel::Errors.new(self)
- periods = Depp::Domain::PERIODS.map { |p| p[1] }
+ periods = Domain::PERIODS.map { |p| p[1] }
return if periods.include? bulk_renew_params[:renew_period]
@epp_errors.add(:epp_errors, msg: 'Invalid renew period', code: '2005')
diff --git a/app/controllers/repp/v1/domains/statuses_controller.rb b/app/controllers/repp/v1/domains/statuses_controller.rb
index d46725c46..b07ce3956 100644
--- a/app/controllers/repp/v1/domains/statuses_controller.rb
+++ b/app/controllers/repp/v1/domains/statuses_controller.rb
@@ -5,6 +5,9 @@ module Repp
before_action :set_domain, only: %i[update destroy]
before_action :verify_status
+ THROTTLED_ACTIONS = %i[update destroy].freeze
+ include Shunter::Integration::Throttle
+
api :DELETE, '/repp/v1/domains/:domain_name/statuses/:status'
param :domain_name, String, desc: 'Domain name'
desc 'Remove status from specific domain'
diff --git a/app/controllers/repp/v1/domains/transfers_controller.rb b/app/controllers/repp/v1/domains/transfers_controller.rb
index e9474d94d..69e685571 100644
--- a/app/controllers/repp/v1/domains/transfers_controller.rb
+++ b/app/controllers/repp/v1/domains/transfers_controller.rb
@@ -4,6 +4,9 @@ module Repp
class TransfersController < BaseController
before_action :set_domain, only: [:create]
+ THROTTLED_ACTIONS = %i[create].freeze
+ include Shunter::Integration::Throttle
+
api :POST, 'repp/v1/domains/:domain_name/transfer'
desc 'Transfer a specific domain'
param :transfer, Hash, required: true, desc: 'Renew parameters' do
diff --git a/app/controllers/repp/v1/domains_controller.rb b/app/controllers/repp/v1/domains_controller.rb
index 6990b0a86..c72c83882 100644
--- a/app/controllers/repp/v1/domains_controller.rb
+++ b/app/controllers/repp/v1/domains_controller.rb
@@ -8,6 +8,9 @@ module Repp
before_action :forward_registrar_id, only: %i[create update destroy]
before_action :set_domain, only: %i[update]
+ THROTTLED_ACTIONS = %i[transfer_info transfer index create show update destroy].freeze
+ include Shunter::Integration::Throttle
+
api :GET, '/repp/v1/domains'
desc 'Get all existing domains'
def index
diff --git a/app/controllers/repp/v1/invoices_controller.rb b/app/controllers/repp/v1/invoices_controller.rb
index 2d4340b3e..fe2c1c50a 100644
--- a/app/controllers/repp/v1/invoices_controller.rb
+++ b/app/controllers/repp/v1/invoices_controller.rb
@@ -4,6 +4,9 @@ module Repp
class InvoicesController < BaseController # rubocop:disable Metrics/ClassLength
load_and_authorize_resource
+ THROTTLED_ACTIONS = %i[download add_credit send_to_recipient cancel index show].freeze
+ include Shunter::Integration::Throttle
+
# rubocop:disable Metrics/MethodLength
api :get, '/repp/v1/invoices'
desc 'Get all invoices'
diff --git a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb
index c55a561d2..dfb1fc3b0 100644
--- a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb
+++ b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb
@@ -3,8 +3,11 @@ module Repp
module Registrar
class AccreditationInfoController < BaseController
if Feature.allow_accr_endspoints?
- api :GET, 'repp/v1/registrar/accreditation/get_info'
- desc 'check login user and return data'
+ THROTTLED_ACTIONS = %i[index].freeze
+ include Shunter::Integration::Throttle
+
+ api :GET, 'repp/v1/registrar/accreditation/get_info'
+ desc 'check login user and return data'
def index
login = current_user
diff --git a/app/controllers/repp/v1/registrar/auth_controller.rb b/app/controllers/repp/v1/registrar/auth_controller.rb
index 46c21459e..5da1b3a38 100644
--- a/app/controllers/repp/v1/registrar/auth_controller.rb
+++ b/app/controllers/repp/v1/registrar/auth_controller.rb
@@ -6,6 +6,9 @@ module Repp
skip_before_action :check_ip_restriction, only: :tara_callback
skip_before_action :validate_client_certs, only: :tara_callback
+ THROTTLED_ACTIONS = %i[index tara_callback].freeze
+ include Shunter::Integration::Throttle
+
api :GET, 'repp/v1/registrar/auth'
desc 'check user auth info and return data'
def index
diff --git a/app/controllers/repp/v1/registrar/nameservers_controller.rb b/app/controllers/repp/v1/registrar/nameservers_controller.rb
index b3c6d8412..1014ddc0d 100644
--- a/app/controllers/repp/v1/registrar/nameservers_controller.rb
+++ b/app/controllers/repp/v1/registrar/nameservers_controller.rb
@@ -4,6 +4,9 @@ module Repp
class NameserversController < BaseController
before_action :verify_nameserver_existance, only: %i[update]
+ THROTTLED_ACTIONS = %i[put].freeze
+ include Shunter::Integration::Throttle
+
api :PUT, 'repp/v1/registrar/nameservers'
desc 'bulk nameserver change'
param :data, Hash, required: true, desc: 'Object holding nameserver changes' do
diff --git a/app/controllers/repp/v1/registrar/notifications_controller.rb b/app/controllers/repp/v1/registrar/notifications_controller.rb
index 6b1d342cc..eb3d158ad 100644
--- a/app/controllers/repp/v1/registrar/notifications_controller.rb
+++ b/app/controllers/repp/v1/registrar/notifications_controller.rb
@@ -4,6 +4,9 @@ module Repp
class NotificationsController < BaseController
before_action :set_notification, only: %i[update show]
+ THROTTLED_ACTIONS = %i[all_notifications index show update].freeze
+ include Shunter::Integration::Throttle
+
api :GET, '/repp/v1/registrar/notifications'
desc 'Get the latest unread poll message'
def index
diff --git a/app/controllers/repp/v1/registrar/summary_controller.rb b/app/controllers/repp/v1/registrar/summary_controller.rb
index a0e266e93..eaa3b0f57 100644
--- a/app/controllers/repp/v1/registrar/summary_controller.rb
+++ b/app/controllers/repp/v1/registrar/summary_controller.rb
@@ -2,6 +2,9 @@ module Repp
module V1
module Registrar
class SummaryController < BaseController
+ THROTTLED_ACTIONS = %i[index].freeze
+ include Shunter::Integration::Throttle
+
api :GET, 'repp/v1/registrar/summary'
desc 'check user summary info and return data'
diff --git a/app/controllers/repp/v1/registrar/xml_console_controller.rb b/app/controllers/repp/v1/registrar/xml_console_controller.rb
new file mode 100644
index 000000000..cedf23819
--- /dev/null
+++ b/app/controllers/repp/v1/registrar/xml_console_controller.rb
@@ -0,0 +1,55 @@
+module Repp
+ module V1
+ module Registrar
+ class XmlConsoleController < BaseController
+ include EppRequestable
+
+ THROTTLED_ACTIONS = %i[load_xml].freeze
+ include Shunter::Integration::Throttle
+
+ PREFS = %w[domain-ee contact-ee eis epp-ee].freeze
+
+ SCHEMA_VERSIONS = {
+ 'epp-ee' => '1.0',
+ 'eis' => '1.0',
+ 'contact-ee' => '1.1',
+ 'default' => '1.2',
+ }.freeze
+
+ def load_xml
+ cl_trid = "#{current_user.username}-#{Time.zone.now.to_i}"
+ obj = ActionController::Base.helpers.sanitize(params[:obj])
+ epp_action = ActionController::Base.helpers.sanitize(params[:epp_action])
+ xml_dir_path = Rails.root.join('app/views/epp/sample_requests').to_s
+ xml = File.read("#{xml_dir_path}/#{obj}/#{epp_action}.xml")
+ xml = prepare_payload(xml, cl_trid)
+
+ render_success(data: { xml: xml })
+ end
+
+ private
+
+ def prepare_payload(xml, cl_trid)
+ PREFS.map do |pref|
+ xml = load_schema_by_prefix(pref, xml)
+ end
+
+ xml.gsub!('ABC-12345 ', "#{cl_trid} ")
+ xml
+ end
+
+ def load_schema_by_prefix(pref, xml)
+ version = version_by_prefix(pref)
+ xml.gsub!("\"#{pref}\"",
+ "\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"")
+ xml
+ end
+
+ def version_by_prefix(pref)
+ key = SCHEMA_VERSIONS.key?(pref) ? pref : 'default'
+ SCHEMA_VERSIONS[key]
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/repp/v1/stats_controller.rb b/app/controllers/repp/v1/stats_controller.rb
index 480c81a6b..ae8489c34 100644
--- a/app/controllers/repp/v1/stats_controller.rb
+++ b/app/controllers/repp/v1/stats_controller.rb
@@ -90,6 +90,8 @@ module Repp
def calculate_market_share(domains_by_rar)
sum = domains_by_rar.values.sum
+ return domains_by_rar if sum.zero?
+
domains_by_rar.transform_values do |v|
value = v.to_f / sum * 100.0
value < 0.1 ? value.round(3) : value.round(1)
diff --git a/app/helpers/registrar/application_helper.rb b/app/helpers/registrar/application_helper.rb
deleted file mode 100644
index 7710cf55c..000000000
--- a/app/helpers/registrar/application_helper.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module Registrar::ApplicationHelper
- def env_style
- return '' if unstable_env.nil?
- "background-image: url(#{image_path("registrar/bg-#{unstable_env}.png")});"
- end
-end
diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb
index ff6eccce2..ca2814fdf 100644
--- a/app/interactions/actions/domain_update.rb
+++ b/app/interactions/actions/domain_update.rb
@@ -30,7 +30,7 @@ module Actions
end
def check_for_same_contacts(contacts, contact_type)
- return unless contacts.uniq.count != contacts.count
+ return if contacts.uniq.count == contacts.count
domain.add_epp_error('2306', contact_type, nil, %i[domain_contacts invalid])
end
@@ -194,22 +194,33 @@ module Actions
def contact_for_action(action:, method:, code:)
contact = Epp::Contact.find_by(code: code)
return contact if action == 'add' || !contact
- return domain.admin_domain_contacts.find_by(contact_id: contact.id) if method == 'admin'
- domain.tech_domain_contacts.find_by(contact_id: contact.id)
+ existing_contact(id: contact.id, admin: method == 'admin')
end
- def assign_contact(obj, add: false, admin: true, code:)
+ def existing_contact(id:, admin: true)
+ return domain.admin_domain_contacts.find_by(contact_id: id) if admin
+
+ domain.tech_domain_contacts.find_by(contact_id: id)
+ end
+
+ def assign_contact(obj, code:, add: false, admin: true)
if obj.blank?
domain.add_epp_error('2303', 'contact', code, %i[domain_contacts not_found])
elsif obj.try(:org?) && admin && add
domain.add_epp_error('2306', 'contact', code,
%i[domain_contacts admin_contact_can_be_only_private_person])
else
- add ? { contact_id: obj.id, contact_code: obj.code } : { id: obj.id, _destroy: 1 }
+ assigned_contact_hash(obj, add, admin)
end
end
+ def assigned_contact_hash(obj, add, admin)
+ return if !existing_contact(id: obj.id, admin: admin).nil? && add
+
+ add ? { contact_id: obj.id, contact_code: obj.code } : { id: obj.id, _destroy: 1 }
+ end
+
def assign_requested_statuses
return unless params[:statuses]
diff --git a/app/interactions/actions/email_check.rb b/app/interactions/actions/email_check.rb
index 6631569f8..67c049cb3 100644
--- a/app/interactions/actions/email_check.rb
+++ b/app/interactions/actions/email_check.rb
@@ -11,7 +11,6 @@ module Actions
def call
result = check_email(email)
save_result(result)
- filtering_old_failed_records(result)
result.success ? log_success : log_failure(result)
result.success
end
@@ -26,27 +25,25 @@ module Actions
Rails.env.test? && check_level == 'smtp' ? :mx : check_level.to_sym
end
- def filtering_old_failed_records(result)
- if @check_level == "mx" && !result.success && validation_eventable.validation_events.count > 3
- validation_eventable.validation_events.order!(created_at: :asc)
- while validation_eventable.validation_events.count > 3
- validation_eventable.validation_events.first.destroy
- end
+ def filtering_old_failed_records(result, contact)
+ ValidationEvent::INVALID_EVENTS_COUNT_BY_LEVEL.each do |level, limit|
+ handle_failed_records(contact: contact, check_level: level, limit: limit, success: result.success)
end
+ end
- if @check_level == "mx" && result.success && validation_eventable.validation_events.count > 1
- validation_eventable.validation_events.order!(created_at: :asc)
- while validation_eventable.validation_events.count > 1
- validation_eventable.validation_events.first.destroy
+ def handle_failed_records(contact:, check_level:, limit:, success:)
+ if @check_level.to_sym == check_level && !success && contact.validation_events.count > limit
+ contact.validation_events.order!(created_at: :asc)
+ while contact.validation_events.count > limit
+ contact.validation_events.first.destroy
end
end
+ end
- if @check_level == "smtp" && validation_eventable.validation_events.count > 1
- validation_eventable.validation_events.order!(created_at: :asc)
- while validation_eventable.validation_events.count > 1
- validation_eventable.validation_events.first.destroy
- end
- end
+ def filtering_old_records(contact:, success:)
+ return unless success
+
+ contact.validation_events.destroy_all
end
def save_result(result)
@@ -61,9 +58,14 @@ module Actions
result.success = result_validation.present?
end
+ result.configuration = nil
+
contacts.find_in_batches(batch_size: 500) do |contact_batches|
contact_batches.each do |contact|
+ # methods should be in this order!
+ filtering_old_records(contact: contact, success: result.success)
contact.validation_events.create(validation_event_attrs(result))
+ filtering_old_failed_records(result, contact)
end
end
rescue ActiveRecord::RecordNotSaved
diff --git a/app/jobs/check_force_delete_lift.rb b/app/jobs/check_force_delete_lift.rb
index 4ad43fb4a..524c4bcdc 100644
--- a/app/jobs/check_force_delete_lift.rb
+++ b/app/jobs/check_force_delete_lift.rb
@@ -6,8 +6,8 @@ class CheckForceDeleteLift < ApplicationJob
.select { |d| d.registrant.need_to_lift_force_delete? }
handle_refresh_status(domains) if domains.present?
- domains = Domain.where("force_delete_data->'template_name' = ?", 'invalid_email')
- .where("force_delete_data->'force_delete_type' = ?", 'soft')
+ domains = (domains + Domain.where("force_delete_data->'template_name' = ?", 'invalid_email')
+ .where("force_delete_data->'force_delete_type' = ?", 'soft')).uniq
domains.each do |domain|
Domains::ForceDeleteLift::Base.run(domain: domain)
@@ -39,15 +39,5 @@ class CheckForceDeleteLift < ApplicationJob
domain.status_notes[DomainStatus::FORCE_DELETE].slice!(registrant.email_history)
domain.status_notes[DomainStatus::FORCE_DELETE].lstrip!
domain.save(validate: false)
-
- notify_registrar(domain) unless domain.status_notes[DomainStatus::FORCE_DELETE].empty?
- end
-
- def notify_registrar(domain)
- domain.registrar.notifications.create!(text: I18n.t('force_delete_auto_email',
- domain_name: domain.name,
- outzone_date: domain.outzone_date,
- purge_date: domain.purge_date,
- email: domain.status_notes[DomainStatus::FORCE_DELETE]))
end
end
diff --git a/app/jobs/outzone_invalid_email_domains_job.rb b/app/jobs/outzone_invalid_email_domains_job.rb
new file mode 100644
index 000000000..95da4944b
--- /dev/null
+++ b/app/jobs/outzone_invalid_email_domains_job.rb
@@ -0,0 +1,21 @@
+class OutzoneInvalidEmailDomainsJob < ApplicationJob
+ queue_as :default
+
+ def perform
+ domains = Domain.where("force_delete_data->'template_name' = ?", 'invalid_email')
+ .where(outzone_at: nil)
+ .where('Date(force_delete_start) <= ?', Time.zone.now)
+
+ domains.each do |domain|
+ outzone(domain)
+ end
+ end
+
+ private
+
+ def outzone(domain)
+ domain.outzone_at = domain.force_delete_start + Domain.expire_warning_period
+ domain.delete_date = domain.outzone_at + Domain.redemption_grace_period
+ domain.save
+ end
+end
diff --git a/app/jobs/send_monthly_invoices_job.rb b/app/jobs/send_monthly_invoices_job.rb
index 3f86df8aa..cd553237f 100644
--- a/app/jobs/send_monthly_invoices_job.rb
+++ b/app/jobs/send_monthly_invoices_job.rb
@@ -2,8 +2,9 @@ class SendMonthlyInvoicesJob < ApplicationJob
queue_as :default
discard_on StandardError
- def perform(dry: false, months_ago: 1)
+ def perform(dry: false, months_ago: 1, overwrite: false)
@dry = dry
+ @overwrite = overwrite
@month = Time.zone.now - months_ago.month
@directo_data = []
@@ -48,7 +49,7 @@ class SendMonthlyInvoicesJob < ApplicationJob
def find_or_init_monthly_invoices(invoices: [])
Registrar.with_cash_accounts.find_each do |registrar|
- invoice = registrar.find_or_init_monthly_invoice(month: @month)
+ invoice = registrar.find_or_init_monthly_invoice(month: @month, overwrite: @overwrite)
invoices << invoice unless invoice.nil?
end
invoices
diff --git a/app/lib/shunter.rb b/app/lib/shunter.rb
new file mode 100644
index 000000000..b06de6b9f
--- /dev/null
+++ b/app/lib/shunter.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Shunter
+ module_function
+
+ class ThrottleError < StandardError; end
+
+ BASE_LOGGER = ::Logger.new($stdout)
+ ONE_MINUTE = 60
+ ONE_HUNDRED_REQUESTS = 100
+
+ BASE_CONNECTION = {
+ host: ENV['shunter_redis_host'] || 'redis',
+ port: (ENV['shunter_redis_port'] || '6379').to_i,
+ }.freeze
+
+ def default_error_message
+ "Session limit exceeded. Current limit is #{default_threshold} in #{default_timespan} seconds"
+ end
+
+ def default_timespan
+ ENV['shunter_default_timespan'] || ONE_MINUTE
+ end
+
+ def default_threshold
+ ENV['shunter_default_threshold'] || ONE_HUNDRED_REQUESTS
+ end
+
+ def default_adapter
+ ENV['shunter_default_adapter'] || 'Shunter::Adapters::Redis'
+ end
+
+ def feature_enabled?
+ ActiveModel::Type::Boolean.new.cast(ENV['shunter_enabled'] || 'false')
+ end
+end
diff --git a/app/lib/shunter/adapters/memory.rb b/app/lib/shunter/adapters/memory.rb
new file mode 100644
index 000000000..eb0b25b27
--- /dev/null
+++ b/app/lib/shunter/adapters/memory.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Shunter
+ module Adapters
+ class Memory
+ attr_reader :store
+
+ def initialize(_options = {})
+ @@store ||= {}
+ end
+
+ def find_counter(key)
+ @@store[key]
+ end
+
+ def write_counter(key)
+ @@store[key] = 1
+ end
+
+ def increment_counter(key)
+ @@store[key] += 1
+ end
+
+ def clear!
+ @@store = {}
+ end
+
+ def expire_counter(_key, _timespan); end
+ end
+ end
+end
diff --git a/app/lib/shunter/adapters/redis.rb b/app/lib/shunter/adapters/redis.rb
new file mode 100644
index 000000000..adf27b359
--- /dev/null
+++ b/app/lib/shunter/adapters/redis.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Shunter
+ module Adapters
+ class Redis
+ attr_reader :redis
+
+ def initialize(options)
+ @redis = ::Redis.new(options)
+ end
+
+ def find_counter(key)
+ @redis.get(key)
+ end
+
+ def write_counter(key)
+ @redis.set(key, 1)
+ end
+
+ def increment_counter(key)
+ @redis.incr(key)
+ end
+
+ def expire_counter(key, timespan)
+ @redis.expire(key, timespan)
+ end
+ end
+ end
+end
diff --git a/app/lib/shunter/base.rb b/app/lib/shunter/base.rb
new file mode 100644
index 000000000..f3f6867f0
--- /dev/null
+++ b/app/lib/shunter/base.rb
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+module Shunter
+ class Base
+ attr_accessor :user_id, :adapter
+
+ def initialize(options = {})
+ @user_id = options[:user_id]
+ adapter_klass = Shunter.default_adapter.constantize
+ @adapter = adapter_klass.new(options[:conn_options])
+ end
+
+ def user_key
+ "counting_#{@user_id}"
+ end
+
+ def blocked_user_key
+ "blocked_#{@user_id}"
+ end
+
+ def throttle
+ return false if blocked?
+
+ valid_counter?
+ end
+
+ def blocked?
+ adapter.find_counter(blocked_user_key).present?
+ end
+
+ def valid_counter?
+ if adapter.find_counter(user_key)
+ number_of_requests = adapter.increment_counter(user_key)
+ if number_of_requests > allowed_requests.to_i
+ init_counter(blocked_user_key)
+ return false
+ end
+ else
+ init_counter(user_key)
+ end
+ true
+ end
+
+ private
+
+ def init_counter(key)
+ adapter.write_counter(key)
+ adapter.expire_counter(key, timespan)
+ end
+
+ def allowed_requests
+ Shunter.default_threshold
+ end
+
+ def timespan
+ Shunter.default_timespan
+ end
+
+ def logger
+ Shunter::BASE_LOGGER
+ end
+ end
+end
diff --git a/app/lib/shunter/integration/throttle.rb b/app/lib/shunter/integration/throttle.rb
new file mode 100644
index 000000000..39d83ad76
--- /dev/null
+++ b/app/lib/shunter/integration/throttle.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'active_support/concern'
+
+module Shunter
+ module Integration
+ module Throttle
+ extend ActiveSupport::Concern
+
+ included do |base|
+ actions = base.const_defined?('THROTTLED_ACTIONS') && base.const_get('THROTTLED_ACTIONS')
+ return if actions.blank?
+
+ around_action :throttle, only: actions
+
+ def throttle
+ if throttled_user.blank? || !Shunter.feature_enabled?
+ yield if block_given?
+ return
+ end
+
+ user_id = throttled_user.id
+
+ shunter = Shunter::Base.new(conn_options: connection_options, user_id: user_id)
+ if shunter.throttle
+ logger.info "Request from #{throttled_user.class}/#{throttled_user.id} is coming through throttling"
+ yield if block_given?
+ else
+ logger.info "Too many requests from #{throttled_user.class}/#{throttled_user.id}." unless Rails.env.test?
+ raise Shunter::ThrottleError
+ end
+ end
+ end
+
+ def connection_options
+ Shunter::BASE_CONNECTION
+ end
+
+ def logger
+ Shunter::BASE_LOGGER
+ end
+ end
+ end
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 31543a586..04d820544 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -31,12 +31,6 @@ class Ability
end
def epp # Registrar/api_user dynamic role
- if @user.registrar.api_ip_white?(@ip)
- can :manage, Depp::Contact
- can :manage, :xml_console
- can :manage, Depp::Domain
- end
-
can :manage, Account
# Poll
@@ -122,7 +116,6 @@ class Ability
customer_service
can :manage, :registrant_domains
can :manage, :registrant_whois
- can :manage, Depp::Domain
can :manage, Domain
end
diff --git a/app/models/auction.rb b/app/models/auction.rb
index d1c46d44e..f0aa1fe6d 100644
--- a/app/models/auction.rb
+++ b/app/models/auction.rb
@@ -37,6 +37,24 @@ class Auction < ApplicationRecord
find_by(domain: domain_name.to_s, status: PENDING_STATUSES)
end
+ def self.domain_exists_in_blocked_disputed_and_registered?(domain_name)
+ Domain.exists?(name: domain_name) ||
+ BlockedDomain.exists?(name: domain_name) ||
+ Dispute.exists?(domain_name: domain_name) ||
+ exception_for_registred_or_unbided_existed_auctions(domain_name)
+ end
+
+ def self.exception_for_registred_or_unbided_existed_auctions(domain_name)
+ return false unless Auction.exists?(domain: domain_name)
+
+ auctions = Auction.where(domain: domain_name).order(:created_at)
+ last_record = auctions.last
+
+ return false if last_record.domain_registered? || last_record.no_bids?
+
+ true
+ end
+
def start
self.status = self.class.statuses[:started]
save!
diff --git a/app/models/concerns/invoice/book_keeping.rb b/app/models/concerns/invoice/book_keeping.rb
index 895b763cf..2c9b8a5ca 100644
--- a/app/models/concerns/invoice/book_keeping.rb
+++ b/app/models/concerns/invoice/book_keeping.rb
@@ -59,8 +59,9 @@ module Invoice::BookKeeping
duration.times do |dur|
single_item_dup = single_item.dup
- single_item_dup['start_date'] = (issue_date + dur.year).end_of_month.strftime('%Y-%m-%d')
- single_item_dup['end_date'] = (issue_date + (dur + 1).year).end_of_month.strftime('%Y-%m-%d')
+ date = (issue_date + dur.year).end_of_month.strftime('%Y-%m-%d')
+ single_item_dup['start_date'] = date
+ single_item_dup['end_date'] = date
single_item_dup['price'] = (item['price'].to_f / duration).round(2)
lines << single_item_dup
end
diff --git a/app/models/concerns/registrar/book_keeping.rb b/app/models/concerns/registrar/book_keeping.rb
index b013de9cd..746bff331 100644
--- a/app/models/concerns/registrar/book_keeping.rb
+++ b/app/models/concerns/registrar/book_keeping.rb
@@ -38,15 +38,26 @@ module Registrar::BookKeeping
lines.as_json
end
- def find_or_init_monthly_invoice(month:)
+ def find_or_init_monthly_invoice(month:, overwrite:)
invoice = invoices.find_by(monthly_invoice: true, issue_date: month.end_of_month.to_date,
cancelled_at: nil)
- return invoice if invoice
+ return invoice if invoice && !overwrite
summary = monthly_summary(month: month)
return unless summary
- init_monthly_invoice(summary)
+ new_invoice = init_monthly_invoice(summary)
+ return overwrite_invoice(invoice, new_invoice) if invoice && overwrite
+
+ new_invoice
+ end
+
+ def overwrite_invoice(original_invoice, new_invoice)
+ params_to_scrub = %i[created_at updated_at id number sent_at
+ e_invoice_sent_at in_directo cancelled_at payment_link]
+ attrs = new_invoice.attributes.with_indifferent_access.except(*params_to_scrub)
+ original_invoice.update(attrs)
+ original_invoice
end
def title_for_summary(date)
diff --git a/app/models/concerns/zone/whois_queryable.rb b/app/models/concerns/zone/whois_queryable.rb
index 7c6ff511d..fe5da8ffb 100644
--- a/app/models/concerns/zone/whois_queryable.rb
+++ b/app/models/concerns/zone/whois_queryable.rb
@@ -32,27 +32,40 @@ module Zone::WhoisQueryable
# 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,
+ {
+ 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 }
+ 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 }
+ {
+ 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] }
+ {
+ 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 phone],
+ }
end
def contact_vars
- { name: Setting.registry_invoice_contact, email: Setting.registry_email,
- disclosed_attributes: %w[name email] }
+ {
+ name: Setting.registry_invoice_contact,
+ email: Setting.registry_email,
+ disclosed_attributes: %w[name email],
+ }
end
def nameserver_vars
diff --git a/app/models/contact.rb b/app/models/contact.rb
index e4628e3c0..36784509b 100644
--- a/app/models/contact.rb
+++ b/app/models/contact.rb
@@ -64,6 +64,8 @@ class Contact < ApplicationRecord
validate :validate_html
validate :validate_country_code, if: -> { self.class.address_processing? }
+ validates :registrant_publishable, inclusion: { in: [true, false] }, if: -> { registrant? }
+ # validates :registrant_publishable, inclusion: { in: [false] }, unless: -> { registrant? }
after_initialize do
self.status_notes = {} if status_notes.nil?
@@ -145,6 +147,19 @@ class Contact < ApplicationRecord
# "clientDeleteProhibited" or "serverDeleteProhibited" status.
PENDING_DELETE = 'pendingDelete'.freeze
+ DISCLOSE_ATTRIBUTES = %w[
+ name
+ email
+ phone
+ registrant_publishable
+ address
+ fax
+ ].freeze
+
+ OPEN_LEGAL_ATTRIBUTES = %w[
+ phone
+ ].freeze
+
STATUSES = [
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED,
CLIENT_TRANSFER_PROHIBITED,
diff --git a/app/models/contact_request.rb b/app/models/contact_request.rb
index f4c6db716..9dc028885 100644
--- a/app/models/contact_request.rb
+++ b/app/models/contact_request.rb
@@ -15,15 +15,6 @@ class ContactRequest < ApplicationRecord
attr_readonly :secret,
:valid_to
- def self.save_record(params)
- contact_request = new(params)
- contact_request.secret = create_random_secret
- contact_request.valid_to = set_valid_to_24_hours_from_now
- contact_request.status = STATUS_NEW
- contact_request.save!
- contact_request
- end
-
def update_record(params)
self.status = params['status'] if params['status']
self.ip_address = params['ip'] if params['ip']
@@ -31,11 +22,22 @@ class ContactRequest < ApplicationRecord
save!
end
- def self.create_random_secret
- SecureRandom.hex(64)
- end
+ class << self
+ def save_record(params)
+ contact_request = new(params)
+ contact_request.secret = create_random_secret
+ contact_request.valid_to = set_valid_to_24_hours_from_now
+ contact_request.status = STATUS_NEW
+ contact_request.save!
+ contact_request
+ end
- def self.set_valid_to_24_hours_from_now
- (Time.zone.now + 24.hours)
+ def create_random_secret
+ SecureRandom.hex(64)
+ end
+
+ def set_valid_to_24_hours_from_now
+ (Time.zone.now + 24.hours)
+ end
end
end
diff --git a/app/models/depp/concerns/.keep b/app/models/depp/concerns/.keep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb
deleted file mode 100644
index 7007bcd00..000000000
--- a/app/models/depp/contact.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-module Depp
- class Contact
- include ActiveModel::Model
-
- attr_accessor :id, :name, :email, :phone, :org_name,
- :ident, :ident_type, :ident_country_code,
- :street, :city, :zip, :state, :country_code,
- :password, :legal_document, :statuses, :code,
- :email_history
-
- DISABLED = 'Disabled'
- DISCLOSURE_TYPES = [DISABLED, '1', '0']
- TYPES = %w( org priv birthday )
- SELECTION_TYPES = [
- ['Business code', 'org'],
- ['Personal identification code', 'priv'],
- ['Birthday', 'birthday']
- ]
-
- validates :phone, e164: true, phone: true
-
- class << self
- attr_reader :epp_xml, :user
-
- def new_from_params(params)
- new(
- id: params[:code],
- code: params[:code],
- email: params[:email],
- phone: params[:phone],
- ident: params[:ident],
- ident_type: params[:ident_type],
- ident_country_code: params[:ident_country_code],
-
- # postalInfo
- name: params[:name],
- org_name: params[:org_name],
-
- # address
- street: params[:street],
- city: params[:city],
- zip: params[:zip],
- state: params[:state],
- country_code: params[:country_code]
- )
- end
-
- def find_by_id(id)
- data = info_xml(id)
-
- res = data.css('epp response resData infData')
- ext = data.css('epp response extension')
- new(
- id: res.css('id').text,
- code: res.css('id').text,
- email: res.css('email').text,
- phone: res.css('voice').text,
- ident: ext.css('ident').text,
- ident_type: ext.css('ident').first.try(:attributes).try(:[], 'type').try(:value),
- ident_country_code: ext.css('ident').first.try(:attributes).try(:[], 'cc').try(:value),
-
- # postalInfo
- name: res.css('postalInfo name').text,
- org_name: res.css('postalInfo org').text,
-
- # address
- street: res.css('postalInfo addr street').text,
- city: res.css('postalInfo addr city').text,
- zip: res.css('postalInfo addr pc').text,
- state: res.css('postalInfo addr sp').text,
- country_code: res.css('postalInfo addr cc').text,
-
- # authInfo
- password: res.css('authInfo pw').text,
-
- # statuses
- statuses: data.css('status').map { |s| [s['s'], s.text] }
- )
- end
-
- def user=(user)
- @user = user
- @epp_xml = EppXml::Contact.new(cl_trid_prefix: user.tag, schema_prefix: 'contact-ee',
- schema_version: '1.1')
- end
-
- def info_xml(id, password = nil)
- xml = epp_xml.info(
- id: { value: id },
- authInfo: { pw: { value: password } }
- )
- user.request(xml)
- end
-
- def construct_check_hash_from_data(data)
- res = data.css('epp response resData chkData cd')
- @contacts = []
- res.each do |_r|
- id = res.css('id').try(:text)
- reason = res.css('reason').present? ? res.css('reason').text : I18n.t(:available)
- @contacts << { id: id, reason: reason }
- end
- @contacts
- end
-
- def contact_id_from_xml(data)
- id = data.css('epp response resData creData id').text
- id.blank? ? nil : id
- end
-
- def construct_create_disclosure_xml(cph, flag)
- xml = { disclose: {} }
- cph.each do |k, v|
- xml[:disclose][k] = {}
- xml[:disclose][k][:value] = v
- end
- xml[:disclose][:attrs] = {}
- xml[:disclose][:attrs][:flag] = flag
- xml.with_indifferent_access
- end
-
- # cpd = contact_params[:disclose]
- def extract_disclosure_hash(cpd)
- return {} unless cpd
-
- cpd.delete_if { |k, v| v if v != '1' && k == 'flag' }
- end
-
- def extract_info_disclosure(data)
- hash = {}
- data.css('disclose').each do |d|
- flag = d.attributes['flag'].value
- next unless flag
- hash[flag] = {}
- d.children.each do |c|
- hash[flag][c.name] = flag if %w( name email fax voice addr org_name ).include?(c.name)
- end
- end
- hash
- end
-
- def type_string(type_code)
- return '' if type_code.blank?
- t = SELECTION_TYPES.select { |tp| tp.second == type_code }
- t.try(:first).try(:first)
- end
- end
-
- def save
- return false unless valid?
-
- hash = {
- id: { value: code },
- postalInfo: {
- name: { value: name },
- org: { value: org_name },
- },
- voice: { value: phone },
- email: { value: email }
- }
-
- if ::Contact.address_processing?
- hash[:postalInfo][:addr] = {
- street: { value: street },
- city: { value: city },
- sp: { value: state },
- pc: { value: zip },
- cc: { value: country_code },
- }
- end
-
- hash[:id] = nil if code.blank?
- create_xml = Depp::Contact.epp_xml.create(hash, extension_xml(:create))
- data = Depp::Contact.user.request(create_xml)
- self.id = data.css('id').text
- handle_errors(data)
- end
-
- # rubocop:disable Metrics/MethodLength
- def update_attributes(params)
- return false unless valid?
-
- self.ident_country_code = params[:ident_country_code]
- self.ident_type = params[:ident_type]
- self.ident = params[:ident]
-
- self.name = params[:name]
- self.email = params[:email]
- self.phone = params[:phone]
-
- self.org_name = params[:org_name]
-
- if ::Contact.address_processing?
- self.street = params[:street]
- self.city = params[:city]
- self.zip = params[:zip]
- self.state = params[:state]
- self.country_code = params[:country_code]
- end
-
- attributes = {
- id: { value: id },
- chg: {
- postalInfo: {
- name: { value: name },
- org: { value: org_name },
- },
- voice: { value: phone },
- email: { value: email },
- authInfo: {
- pw: { value: password }
- }
- }
- }
-
- if ::Contact.address_processing?
- attributes[:chg][:postalInfo][:addr] = {
- street: { value: street },
- city: { value: city },
- sp: { value: state },
- pc: { value: zip },
- cc: { value: country_code }
- }
- end
-
- update_xml = Depp::Contact.epp_xml.update(attributes, extension_xml(:update))
- data = Depp::Contact.user.request(update_xml)
- handle_errors(data)
- end
- # rubocop:enable Metrics/MethodLength
-
- def delete
- delete_xml = Contact.epp_xml.delete(
- {
- id: { value: id },
- authInfo: { pw: { value: password } }
- },
- extension_xml(:delete)
- )
- data = Depp::Contact.user.request(delete_xml)
- handle_errors(data)
- end
-
- def extension_xml(action)
- xml = { _anonymus: [] }
-
- case action
- when :create
- ident = ident_xml[:_anonymus].try(:first)
- when :update
- # detect if any ident has changed, nb! ident and self.ident is not always same
- unless ident == self.ident && ident == ident_type && ident_country_code == self.ident_country_code
- ident = ident_xml[:_anonymus].try(:first)
- end
- end
-
- legal = legal_document_xml[:_anonymus].try(:first)
- xml[:_anonymus] << ident if ident.present?
- xml[:_anonymus] << legal if legal.present?
- xml
- end
-
- def ident_xml
- {
- _anonymus: [
- ident: { value: ident, attrs: { type: ident_type, cc: ident_country_code } }
- ]
- }
- end
-
- def legal_document_xml
- return {} if legal_document.blank?
-
- type = legal_document.original_filename.split('.').last.downcase
- {
- _anonymus: [
- legalDocument: { value: Base64.encode64(legal_document.read), attrs: { type: type } }
- ]
- }
- end
-
- def check(id)
- xml = epp_xml.check(id: { value: id })
- current_user.request(xml)
- end
-
- def country_name
- Country.new(country_code) || 'No access'
- end
-
- def org?
- ident_type == 'org'
- end
-
- def priv?
- ident_type == 'priv'
- end
-
- def persisted?
- id.present?
- end
-
- def handle_errors(data)
- data.css('result').each do |x|
- success_codes = %(1000, 1300, 1301)
- next if success_codes.include?(x['code'])
-
- message = "#{x.css('msg').text} #{x.css('value').text}"
- attr = message.split('[').last.strip.sub(']', '') if message.include?('[')
- attr = :base if attr.nil?
- attr = 'phone' if attr == 'voice'
- attr = 'zip' if attr == 'pc'
- errors.add(attr, message)
- end
- errors.blank?
- end
- end
-end
diff --git a/app/models/depp/dnskey.rb b/app/models/depp/dnskey.rb
deleted file mode 100644
index f4e99eb6d..000000000
--- a/app/models/depp/dnskey.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-module Depp
- class Dnskey
- FLAGS = [
- ['0 - not for DNSSEC validation', 0],
- ['256 - ZSK', 256],
- ['257 - KSK', 257]
- ]
-
- ALGORITHMS = [
- ['3 - DSA/SHA-1', 3],
- ['5 - RSA/SHA-1', 5],
- ['6 - DSA-NSEC3-SHA1', 6],
- ['7 - RSASHA1-NSEC3-SHA1', 7],
- ['8 - RSA/SHA-256', 8],
- ['10 - RSA/SHA-512', 10],
- ['13 - ECDSA Curve P-256 with SHA-256', 13],
- ['14 - ECDSA Curve P-384 with SHA-384', 14],
- ['15 - Ed25519', 15],
- ['16 - Ed448', 16],
- ].freeze
-
- PROTOCOLS = [3]
-
- DS_DIGEST_TYPES = [1, 2]
- end
-end
diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb
deleted file mode 100644
index 0df6ae2b1..000000000
--- a/app/models/depp/domain.rb
+++ /dev/null
@@ -1,351 +0,0 @@
-module Depp
- class Domain
- include ActiveModel::Conversion
- include RemoveHold
- extend ActiveModel::Naming
-
- attr_accessor :name, :current_user, :epp_xml
-
- STATUSES = %w[
- clientDeleteProhibited
- clientHold
- clientRenewProhibited
- clientTransferProhibited
- clientUpdateProhibited
- ].freeze
-
- PERIODS = [
- ['3 months', '3m'],
- ['6 months', '6m'],
- ['9 months', '9m'],
- ['1 year', '1y'],
- ['2 years', '2y'],
- ['3 years', '3y'],
- ['4 years', '4y'],
- ['5 years', '5y'],
- ['6 years', '6y'],
- ['7 years', '7y'],
- ['8 years', '8y'],
- ['9 years', '9y'],
- ['10 years', '10y'],
- ].freeze
-
- def initialize(args = {})
- self.current_user = args[:current_user]
- self.epp_xml = EppXml::Domain.new(
- cl_trid_prefix: current_user.tag,
- schema_prefix: 'domain-ee',
- schema_version: '1.1'
- )
- end
-
- def info(domain_name)
- xml = epp_xml.info(name: { value: domain_name })
- current_user.request(xml)
- end
-
- def check(domain_name)
- xml = epp_xml.check(
- _anonymus: [
- name: { value: domain_name }
- ]
- )
- current_user.request(xml)
- end
-
- def create(domain_params)
- dns_hash = {}
- keys = Domain.create_dnskeys_hash(domain_params)
- dns_hash[:_anonymus] = keys if keys.any?
-
- period = domain_params[:period].to_i.to_s
- period_unit = domain_params[:period][-1].to_s
-
- xml = if domain_params[:nameservers_attributes]
- .select { |_key, value| value['hostname'].present? }.any?
- epp_xml.create({
- name: { value: domain_params[:name] },
- period: { value: period, attrs: { unit: period_unit } },
- ns: Domain.create_nameservers_hash(domain_params),
- registrant: { value: domain_params[:registrant] },
- _anonymus: Domain.create_contacts_hash(domain_params)
- }, dns_hash, Domain.construct_custom_params_hash(domain_params))
- else
- epp_xml.create({
- name: { value: domain_params[:name] },
- period: { value: period, attrs: { unit: period_unit } },
- registrant: { value: domain_params[:registrant] },
- _anonymus: Domain.create_contacts_hash(domain_params)
- }, dns_hash, Domain.construct_custom_params_hash(domain_params))
- end
-
- current_user.request(xml)
- end
-
- def update(domain_params)
- data = current_user.request(epp_xml.info(name: { value: domain_params[:name] }))
- old_domain_params = Depp::Domain.construct_params_from_server_data(data)
-
- xml = epp_xml.update(
- Depp::Domain.construct_edit_hash(domain_params, old_domain_params),
- Depp::Domain.construct_ext_edit_hash(domain_params, old_domain_params),
- Depp::Domain.construct_custom_params_hash(domain_params)
- )
-
- current_user.request(xml)
- end
-
- def delete(domain_params)
- xml = epp_xml.delete({
- name: { value: domain_params[:name] },
- },
- Depp::Domain.construct_custom_params_hash(domain_params),
- (domain_params[:verified].present? && 'yes'))
-
- current_user.request(xml)
- end
-
- def renew(params)
- period = params[:period].to_i.to_s
- period_unit = params[:period][-1].to_s
-
- current_user.request(epp_xml.renew(name: { value: params[:domain_name] },
- curExpDate: { value: params[:cur_exp_date] },
- period: { value: period, attrs: { unit: period_unit } }))
- end
-
- def transfer(params)
- op = params[:request] ? 'request' : nil
- op = params[:query] ? 'query' : op
- op = params[:approve] ? 'approve' : op
- op = params[:reject] ? 'reject' : op
-
- current_user.request(epp_xml.transfer({
- name: { value: params[:domain_name] },
- authInfo: { pw: { value: params[:transfer_code] } }
- }, op, Domain.construct_custom_params_hash(params)))
- end
-
- def confirm_transfer(domain_params)
- data = current_user.request(epp_xml.info(name: { value: domain_params[:name] }))
- pw = data.css('pw').text
-
- xml = epp_xml.transfer({
- name: { value: domain_params[:name] },
- authInfo: { pw: { value: pw } }
- }, 'approve')
-
- current_user.request(xml)
- end
-
- class << self
- def default_period
- '1y'
- end
-
- def default_params
- ret = {}
-
- ret[:contacts_attributes] ||= {}
- ENV['default_admin_contacts_count'].to_i.times do |i|
- ret[:contacts_attributes][i] = { code: '', type: 'admin' }
- end
-
- ret[:nameservers_attributes] ||= {}
- ENV['default_nameservers_count'].to_i.times do |i|
- ret[:nameservers_attributes][i] = {}
- end
-
- ret[:dnskeys_attributes] ||= { 0 => {} }
- ret[:statuses_attributes] ||= { 0 => {} }
- ret.with_indifferent_access
- end
-
- def construct_params_from_server_data(data)
- ret = default_params
- ret[:name] = data.css('name').text
- ret[:registrant] = data.css('registrant').text
-
- data.css('contact').each_with_index do |x, i|
- ret[:contacts_attributes][i] = { code: x.text, type: x['type'] }
- end
-
- data.css('hostAttr').each_with_index do |x, i|
- ret[:nameservers_attributes][i] = {
- hostname: x.css('hostName').text,
- ipv4: Array(x.css('hostAddr[ip="v4"]')).map(&:text).join(','),
- ipv6: Array(x.css('hostAddr[ip="v6"]')).map(&:text).join(',')
- }
- end
-
- data.css('keyData').each_with_index do |x, i|
- ret[:dnskeys_attributes][i] = {
- flags: x.css('flags').text,
- protocol: x.css('protocol').text,
- alg: x.css('alg').text,
- public_key: x.css('pubKey').text,
- ds_key_tag: x.css('keyTag').first.try(:text),
- ds_alg: x.css('alg').first.try(:text),
- ds_digest_type: x.css('digestType').first.try(:text),
- ds_digest: x.css('digest').first.try(:text)
- }
- end
-
- data.css('status').each_with_index do |x, i|
- next unless STATUSES.include?(x['s'])
-
- ret[:statuses_attributes][i] = {
- code: x['s'],
- description: x.text
- }
- end
-
- ret
- end
-
- def construct_custom_params_hash(domain_params)
- custom_params = { _anonymus: [] }
- if domain_params[:legal_document].present?
- type = domain_params[:legal_document].original_filename.split('.').last.downcase
- custom_params[:_anonymus] << {
- legalDocument: { value: Base64.encode64(domain_params[:legal_document].read), attrs: { type: type } }
- }
- end
-
- if domain_params[:reserved_pw].present?
- custom_params[:_anonymus] << { reserved: { pw: { value: domain_params[:reserved_pw] } } }
- end
-
- custom_params
- end
-
- def construct_edit_hash(domain_params, old_domain_params)
- contacts = array_difference(create_contacts_hash(domain_params), create_contacts_hash(old_domain_params))
- add_anon = contacts
-
- contacts = array_difference(create_contacts_hash(old_domain_params), create_contacts_hash(domain_params))
- rem_anon = contacts
-
- add_arr = []
- add_ns = create_nameservers_hash(domain_params) - create_nameservers_hash(old_domain_params)
- add_arr << { ns: add_ns } if add_ns.any?
- add_arr << { _anonymus: add_anon } if add_anon.any?
-
- rem_arr = []
- rem_ns = create_nameservers_hash(old_domain_params) - create_nameservers_hash(domain_params)
- rem_arr << { ns: rem_ns } if rem_ns.any?
- rem_arr << { _anonymus: rem_anon } if rem_anon.any?
-
- if domain_params[:registrant] != old_domain_params[:registrant]
- chg = [{ registrant: { value: domain_params[:registrant] } }] unless domain_params[:verified].present?
- if domain_params[:verified]
- chg = [{ registrant: { value: domain_params[:registrant], attrs: { verified: 'yes' } } }]
- end
- end
-
- add_arr = nil if add_arr.none?
- rem_arr = nil if rem_arr.none?
-
- {
- name: { value: domain_params[:name] },
- add: add_arr,
- rem: rem_arr,
- chg: chg
- }
- end
-
- def construct_ext_edit_hash(domain_params, old_domain_params)
- rem_keys = create_dnskeys_hash(old_domain_params) - create_dnskeys_hash(domain_params)
- add_keys = create_dnskeys_hash(domain_params) - create_dnskeys_hash(old_domain_params)
- hash = {}
- hash[:rem] = rem_keys if rem_keys.any?
- hash[:add] = add_keys if add_keys.any?
- hash
- end
-
- def create_nameservers_hash(domain_params)
- ret = []
- domain_params[:nameservers_attributes].each do |_k, v|
- next if v['hostname'].blank?
-
- host_attr = []
- host_attr << { hostName: { value: v['hostname'] } }
- if v['ipv4'].present?
- v['ipv4'].to_s.split(',').each do |ip|
- host_attr << { hostAddr: { value: ip, attrs: { ip: 'v4' } } }
- end
- end
-
- if v['ipv6'].present?
- v['ipv6'].to_s.split(',').each do |ip|
- host_attr << { hostAddr: { value: ip, attrs: { ip: 'v6' } } }
- end
- end
-
- ret << { hostAttr: host_attr }
- end
-
- ret
- end
-
- def create_contacts_hash(domain_params)
- ret = []
- domain_params[:contacts_attributes].each do |_k, v|
- next if v['code'].blank?
-
- ret << {
- contact: { value: v['code'], attrs: { type: v['type'] } }
- }
- end
-
- ret
- end
-
- def create_dnskeys_hash(domain_params)
- ret = []
- domain_params[:dnskeys_attributes].each do |_k, v|
- if v['ds_key_tag'].blank?
- kd = create_key_data_hash(v)
- if kd
- ret << {
- keyData: kd
- }
- end
- else
- ret << {
- dsData: [
- keyTag: { value: v['ds_key_tag'] },
- alg: { value: v['ds_alg'] },
- digestType: { value: v['ds_digest_type'] },
- digest: { value: v['ds_digest'] },
- keyData: create_key_data_hash(v)
- ]
- }
- end
- end
-
- ret
- end
-
- def create_key_data_hash(key_data_params)
- return nil if key_data_params['public_key'].blank?
-
- {
- flags: { value: key_data_params['flags'] },
- protocol: { value: key_data_params['protocol'] },
- alg: { value: key_data_params['alg'] },
- pubKey: { value: key_data_params['public_key'] }
- }
- end
-
- def array_difference(x, y)
- ret = x.dup
- y.each do |element|
- index = ret.index(element)
- ret.delete_at(index) if index
- end
- ret
- end
- end
- end
-end
diff --git a/app/models/depp/user.rb b/app/models/depp/user.rb
deleted file mode 100644
index 36fc48fdc..000000000
--- a/app/models/depp/user.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-module Depp
- class User
- include ActiveModel::Validations
- include ActiveModel::Conversion
- extend ActiveModel::Naming
-
- attr_accessor :tag, :password, :pki
-
- validates :tag, :password, presence: true
-
- validate :validate_existance_in_server
-
- def initialize(args = {})
- args.each { |k, v| send("#{k}=", v) }
- end
-
- def server
- client_cert = File.read(ENV['cert_path'])
- client_key = File.read(ENV['key_path'])
- port = ENV['epp_port'] || '700'
-
- @server_cache ||= Epp::Server.new({
- server: ENV['epp_hostname'],
- tag: tag,
- password: password,
- port: port,
- cert: OpenSSL::X509::Certificate.new(client_cert),
- key: OpenSSL::PKey::RSA.new(client_key)
- })
- end
-
- def request(xml)
- Nokogiri::XML(server.request(xml)).remove_namespaces!
- rescue EppErrorResponse => e
- Nokogiri::XML(e.response_xml.to_s).remove_namespaces!
- end
-
- private
-
- def validate_existance_in_server
- return if errors.any?
- res = server.open_connection
- unless Nokogiri::XML(res).css('greeting')
- errors.add(:base, :failed_to_open_connection_to_epp_server)
- server.close_connection # just in case
- return
- end
-
- ex = EppXml::Session.new(cl_trid_prefix: tag)
- xml = ex.login(clID: { value: tag }, pw: { value: password })
- res = server.send_request(xml)
-
- if Nokogiri::XML(res).css('result').first['code'] != '1000'
- errors.add(:base, Nokogiri::XML(res).css('result').text)
- end
-
- server.close_connection
-
- rescue OpenSSL::SSL::SSLError => e
- Rails.logger.error "INVALID CERT: #{e}"
- Rails.logger.error "INVALID CERT DEBUG INFO: epp_hostname: #{ENV['epp_hostname']}," \
- "port: #{ENV['epp_port']}, cert_path: #{ENV['cert_path']}, key_path: #{ENV['key_path']}"
- errors.add(:base, :invalid_cert)
- end
- end
-end
diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb
index 86584b700..08c612662 100644
--- a/app/models/dnskey.rb
+++ b/app/models/dnskey.rb
@@ -25,10 +25,10 @@ class Dnskey < ApplicationRecord
}
# IANA numbers, single authority list
- ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze
- PROTOCOLS = %w(3)
- FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK
- DS_DIGEST_TYPE = [1,2]
+ ALGORITHMS = %w[3 5 6 7 8 10 13 14 15 16].freeze
+ PROTOCOLS = %w[3].freeze
+ FLAGS = %w[0 256 257].freeze # 256 = ZSK, 257 = KSK
+ DS_DIGEST_TYPE = [1, 2].freeze
RESOLVERS = ENV['dnssec_resolver_ips'].to_s.strip.split(', ').freeze
self.ignored_columns = %w[legacy_domain_id]
diff --git a/app/models/domain.rb b/app/models/domain.rb
index e75f5165c..f770b623f 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -13,6 +13,22 @@ class Domain < ApplicationRecord
include Domain::Disputable
include Domain::BulkUpdatable
+ PERIODS = [
+ ['3 months', '3m'],
+ ['6 months', '6m'],
+ ['9 months', '9m'],
+ ['1 year', '1y'],
+ ['2 years', '2y'],
+ ['3 years', '3y'],
+ ['4 years', '4y'],
+ ['5 years', '5y'],
+ ['6 years', '6y'],
+ ['7 years', '7y'],
+ ['8 years', '8y'],
+ ['9 years', '9y'],
+ ['10 years', '10y'],
+ ].freeze
+
attr_accessor :roles,
:legal_document_id,
:is_admin,
@@ -49,7 +65,6 @@ class Domain < ApplicationRecord
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
end
-
# NB! contacts, admin_contacts, tech_contacts are empty for a new record
has_many :domain_contacts, dependent: :destroy
has_many :contacts, through: :domain_contacts, source: :contact
diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb
index c6589b63d..bb2bc84a1 100644
--- a/app/models/epp/domain.rb
+++ b/app/models/epp/domain.rb
@@ -105,6 +105,9 @@ class Epp::Domain < Domain
max: Setting.ns_max_count
}
],
+ '2502' => [ # Rate limit exceeded
+ %i[base session_limit_exceeded],
+ ],
]
}
end
diff --git a/app/models/epp/response/result/code.rb b/app/models/epp/response/result/code.rb
index f2b1ccd3b..916683840 100644
--- a/app/models/epp/response/result/code.rb
+++ b/app/models/epp/response/result/code.rb
@@ -62,7 +62,7 @@ module Epp
2308 => 'Data management policy violation',
2400 => 'Command failed',
2501 => 'Authentication error; server closing connection',
- 2502 => 'Session limit exceeded; server closing connection',
+ 2502 => Shunter.default_error_message,
}.freeze
private_constant :DEFAULT_DESCRIPTIONS
diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb
index cafd04af7..e70fa2d12 100644
--- a/app/models/legal_document.rb
+++ b/app/models/legal_document.rb
@@ -1,4 +1,4 @@
-class LegalDocument < ApplicationRecord
+class LegalDocument < ApplicationRecord # rubocop:disable Metrics/ClassLength
include EppErrors
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
MAX_BODY_SIZE = 8.megabytes
@@ -14,7 +14,7 @@ class LegalDocument < ApplicationRecord
belongs_to :documentable, polymorphic: true
- validate :val_body_length, if: ->(file) { file.path.blank? }
+ validate :val_body_length, if: ->(file) { file.path.blank? && (Rails.env.production? || Rails.env.test?) }
before_create :add_creator
before_save :save_to_filesystem, if: :body
@@ -24,7 +24,7 @@ class LegalDocument < ApplicationRecord
'2308' => [
%i[body length_more_than],
%i[body length_less_than],
- ]
+ ],
}
end
@@ -41,12 +41,13 @@ class LegalDocument < ApplicationRecord
digest = Digest::SHA1.new.update(binary).to_s
loop do
- rand = SecureRandom.random_number.to_s.last(4)
- next if rand.to_i == 0 || rand.length < 4
- dir = "#{ENV['legal_documents_dir']}/#{Time.zone.now.strftime('%Y/%m/%d')}"
- FileUtils.mkdir_p(dir, mode: 0775)
- self.path = "#{dir}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{document_type}"
- break unless File.file?(path)
+ rand = SecureRandom.random_number.to_s.last(4)
+ next if rand.to_i.zero? || rand.length < 4
+
+ dir = "#{ENV['legal_documents_dir']}/#{Time.zone.now.strftime('%Y/%m/%d')}"
+ FileUtils.mkdir_p(dir, mode: 0775)
+ self.path = "#{dir}/#{Time.zone.now.to_formatted_s(:number)}_#{rand}.#{document_type}"
+ break unless File.file?(path)
end
File.open(path, 'wb') { |f| f.write(binary) } unless Rails.env.test?
@@ -69,50 +70,57 @@ class LegalDocument < ApplicationRecord
start = Time.zone.now.to_f
Rails.logger.info '-----> Removing legal documents duplicates'
count = 0
- modified = Array.new
+ modified = []
- LegalDocument.where(documentable_type: "Domain").where.not(checksum: [nil, ""]).find_each do |orig_legal|
+ LegalDocument.where(documentable_type: 'Domain')
+ .where.not(checksum: [nil, ''])
+ .find_each do |orig_legal|
next if modified.include?(orig_legal.checksum)
- next if !File.exist?(orig_legal.path)
+ next unless File.exist?(orig_legal.path)
+
modified.push(orig_legal.checksum)
- LegalDocument.where(documentable_type: "Domain", documentable_id: orig_legal.documentable_id).
- where(checksum: orig_legal.checksum).
- where.not(id: orig_legal.id).where.not(path: orig_legal.path).each do |new_legal|
- unless modified.include?(orig_legal.id)
- File.delete(new_legal.path) if File.exist?(new_legal.path)
- new_legal.update(path: orig_legal.path)
- count += 1
- Rails.logger.info "File #{new_legal.path} has been removed by Domain "\
- "#{new_legal.documentable_id}. Document id: #{new_legal.id}"
- end
+ LegalDocument.where(documentable_type: 'Domain', documentable_id: orig_legal.documentable_id)
+ .where(checksum: orig_legal.checksum)
+ .where.not(id: orig_legal.id)
+ .where.not(path: orig_legal.path).each do |new_legal|
+ next if modified.include?(orig_legal.id)
+
+ File.delete(new_legal.path) if File.exist?(new_legal.path)
+ new_legal.update(path: orig_legal.path)
+ count += 1
+ Rails.logger.info "File #{new_legal.path} has been removed by Domain "\
+ "#{new_legal.documentable_id}. Document id: #{new_legal.id}"
end
- 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|
+ 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 do |id|
case id
- when Hash
- id["id"]
- when String
- JSON.parse(id) rescue id.to_i
- else
- id
- end
- }.flatten.compact.uniq
- LegalDocument.where(documentable_type: "Contact", documentable_id: contact_ids).
- where(checksum: orig_legal.checksum).where.not(path: orig_legal.path).each do |new_legal|
- unless modified.include?(orig_legal.id)
- File.delete(new_legal.path) if File.exist?(new_legal.path)
- new_legal.update(path: orig_legal.path)
- count += 1
- Rails.logger.info "File #{new_legal.path} has been removed by Contact "\
- "#{new_legal.documentable_id}. Document id: #{new_legal.id}"
+ when Hash
+ id['id']
+ when String
+ JSON.parse(id) rescue id.to_i
+ else
+ id
end
+ end.flatten.compact.uniq
+ LegalDocument.where(documentable_type: 'Contact', documentable_id: contact_ids)
+ .where(checksum: orig_legal.checksum)
+ .where.not(path: orig_legal.path).each do |new_legal|
+ next if modified.include?(orig_legal.id)
+
+ File.delete(new_legal.path) if File.exist?(new_legal.path)
+ new_legal.update(path: orig_legal.path)
+ count += 1
+ Rails.logger.info "File #{new_legal.path} has been removed by Contact "\
+ "#{new_legal.documentable_id}. Document id: #{new_legal.id}"
end
end
Rails.logger.info "-----> Duplicates fixed for #{count} rows in #{(Time.zone.now.to_f - start).round(2)} seconds"
-
end
end
diff --git a/app/models/registrant.rb b/app/models/registrant.rb
index 026431d6c..a8eae9c31 100644
--- a/app/models/registrant.rb
+++ b/app/models/registrant.rb
@@ -3,4 +3,8 @@ class Registrant < Contact
def epp_code_map
{}
end
+
+ def publishable?
+ registrant_publishable
+ end
end
diff --git a/app/models/validation_event.rb b/app/models/validation_event.rb
index 3e7670fac..80327f7c2 100644
--- a/app/models/validation_event.rb
+++ b/app/models/validation_event.rb
@@ -23,7 +23,7 @@ class ValidationEvent < ApplicationRecord
smtp: 1,
}.freeze
- store_accessor :event_data, :errors, :check_level, :email
+ store_accessor :event_data, :check_level, :email
belongs_to :validation_eventable, polymorphic: true
diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb
index 8d30110b4..d10aa0f73 100644
--- a/app/models/whois_record.rb
+++ b/app/models/whois_record.rb
@@ -51,7 +51,9 @@ class WhoisRecord < ApplicationRecord
end
h[:email] = registrant.email
- h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
+ h[:phone] = registrant.phone
+ h[:registrant_publishable] = registrant.publishable?
+ h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes
h[:admin_contacts] = []
@@ -78,7 +80,6 @@ class WhoisRecord < ApplicationRecord
h[:dnssec_keys] = domain.dnskeys.map { |key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" }
h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil
-
h
end
@@ -112,8 +113,10 @@ class WhoisRecord < ApplicationRecord
{
name: contact.name,
email: contact.email,
+ phone: contact.phone,
changed: contact.updated_at.try(:to_s, :iso8601),
disclosed_attributes: contact.disclosed_attributes,
+ contact_publishable: contact.registrant_publishable?,
}
end
end
diff --git a/app/presenters/registrar/domain_list_csv_presenter.rb b/app/presenters/registrar/domain_list_csv_presenter.rb
deleted file mode 100644
index a216d9561..000000000
--- a/app/presenters/registrar/domain_list_csv_presenter.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-class Registrar::DomainListCsvPresenter
- def initialize(domains:, view:)
- @domains = domains
- @view = view
- end
-
- def to_s
- table = CSV::Table.new([header])
-
- domains.each do |domain|
- table << domain_to_row(domain: domain)
- end
-
- table.to_s
- end
-
- private
-
- def header
- columns = %w[
- domain_name
- transfer_code
- registrant_name
- registrant_code
- expire_time
- ]
-
- columns.map! { |column| view.t("registrar.domains.index.csv.#{column}") }
-
- CSV::Row.new(columns, [], true)
- end
-
- def domain_to_row(domain:)
- row = []
- row[0] = domain.name
- row[1] = domain.transfer_code
- row[2] = domain.registrant.name
- row[3] = domain.registrant.code
- row[4] = domain.expire_date
-
- CSV::Row.new([], row)
- end
-
- attr_reader :domains, :view
-end
diff --git a/app/views/admin/invoices/index.haml b/app/views/admin/invoices/index.haml
index 8b8fe12c3..e179a6b6e 100644
--- a/app/views/admin/invoices/index.haml
+++ b/app/views/admin/invoices/index.haml
@@ -1,7 +1,7 @@
- content_for :actions do
= link_to(t(:add), new_admin_invoice_path, class: 'btn btn-primary')
= render 'shared/title', name: t(:invoices)
-= render 'search_form'
+= render 'admin/invoices/partials/search_form'
.row
.col-md-12
diff --git a/app/views/registrar/invoices/partials/_buyer.haml b/app/views/admin/invoices/partials/_buyer.haml
similarity index 92%
rename from app/views/registrar/invoices/partials/_buyer.haml
rename to app/views/admin/invoices/partials/_buyer.haml
index 30824ff01..96e767d9b 100644
--- a/app/views/registrar/invoices/partials/_buyer.haml
+++ b/app/views/admin/invoices/partials/_buyer.haml
@@ -20,4 +20,4 @@
%dd= @invoice.buyer_url
%dt= t(:email)
- %dd= @invoice.buyer_email
+ %dd= @invoice.buyer_email
\ No newline at end of file
diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/admin/invoices/partials/_details.haml
similarity index 96%
rename from app/views/registrar/invoices/partials/_details.haml
rename to app/views/admin/invoices/partials/_details.haml
index 150869dfa..723e94bd4 100644
--- a/app/views/registrar/invoices/partials/_details.haml
+++ b/app/views/admin/invoices/partials/_details.haml
@@ -36,4 +36,4 @@
%dd=@invoice.description
%dt= Invoice.human_attribute_name :reference_no
- %dd= @invoice.reference_no
+ %dd= @invoice.reference_no
\ No newline at end of file
diff --git a/app/views/registrar/invoices/partials/_items.haml b/app/views/admin/invoices/partials/_items.haml
similarity index 95%
rename from app/views/registrar/invoices/partials/_items.haml
rename to app/views/admin/invoices/partials/_items.haml
index 26985b1c1..9d56ef549 100644
--- a/app/views/registrar/invoices/partials/_items.haml
+++ b/app/views/admin/invoices/partials/_items.haml
@@ -29,4 +29,4 @@
%tr
%th.no-border{colspan: 3}
%th= t(:total)
- %td= number_to_currency @invoice.total
+ %td= number_to_currency @invoice.total
\ No newline at end of file
diff --git a/app/views/registrar/invoices/partials/_monthly_invoice_items.haml b/app/views/admin/invoices/partials/_monthly_invoice_items.haml
similarity index 100%
rename from app/views/registrar/invoices/partials/_monthly_invoice_items.haml
rename to app/views/admin/invoices/partials/_monthly_invoice_items.haml
diff --git a/app/views/registrar/invoices/partials/_payment_orders.haml b/app/views/admin/invoices/partials/_payment_orders.haml
similarity index 93%
rename from app/views/registrar/invoices/partials/_payment_orders.haml
rename to app/views/admin/invoices/partials/_payment_orders.haml
index d418ea1ac..d7d4f0ee9 100644
--- a/app/views/registrar/invoices/partials/_payment_orders.haml
+++ b/app/views/admin/invoices/partials/_payment_orders.haml
@@ -16,4 +16,4 @@
%td= payment_order.channel
%td= payment_order.status
%td= payment_order.created_at
- %td= payment_order.notes
+ %td= payment_order.notes
\ No newline at end of file
diff --git a/app/views/admin/invoices/_search_form.html.erb b/app/views/admin/invoices/partials/_search_form.html.erb
similarity index 91%
rename from app/views/admin/invoices/_search_form.html.erb
rename to app/views/admin/invoices/partials/_search_form.html.erb
index 91ccf4421..8dbbea00a 100644
--- a/app/views/admin/invoices/_search_form.html.erb
+++ b/app/views/admin/invoices/partials/_search_form.html.erb
@@ -69,10 +69,10 @@
- <%= link_to t('.download_btn'), admin_invoices_path(format: :csv, params: params.permit!),
- "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('.download_btn'),
+ <%= link_to t('admin.invoices.search_form.download_btn'), admin_invoices_path(format: :csv, params: params.permit!),
+ "data-toggle" => "tooltip", "data-placement" => "bottom", "title" => t('admin.invoices.search_form.download_btn'),
class: 'btn btn-default' %>
- <%= link_to t('.reset_btn'), admin_invoices_path, class: 'btn btn-default' %>
+ <%= link_to t('admin.invoices.search_form.reset_btn'), admin_invoices_path, class: 'btn btn-default' %>
<% end %>
diff --git a/app/views/registrar/invoices/partials/_seller.haml b/app/views/admin/invoices/partials/_seller.haml
similarity index 94%
rename from app/views/registrar/invoices/partials/_seller.haml
rename to app/views/admin/invoices/partials/_seller.haml
index 30f27bcef..7326a6e46 100644
--- a/app/views/registrar/invoices/partials/_seller.haml
+++ b/app/views/admin/invoices/partials/_seller.haml
@@ -35,4 +35,4 @@
%dd= @invoice.seller_email
%dt= t(:issuer)
- %dd= @invoice.seller_contact_name
+ %dd= @invoice.seller_contact_name
\ No newline at end of file
diff --git a/app/views/admin/invoices/show.haml b/app/views/admin/invoices/show.haml
index 42f7d769c..d92ab8207 100644
--- a/app/views/admin/invoices/show.haml
+++ b/app/views/admin/invoices/show.haml
@@ -20,14 +20,14 @@
= render 'shared/full_errors', object: @invoice
.row
- .col-md-6= render 'registrar/invoices/partials/details'
+ .col-md-6= render 'admin/invoices/partials/details'
.row
- .col-md-6= render 'registrar/invoices/partials/seller'
- .col-md-6= render 'registrar/invoices/partials/buyer'
+ .col-md-6= render 'admin/invoices/partials/seller'
+ .col-md-6= render 'admin/invoices/partials/buyer'
.row
- - if @invoice.monthly_invoice
- .col-md-12= render 'registrar/invoices/partials/monthly_invoice_items'
+ - if @invoice.monthly_invoice
+ .col-md-12= render 'admin/invoices/partials/monthly_invoice_items'
- else
- .col-md-12= render 'registrar/invoices/partials/items'
+ .col-md-12= render 'admin/invoices/partials/items'
.row
- .col-md-12= render 'registrar/invoices/partials/payment_orders'
+ .col-md-12= render 'admin/invoices/partials/payment_orders'
\ No newline at end of file
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/check.xml b/app/views/epp/sample_requests/contact/check.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/check.xml
rename to app/views/epp/sample_requests/contact/check.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml b/app/views/epp/sample_requests/contact/check_multiple.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/check_multiple.xml
rename to app/views/epp/sample_requests/contact/check_multiple.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/create.xml b/app/views/epp/sample_requests/contact/create.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/create.xml
rename to app/views/epp/sample_requests/contact/create.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/delete.xml b/app/views/epp/sample_requests/contact/delete.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/delete.xml
rename to app/views/epp/sample_requests/contact/delete.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/info.xml b/app/views/epp/sample_requests/contact/info.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/info.xml
rename to app/views/epp/sample_requests/contact/info.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml b/app/views/epp/sample_requests/contact/update_chg.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/contact/update_chg.xml
rename to app/views/epp/sample_requests/contact/update_chg.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/check.xml b/app/views/epp/sample_requests/domain/check.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/check.xml
rename to app/views/epp/sample_requests/domain/check.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml b/app/views/epp/sample_requests/domain/client_hold.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/client_hold.xml
rename to app/views/epp/sample_requests/domain/client_hold.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/create.xml b/app/views/epp/sample_requests/domain/create.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/create.xml
rename to app/views/epp/sample_requests/domain/create.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/delete.xml b/app/views/epp/sample_requests/domain/delete.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/delete.xml
rename to app/views/epp/sample_requests/domain/delete.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/info.xml b/app/views/epp/sample_requests/domain/info.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/info.xml
rename to app/views/epp/sample_requests/domain/info.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/renew.xml b/app/views/epp/sample_requests/domain/renew.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/renew.xml
rename to app/views/epp/sample_requests/domain/renew.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml b/app/views/epp/sample_requests/domain/transfer.xml
similarity index 69%
rename from app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml
rename to app/views/epp/sample_requests/domain/transfer.xml
index f6ee87b79..6ab951eeb 100644
--- a/app/views/registrar/xml_consoles/epp_requests/domain/transfer.xml
+++ b/app/views/epp/sample_requests/domain/transfer.xml
@@ -10,13 +10,6 @@
-
-
-
- dGVzdCBmYWlsCg==
-
-
-
ABC-12345
diff --git a/app/views/registrar/xml_consoles/epp_requests/domain/update.xml b/app/views/epp/sample_requests/domain/update.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/domain/update.xml
rename to app/views/epp/sample_requests/domain/update.xml
diff --git a/app/views/registrar/xml_consoles/epp_requests/poll/poll.xml b/app/views/epp/sample_requests/poll/poll.xml
similarity index 100%
rename from app/views/registrar/xml_consoles/epp_requests/poll/poll.xml
rename to app/views/epp/sample_requests/poll/poll.xml
diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb
deleted file mode 100644
index 3c90db35c..000000000
--- a/app/views/layouts/registrar/base.html.erb
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
-
- <% if content_for? :head_title %>
- <%= yield :head_title %>
- <% else %>
-
- <%= t(:registrar_head_title) %>
-
- <% end %>
- <%= csrf_meta_tags %>
- <%= stylesheet_link_tag 'registrar-manifest', media: 'all' %>
- <%= favicon_link_tag 'favicon.ico' %>
-
-
-
-
-
- <%= render 'navbar' %>
-
-
-
- <%= render 'flash_messages' %>
- <% if depp_controller? %>
- <%= render 'registrar/shared/epp_results' %>
- <% end %>
- <%= yield %>
-
-
- <%= javascript_include_tag 'registrar-manifest', async: true %>
-
-
diff --git a/app/views/layouts/registrar/sessions.html.erb b/app/views/layouts/registrar/sessions.html.erb
deleted file mode 100644
index ace645199..000000000
--- a/app/views/layouts/registrar/sessions.html.erb
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
- <% if content_for? :head_title %>
- <%= yield :head_title %>
- <% else %>
-
- <%= t(:registrar_head_title) %>
-
- <% end %>
- <%= csrf_meta_tags %>
- <%= stylesheet_link_tag 'registrar-manifest', media: 'all' %>
- <%= javascript_include_tag 'registrar-manifest' %>
-
-
-
-
-
-
-
-
-
- <%= render 'flash_messages' %>
- <%= yield %>
-
-
-
-
-
diff --git a/app/views/registrar/account/_balance_auto_reload.html.erb b/app/views/registrar/account/_balance_auto_reload.html.erb
deleted file mode 100644
index 9b6f2791a..000000000
--- a/app/views/registrar/account/_balance_auto_reload.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
- <%= t '.header' %>
-
-
-
- <% if setting %>
- <%= t '.enabled' %>
- <%= t '.enabled_state_details', amount: number_to_currency(setting['type']['amount']),
- threshold: number_to_currency(setting['type']['threshold']) %>
- <% else %>
- <%= t '.disabled' %>
- <% end %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/registrar/account/_details.html.erb b/app/views/registrar/account/_details.html.erb
deleted file mode 100644
index 185b046c8..000000000
--- a/app/views/registrar/account/_details.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- <%= t '.header' %>
-
-
-
-
- <%= Registrar.human_attribute_name :billing_email %>
- <%= registrar.billing_email %>
-
- <%= Registrar.human_attribute_name :iban %>
- <%= registrar.iban %>
-
-
-
-
-
diff --git a/app/views/registrar/account/_form.html.erb b/app/views/registrar/account/_form.html.erb
deleted file mode 100644
index ab1fb0294..000000000
--- a/app/views/registrar/account/_form.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-<%= form_for @registrar, url: registrar_account_path, method: :patch, html: { class: 'form-horizontal' } do |f| %>
- <%= render 'form_errors', target: @registrar %>
-
-
-
-
-
-
-
-
-
- <%= f.submit t('.submit_btn'), class: 'btn btn-success' %>
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrar/account/_linked_users.html.erb b/app/views/registrar/account/_linked_users.html.erb
deleted file mode 100644
index fa8d868b4..000000000
--- a/app/views/registrar/account/_linked_users.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
<%= t '.header' %>
-
-
- <% linked_users.each do |user| %>
- <% user_presenter = UserPresenter.new(user: user, view: self) %>
- <%= user_presenter.login_with_role %>
- <%= link_to t('.switch_btn'),
- registrar_switch_current_user_path(user),
- method: :put,
- id: "switch-current-user-#{user.id}-btn",
- class: 'btn btn-primary btn-xs' %>
-
- <% end %>
-
-
-
-
diff --git a/app/views/registrar/account/edit.html.erb b/app/views/registrar/account/edit.html.erb
deleted file mode 100644
index 20aa88d2d..000000000
--- a/app/views/registrar/account/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
- <%= link_to t('registrar.account.show.header'), registrar_account_path %>
- <%= t '.header' %>
-
-
-
-
-<%= render 'form' %>
\ No newline at end of file
diff --git a/app/views/registrar/account/show.html.erb b/app/views/registrar/account/show.html.erb
deleted file mode 100644
index 75d0ce400..000000000
--- a/app/views/registrar/account/show.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- <%= render 'details', registrar: current_registrar_user.registrar %>
-
-
-
-
-
- <%= render 'linked_users', linked_users: current_registrar_user.linked_users %>
-
-
-
-<% if can?(:manage, :balance_auto_reload) %>
-
-
- <%= render 'balance_auto_reload', setting: balance_auto_reload_setting %>
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrar/account_activities/_search_form.html.erb b/app/views/registrar/account_activities/_search_form.html.erb
deleted file mode 100644
index 92a715096..000000000
--- a/app/views/registrar/account_activities/_search_form.html.erb
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
- <%= search_form_for @q, url: [:registrar, :account_activities], html: { style: 'margin-bottom: 0;' } do |f| %>
-
-
-
- <%= f.label t(:activity_type) %>
- <%= f.select :activity_type_in, AccountActivity.types_for_select, {}, class: 'form-control js-combobox', placeholder: t(:choose), multiple: true %>
-
-
-
-
-
- <%= f.label t(:description) %>
- <%= f.search_field :description_cont, class: 'form-control', placeholder: t(:description), autocomplete: 'off' %>
-
-
-
-
-
-
-
- <%= f.label t(:receipt_date_from) %>
- <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_from) %>
-
-
-
-
-
- <%= f.label t(:receipt_date_until) %>
- <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:receipt_date_until) %>
-
-
-
-
-
-
-
-
-
- <%= button_tag t('.download_btn'),
- formaction: registrar_account_activities_path(format: 'csv'),
- class: 'btn btn-default' %>
- <%= link_to(t('.reset_btn'), registrar_account_activities_path, class: 'btn btn-default') %>
-
-
- <% end %>
-
-
diff --git a/app/views/registrar/account_activities/index.html.erb b/app/views/registrar/account_activities/index.html.erb
deleted file mode 100644
index aefcdd47f..000000000
--- a/app/views/registrar/account_activities/index.html.erb
+++ /dev/null
@@ -1,66 +0,0 @@
-<% content_for :actions do %>
- <%= link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default') %>
-<% end %>
-
-<%= render 'shared/title', name: t(:account_activity) %>
-
-<%= render 'search_form' %>
-
-
-
-
-
-
-
-
-
-
- <%= sort_link(@q, 'description') %>
-
-
- <%= sort_link(@q, 'activity_type') %>
-
-
- <%= sort_link(@q, 'created_at', AccountActivity.human_attribute_name(:created_at)) %>
-
-
- <%= sort_link(@q, 'sum') %>
-
-
- <%= sort_link(@q, 'new_balance', 'New balance') %>
-
-
-
-
- <% @account_activities.each do |x| %>
-
-
- <%= x.description.present? ? x.description : '-' %>
-
-
- <%= x.activity_type ? t(x.activity_type) : '' %>
-
-
- <%= l(x.created_at) %>
-
- <% c = x.sum > 0.0 ? 'text-success' : 'text-danger' %>
- <% s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" %>
-
- <%= s %>
-
-
- <%= x.new_balance.present? ? "#{currency(x.new_balance)} EUR" : 'N/A' %>
-
-
- <% end %>
-
-
-
-
-
-
-
-
- <%= paginate @account_activities %>
-
-
diff --git a/app/views/registrar/base/_current_user.html.erb b/app/views/registrar/base/_current_user.html.erb
deleted file mode 100644
index a21792b3c..000000000
--- a/app/views/registrar/base/_current_user.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-<% current_user_presenter = UserPresenter.new(user: current_registrar_user, view: self) %>
-<%= link_to current_user_presenter.login_with_role, registrar_account_path, class: 'navbar-link' %>
-|
-<%= link_to t('.sign_out'), destroy_registrar_user_session_path, method: :delete, class: 'navbar-link' %>
diff --git a/app/views/registrar/base/_form_errors.html.erb b/app/views/registrar/base/_form_errors.html.erb
deleted file mode 100644
index 0f898c81d..000000000
--- a/app/views/registrar/base/_form_errors.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<% if target.errors.any? %>
-
-
<%= pluralize(target.errors.count, 'error') %> prohibited this <%= target.model_name.human.downcase %> from being saved:
-
-
- <% target.errors.full_messages.each do |message| %>
- <%= message %>
- <% end %>
-
-
-<% end %>
diff --git a/app/views/registrar/base/_navbar.haml b/app/views/registrar/base/_navbar.haml
deleted file mode 100644
index 4361e8b31..000000000
--- a/app/views/registrar/base/_navbar.haml
+++ /dev/null
@@ -1,20 +0,0 @@
-.navbar-collapse.collapse
- %ul.nav.navbar-nav
- - if can? :view, Depp::Domain
- - active_class = %w(registrar/domains registrar/check registrar/renew registrar/tranfer).include?(params[:controller]) ? 'active' :nil
- %li{class: active_class}= link_to t(:domains), registrar_domains_path
-
- - if can? :view, Depp::Contact
- - active_class = ['registrar/contacts'].include?(params[:controller]) ? 'active' :nil
- %li{class: active_class}= link_to t(:contacts), registrar_contacts_path
-
- - if can? :show, Invoice
- - active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil
- %li{class: active_class}= link_to t(:billing), registrar_invoices_path
-
- - if !Rails.env.production? && can?(:manage, :xml_console)
- - active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil
- %li{class: active_class}= link_to t(:xml_console), registrar_xml_console_path
-
- %div.navbar-text.navbar-right
- = render 'current_user'
diff --git a/app/views/registrar/bulk_change/_admin_contact_form.html.erb b/app/views/registrar/bulk_change/_admin_contact_form.html.erb
deleted file mode 100644
index 77734e872..000000000
--- a/app/views/registrar/bulk_change/_admin_contact_form.html.erb
+++ /dev/null
@@ -1,65 +0,0 @@
-<%= form_tag registrar_admin_contacts_path, method: :patch, class: 'form-horizontal' do %>
- <% if @error %>
-
- <%= @error %>
-
- <% end %>
-
-
-
-
-
-
-
-
-<% end %>
-
-
- <% available_contacts.each do |data| %>
- <%= data.first %>
- <% end %>
-
diff --git a/app/views/registrar/bulk_change/_api_errors.html.erb b/app/views/registrar/bulk_change/_api_errors.html.erb
deleted file mode 100644
index 8d8862959..000000000
--- a/app/views/registrar/bulk_change/_api_errors.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-<% if @api_errors %>
-
-
- <% if @api_errors.is_a?(String) %>
- <%= @api_errors %>
- <% else %>
- <% @api_errors.each do |error| %>
- <%= error[:title] %>
- <% end %>
- <% end %>
-
-
-<% end %>
diff --git a/app/views/registrar/bulk_change/_bulk_renew_form.html.erb b/app/views/registrar/bulk_change/_bulk_renew_form.html.erb
deleted file mode 100644
index 5db40365f..000000000
--- a/app/views/registrar/bulk_change/_bulk_renew_form.html.erb
+++ /dev/null
@@ -1,57 +0,0 @@
-<%= form_with url: registrar_bulk_renew_path, multipart: true, class: 'form-horizontal' do |f|%>
- <%= render 'api_errors' %>
-
-
-
-
-
-
-
-
- <% if @domains.present? %>
-
- <% end %>
-
-
- <%= f.submit "#{t '.filter_btn'}", name: 'filter', class: 'btn btn-warning' %>
- <% if @domains.present? %>
- <%= f.submit "#{t '.renew_btn'}", name: 'renew', class: 'btn btn-primary' %>
- <% end %>
-
-<% end %>
diff --git a/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb b/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb
deleted file mode 100644
index 0a953845b..000000000
--- a/app/views/registrar/bulk_change/_bulk_transfer_form.html.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
- <%= render 'registrar/domain_transfers/form/api_errors' %>
-
-
-
-
-
-
-<% end %>
diff --git a/app/views/registrar/bulk_change/_nameserver_form.html.erb b/app/views/registrar/bulk_change/_nameserver_form.html.erb
deleted file mode 100644
index 45ae6a7dd..000000000
--- a/app/views/registrar/bulk_change/_nameserver_form.html.erb
+++ /dev/null
@@ -1,77 +0,0 @@
-<%= form_tag registrar_nameservers_path, multipart: true, method: :patch, class: 'form-horizontal' do %>
- <%= render 'registrar/domain_transfers/form/api_errors' %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<% end %>
diff --git a/app/views/registrar/bulk_change/_tech_contact_form.html.erb b/app/views/registrar/bulk_change/_tech_contact_form.html.erb
deleted file mode 100644
index 789db92ba..000000000
--- a/app/views/registrar/bulk_change/_tech_contact_form.html.erb
+++ /dev/null
@@ -1,60 +0,0 @@
-<%= form_tag registrar_tech_contacts_path, method: :patch, class: 'form-horizontal' do %>
- <% if @error %>
-
- <%= @error %>
-
- <% end %>
-
-
-
-
-
-
-
-
-<% end %>
-
-
- <% available_contacts.each do |data| %>
- <%= data.first %>
- <% end %>
-
diff --git a/app/views/registrar/bulk_change/new.html.erb b/app/views/registrar/bulk_change/new.html.erb
deleted file mode 100644
index f3095a53d..000000000
--- a/app/views/registrar/bulk_change/new.html.erb
+++ /dev/null
@@ -1,54 +0,0 @@
-
- <%= link_to t('registrar.domains.index.header'), registrar_domains_path %>
-
-
-
-
-
-
-
-
-
- <%= render 'tech_contact_form', available_contacts: available_contacts %>
-
-
-
- <%= render 'admin_contact_form', available_contacts: available_contacts %>
-
-
-
- <%= render 'nameserver_form' %>
-
-
-
- <%= render 'bulk_transfer_form' %>
-
-
-
- <%= render 'bulk_renew_form' %>
-
-
diff --git a/app/views/registrar/contacts/_form.haml b/app/views/registrar/contacts/_form.haml
deleted file mode 100644
index 953c502e5..000000000
--- a/app/views/registrar/contacts/_form.haml
+++ /dev/null
@@ -1,26 +0,0 @@
-= render 'registrar/shared/error_messages', f: f
-= f.hidden_field :id
-= f.hidden_field :password
-.row
- .col-md-8
- = render 'registrar/contacts/form/general', f: f
-
-- if Contact.address_processing?
- .row
- .col-md-8
- = render 'registrar/contacts/form/address', f: f
-
-- if !@contact.persisted?
- .row
- .col-md-8
- = render 'registrar/contacts/form/code', f: f
-.row
- .col-md-8
- = render 'registrar/contacts/form/legal_document', f: f
-
-.row
- .col-md-8.text-right
- - if @contact.persisted?
- = button_tag t(:save), class: 'btn btn-warning'
- - else
- = button_tag t(:create), class: 'btn btn-warning'
diff --git a/app/views/registrar/contacts/_search_form.html.erb b/app/views/registrar/contacts/_search_form.html.erb
deleted file mode 100644
index 73c1281e0..000000000
--- a/app/views/registrar/contacts/_search_form.html.erb
+++ /dev/null
@@ -1,117 +0,0 @@
-<%= search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %>
-
-
-
- <%= f.label :name %>
- <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
-
-
-
-
-
- <%= f.label t(:id) %>
- <%= f.search_field :code_eq, class: 'form-control', placeholder: t(:id) %>
-
-
-
-
-
- <%= f.label t(:ident) %>
- <%= f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident) %>
-
-
-
-
-
- <%= label_tag t(:ident_type) %>
- <%= select_tag '[q][ident_type_eq]', options_for_select(ident_types, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
-
-
-
-
-
-
-
- <%= f.label t(:email) %>
- <%= f.search_field :email_matches, class: 'form-control', placeholder: t(:email) %>
-
-
-
-
-
- <%= label_tag t(:country) %>
- <%= select_tag '[q][country_code_eq]', ApplicationController.helpers.all_country_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %>
-
-
-
-
-
- <%= label_tag t(:contact_type) %>
- <%= select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %>
-
-
-
-
-
-
-
- <%= f.label t(:registrar_name) %>
- <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) %>
-
-
-
-
-
- <%= f.label t(:created_at_from) %>
- <%= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control js-datepicker', placeholder: t(:created_at_from) %>
-
-
-
-
-
- <%= f.label t(:created_at_until) %>
- <%= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control js-datepicker', placeholder: t(:created_at_until) %>
-
-
-
-
-
- <%= f.label t(:updated_at) %>
- <%= f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control js-datepicker', placeholder: t(:updated_at) %>
-
-
-
-
-
-
-
- <%= label_tag t(:status) %>
- <%= select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %>
-
-
-
-
-
- <%= label_tag t(:results_per_page) %>
- <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
-
-
-
-
-
-
-
-
-
- <%= button_tag t('.download_pdf_btn'),
- formaction: registrar_contacts_path(format: :pdf),
- name: nil,
- class: 'btn btn-default' %>
- <%= button_tag t('.download_csv_btn'),
- formaction: registrar_contacts_path(format: :csv),
- name: nil,
- class: 'btn btn-default' %>
- <%= link_to(t('.reset_btn'), registrar_contacts_path, class: 'btn btn-default') %>
-
-
-<% end %>
diff --git a/app/views/registrar/contacts/delete.haml b/app/views/registrar/contacts/delete.haml
deleted file mode 100644
index 8662b738c..000000000
--- a/app/views/registrar/contacts/delete.haml
+++ /dev/null
@@ -1,20 +0,0 @@
-- if @contact.persisted?
- = render 'shared/title', name: "#{t(:delete)}: #{@contact.name}"
-
- = form_for(@contact, url: registrar_contact_path(@contact),
- class: 'form-horizontal', multipart: true, method: :delete) do |f|
-
- = render 'registrar/shared/error_messages', f: f
- = f.hidden_field :id
- = f.hidden_field :password
-
- .row
- .col-md-8
- = render 'registrar/contacts/form/legal_document', f: f
-
- %hr
- .row
- .col-md-8.text-right
- = button_tag t(:delete), class: 'btn btn-danger'
-- else
- %h2= "#{t(:delete)}: #{t(:not_found)}"
diff --git a/app/views/registrar/contacts/edit.haml b/app/views/registrar/contacts/edit.haml
deleted file mode 100644
index bfbcf21e9..000000000
--- a/app/views/registrar/contacts/edit.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-= render 'shared/title', name: "#{t(:edit)}: #{@contact.name}"
-
-= form_for(@contact, url: registrar_contact_path(@contact),
- html: {class: 'form-horizontal js-contact-form'}) do |f|
- - render 'form', f: f
diff --git a/app/views/registrar/contacts/form/_address.haml b/app/views/registrar/contacts/form/_address.haml
deleted file mode 100644
index e70d00cd8..000000000
--- a/app/views/registrar/contacts/form/_address.haml
+++ /dev/null
@@ -1,36 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:address)
- .panel-body
- .form-group
- .col-md-3.control-label
- = f.label :street, t(:street) + '*'
- .col-md-7
- = f.text_field :street, class: 'form-control', required: true
-
- .form-group
- .col-md-3.control-label
- = f.label :city, t(:city) + '*'
- .col-md-7
- = f.text_field :city, class: 'form-control', required: true
-
- .form-group
- .col-md-3.control-label
- = f.label :zip, t(:zip) + '*'
- .col-md-7
- = f.text_field :zip, class: 'form-control', required: true
-
- .form-group
- .col-md-3.control-label
- = f.label :state, t(:state)
- .col-md-7
- = f.text_field :state, class: 'form-control'
-
- .form-group
- .col-md-3.control-label
- = f.label :country_code, t(:country) + '*'
- .col-md-7
- - country_selected = f.object.persisted? ? f.object.country_code : 'EE'
- = f.select(:country_code, ApplicationController.helpers.all_country_options(country_selected),
- { include_blank: true }, required: true)
-
diff --git a/app/views/registrar/contacts/form/_code.haml b/app/views/registrar/contacts/form/_code.haml
deleted file mode 100644
index f4bc2733f..000000000
--- a/app/views/registrar/contacts/form/_code.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:id)
- .panel-body
- .form-group
- .col-md-2.control-label
- = f.label :code, t(:id)
- .col-md-10
- = f.text_field :code, class: 'form-control'
diff --git a/app/views/registrar/contacts/form/_general.haml b/app/views/registrar/contacts/form/_general.haml
deleted file mode 100644
index 5f1c90098..000000000
--- a/app/views/registrar/contacts/form/_general.haml
+++ /dev/null
@@ -1,67 +0,0 @@
-- ident_complete = f.object.ident_country_code.present? && f.object.ident_type.present? && f.object.ident.present?
-- if @contact.persisted?
- - country_selected = f.object.ident_country_code || (params[:depp_contact].try(:[], :ident_country_code))
- - type_selected = f.object.ident_type || (params[:depp_contact].try(:[], :ident_type))
-- else
- - country_selected = (params[:depp_contact].try(:[], :ident_country_code) || 'EE')
- - type_selected = (params[:depp_contact].try(:[], :ident_type) || 'org')
-
-.panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:ident)
- .panel-body
- .form-group
- .col-md-3.control-label
- = f.label :ident_country_code, t(:country) + '*'
- .col-md-7
- - if ident_complete && @contact.persisted? && f.object.ident_country_code.present?
- = f.text_field :ident_country_code, value: f.object.ident_country_code, :readonly => true
- - else
- = f.select(:ident_country_code, ApplicationController.helpers.all_country_options(country_selected), {},
- class: 'js-ident-country-code', required: true)
-
- .form-group
- .col-md-3.control-label
- = f.label :ident_type, t(:type) + '*'
- .col-md-7
- - if ident_complete && @contact.persisted? && f.object.ident_type.present?
- = f.text_field :ident_type, value: f.object.ident_type, :readonly => true
- - else
- = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected },
- class: 'js-ident-type', required: true)
-
- .form-group
- .col-md-3.control-label
- = f.label :ident, t(:ident) + '*'
- .col-md-7
- - if ident_complete && @contact.persisted? && f.object.ident.present?
- = f.text_field :ident, value: f.object.ident, :readonly => true
- - else
- = f.text_field :ident, class: 'form-control', required: true
- - tip_visibility = f.object.ident_type == 'birthday' ? '' : 'display: none'
- .js-ident-tip{ style: tip_visibility }
- = t(:birthday_format)
-
-.panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:general)
- .panel-body
- .form-group
- .col-md-3.control-label
- = f.label :name, t(:name) + '*'
- .col-md-7
- = f.text_field :name, class: 'form-control', required: true
-
- .form-group
- .col-md-3.control-label
- = f.label :email, t(:email) + '*'
- .col-md-7
- = f.email_field :email, class: 'form-control', required: true,
- pattern: "[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
-
- .form-group
- .col-md-3.control-label
- = f.label :phone, t(:phone) + '*'
- .col-md-7
- = f.text_field :phone, class: 'form-control',
- placeholder: '+372.12323344', required: true
diff --git a/app/views/registrar/contacts/form/_legal_document.haml b/app/views/registrar/contacts/form/_legal_document.haml
deleted file mode 100644
index 6507da1d9..000000000
--- a/app/views/registrar/contacts/form/_legal_document.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-.form-group
- .col-md-10
-
-.panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:legal_document)
- .panel-body
- .form-group
- .col-md-3.control-label
- = f.label :legal_document, t(:legal_document)
- %p.help-block= t(:legal_document_max_size)
- .col-md-7
- = f.legal_document_field :legal_document
diff --git a/app/views/registrar/contacts/index.html.erb b/app/views/registrar/contacts/index.html.erb
deleted file mode 100644
index 4a7e8759a..000000000
--- a/app/views/registrar/contacts/index.html.erb
+++ /dev/null
@@ -1,77 +0,0 @@
-<% content_for :actions do %>
- <%= link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary') %>
-<% end %>
-<%= render 'shared/title', name: t(:contacts) %>
-
-
- <%= render 'search_form' %>
-
-
-
-
-
-
- <%= paginate @contacts %>
-
-
-
-
-
diff --git a/app/views/registrar/contacts/info_index.haml b/app/views/registrar/contacts/info_index.haml
deleted file mode 100644
index 8bec10ee0..000000000
--- a/app/views/registrar/contacts/info_index.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-= render 'shared/title', name: t(:contacts_info)
-
-.row
- .col-md-12
- = form_tag registrar_contact_path, class: 'form-horizontal', method: :get do
- .form-group
- = label_tag :contact_id, t(:contact_id), class: 'col-md-2 control-label'
- .col-md-10
- = text_field_tag :contact_id, params[:contact_id], class: 'form-control', autocomplete: 'off'
- .form-group
- = label_tag :password, t(:password), class: 'col-md-2 control-label'
- .col-md-10
- = text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off'
- .form-group
- .col-md-offset-2.col-md-10
- %button.btn.btn-primary
-
- %span.glyphicon.glyphicon-search
-
diff --git a/app/views/registrar/contacts/list_pdf.html.erb b/app/views/registrar/contacts/list_pdf.html.erb
deleted file mode 100644
index b9bbb1c0e..000000000
--- a/app/views/registrar/contacts/list_pdf.html.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
- <%= Contact.human_attribute_name :name %>
- <%= Contact.human_attribute_name :code %>
- <%= Contact.human_attribute_name :ident %>
- <%= Contact.human_attribute_name :created_at %>
- <%= Registrar.model_name.human %>
-
-
-
-
- <% @contacts.each do |contact| %>
-
- <%= contact %>
- <%= contact.code %>
- <%= ident_for(contact) %>
- <%= l(contact.created_at, format: :short) %>
- <%= contact.registrar %>
-
- <% end %>
-
-
-
-
-
-
-
diff --git a/app/views/registrar/contacts/new.haml b/app/views/registrar/contacts/new.haml
deleted file mode 100644
index d554da015..000000000
--- a/app/views/registrar/contacts/new.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-= render 'shared/title', name: t(:new_contact)
-
-= form_for(@contact, url: registrar_contacts_path,
- html: {class: 'form-horizontal js-contact-form'}) do |f|
- - render 'form', f: f
diff --git a/app/views/registrar/contacts/partials/_address.haml b/app/views/registrar/contacts/partials/_address.haml
deleted file mode 100644
index ce26b5667..000000000
--- a/app/views/registrar/contacts/partials/_address.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-.panel.panel-default
- .panel-heading
- %h3.panel-title= t(:address)
- .panel-body
- %dl.dl-horizontal
- - if @contact.org_name.present?
- %dt= t(:org_name)
- %dd= @contact.org_name
-
- %dt= t(:street)
- %dd= @contact.street
-
- %dt= t(:city)
- %dd= @contact.city
-
- %dt= t(:zip)
- %dd= @contact.zip
-
- %dt= t(:state)
- %dd= @contact.state
-
- %dt= t(:country)
- %dd= @contact.country_name
diff --git a/app/views/registrar/contacts/partials/_domains.haml b/app/views/registrar/contacts/partials/_domains.haml
deleted file mode 100644
index cf721cb86..000000000
--- a/app/views/registrar/contacts/partials/_domains.haml
+++ /dev/null
@@ -1,31 +0,0 @@
-- domains = contact.all_domains(page: params[:domain_page], per: 20,
- params: domain_filter_params.to_h)
-.panel.panel-default
- .panel-heading
- .pull-left
- = t(:domains)
- .pull-right
- = form_tag request.path, method: :get do
- = select_tag :domain_filter, options_for_select(%w(Registrant AdminDomainContact TechDomainContact), selected: params[:domain_filter]),
- include_blank: true, class: 'form-control2 selectize2'
- %button.btn.btn-primary
- %span.glyphicon.glyphicon-search
- .clearfix
-
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-3'}=custom_sort_link t(:domain_name), :name
- %th{class: 'col-xs-3'}=custom_sort_link t(:registrar_name), :registrar_name
- %th{class: 'col-xs-3'}=custom_sort_link t(:valid_to), :valid_to
- %th{class: 'col-xs-3'}= t('.roles')
- %tbody
- - domains.each do |x|
- %tr
- %td= link_to(x.name, info_registrar_domains_path(domain_name: x.name))
- %td= x.registrar.name
- %td= l(x.valid_to, format: :short)
- %td= x.roles.join(", ")
-
-= paginate domains, param_name: :domain_page
diff --git a/app/views/registrar/contacts/partials/_general.haml b/app/views/registrar/contacts/partials/_general.haml
deleted file mode 100644
index 5fc8ec027..000000000
--- a/app/views/registrar/contacts/partials/_general.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-.panel.panel-default
- .panel-heading
- %h3.panel-title= t(:general)
- .panel-body
- %dl.dl-horizontal
- %dt= t(:id)
- %dd= @contact.id
-
- %dt= Contact.human_attribute_name :auth_info
- %dd
- = tag :input, type: 'text', value: @contact.password, readonly: true,
- class: 'form-control input-sm'
-
- %br
-
- %dt= t(:ident)
- %dd= ident_for(@contact)
-
- %dt= t(:email)
- %dd= @contact.email
-
- %dt= t(:phone)
- %dd= @contact.phone
diff --git a/app/views/registrar/contacts/partials/_statuses.haml b/app/views/registrar/contacts/partials/_statuses.haml
deleted file mode 100644
index c926c04cf..000000000
--- a/app/views/registrar/contacts/partials/_statuses.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-.panel.panel-default
- .panel-heading
- %h3.panel-title= 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(:description)
- %tbody
- - statuses.each do |s|
- %tr
- %td= s.first
- %td= s.second
diff --git a/app/views/registrar/contacts/show.haml b/app/views/registrar/contacts/show.haml
deleted file mode 100644
index 9fb23182d..000000000
--- a/app/views/registrar/contacts/show.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-- if @contact.id.present?
- - content_for :actions do
- = link_to(t(:edit), edit_registrar_contact_path(@contact.id), class: 'btn btn-primary')
- = link_to(t(:delete), delete_registrar_contact_path(@contact.id), class: 'btn btn-default')
- = render 'shared/title', name: @contact.name
-
- .row
- .col-md-6= render 'registrar/contacts/partials/general'
- .col-md-6= render 'registrar/contacts/partials/address' if Contact.address_processing?
- .row
- .col-md-12= render 'registrar/contacts/partials/statuses', statuses: @contact.statuses
- .row
- - if @contact.ident.present?
- .col-md-12= render 'registrar/contacts/partials/domains', contact: Contact.find_by(code: params[:id])
-
-- else
- .row
- .col-sm-6
- %h1= t(:not_found)
diff --git a/app/views/registrar/deposits/new.haml b/app/views/registrar/deposits/new.haml
deleted file mode 100644
index abb04f916..000000000
--- a/app/views/registrar/deposits/new.haml
+++ /dev/null
@@ -1,28 +0,0 @@
-- content_for :actions do
- = link_to(t(:back_to_billing), registrar_invoices_path, class: 'btn btn-default')
-= render 'shared/title', name: t(:add_deposit)
-
-= form_for([:registrar, @deposit], method: :post, html: { class: 'form-horizontal' }) do |f|
- = render 'shared/full_errors', object: @deposit
-
- .row
- .col-md-8
- .form-group
- .col-md-4.control-label
- = f.label :amount, class: 'required'
- .col-md-7
- .input-group
- = f.text_field :amount, class: 'form-control', required: true
- .input-group-addon
- EUR
-
- .form-group
- .col-md-4.control-label
- = f.label :description
- .col-md-7
- = f.text_area :description, class: 'form-control'
-
- %hr
- .row
- .col-md-8.text-right
- = button_tag(t(:add), class: 'btn btn-warning')
diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/_form.html.erb
deleted file mode 100644
index 52dcca468..000000000
--- a/app/views/registrar/domain_transfers/_form.html.erb
+++ /dev/null
@@ -1,39 +0,0 @@
-<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
- <%= render 'registrar/domain_transfers/form/api_errors' %>
-
-
-
-
-
-
-
-
-<% end %>
diff --git a/app/views/registrar/domain_transfers/create.html.erb b/app/views/registrar/domain_transfers/create.html.erb
deleted file mode 100644
index bf258e476..000000000
--- a/app/views/registrar/domain_transfers/create.html.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
- <%= t(:result) %>
-
-
-
-
- <%= t(:domain_name) %>
- <%= @data.css('name').text %>
-
- <% @data.css('trnData').children.each do |x| %>
- <% next if x.blank? %>
- <%= t(x.name) %>
- <%= x.text %>
- <% end %>
-
-
-
-
-
diff --git a/app/views/registrar/domain_transfers/form/_api_errors.html.erb b/app/views/registrar/domain_transfers/form/_api_errors.html.erb
deleted file mode 100644
index 8d8862959..000000000
--- a/app/views/registrar/domain_transfers/form/_api_errors.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-<% if @api_errors %>
-
-
- <% if @api_errors.is_a?(String) %>
- <%= @api_errors %>
- <% else %>
- <% @api_errors.each do |error| %>
- <%= error[:title] %>
- <% end %>
- <% end %>
-
-
-<% end %>
diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb
deleted file mode 100644
index 52dd3f900..000000000
--- a/app/views/registrar/domain_transfers/new.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-<%= render 'registrar/domain_transfers/form/api_errors' %>
-
-
-
- <%= render 'form' %>
-
-
diff --git a/app/views/registrar/domains/_check_form.haml b/app/views/registrar/domains/_check_form.haml
deleted file mode 100644
index 2468fa69a..000000000
--- a/app/views/registrar/domains/_check_form.haml
+++ /dev/null
@@ -1,10 +0,0 @@
-= form_tag check_registrar_domains_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'
- .col-md-1.text-right.text-center-xs
- .form-group
- %button.btn.btn-primary
-
- %span.glyphicon.glyphicon-search
-
diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb
deleted file mode 100644
index 8cc6da6f7..000000000
--- a/app/views/registrar/domains/_domain.html.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-
- <%= link_to truncate(domain.name), info_registrar_domains_path(domain_name: domain.name) %>
- <%= link_to domain.registrant, registrar_contact_path(id: domain.registrant.code) %>
- <%= l domain.expire_time %>
-
- <%= link_to t('.edit_btn'), edit_registrar_domains_path(domain_name: domain.name),
- class: 'btn btn-primary btn-xs' %>
- <%= link_to t('.renew_btn'), renew_registrar_domains_path(domain_name: domain.name),
- class: 'btn btn-default btn-xs' %>
- <% unless (domain.statuses & %w[pendingDelete pendingDeleteConfirmation]).any? %>
- <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name),
- class: 'btn btn-default btn-xs' %>
- <% end %>
-
-
diff --git a/app/views/registrar/domains/_form.haml b/app/views/registrar/domains/_form.haml
deleted file mode 100644
index 690d0ee06..000000000
--- a/app/views/registrar/domains/_form.haml
+++ /dev/null
@@ -1,30 +0,0 @@
-- path = (params[:domain_name]) ? update_registrar_domains_path : registrar_domains_path
-- legaldoc_mandatory = params[:domain_name].blank? && current_registrar_user.legaldoc_mandatory?
-= form_tag(path, class: 'form-horizontal', multipart: true) do
- .row
- .col-md-8
- #general-tab.tab-pane.active
- = render 'registrar/domains/form/general'
- = render 'registrar/domains/form/contacts'
- = render 'registrar/domains/form/nameservers'
- = render 'registrar/domains/form/dnskeys'
-
- .panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:legal_document)
- .panel-body
- .form-group
- .col-md-3.control-label
- - c, fr = 'required', true if legaldoc_mandatory
- = label_tag 'domain[legal_document]', t(:legal_document), class: c
- %p.help-block= t(:legal_document_max_size)
- .col-md-7
- = legal_document_field_tag 'domain[legal_document]', required: fr
- .col-md-4
- %p.domain-general-help= t(:domain_general_help).html_safe
- %p.domain-admin-contact-help= t(:domain_admin_contact_help).html_safe
- %p.domain-tech-contact-help= t(:domain_tech_contact_help).html_safe
-
- .row
- .col-md-8.text-right
- = button_tag(t('.save_btn'), class: 'btn btn-warning')
diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb
deleted file mode 100644
index 584b15ba1..000000000
--- a/app/views/registrar/domains/_search_form.html.erb
+++ /dev/null
@@ -1,89 +0,0 @@
-<%= search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
-
-
-
- <%= f.label :name, for: nil %>
- <%= f.search_field :name_matches, value: search_params[:name_matches], class: 'form-control',
- placeholder: t(:name) %>
-
-
-
-
-
- <%= f.label :registrant_ident, for: nil %>
- <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
-
-
-
-
-
- <%= f.label :contact_ident, for: nil %>
- <%= f.search_field :contacts_ident_eq, value: search_params[:contacts_ident_eq],
- class: 'form-control', placeholder: t(:contact_ident) %>
-
-
-
-
-
- <%= f.label :nameserver_hostname, for: nil %>
- <%= f.search_field :nameservers_hostname_eq, class: 'form-control',
- placeholder: t(:nameserver_hostname) %>
-
-
-
-
-
-
-
- <%= label_tag :status, nil, for: nil %>
- <%= select_tag :statuses_contains,
- options_for_select(DomainStatus::STATUSES, params[:statuses_contains]),
- { multiple: true, class: 'form-control js-combobox' } %>
-
-
-
-
-
- <%= f.label :valid_to_gteq, for: nil %>
- <%= f.search_field :valid_to_gteq, value: search_params[:valid_to_gteq],
- class: 'form-control js-datepicker',
- placeholder: t(:valid_to_from) %>
-
-
-
-
-
- <%= f.label :valid_to_lteq, for: nil %>
- <%= f.search_field :valid_to_lteq, value: search_params[:valid_to_lteq],
- class: 'form-control js-datepicker',
- placeholder: t(:valid_to_until) %>
-
-
-
-
-
-
- <%= label_tag :results_per_page, nil, for: nil %>
-
-
-
-
-
-
- <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control',
- placeholder: t(:results_per_page) %>
-
-
-
-
-
-
-
-
-
- <%= button_tag t('.download_btn'), formaction: registrar_domains_path(format: 'csv'),
- class: 'btn btn-default' %>
- <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %>
-
-
-<% end %>
diff --git a/app/views/registrar/domains/check.haml b/app/views/registrar/domains/check.haml
deleted file mode 100644
index f8ebfeaca..000000000
--- a/app/views/registrar/domains/check.haml
+++ /dev/null
@@ -1,25 +0,0 @@
-= render 'shared/title', name: t(:check_domain)
-
-.row
- .col-md-12
- = render 'check_form'
-
-%hr
-
-.row
- .col-md-12
- .panel.panel-default
- .panel-heading
- %h3.panel-title= t(:result)
- .panel-body
- %dl.dl-horizontal
- %dt= t(:name)
- %dd= @data.css('name').text
-
- - name = @data.css('name').first
- %dt= t(:available)
- %dd= name['avail']
-
- - if @data.css('reason').text.present?
- %dt= t(:reason)
- %dd= @data.css('reason').text
diff --git a/app/views/registrar/domains/check_index.haml b/app/views/registrar/domains/check_index.haml
deleted file mode 100644
index ee4bf074b..000000000
--- a/app/views/registrar/domains/check_index.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-= render 'shared/title', name: t(:check_domain)
-
-.row
- .col-md-12
- = render 'check_form'
diff --git a/app/views/registrar/domains/delete.haml b/app/views/registrar/domains/delete.haml
deleted file mode 100644
index bea9ed118..000000000
--- a/app/views/registrar/domains/delete.haml
+++ /dev/null
@@ -1,25 +0,0 @@
-= render 'shared/title', name: "#{t(:delete)}: #{params[:domain_name]}"
-
-= form_tag(destroy_registrar_domains_path, class: 'form-horizontal', multipart: true, method: :delete) do
- .col-md-8
- .panel.panel-default
- .panel-heading.clearfix
- = t(:legal_document)
- .panel-body
- .form-group
- .col-md-4.control-label
- = label_tag 'domain[verified]', t(:verified)
- .col-md-6
- = check_box_tag 'domain[verified]', '1', params[:verified].eql?('1'), onclick: ("return (confirm('#{t(:verified_confirm)}') ? true : false);" if current_registrar_user.legaldoc_mandatory?)
-
- .form-group
- .col-md-4.control-label
- = label_tag 'domain[legal_document]', t(:legal_document)
- %p.help-block= t(:legal_document_max_size)
- .col-md-6
- = file_field_tag 'domain[legal_document]'
- = hidden_field_tag 'domain[name]', params[:domain_name]
- %hr
- .row
- .col-md-8.text-right
- = button_tag t(:delete), class: 'btn btn-danger'
diff --git a/app/views/registrar/domains/edit.haml b/app/views/registrar/domains/edit.haml
deleted file mode 100644
index 4b8d5db6b..000000000
--- a/app/views/registrar/domains/edit.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-= render 'shared/title', name: "#{t(:edit)}: #{params[:domain_name]}"
-
-= render 'form'
diff --git a/app/views/registrar/domains/form/_contacts.haml b/app/views/registrar/domains/form/_contacts.haml
deleted file mode 100644
index 8e01ffda3..000000000
--- a/app/views/registrar/domains/form/_contacts.haml
+++ /dev/null
@@ -1,44 +0,0 @@
-#js-domain-contacts
- - @domain_params['contacts_attributes'].each do |k, v|
- .js-contact
- .panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:contact)
- .pull-right
- = link_to(t(:add_another), '#', class: 'btn btn-default btn-xs add-domain-contact')
- = link_to(t(:delete), '#', class: 'btn btn-default btn-xs destroy')
- .panel-body
- .form-group
- .col-md-3.control-label
- = label_tag "domain_contacts_attributes_#{k}_type", t(:contact_type), class: 'required'
- .col-md-7
- = select_tag "domain[contacts_attributes][#{k}][type]", options_for_select(['admin', 'tech'], v['type']), {class: 'form-control js-contact-type'}
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_contacts_attributes_#{k}_code", t(:id), class: 'required'
- .col-md-7.has-feedback
- = text_field_tag "domain[contacts_attributes][#{k}][code]", v['code'], class: "hidden"
- = text_field_tag "domain[contacts_attributes][#{k}][code_helper]", contacts.find_by(code: v['code']).try(:search_name), class: 'form-control', data: {autocomplete: search_contacts_registrar_domains_path}, required: true
-
-:coffee
- load_listener = ->
- clone = $('.js-contact:first').clone()
- $("#js-domain-contacts").nestedAttributes
- bindAddTo: $(".add-domain-contact")
- afterAdd: (item) ->
- # preselect type
- item.find('select.js-contact-type').each (k, v) ->
- $(v).val($(v).find('option:last-child').val())
- # add combobex
- item.find('select.js-contact-code').each (k, v) ->
- $(v).select2
- width: "100%"
- selectOnBlur: true
- dropdownAutoWidth: if self==top then true else false
- # remove link for temp
- item.find('a.add-domain-contact').each (k, v) ->
- $(v).hide()
- new Autocomplete()
- $clone: clone
- window.addEventListener 'load', load_listener
diff --git a/app/views/registrar/domains/form/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml
deleted file mode 100644
index 630e16303..000000000
--- a/app/views/registrar/domains/form/_dnskeys.haml
+++ /dev/null
@@ -1,77 +0,0 @@
-#dnskeys
- - @domain_params['dnskeys_attributes'].each do |k, v|
- .panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:dnskey)
- .pull-right
- = link_to(t(:add_another), '#', class: 'btn btn-default btn-xs add-dnskey')
- = link_to(t(:delete), '#', class: 'btn btn-default btn-xs destroy')
- .panel-body
- - if ENV['show_ds_data_fields'] == 'true'
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_ds_key_tag", t(:ds_key_tag)
- .col-md-7
- = text_field_tag "domain[dnskeys_attributes][#{k}][ds_key_tag]", v['ds_key_tag'],
- {class: 'form-control'}
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_ds_alg", t(:ds_algorithm)
- .col-md-7
- = select_tag "domain[dnskeys_attributes][#{k}][ds_alg]",
- options_for_select(Depp::Dnskey::ALGORITHMS, v['ds_alg']), {class: 'form-control'}
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_ds_digest_type", t(:ds_digest_type)
- .col-md-7
- = select_tag "domain[dnskeys_attributes][#{k}][ds_digest_type]",
- options_for_select(Depp::Dnskey::DS_DIGEST_TYPES, v['ds_digest_type']),
- {class: 'form-control'}
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_ds_digest", t(:ds_digest)
- .col-md-7
- = text_field_tag "domain[dnskeys_attributes][#{k}][ds_digest]", v['ds_digest'],
- {class: 'form-control'}
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_flags", t('.flags')
- .col-md-7
- = select_tag "domain[dnskeys_attributes][#{k}][flags]",
- options_for_select(Depp::Dnskey::FLAGS, v['flags']),
- { class: 'form-control' }
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_protocol", t(:protocol)
- .col-md-7
- = select_tag "domain[dnskeys_attributes][#{k}][protocol]",
- options_for_select(Depp::Dnskey::PROTOCOLS, v['protocol']),
- { class: 'form-control' }
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_alg", t('.alg')
- .col-md-7
- = select_tag "domain[dnskeys_attributes][#{k}][alg]",
- options_for_select(Depp::Dnskey::ALGORITHMS, v['alg']), { class: 'form-control' }
-
- .form-group
- .col-md-3.control-label
- = label_tag "domain_dnskeys_attributes_#{k}_public_key", t(:public_key)
- .col-md-7
- = text_field_tag "domain[dnskeys_attributes][#{k}][public_key]", v['public_key'],
- class: 'form-control'
-
-:coffee
- load_listener = ->
- $("#dnskeys").nestedAttributes
- bindAddTo: $(".add-dnskey")
- afterAdd: (item) ->
- item.find('select').each (k, v) ->
- $(v).val($(v).find('option:first-child').val())
- window.addEventListener 'load', load_listener
diff --git a/app/views/registrar/domains/form/_general.haml b/app/views/registrar/domains/form/_general.haml
deleted file mode 100644
index 5fa4d2a89..000000000
--- a/app/views/registrar/domains/form/_general.haml
+++ /dev/null
@@ -1,39 +0,0 @@
-.general-tab.panel.panel-default
- .panel-body
- .form-group
- .col-md-3.control-label
- = label_tag :domain_name, t(:name), class: 'required'
- .col-md-7
- - readonly = params[:domain_name] ? true : false
- = text_field_tag('domain[name]', @domain_params[:name],
- class: 'form-control', readonly: readonly, required: true)
-
- - unless params[:domain_name]
- .form-group
- .col-md-3.control-label
- = label_tag :domain_period, t(:period), class: 'required'
- .col-md-7
- = select_tag 'domain[period]',
- options_for_select(Depp::Domain::PERIODS, @domain_params[:period]), { class: 'form-control' }
-
- .form-group
- .col-md-3.control-label
- = label_tag :domain_registrant, t('.registrant'), class: 'required'
- .col-md-7
- = text_field_tag 'domain[registrant]', @domain_params[:registrant], class: "hidden"
- = text_field_tag 'domain[registrant_helper]', contacts.find_by(code: @domain_params[:registrant]).try(:search_name),
- class: 'form-control', data: {autocomplete: search_contacts_registrar_domains_path}, required: true
-
- - if params[:domain_name]
- .form-group
- .col-md-3.control-label
- = label_tag :verified, t(:verified)
- .col-md-7
- = check_box_tag 'domain[verified]', '1', @domain_params[:verified].eql?('1'), onclick: "return (confirm('#{t(:verified_confirm)}') ? true : false);"
-
- - if !params[:domain_name] || @dispute.present?
- .form-group
- .col-md-3.control-label
- = label_tag :domain_reserved_pw, t(:reserved_pw)
- .col-md-7
- = text_field_tag('domain[reserved_pw]', @domain_params[:reserved_pw], class: 'form-control')
diff --git a/app/views/registrar/domains/form/_nameservers.haml b/app/views/registrar/domains/form/_nameservers.haml
deleted file mode 100644
index 75d34b924..000000000
--- a/app/views/registrar/domains/form/_nameservers.haml
+++ /dev/null
@@ -1,33 +0,0 @@
-#nameservers
- - @domain_params['nameservers_attributes'].each do |k, v|
- .panel.panel-default
- .panel-heading.clearfix
- .pull-left= t(:nameserver)
- .pull-right
- = link_to(t(:add_another), '#', class: 'btn btn-default btn-xs add-nameserver')
- = link_to(t(:delete), '#', class: 'btn btn-default btn-xs destroy')
- .panel-body
- .form-group
- .col-md-3.control-label
- = label_tag "domain_nameservers_attributes_#{k}_hostname", t(:hostname),
- class: Domain.nameserver_required? ? 'required' : nil
- .col-md-7
- = text_field_tag "domain[nameservers_attributes][#{k}][hostname]", v['hostname'],
- class: 'form-control', required: Domain.nameserver_required?
- .form-group
- .col-md-3.control-label
- = label_tag "domain_nameservers_attributes_#{k}_ipv4", t(:ipv4)
- .col-md-7
- = text_field_tag "domain[nameservers_attributes][#{k}][ipv4]", v['ipv4'],
- class: 'form-control'#, ipv4: true
- .form-group
- .col-md-3.control-label
- = label_tag "domain_nameservers_attributes_#{k}_ipv6", t(:ipv6)
- .col-md-7
- = text_field_tag "domain[nameservers_attributes][#{k}][ipv6]", v['ipv6'],
- class: 'form-control'#, ipv6: true
-:coffee
- load_listener = ->
- $("#nameservers").nestedAttributes
- bindAddTo: $(".add-nameserver")
- window.addEventListener 'load', load_listener
diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb
deleted file mode 100644
index c643fd613..000000000
--- a/app/views/registrar/domains/index.html.erb
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
- <%= render 'search_form' %>
-
-
-
-
-
-
-
-
-
-
- <%= sort_link(@q, 'name') %>
-
-
- <%= sort_link @q, 'registrant_name', Registrant.model_name.human %>
-
-
- <%= sort_link @q, 'valid_to', Domain.human_attribute_name(:expire_time) %>
-
-
-
-
-
-
- <%= render partial: 'domain', collection: @domains %>
-
-
-
-
-
-
-
-
- <%= paginate @domains %>
-
-
-
-
-
-
diff --git a/app/views/registrar/domains/info.html.erb b/app/views/registrar/domains/info.html.erb
deleted file mode 100644
index c2f219bf9..000000000
--- a/app/views/registrar/domains/info.html.erb
+++ /dev/null
@@ -1,59 +0,0 @@
-<% content_for :actions do %>
- <% if @data.css('pw').text.present? %>
- <%= link_to(t(:edit), edit_registrar_domains_path(domain_name: params[:domain_name]),
- class: 'btn btn-default') %>
- <%= link_to(t(:renew), renew_registrar_domains_path(domain_name: params[:domain_name]),
- class: 'btn btn-default') %>
- <% unless @pending_delete %>
- <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]),
- class: 'btn btn-default') %>
- <% end %>
- <% if @client_holded %>
- <%= link_to(t(:remove_client_hold), remove_hold_registrar_domains_path(domain_name: params[:domain_name]),
- class: 'btn btn-default') %>
- <% end %>
- <% else %>
- <%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path(domain_name: params[:domain_name]),
- class: 'btn btn-default' %>
- <% end %>
-<% end %>
-<%= render 'shared/title', name: truncate(@data.css('name').text) %>
-
-
- <% if @data.css('result').first['code'] == '1000' %>
-
-
- <%= render 'registrar/domains/partials/general' %>
-
-
-
-
- <%= render 'registrar/domains/partials/contacts' %>
-
-
-
-
- <%= render 'registrar/domains/partials/statuses' %>
-
-
-
-
- <%= render 'registrar/domains/partials/nameservers' %>
-
-
-
-
- <%= render 'registrar/domains/partials/dnskeys' %>
-
-
- <% else %>
-
-
-
- <%= t(:not_found) %>
-
-
-
- <% end %>
-
-
diff --git a/app/views/registrar/domains/new.haml b/app/views/registrar/domains/new.haml
deleted file mode 100644
index 50808df22..000000000
--- a/app/views/registrar/domains/new.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-= render 'shared/title', name: t(:new_domain)
-
-= render 'form'
diff --git a/app/views/registrar/domains/partials/_contacts.haml b/app/views/registrar/domains/partials/_contacts.haml
deleted file mode 100644
index e6ef9aa8f..000000000
--- a/app/views/registrar/domains/partials/_contacts.haml
+++ /dev/null
@@ -1,17 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- %h3.panel-title= t(:contacts)
- .table-responsive
- %table.table.table-hover.table-bordered.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-4'}= t(:type)
- %th{class: 'col-xs-4'}= t(:name)
- %th{class: 'col-xs-4'}= t(:id)
- %tbody
- - @data.css('contact').each do |x|
- - registrant = Contact.find_by_code(x.text)
- %tr
- %td= x['type']
- %td= registrant.registrar == current_registrar_user.registrar ? registrant.name : 'N/A'
- %td= x.text
diff --git a/app/views/registrar/domains/partials/_dnskeys.haml b/app/views/registrar/domains/partials/_dnskeys.haml
deleted file mode 100644
index 7e8e5b940..000000000
--- a/app/views/registrar/domains/partials/_dnskeys.haml
+++ /dev/null
@@ -1,66 +0,0 @@
-.panel.panel-default
- .panel-heading
- %h3.panel-title= t(:dnskeys)
- .panel-body{style: 'word-wrap: break-word;'}
- .table-responsive
- %table.table.table-hover.table-condensed
- %tbody
- - @data.css('dsData').each_with_index do |x, index|
- - if x.css('digest').text.present?
- %tr
- %td
- %b= "#{t(:ds_key_tag)}:"
- = x.css('keyTag').text
- %tr
- %td
- %b= "#{t(:ds_algorithm)}:"
- = x.css('alg').first.text
- %tr
- %td
- %b= "#{t(:ds_digest_type)}:"
- = x.css('digestType').text
- %tr
- %td
- %b= "#{t(:ds_digest)}:"
- = x.css('digest').text
- %tr
- %td
- %b= "#{t(:flag)}:"
- = x.css('keyData').css('flags').text
- %tr
- %td
- %b= "#{t(:protocol)}:"
- = x.css('keyData').css('protocol').text
- %tr
- %td
- %b= "#{t(:algorithm)}:"
- = x.css('alg').last.text
- %tr
- %td{:colspan => "3"}
- %b= "#{t(:public_key)}:"
- = x.css('keyData').css('pubKey').text
- - if index != @data.css('keyData').size - 1
- %tr
- %td{:colspan => "3"}
- = " ".html_safe
-
- - if @data.css('dsData').empty?
- - @data.css('keyData').each_with_index do |x, index|
- %tr
- %td
- %b= "#{t(:flag)}:"
- = x.css('flags').text
- %td
- %b= "#{t(:protocol)}:"
- = x.css('protocol').text
- %td
- %b= "#{t(:algorithm)}:"
- = x.css('alg').text
- %tr
- %td{:colspan => "3"}
- %b= "#{t(:public_key)}:"
- = x.css('pubKey').text
- - if index != @data.css('keyData').size - 1
- %tr
- %td{:colspan => "3"}
- = " ".html_safe
\ No newline at end of file
diff --git a/app/views/registrar/domains/partials/_general.html.erb b/app/views/registrar/domains/partials/_general.html.erb
deleted file mode 100644
index ff064857c..000000000
--- a/app/views/registrar/domains/partials/_general.html.erb
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- <%= t(:general) %>
-
-
-
-
-
- <%= Domain.human_attribute_name :transfer_code %>
-
- <% if @data.css('pw').text.present? %>
- <%= tag(:input, type: 'text', value: @data.css('pw').text, readonly: true,
- class: 'form-control input-sm') %>
- <% end %>
-
-
-
- <% if @data.css('pw').text.blank? %>
- <%= t(:registrar_name) %>
- <%= @data.css('clID').text %>
- <% end %>
-
- <% registrant = Contact.find_by_code(@data.css('registrant').text) %>
- <%= t('.registrant') %>
- <%= registrant.registrar == current_registrar_user.registrar ? "#{registrant.name} (#{@data.css('registrant').text})" : @data.css('registrant').text %>
-
- <%= t('.registered') %>
- <%= @data.css('crDate').text %>
-
- <%= t(:valid_to) %>
- <%= @data.css('exDate').text %>
-
- <%= t('.created') %>
- <%= @data.css('crDate').text %>
-
- <%= t('.updated') %>
- <%= @data.css('upDate').text %>
-
-
-
diff --git a/app/views/registrar/domains/partials/_nameservers.haml b/app/views/registrar/domains/partials/_nameservers.haml
deleted file mode 100644
index 69f147bc4..000000000
--- a/app/views/registrar/domains/partials/_nameservers.haml
+++ /dev/null
@@ -1,17 +0,0 @@
-.panel.panel-default
- .panel-heading.clearfix
- %h3.panel-title= 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
- - @data.css('hostAttr').each do |x|
- %tr
- %td= x.css('hostName').text
- %td= Array(x.css('hostAddr[ip="v4"]')).map(&:text).join(", ")
- %td= Array(x.css('hostAddr[ip="v6"]')).map(&:text).join(", ")
-
diff --git a/app/views/registrar/domains/partials/_statuses.haml b/app/views/registrar/domains/partials/_statuses.haml
deleted file mode 100644
index 125309caf..000000000
--- a/app/views/registrar/domains/partials/_statuses.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-#domain_statuses.panel.panel-default
- .panel-heading.clearfix
- %h3.panel-title= 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
- - @data.css('status').each do |x|
- %tr
- %td= x['s']
- %td= x.text
diff --git a/app/views/registrar/domains/renew.haml b/app/views/registrar/domains/renew.haml
deleted file mode 100644
index aebcac4b4..000000000
--- a/app/views/registrar/domains/renew.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-= render 'shared/title', name: t(:renew_domain)
-
-.row
- .col-md-8
- .panel.panel-default
- .panel-heading
- %h3.panel-title= t(:result)
- .panel-body
- %dl.dl-horizontal
- %dt= t(:domain_name)
- %dd= @data.css('name').text
-
- %dt= t(:valid_to)
- %dd= @data.css('exDate').text
diff --git a/app/views/registrar/domains/renew_index.haml b/app/views/registrar/domains/renew_index.haml
deleted file mode 100644
index 92f7a8108..000000000
--- a/app/views/registrar/domains/renew_index.haml
+++ /dev/null
@@ -1,30 +0,0 @@
-= render 'shared/title', name: t(:renew_domain)
-
-.row
- .col-md-8
- = form_tag renew_registrar_domains_path, class: 'form-horizontal', method: :get do
- .form-group
- .col-md-3.control-label
- = label_tag :domain_name, t(:name), class: 'required'
- .col-md-7
- = text_field_tag :domain_name, params[:domain_name],
- class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', required: true
-
- .form-group
- .col-md-3.control-label
- = label_tag :cur_exp_date, t(:cur_exp_date), class: 'required'
- .col-md-7
- = text_field_tag :cur_exp_date, params[:cur_exp_date],
- class: 'form-control', placeholder: 'yyyy-mm-dd', autocomplete: 'off', required: true
-
- .form-group
- .col-md-3.control-label
- = label_tag :domain_period, t(:period), class: 'required'
- .col-md-7
- = select_tag :period,
- options_for_select(Depp::Domain::PERIODS, params[:period]), { class: 'form-control' }
-
- %hr
- .form-group
- .col-md-10.text-right
- %button.btn.btn-warning= t(:renew)
diff --git a/app/views/registrar/invoices/delivery/new.html.erb b/app/views/registrar/invoices/delivery/new.html.erb
deleted file mode 100644
index 20db81418..000000000
--- a/app/views/registrar/invoices/delivery/new.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-
- <%= link_to t('registrar.invoices.index.header'), registrar_invoices_path %>
- <%= link_to @invoice, registrar_invoice_path(@invoice) %>
-
-
-
-
-<%= form_tag(registrar_invoice_delivery_path(@invoice)) do %>
-
-
-
- <%= label_tag :recipient %>
- <%= email_field_tag :recipient, @recipient, required: true, autofocus: true,
- class: 'form-control' %>
-
-
-
- <%= submit_tag t('.submit_btn'), class: 'btn btn-warning' %>
-
-
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrar/invoices/index.haml b/app/views/registrar/invoices/index.haml
deleted file mode 100644
index cc15beeb8..000000000
--- a/app/views/registrar/invoices/index.haml
+++ /dev/null
@@ -1,73 +0,0 @@
-- content_for :actions do
- = link_to(t(:add_deposit), new_registrar_deposit_path, class: 'btn btn-primary')
- = link_to(t(:account_activity), registrar_account_activities_path, class: 'btn btn-default')
-= render 'shared/title', name: t(:your_account)
-
-= t(:your_current_account_balance_is,
- balance: currency(current_registrar_user.registrar.cash_account.balance),
- currency: current_registrar_user.registrar.cash_account.currency)
-
-%h1= t(:invoices)
-.row
- .col-md-12
- %hr
- = search_form_for @q, url: [:registrar, :invoices], html: { style: 'margin-bottom: 0;' } do |f|
- .row
- .col-md-3
- .form-group
- = f.label t(:minimum_invoice_no)
- = f.search_field :number_gteq, class: 'form-control', placeholder: t(:minimum_invoice_no), autocomplete: 'off'
- .col-md-3
- .form-group
- = f.label t(:maximum_invoice_no)
- = f.search_field :number_lteq, class: 'form-control', placeholder: t(:maximum_invoice_no), autocomplete: 'off'
- .col-md-3
- .form-group
- = f.label t(:due_date_from)
- = f.search_field :due_date_gteq, value: params[:q][:due_date_gteq], class: 'form-control js-datepicker', placeholder: t(:due_date_from)
- .col-md-3
- .form-group
- = f.label t(:due_date_until)
- = f.search_field :due_date_lteq, value: params[:q][:due_date_lteq], class: 'form-control js-datepicker', placeholder: t(:due_date_until)
- .row
- .col-md-3
- .form-group
- = f.label t(:minimum_total)
- = f.search_field :total_gteq, class: 'form-control', placeholder: t(:minimum_total), autocomplete: 'off'
- .col-md-3
- .form-group
- = f.label t(:maximum_total)
- = f.search_field :total_lteq, class: 'form-control', placeholder: t(:maximum_total), autocomplete: 'off'
- .col-md-3{style: 'padding-top: 25px;'}
- %button.btn.btn-default
-
- %span.glyphicon.glyphicon-search
-
- = link_to(t('.reset_btn'), registrar_invoices_path, class: 'btn btn-default')
-%hr
-.row
- .col-md-12
- .table-responsive
- %table.table.table-hover.table-condensed
- %thead
- %tr
- %th{class: 'col-xs-3'}= t('invoice.title')
- %th{class: 'col-xs-3'}= Invoice.human_attribute_name :receipt_date
- %th{class: 'col-xs-3'}= t(:due_date)
- %th{class: 'col-xs-3'}= t(:total)
- %tbody
- - @invoices.each do |invoice|
- %tr
- %td= link_to(invoice, [:registrar, invoice])
- - if invoice.paid?
- %td= l invoice.receipt_date
- - elsif invoice.cancelled?
- %td.text-grey= t(:cancelled)
- - else
- %td{class: 'text-danger'}= t(:unpaid)
-
- %td= l invoice.due_date
- %td= currency(invoice.total)
-.row
- .col-md-12
- = paginate @invoices
diff --git a/app/views/registrar/invoices/partials/_banklinks.haml b/app/views/registrar/invoices/partials/_banklinks.haml
deleted file mode 100644
index 339ae4705..000000000
--- a/app/views/registrar/invoices/partials/_banklinks.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-%h4= t('registrar.invoices.pay_invoice')
-%hr
-
- - if @invoice.payment_link.present?
- = link_to @invoice.payment_link, target: :_blank do
- = image_tag("everypay.png", class: 'everypay', style: "width: 100px; height: 20px;")
- - else
- = "No everypay link"
diff --git a/app/views/registrar/invoices/show.haml b/app/views/registrar/invoices/show.haml
deleted file mode 100644
index dd19a0bea..000000000
--- a/app/views/registrar/invoices/show.haml
+++ /dev/null
@@ -1,23 +0,0 @@
-- content_for :actions do
- = link_to(t('.download_btn'), download_registrar_invoice_path(@invoice), class: 'btn btn-default')
- = link_to(t('.deliver_btn'), new_registrar_invoice_delivery_path(@invoice), class: 'btn btn-default')
- - if @invoice.cancellable?
- = link_to(t(:cancel), cancel_registrar_invoice_path(@invoice), method: :patch, class: 'btn btn-warning')
- = link_to(t(:back), registrar_invoices_path, class: 'btn btn-default')
-= render 'shared/title', name: @invoice.to_s
-= render 'shared/full_errors', object: @invoice
-
-.row
- .col-md-6= render 'registrar/invoices/partials/details'
-.row
- .col-md-6= render 'registrar/invoices/partials/seller'
- .col-md-6= render 'registrar/invoices/partials/buyer'
-.row
- - if @invoice.monthly_invoice
- .col-md-12= render 'registrar/invoices/partials/monthly_invoice_items'
- - else
- .col-md-12= render 'registrar/invoices/partials/items'
-
-- if @invoice.payable?
- .row.semifooter
- .col-md-6-offset-6.text-right= render 'registrar/invoices/partials/banklinks', locals: { payment_channels: PaymentOrder::CUSTOMER_PAYMENT_METHODS }
diff --git a/app/views/registrar/payments/pay.html.haml b/app/views/registrar/payments/pay.html.haml
deleted file mode 100644
index dd3fc982f..000000000
--- a/app/views/registrar/payments/pay.html.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-.h3
- = t('registrar.invoices.redirected_to_intermediary')
-
-.payment-form
- = form_tag @payment_order.form_url, method: :post do
- - @payment_order.form_fields.each do |k, v|
- = hidden_field_tag k, v
- = submit_tag t('registrar.invoices.go_to_intermediary')
-
-:javascript
- function load_listener() {
- $('.payment-form form').submit();
- }
- window.addEventListener('load', load_listener)
diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml
deleted file mode 100644
index c97d7a5d5..000000000
--- a/app/views/registrar/polls/show.haml
+++ /dev/null
@@ -1,48 +0,0 @@
-- if @data.css('msgQ').any?
- - msg_q = @data.css('msgQ').first
- .row
- .col-sm-12
- %h2= t '.header', count: msg_q['count']
- %hr
- .row
- .col-md-12
- .panel.panel-default
- .panel-heading.clearfix
- .pull-left= t('message_no', id: msg_q['id'])
- .pull-right
- - if @data.css('trnData trStatus').any? # this is a transfer request
- - unless ['serverApproved', 'clientApproved'].include?(@data.css('trStatus').first.text)
- = link_to(t(:confirm), 'javascript: void(0);', class: 'btn btn-warning btn-xs js-transfer-confirm')
- = link_to(t(:dequeue), registrar_poll_path(id: msg_q['id']), method: :delete, class: 'btn btn-primary btn-xs')
- .panel-body
- %dl.dl-horizontal
- %dt= t(:message)
- %dd= msg_q.css('msg').text
-
- %dt= t(:queue_date)
- %dd= @data.css('qDate').text
-
- %dl.dl-horizontal
- - if @data.css('trnData trStatus').any? # this is a transfer request
- = form_tag confirm_transfer_registrar_poll_path, class: 'js-transfer-form' do
- = hidden_field_tag 'domain[name]', @data.css('name').text
-
- - @data.css('trnData').children.each do |x|
- - next if x.blank?
- %dt= t(x.name)
- %dd= x.text
-
-- else
- .row
- .col-sm-12
- %h2= t '.header', count: 0
- %hr
- .row
- .col-md-12
- %p.bg-info{style: 'padding: 15px;'}= t(:you_have_no_new_messages)
-
-:coffee
- load_listener = ->
- $(".js-transfer-confirm").on "click", ->
- $(".js-transfer-form").submit()
- window.addEventListener 'load', load_listener
diff --git a/app/views/registrar/sessions/new.html.erb b/app/views/registrar/sessions/new.html.erb
deleted file mode 100644
index 2ce0b0f1a..000000000
--- a/app/views/registrar/sessions/new.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
<%= t '.header_html' %>
-
-
-
- <%= form_for resource, as: resource_name, url: session_path(resource_name) do |f| %>
- <%= f.text_field :username, placeholder: ApiUser.human_attribute_name(:username),
- autofocus: true,
- required: true,
- class: 'form-control' %>
- <%= f.password_field :password,
- placeholder: ApiUser.human_attribute_name(:password),
- required: true,
- class: 'form-control' %>
-
- <%= f.submit t('.submit_btn'), class: 'btn btn-lg btn-primary btn-block' %>
- <% end %>
-
-
-
-
-
<%= t('.sign_in_with_identity_document') %>
-
<%= t('.identity_document_text')%>
- <%= link_to t(:sign_in), "/auth/tara", method: :post, class: 'btn btn-lg btn-primary btn-block' %>
-
-
-
diff --git a/app/views/registrar/settings/balance_auto_reload/_form.html.erb b/app/views/registrar/settings/balance_auto_reload/_form.html.erb
deleted file mode 100644
index ecd34980e..000000000
--- a/app/views/registrar/settings/balance_auto_reload/_form.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render 'registrar/settings/balance_auto_reload/form/types/threshold', type: @type %>
\ No newline at end of file
diff --git a/app/views/registrar/settings/balance_auto_reload/edit.html.erb b/app/views/registrar/settings/balance_auto_reload/edit.html.erb
deleted file mode 100644
index 20aa88d2d..000000000
--- a/app/views/registrar/settings/balance_auto_reload/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
- <%= link_to t('registrar.account.show.header'), registrar_account_path %>
- <%= t '.header' %>
-
-
-
-
-<%= render 'form' %>
\ No newline at end of file
diff --git a/app/views/registrar/settings/balance_auto_reload/form/types/_threshold.erb b/app/views/registrar/settings/balance_auto_reload/form/types/_threshold.erb
deleted file mode 100644
index bcb649421..000000000
--- a/app/views/registrar/settings/balance_auto_reload/form/types/_threshold.erb
+++ /dev/null
@@ -1,40 +0,0 @@
-<%= t '.description' %>
-
-<%= form_for type, as: :type, url: registrar_settings_balance_auto_reload_path, method: :patch,
- html: { class: 'form-horizontal' } do |f| %>
- <%= render 'form_errors', target: type %>
-
-
-
-
-
-
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/registrar/shared/_epp_results.haml b/app/views/registrar/shared/_epp_results.haml
deleted file mode 100644
index 4dfaadaed..000000000
--- a/app/views/registrar/shared/_epp_results.haml
+++ /dev/null
@@ -1,31 +0,0 @@
-- if @data && @data.css('result')
- - @results ||= @data.css('result')
-
-- if @results || flash[:epp_results]
- - success_codes = %(1000, 1300, 1301, 200)
-
- - if @results
- - @results.each do |x|
- - next if success_codes.include?(x['code'])
- .row
- .col-md-12
- %p{class: "alert alert-danger"}
- = x.css('msg').text.split('[').first
- - if x.css('value').text.present?
- = " - #{x.css('value').text}"
- %span.pull-right
- = "[code: #{x['code']}]"
-
- - if flash[:epp_results]
- - flash[:epp_results].each do |x|
- - next if success_codes.include?(x['code']) && x['show'] != true
- - c = 'alert-danger'
- - c = 'alert-success' if success_codes.include?(x['code'])
- .row
- .col-md-12
- %p{class: "alert #{c}"}
- = x['msg'].split('[').first
- - if x['value'].present?
- = " - #{x['value']}"
- %span.pull-right
- = "[code: #{x['code']}]"
diff --git a/app/views/registrar/shared/_error_messages.haml b/app/views/registrar/shared/_error_messages.haml
deleted file mode 100644
index fd9b5bfbc..000000000
--- a/app/views/registrar/shared/_error_messages.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-- if f.object.errors.present?
- .alert.alert-warning
- %ul
- - f.object.errors.messages.each do |message|
- %li= message.second.first.split('[').first
diff --git a/app/views/registrar/tara/callback.html.erb b/app/views/registrar/tara/callback.html.erb
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/views/registrar/xml_consoles/show.haml b/app/views/registrar/xml_consoles/show.haml
deleted file mode 100644
index bb66116ee..000000000
--- a/app/views/registrar/xml_consoles/show.haml
+++ /dev/null
@@ -1,73 +0,0 @@
-= render 'shared/title', name: t(:xml_console)
-
-.row
- .col-md-8
- = form_tag(registrar_xml_console_path) do
- .form-group
- = text_area_tag(:payload, params[:payload], class: 'form-control', rows: 15, style: 'font-family:monospace; font-size: 11px;')
-
- = button_tag t(:send_epp_request), class: 'btn btn-default'
- .col-md-4
- %h4 Domain
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'create'}}
- Create
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'update'}}
- Update
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'info'}}
- Info
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'renew'}}
- Renew
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'check'}}
- Check
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'transfer'}}
- Transfer
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'delete'}}
- Delete
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'domain', epp_action: 'client_hold'}}
- Remove Client Hold
-
- %h4 Poll
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'poll', epp_action: 'poll'}}
- Poll
-
- %h4 Contact
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'create'}}
- Create
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'check'}}
- Check
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'check_multiple'}}
- Check(multiple)
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'delete'}}
- Delete
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'info'}}
- Info
- ,
- %a.js-load-xml{href: 'javascript:void(0)', data: {obj: 'contact', epp_action: 'update_chg'}}
- Update(chg)
-
-- if @result
- %hr
- .row
- .col-md-12
- = preserve do
- = CodeRay.scan(@result.to_s.force_encoding("UTF-8"), :xml).div().html_safe
-
-:javascript
- window.addEventListener('load',
- function(){
- $('.js-load-xml').click(function() {
- $.get('xml_console/load_xml', {obj: $(this).data('obj'), epp_action: $(this).data('epp-action')}, function(data) {
- $('textarea[name="payload"]').html(data);
- });
- });});
diff --git a/config/application.yml.sample b/config/application.yml.sample
index 5a92443c4..61bf6f223 100644
--- a/config/application.yml.sample
+++ b/config/application.yml.sample
@@ -62,15 +62,12 @@ contact_org_enabled: 'false'
# legal_document_types: "pdf,asice,sce,asics,scs,adoc,edoc,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx"
#
-# REGISTRAR configuration (DEPP)
+# REGISTRAR configuration
#
-show_ds_data_fields: 'false'
-default_nameservers_count: '2'
-default_admin_contacts_count: '1'
epp_port: '700'
-cert_path: '/home/registry/registry/shared/ca/certs/webclient.cert.pem'
-key_path: '/home/registry/registry/shared/ca/private/webclient.key.pem'
-epp_hostname: 'registry.gitlab.eu'
+cert_path: '/opt/ca/certs/webclient.crt.pem'
+key_path: '/opt/ca/private/webclient.key.pem'
+epp_hostname: 'epp_proxy'
repp_url: 'http://epp:3000/repp/v1/'
# Estonian Company Register
@@ -207,6 +204,10 @@ test:
cdns_scanner_output_file: 'test/fixtures/files/cdns_output.txt'
dnssec_resolver_ips: 8.8.8.8, 8.8.4.4
legal_documents_dir: 'test/fixtures/files'
+ shunter_default_adapter: "Shunter::Adapters::Memory"
+ shunter_enabled: "false"
+ shunter_redis_host: "redis"
+ shunter_redis_port: "6379"
openssl_config_path: 'test/fixtures/files/test_ca/openssl.cnf'
crl_dir: 'test/fixtures/files/test_ca/crl'
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 028c61b47..6e680b9c0 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -41,4 +41,6 @@ Rails.application.configure do
# If set to :null_store, Setting.x returns nil after first spec runs (database is emptied)
config.cache_store = :memory_store
+
+ config.log_level = :fatal
end
diff --git a/config/initializers/truemail.rb b/config/initializers/truemail.rb
index fbb2fbc40..10c7374c8 100644
--- a/config/initializers/truemail.rb
+++ b/config/initializers/truemail.rb
@@ -83,6 +83,6 @@ Truemail.configure do |config|
# stdout, write to file or both of these. Tracking event by default is :error
# Available tracking event: :all, :unrecognized_error, :recognized_error, :error
unless Rails.env.test?
- config.logger = { tracking_event: :all, stdout: true, log_absolute_path: Rails.root.join('log', 'truemail.log').to_s }
+ config.logger = { tracking_event: :error, stdout: true, log_absolute_path: Rails.root.join('log', 'truemail.log').to_s }
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index ae5177470..7a6fa2eb9 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -187,6 +187,9 @@ en:
required_ident_attribute_missing: "Required ident attribute missing: %{key}"
invalid_iso31661_alpha2: does not conform to ISO 3166-1 alpha-2 standard
invalid_iso8601_date: has invalid date format YYYY-MM-DD (ISO 8601)
+ invalid_cert: 'Invalid certificate'
+ failed_epp_conn: 'Failed to open connection to EPP server!'
+ epp_conn_error: 'CONNECTION ERROR - Is the EPP server running?'
code: 'Code'
action: 'Action'
@@ -380,33 +383,9 @@ en:
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
parameter_value_syntax_error: 'Parameter value syntax error:'
- # DEPP
- activemodel:
- errors:
- models:
- 'depp/contact':
- attributes:
- phone:
- invalid: "Phone number must be in +XXX.YYYYYYY format"
- too_long: "Phone number is too long"
- 'depp/user':
- attributes:
- base:
- failed_to_open_connection_to_epp_server: 'Failed to open connection to EPP server!'
- authorization_error: 'Authorization error'
- invalid_cert: 'Invalid certificate'
- not_active: 'User is not active'
- webserver_missing_user_name_directive: 'Webserver configuration error: Apache or nginx is missing user name directive.'
- webserver_user_name_directive_should_be_required: 'Webserver configuration error: Apache or nginx should require name directive.'
- tag:
- blank: "Username can't be blank"
- password:
- blank: "Password can't be blank"
-
username: 'Username'
register: 'Register'
domain_info: 'Domain info'
- xml_console: 'XML Console'
info: 'Info'
send_epp_request: 'Send EPP Request'
updated_at: 'Updated at'
diff --git a/config/routes.rb b/config/routes.rb
index 26b57b42b..d8d52f322 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -106,7 +106,7 @@ Rails.application.routes.draw do
end
end
namespace :registrar do
- resources :notifications, only: [:index, :show, :update] do
+ resources :notifications, only: %i[index show update] do
collection do
get '/all_notifications', to: 'notifications#all_notifications'
end
@@ -128,6 +128,11 @@ Rails.application.routes.draw do
post '/tara_callback', to: 'auth#tara_callback'
end
end
+ resource :xml_console, controller: 'xml_console', only: %i[create] do
+ collection do
+ get 'load_xml'
+ end
+ end
end
resources :domains, constraints: { id: /.*/ } do
resources :nameservers, only: %i[index create destroy], constraints: { id: /.*/ }, controller: 'domains/nameservers'
@@ -136,8 +141,8 @@ Rails.application.routes.draw do
resources :renew, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/renews'
resources :transfer, only: %i[create], constraints: { id: /.*/ }, controller: 'domains/transfers'
resources :statuses, only: %i[update destroy], constraints: { id: /.*/ }, controller: 'domains/statuses'
- match "dnssec", to: "domains/dnssec#destroy", via: "delete", defaults: { id: nil }
- match "contacts", to: "domains/contacts#destroy", via: "delete", defaults: { id: nil }
+ match 'dnssec', to: 'domains/dnssec#destroy', via: 'delete', defaults: { id: nil }
+ match 'contacts', to: 'domains/contacts#destroy', via: 'delete', defaults: { id: nil }
collection do
get ':id/transfer_info', to: 'domains#transfer_info', constraints: { id: /.*/ }
post 'transfer', to: 'domains#transfer'
@@ -197,93 +202,7 @@ Rails.application.routes.draw do
# REGISTRAR ROUTES
namespace :registrar do
- root 'polls#show'
-
devise_for :users, path: '', class_name: 'ApiUser', skip: %i[sessions]
-
- resources :invoices, except: %i[new create edit update destroy] do
- resource :delivery, controller: 'invoices/delivery', only: %i[new create]
-
- member do
- get 'download'
- patch 'cancel'
- end
- end
-
- resources :deposits
- resources :account_activities
-
- put 'current_user/switch/:new_user_id', to: 'current_user#switch', as: :switch_current_user
- resource :account, controller: :account, only: %i[show edit update]
-
- resources :domains do
- collection do
- post 'update', as: 'update'
- post 'destroy', as: 'destroy'
- get 'renew'
- get 'edit'
- get 'info'
- get 'check'
- get 'delete'
- get 'search_contacts'
- get 'remove_hold'
- end
- end
- resources :domain_transfers, only: %i[new create]
- resource :bulk_change, controller: :bulk_change, only: :new
- post '/bulk_renew/new', to: 'bulk_change#bulk_renew', as: :bulk_renew
- resource :tech_contacts, only: :update
- resource :admin_contacts, only: :update
- resource :nameservers, only: :update
- resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do
- member do
- get 'delete'
- end
-
- collection do
- get 'check'
- end
- end
-
- resource :poll, only: %i[show destroy] do
- collection do
- post 'confirm_transfer'
- end
- end
-
- resource :xml_console do
- collection do
- get 'load_xml'
- end
- end
-
- get 'pay/return/:payment_order' => 'payments#back', as: 'return_payment_with'
- post 'pay/return/:payment_order' => 'payments#back'
- put 'pay/return/:payment_order' => 'payments#back'
- post 'pay/callback/:payment_order' => 'payments#callback', as: 'response_payment_with'
- get 'pay/go/:bank' => 'payments#pay', as: 'payment_with'
-
- namespace :settings do
- resource :balance_auto_reload, controller: :balance_auto_reload, only: %i[edit update destroy]
- end
- end
-
- scope :registrar do
- devise_scope :registrar_user do
- get 'sign_in', to: 'registrar/sessions#new', as: :new_registrar_user_session
-
- # /registrar/sessions path is hardcoded in Apache config for certificate-based authentication
- # See https://github.com/internetee/registry/blob/master/README.md#installation
- # Client certificate is asked only on login form submission, therefore the path must be
- # different from the one in `new_registrar_user_session` route
- post 'sessions', to: 'registrar/sessions#create', as: :registrar_user_session
-
- delete 'sign_out', to: 'registrar/sessions#destroy', as: :destroy_registrar_user_session
-
- # TARA
- match '/open_id/callback', via: %i[get post], to: 'sso/tara#registrar_callback'
- match '/open_id/cancel', via: %i[get post delete], to: 'sso/tara#cancel'
- end
end
namespace :registrant do
diff --git a/db/migrate/20220715145808_add_registrant_publishable_to_contacts.rb b/db/migrate/20220715145808_add_registrant_publishable_to_contacts.rb
new file mode 100644
index 000000000..d7d4ab426
--- /dev/null
+++ b/db/migrate/20220715145808_add_registrant_publishable_to_contacts.rb
@@ -0,0 +1,5 @@
+class AddRegistrantPublishableToContacts < ActiveRecord::Migration[6.1]
+ def change
+ add_column :contacts, :registrant_publishable, :boolean, default: false
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 0e37313ef..661b4e66b 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -216,7 +216,7 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex
SET default_tablespace = '';
-SET default_with_oids = false;
+SET default_table_access_method = heap;
--
-- Name: account_activities; Type: TABLE; Schema: public; Owner: -
@@ -670,7 +670,8 @@ CREATE TABLE public.contacts (
up_date timestamp without time zone,
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
disclosed_attributes character varying[] DEFAULT '{}'::character varying[] NOT NULL,
- email_history character varying
+ email_history character varying,
+ registrant_publishable boolean DEFAULT false
);
@@ -955,14 +956,15 @@ CREATE TABLE public.domains (
pending_json jsonb,
force_delete_date date,
statuses character varying[],
- status_notes public.hstore,
+ statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[],
upid integer,
up_date timestamp without time zone,
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
locked_by_registrant_at timestamp without time zone,
force_delete_start timestamp without time zone,
force_delete_data public.hstore,
- json_statuses_history jsonb
+ json_statuses_history jsonb,
+ status_notes public.hstore
);
@@ -2285,74 +2287,6 @@ CREATE SEQUENCE public.payment_orders_id_seq
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
---
--- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.pghero_query_stats (
- id bigint NOT NULL,
- database text,
- "user" text,
- query text,
- query_hash bigint,
- total_time double precision,
- calls bigint,
- captured_at timestamp without time zone
-);
-
-
---
--- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.pghero_query_stats_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id;
-
-
---
--- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.pghero_space_stats (
- id bigint NOT NULL,
- database text,
- schema text,
- relation text,
- size bigint,
- captured_at timestamp without time zone
-);
-
-
---
--- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.pghero_space_stats_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id;
-
-
--
-- Name: prices; Type: TABLE; Schema: public; Owner: -
--
@@ -2391,48 +2325,6 @@ CREATE SEQUENCE public.prices_id_seq
ALTER SEQUENCE public.prices_id_seq OWNED BY public.prices.id;
---
--- Name: que_jobs; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.que_jobs (
- priority smallint DEFAULT 100 NOT NULL,
- run_at timestamp with time zone DEFAULT now() NOT NULL,
- job_id bigint NOT NULL,
- job_class text NOT NULL,
- args json DEFAULT '[]'::json NOT NULL,
- error_count integer DEFAULT 0 NOT NULL,
- last_error text,
- queue text DEFAULT ''::text NOT NULL
-);
-
-
---
--- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: -
---
-
-COMMENT ON TABLE public.que_jobs IS '3';
-
-
---
--- Name: que_jobs_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.que_jobs_job_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: que_jobs_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.que_jobs_job_id_seq OWNED BY public.que_jobs.job_id;
-
-
--
-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -
--
@@ -2713,7 +2605,8 @@ CREATE TABLE public.validation_events (
validation_eventable_type character varying,
validation_eventable_id bigint,
created_at timestamp(6) without time zone NOT NULL,
- updated_at timestamp(6) without time zone NOT NULL
+ updated_at timestamp(6) without time zone NOT NULL,
+ event_type public.validation_type
);
@@ -3255,20 +3148,6 @@ ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('publi
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
---
--- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass);
-
-
---
--- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass);
-
-
--
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -3276,13 +3155,6 @@ ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('
ALTER TABLE ONLY public.prices ALTER COLUMN id SET DEFAULT nextval('public.prices_id_seq'::regclass);
---
--- Name: que_jobs job_id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.que_jobs ALTER COLUMN job_id SET DEFAULT nextval('public.que_jobs_job_id_seq'::regclass);
-
-
--
-- Name: registrant_verifications id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -3792,22 +3664,6 @@ ALTER TABLE ONLY public.payment_orders
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
---
--- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.pghero_query_stats
- ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id);
-
-
---
--- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.pghero_space_stats
- ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id);
-
-
--
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -3816,14 +3672,6 @@ ALTER TABLE ONLY public.prices
ADD CONSTRAINT prices_pkey PRIMARY KEY (id);
---
--- Name: que_jobs que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.que_jobs
- ADD CONSTRAINT que_jobs_pkey PRIMARY KEY (queue, priority, run_at, job_id);
-
-
--
-- Name: registrant_verifications registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -4578,20 +4426,6 @@ CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING b
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
---
--- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at);
-
-
---
--- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at);
-
-
--
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
--
@@ -4648,6 +4482,13 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
+--
+-- Name: index_validation_events_on_event_type; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_validation_events_on_event_type ON public.validation_events USING btree (event_type);
+
+
--
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
--
@@ -5393,11 +5234,9 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210708131814'),
('20210729131100'),
('20210729134625'),
-('20211028122103'),
-('20211028125245'),
-('20211029082225'),
+('20210827185249'),
+('20211029073644'),
('20211124071418'),
-('20211124084308'),
('20211125181033'),
('20211125184334'),
('20211126085139'),
@@ -5406,6 +5245,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220113201642'),
('20220113220809'),
('20220124105717'),
+('20220216113112'),
('20220228093211'),
('20220316140727'),
('20220406085500'),
@@ -5416,6 +5256,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220504090512'),
('20220524130709'),
('20220701113409'),
+('20220715145808'),
('20220818075833'),
('20221011061840');
diff --git a/doc/registrant-api/v1/contact.md b/doc/registrant-api/v1/contact.md
index 87519c0aa..a36e0c1c6 100644
--- a/doc/registrant-api/v1/contact.md
+++ b/doc/registrant-api/v1/contact.md
@@ -102,18 +102,19 @@ Update contact.
#### Parameters
-| Field name | Required | Type | Allowed values | Description |
-| ---- | --- | --- | --- | --- |
-| name | false | String | | New name |
-| email | false | String | | New email |
-| phone | false | String | | New phone number |
-| fax | false | String | | New fax number |
-| address[street] | false | String | | New street name |
-| address[zip] | false | String | | New zip |
-| address[city] | false | String | | New city name |
-| address[state] | false | String | | New state name |
-| address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) |
-| disclosed_attributes | false | Array | | Possible values: "name", "email"
+| Field name | Required | Type | Allowed values | Description |
+| ---- | --- | --- | --- | --- |
+| name | false | String | | New name |
+| email | false | String | | New email |
+| phone | false | String | | New phone number |
+| fax | false | String | | New fax number |
+| address[street] | false | String | | New street name |
+| address[zip] | false | String | | New zip |
+| address[city] | false | String | | New city name |
+| address[state] | false | String | | New state name |
+| address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) |
+| disclosed_attributes | false | Array | | Possible values: "name", "email", "phone" |
+| registrant_publishable | false | Boolean | | Possible values: true, false |
#### Request
diff --git a/lib/serializers/registrant_api/contact.rb b/lib/serializers/registrant_api/contact.rb
index 023544174..6f3aa03b9 100644
--- a/lib/serializers/registrant_api/contact.rb
+++ b/lib/serializers/registrant_api/contact.rb
@@ -31,6 +31,7 @@ module Serializers
auth_info: contact.auth_info,
statuses: contact.statuses,
disclosed_attributes: contact.disclosed_attributes,
+ registrant_publishable: contact.registrant_publishable,
}
obj[:links] = contact.related_domains if @links
diff --git a/lib/serializers/repp/domain.rb b/lib/serializers/repp/domain.rb
index c851a1f0d..ee34ec4fe 100644
--- a/lib/serializers/repp/domain.rb
+++ b/lib/serializers/repp/domain.rb
@@ -58,12 +58,13 @@ module Serializers
}
end
- def statuses
- statuses_with_notes = domain.status_notes
+ def statuses(statuses_with_notes = {})
+ status_notes = domain.status_notes
domain.statuses.each do |status|
- statuses_with_notes.merge!({ "#{status}": '' }) unless statuses_with_notes.key?(status)
+ status_note = status_notes[status.to_s].presence || ''
+ statuses_with_notes.merge!({ "#{status}": status_note })
end
- statuses_with_notes
+ statuses_with_notes.with_indifferent_access
end
private
diff --git a/lib/tasks/assing_auction_platform_type.rake b/lib/tasks/assing_auction_platform_type.rake
new file mode 100644
index 000000000..aaa3e54be
--- /dev/null
+++ b/lib/tasks/assing_auction_platform_type.rake
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+namespace :auction do
+ desc 'Check closed disputes with expired_at in the Past'
+ task assign_platform_type: :environment do
+ auctions = Auction.where(platform: nil)
+
+ auctions.each do |auction|
+ auction.update(platform: :auto)
+ end
+ end
+end
diff --git a/lib/tasks/outzone_invalid_email_domains.rake b/lib/tasks/outzone_invalid_email_domains.rake
new file mode 100644
index 000000000..bba329f83
--- /dev/null
+++ b/lib/tasks/outzone_invalid_email_domains.rake
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+desc 'Rake task run outzone setter task for force deleted domains by invalid emails'
+
+task outzone_invalid_email_domains: :environment do
+ OutzoneInvalidEmailDomainsJob.perform_later
+end
diff --git a/test/integration/api/domain_admin_contacts_test.rb b/test/integration/api/domain_admin_contacts_test.rb
index 6aa412c23..8064483bc 100644
--- a/test/integration/api/domain_admin_contacts_test.rb
+++ b/test/integration/api/domain_admin_contacts_test.rb
@@ -10,6 +10,8 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
@admin_new.update(ident: @admin_current.ident,
ident_type: @admin_current.ident_type,
ident_country_code: @admin_current.ident_country_code)
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_replace_all_admin_contacts_when_ident_data_doesnt_match
@@ -148,6 +150,27 @@ class APIDomainAdminContactsTest < ApplicationIntegrationTest
JSON.parse(response.body, symbolize_names: true)
end
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ domain = domains(:airport)
+ domain.admin_contacts = [@admin_current]
+ patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
+ new_contact_id: @admin_new.code },
+ headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
+ patch '/repp/v1/domains/admin_contacts', params: { current_contact_id: @admin_current.code,
+ new_contact_id: @admin_new.code },
+ headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def http_auth_key
diff --git a/test/integration/api/v1/registrant/contacts/details_test.rb b/test/integration/api/v1/registrant/contacts/details_test.rb
index 0352ade8d..66aecb28a 100644
--- a/test/integration/api/v1/registrant/contacts/details_test.rb
+++ b/test/integration/api/v1/registrant/contacts/details_test.rb
@@ -38,7 +38,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
},
auth_info: @contact.auth_info,
statuses: @contact.statuses,
- disclosed_attributes: @contact.disclosed_attributes }),
+ disclosed_attributes: @contact.disclosed_attributes,
+ registrant_publishable: @contact.registrant_publishable }),
JSON.parse(response.body, symbolize_names: true)
end
diff --git a/test/integration/api/v1/registrant/contacts/update_test.rb b/test/integration/api/v1/registrant/contacts/update_test.rb
index d7a3060b6..d3fba62c3 100644
--- a/test/integration/api/v1/registrant/contacts/update_test.rb
+++ b/test/integration/api/v1/registrant/contacts/update_test.rb
@@ -9,7 +9,6 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@original_address_processing = Setting.address_processing
@original_fax_enabled_setting = ENV['fax_enabled']
@user = users(:registrant)
-
end
teardown do
@@ -92,7 +91,7 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_update_address_when_enabled_without_address_params
- Setting.address_processing = true
+ Setting.address_processing = false
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { } },
as: :json,
@@ -104,19 +103,6 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@contact.address
end
- def test_update_address_when_enabled_without_address_params
- Setting.address_processing = true
-
- patch api_v1_registrant_contact_path(@contact.uuid), params: { },
- as: :json,
- headers: { 'HTTP_AUTHORIZATION' => auth_token }
-
- assert_response :bad_request
- @contact.reload
- assert_equal Contact::Address.new(nil, nil, nil, nil, nil),
- @contact.address
- end
-
def test_address_is_optional_when_enabled
Setting.address_processing = true
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
@@ -192,7 +178,7 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_legal_persons_disclosed_attributes_cannot_be_changed
@contact = contacts(:acme_ltd)
- # contacts(:acme_ltd).ident
+ contacts(:acme_ltd).ident
assert_equal '1234567', @contact.ident
assert_equal Contact::ORG, @contact.ident_type
@@ -215,38 +201,52 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
JSON.parse(response.body, symbolize_names: true)
end
- def test_return_contact_details
- patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
+ def test_legal_persons_disclosed_attributes_change_when_phone
+ @contact = contacts(:acme_ltd)
+ @contact.update!(disclosed_attributes: %w[])
+
+ patch api_v1_registrant_contact_path(@contact.uuid),
+ params: { disclosed_attributes: %w[phone] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
- assert_equal ({ id: @contact.uuid,
- name: 'new name',
- code: @contact.code,
- fax: @contact.fax,
- ident: {
- code: @contact.ident,
- type: @contact.ident_type,
- country_code: @contact.ident_country_code,
- },
- email: @contact.email,
- phone: @contact.phone,
- address: {
- street: @contact.street,
- zip: @contact.zip,
- city: @contact.city,
- state: @contact.state,
- country_code: @contact.country_code,
- },
- auth_info: @contact.auth_info,
- statuses: @contact.statuses,
- disclosed_attributes: @contact.disclosed_attributes }),
- JSON.parse(response.body, symbolize_names: true)
+ @contact.reload
+
+ assert_response :ok
+ assert_equal %w[phone], @contact.disclosed_attributes
+ end
+
+ def test_registrant_publishable_change_when_true
+ @contact = contacts(:acme_ltd)
+ @contact.update!(registrant_publishable: false)
+
+ patch api_v1_registrant_contact_path(@contact.uuid),
+ params: { disclosed_attributes: %w[], registrant_publishable: true },
+ as: :json,
+ headers: { 'HTTP_AUTHORIZATION' => auth_token }
+ @contact.reload
+
+ assert_response :ok
+ assert @contact.registrant_publishable
+ end
+
+ def test_registrant_publishable_change_when_false
+ @contact = contacts(:acme_ltd)
+ @contact.update!(registrant_publishable: true)
+
+ patch api_v1_registrant_contact_path(@contact.uuid),
+ params: { disclosed_attributes: %w[], registrant_publishable: false },
+ as: :json,
+ headers: { 'HTTP_AUTHORIZATION' => auth_token }
+ @contact.reload
+
+ assert_response :ok
+ assert_not @contact.registrant_publishable
end
def test_errors
patch api_v1_registrant_contact_path(@contact.uuid), params: { phone: 'invalid' },
- as: :json,
- headers: { 'HTTP_AUTHORIZATION' => auth_token }
+ as: :json,
+ headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :bad_request
assert_equal ({ errors: { phone: ['Phone nr is invalid'] } }), JSON.parse(response.body,
@@ -254,13 +254,13 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_org_disclosed_attributes
- patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
+ patch api_v1_registrant_contact_path(@contact_org.uuid), params: { disclosed_attributes: ["some_attr"] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :bad_request
- err_msg = "Legal person's data is visible by default and cannot be concealed. Please remove this parameter."
+ err_msg = "Request contains extra attributes: some_attr"
response_json = JSON.parse(response.body, symbolize_names: true)
response_msg = response_json[:errors][0][:disclosed_attributes][0]
diff --git a/test/integration/epp/contact/check/base_test.rb b/test/integration/epp/contact/check/base_test.rb
index 6ad027fc6..367436fc5 100644
--- a/test/integration/epp/contact/check/base_test.rb
+++ b/test/integration/epp/contact/check/base_test.rb
@@ -3,6 +3,9 @@ require 'test_helper'
class EppContactCheckBaseTest < EppTestCase
setup do
@contact = contacts(:john)
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_valid_response
@@ -157,6 +160,59 @@ class EppContactCheckBaseTest < EppTestCase
# assert_equal 'in use', response_xml.at_xpath('//contact:reason', contact: xml_schema).text
end
+ def test_returns_valid_response_if_not_throttled
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+
+
+ XML
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+
+
+ XML
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def xml_schema
diff --git a/test/integration/epp/contact/create/base_test.rb b/test/integration/epp/contact/create/base_test.rb
index ba94fcd6f..1f16d531f 100644
--- a/test/integration/epp/contact/create/base_test.rb
+++ b/test/integration/epp/contact/create/base_test.rb
@@ -1,6 +1,11 @@
require 'test_helper'
class EppContactCreateBaseTest < EppTestCase
+ setup do
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
+ end
+
def test_creates_new_contact_with_required_attributes
name = 'new'
email = 'new@registrar.test'
@@ -362,4 +367,82 @@ class EppContactCreateBaseTest < EppTestCase
assert_equal country_code, contact.country_code
assert_equal state, contact.state
end
+
+ def test_returns_valid_response_if_not_throttled
+ name = 'new'
+ email = 'new@registrar.test'
+ phone = '+1.2'
+
+ request_xml = <<-XML
+
+
+
+
+
+
+ #{name}
+
+ #{phone}
+ #{email}
+
+
+
+
+ any
+
+
+
+
+ XML
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ name = 'new'
+ email = 'new@registrar.test'
+ phone = '+1.2'
+
+ request_xml = <<-XML
+
+
+
+
+
+
+ #{name}
+
+ #{phone}
+ #{email}
+
+
+
+
+ any
+
+
+
+
+ XML
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/epp/contact/info/base_test.rb b/test/integration/epp/contact/info/base_test.rb
index dc8fcd5f7..09d0b0308 100644
--- a/test/integration/epp/contact/info/base_test.rb
+++ b/test/integration/epp/contact/info/base_test.rb
@@ -3,6 +3,9 @@ require 'test_helper'
class EppContactInfoBaseTest < EppTestCase
setup do
@contact = contacts(:john)
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_valid_response
@@ -129,6 +132,62 @@ class EppContactInfoBaseTest < EppTestCase
assert_equal 'No access', response_xml.at_xpath('//contact:name', contact: xml_schema).text
end
+ def test_returns_valid_response_if_not_throttled
+ @contact.update_columns(code: @contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+
+
+ XML
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ @contact.update_columns(code: @contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+
+
+ XML
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def xml_schema
diff --git a/test/integration/epp/contact/update/base_test.rb b/test/integration/epp/contact/update/base_test.rb
index 0c55c5223..6999e3f2d 100644
--- a/test/integration/epp/contact/update/base_test.rb
+++ b/test/integration/epp/contact/update/base_test.rb
@@ -6,6 +6,9 @@ class EppContactUpdateBaseTest < EppTestCase
setup do
@contact = contacts(:john)
ActionMailer::Base.deliveries.clear
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_updates_contact
@@ -470,6 +473,76 @@ class EppContactUpdateBaseTest < EppTestCase
assert_equal '+123.4', @contact.phone
end
+ def test_returns_valid_response_if_not_throttled
+ @contact.update_columns(code: @contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+ new name
+
+ +123.4
+ new-email@inbox.test
+
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ @contact.update_columns(code: @contact.code.upcase)
+
+ request_xml = <<-XML
+
+
+
+
+
+ john-001
+
+
+ new name
+
+ +123.4
+ new-email@inbox.test
+
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
diff --git a/test/integration/epp/domain/check/base_test.rb b/test/integration/epp/domain/check/base_test.rb
index 7a1c20c88..536d6525a 100644
--- a/test/integration/epp/domain/check/base_test.rb
+++ b/test/integration/epp/domain/check/base_test.rb
@@ -1,6 +1,11 @@
require 'test_helper'
class EppDomainCheckBaseTest < EppTestCase
+ setup do
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
+ end
+
def test_returns_valid_response
request_xml = <<-XML
@@ -193,4 +198,56 @@ class EppDomainCheckBaseTest < EppTestCase
assert_correct_against_schema response_xml
assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").size
end
+
+ def test_returns_valid_response_if_not_throttled
+ request_xml = <<-XML
+
+
+
+
+
+ some.test
+
+
+
+
+ XML
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ request_xml = <<-XML
+
+
+
+
+
+ some.test
+
+
+
+
+ XML
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_check_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb
index 4932c6989..180d165b3 100644
--- a/test/integration/epp/domain/create/base_test.rb
+++ b/test/integration/epp/domain/create/base_test.rb
@@ -1,6 +1,10 @@
require 'test_helper'
class EppDomainCreateBaseTest < EppTestCase
+ setup do
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
+ end
def test_illegal_chars_in_dns_key
name = "new.#{dns_zones(:one).origin}"
@@ -852,4 +856,85 @@ class EppDomainCreateBaseTest < EppTestCase
assert_correct_against_schema response_xml
assert_epp_response :completed_successfully
end
+
+ def test_returns_valid_response_if_not_throttled
+ now = Time.zone.parse('2010-07-05')
+ travel_to now
+ disputed_domain = disputes(:active)
+ password = disputed_domain.password
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{disputed_domain.domain_name}
+ #{contacts(:john).code}
+
+
+
+
+ #{'test' * 2000}
+
+ #{password}
+
+
+
+
+
+ XML
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ now = Time.zone.parse('2010-07-05')
+ travel_to now
+ disputed_domain = disputes(:active)
+ password = disputed_domain.password
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{disputed_domain.domain_name}
+ #{contacts(:john).code}
+
+
+
+
+ #{'test' * 2000}
+
+ #{password}
+
+
+
+
+
+ XML
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_create_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/epp/domain/info/base_test.rb b/test/integration/epp/domain/info/base_test.rb
index da3be1d38..15939e212 100644
--- a/test/integration/epp/domain/info/base_test.rb
+++ b/test/integration/epp/domain/info/base_test.rb
@@ -1,6 +1,11 @@
require 'test_helper'
class EppDomainInfoBaseTest < EppTestCase
+ setup do
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
+ end
+
def test_returns_valid_response
assert_equal 'john-001', contacts(:john).code
domains(:shop).update_columns(statuses: [DomainStatus::OK],
@@ -180,6 +185,63 @@ class EppDomainInfoBaseTest < EppTestCase
assert_correct_against_schema response_xml
end
+ def test_returns_valid_response_if_not_throttled
+ domain = domains(:shop)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{domain.name}
+
+
+
+
+ XML
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ domain = domains(:shop)
+
+ request_xml = <<-XML
+
+
+
+
+
+ #{domain.name}
+
+
+
+
+ XML
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_info_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ # binding.pry
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_returns_valid_response_if_release_prohibited
domain = domains(:shop)
domain.update_columns(statuses: [DomainStatus::SERVER_RELEASE_PROHIBITED],
diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb
index 10c92ebc5..dbcbe3cb2 100644
--- a/test/integration/epp/domain/update/base_test.rb
+++ b/test/integration/epp/domain/update/base_test.rb
@@ -10,6 +10,9 @@ class EppDomainUpdateBaseTest < EppTestCase
@original_registrant_change_verification =
Setting.request_confirmation_on_registrant_change_enabled
ActionMailer::Base.deliveries.clear
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
teardown do
@@ -882,6 +885,88 @@ class EppDomainUpdateBaseTest < EppTestCase
assert_epp_response :object_does_not_exist
end
+ def test_returns_valid_response_if_not_throttled
+ ENV['obj_and_extensions_prohibited'] = 'true'
+ @domain = domains(:shop)
+ @domain.statuses << DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED
+ @domain.save
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+ #{nameservers(:shop_ns1).hostname}
+
+
+ #{nameservers(:shop_ns2).hostname}
+
+
+
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+ ENV['obj_and_extensions_prohibited'] = 'true'
+ @domain = domains(:shop)
+ @domain.statuses << DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED
+ @domain.save
+
+ request_xml = <<-XML
+
+
+
+
+
+ shop.test
+
+
+
+ #{nameservers(:shop_ns1).hostname}
+
+
+ #{nameservers(:shop_ns2).hostname}
+
+
+
+
+
+
+
+ XML
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_update_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def assert_verification_and_notification_emails
diff --git a/test/integration/epp/poll_test.rb b/test/integration/epp/poll_test.rb
index 7b114f7c0..0f7dc3765 100644
--- a/test/integration/epp/poll_test.rb
+++ b/test/integration/epp/poll_test.rb
@@ -2,6 +2,8 @@ require 'test_helper'
class EppPollTest < EppTestCase
setup do
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
@notification = notifications(:complete)
end
@@ -149,6 +151,44 @@ class EppPollTest < EppTestCase
assert_epp_response :authorization_error
end
+ def test_returns_valid_response_if_not_throttled
+ notification = notifications(:greeting)
+
+ request_xml = <<-XML
+
+
+
+
+
+
+ XML
+
+ post epp_poll_path, params: { frame: request_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :completed_successfully
+ assert_correct_against_schema response_xml
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ post epp_poll_path, params: { frame: request_req_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ post epp_poll_path, params: { frame: request_req_xml },
+ headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
+
+ response_xml = Nokogiri::XML(response.body)
+ assert_epp_response :session_limit_exceeded_server_closing_connection
+ assert_correct_against_schema response_xml
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def request_req_xml
diff --git a/test/integration/registrar_area/contacts_test.rb b/test/integration/registrar_area/contacts_test.rb
deleted file mode 100644
index a8e50aafa..000000000
--- a/test/integration/registrar_area/contacts_test.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'test_helper'
-
-class RegistrarAreaContactsIntegrationTest < ApplicationIntegrationTest
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_downloads_list_as_csv
- get registrar_contacts_path(format: :csv)
-
- assert_response :ok
- assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
- assert_equal "attachment; filename=\"contacts.csv\"; filename*=UTF-8''contacts.csv", response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-
- def test_downloads_list_as_pdf
- get registrar_contacts_path(format: :pdf)
-
- assert_response :ok
- assert_equal Mime[:pdf], response.headers['Content-Type']
- assert_equal "attachment; filename=\"contacts.pdf\"; filename*=UTF-8''contacts.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
deleted file mode 100644
index 307bcae5e..000000000
--- a/test/integration/registrar_area/domains_test.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'test_helper'
-
-class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
- include FormTagHelper
-
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_downloads_list_as_csv
- now = Time.zone.parse('2010-07-05 08:00')
- travel_to now
-
- get registrar_domains_path(format: :csv)
-
- assert_response :ok
- assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
- assert_equal %(attachment; filename="Domains_#{l(now, format: :filename)}.csv"; filename*=UTF-8''Domains_#{l(now, format: :filename)}.csv),
- response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-end
diff --git a/test/integration/registrar_area/invoices/payment_callback_test.rb b/test/integration/registrar_area/invoices/payment_callback_test.rb
deleted file mode 100644
index 94ca6e373..000000000
--- a/test/integration/registrar_area/invoices/payment_callback_test.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require 'test_helper'
-
-class PaymentCallbackTest < ApplicationIntegrationTest
- def setup
- super
-
- @user = users(:api_bestnames)
- sign_in @user
-
- @payment_order = payment_orders(:everypay_issued)
- @invoice = invoices(:one)
- @invoice.update!(account_activity: nil, total: 12)
- end
-
- def test_every_pay_callback_returns_status_200
- request_params = every_pay_request_params
- post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
-
- assert_response :ok
- end
-
- def test_invoice_is_marked_as_paid
- request_params = every_pay_request_params
- post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
-
- assert @payment_order.invoice.paid?
- end
-
- def failure_log_is_created_if_unsuccessful_payment
- request_params = every_pay_request_params.dup
- request_params['payment_state'] = 'cancelled'
- request_params['transaction_result'] = 'failed'
-
- post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
-
- @payment_order.reload
- assert @payment_order.cancelled?
- assert_includes @payment_order.notes, 'Payment state: cancelled'
- end
-
- private
-
- def every_pay_request_params
- {
- nonce: "392f2d7748bc8cb0d14f263ebb7b8932",
- timestamp: "1524136727",
- api_username: "ca8d6336dd750ddb",
- transaction_result: "completed",
- payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56",
- payment_state: "settled",
- amount: "12.00",
- order_reference: "e468a2d59a731ccc546f2165c3b1a6",
- account_id: "EUR3D1",
- cc_type: "master_card",
- cc_last_four_digits: "0487",
- cc_month: "10",
- cc_year: "2018",
- cc_holder_name: "John Doe",
- hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result",
- hmac: "efac1c732835668cd86023a7abc140506c692f0d",
- invoice_id: "12900000",
- payment_method: "every_pay"
- }
- end
-end
diff --git a/test/integration/registrar_area/invoices/payment_return_test.rb b/test/integration/registrar_area/invoices/payment_return_test.rb
deleted file mode 100644
index a4adb8160..000000000
--- a/test/integration/registrar_area/invoices/payment_return_test.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-require 'test_helper'
-
-class PaymentReturnTest < ApplicationIntegrationTest
- def setup
- super
-
- @user = users(:api_bestnames)
- sign_in @user
-
- @invoice = invoices(:one)
- @invoice.update!(account_activity: nil, total: 12)
- @everypay_order = payment_orders(:everypay_issued)
- @banklink_order = payment_orders(:banklink_issued)
- end
-
- def every_pay_request_params
- {
- nonce: "392f2d7748bc8cb0d14f263ebb7b8932",
- timestamp: "1524136727",
- api_username: "ca8d6336dd750ddb",
- transaction_result: "completed",
- payment_reference: "fd5d27b59a1eb597393cd5ff77386d6cab81ae05067e18d530b10f3802e30b56",
- payment_state: "settled",
- amount: "12.00",
- order_reference: "e468a2d59a731ccc546f2165c3b1a6",
- account_id: "EUR3D1",
- cc_type: "master_card",
- cc_last_four_digits: "0487",
- cc_month: "10",
- cc_year: "2018",
- cc_holder_name: "John Doe",
- hmac_fields: "account_id,amount,api_username,cc_holder_name,cc_last_four_digits,cc_month,cc_type,cc_year,hmac_fields,nonce,order_reference,payment_reference,payment_state,timestamp,transaction_result",
- hmac: "efac1c732835668cd86023a7abc140506c692f0d",
- invoice_id: "12900000",
- payment_method: "every_pay"
- }
- end
-
- def bank_link_request_params
- {
- "VK_SERVICE": "1111",
- "VK_VERSION": "008",
- "VK_SND_ID": "testvpos",
- "VK_REC_ID": "seb",
- "VK_STAMP": 1,
- "VK_T_NO": "1",
- "VK_AMOUNT": "12.00",
- "VK_CURR": "EUR",
- "VK_REC_ACC": "1234",
- "VK_REC_NAME": "Eesti Internet",
- "VK_SND_ACC": "1234",
- "VK_SND_NAME": "John Doe",
- "VK_REF": "",
- "VK_MSG": "Order nr 1",
- "VK_T_DATETIME": "2018-04-01T00:30:00+0300",
- "VK_MAC": "CZZvcptkxfuOxRR88JmT4N+Lw6Hs4xiQfhBWzVYldAcRTQbcB/lPf9MbJzBE4e1/HuslQgkdCFt5g1xW2lJwrVDBQTtP6DAHfvxU3kkw7dbk0IcwhI4whUl68/QCwlXEQTAVDv1AFnGVxXZ40vbm/aLKafBYgrirB5SUe8+g9FE=",
- "VK_ENCODING": "UTF-8",
- "VK_LANG": "ENG",
- payment_method: "seb"
- }
- end
-
- def test_successful_bank_payment_marks_invoice_as_paid
- @invoice.update!(account_activity: nil)
- request_params = bank_link_request_params
-
- post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
-
- @banklink_order.reload
- assert @banklink_order.invoice.paid?
- end
-
- def test_every_pay_return_creates_activity_redirects_to_invoice_path
- request_params = every_pay_request_params
-
- post "/registrar/pay/return/#{@everypay_order.id}", params: request_params
- assert_equal(302, response.status)
- assert_redirected_to(registrar_invoice_path(@invoice))
- end
-
- def test_every_pay_return_raises_record_not_found
- request_params = every_pay_request_params
- assert_raises(ActiveRecord::RecordNotFound) do
- post '/registrar/pay/return/123456', params: request_params
- end
- end
-
- def test_bank_link_return_redirects_to_invoice_paths
- request_params = bank_link_request_params
-
- post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
- assert_equal(302, response.status)
- assert_redirected_to(registrar_invoice_path(@invoice))
- end
-
- def test_bank_link_return
- request_params = bank_link_request_params
- assert_raises(ActiveRecord::RecordNotFound) do
- post '/registrar/pay/return/123456', params: request_params
- end
- end
-
- def test_marks_as_paid_and_adds_notes_if_failed_to_bind
- request_params = bank_link_request_params
-
- post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
- post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
- @banklink_order.reload
-
- assert @banklink_order.notes.present?
- assert @banklink_order.paid?
- assert_includes @banklink_order.notes, 'Failed to bind'
- end
-
- def test_failed_bank_link_payment_creates_brief_error_explanation
- request_params = bank_link_request_params.dup
- request_params['VK_SERVICE'] = '1911'
-
- post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
-
- @banklink_order.reload
-
- assert_includes @banklink_order.notes, 'Bank responded with code 1911'
- end
-
- def test_failed_every_pay_payment_creates_brief_error_explanation
- request_params = every_pay_request_params.dup
- request_params['payment_state'] = 'cancelled'
- request_params['transaction_result'] = 'failed'
-
- post "/registrar/pay/return/#{@everypay_order.id}", params: request_params
-
- @everypay_order.reload
-
- assert_includes @everypay_order.notes, 'Payment state: cancelled'
- end
-end
diff --git a/test/integration/registrar_area/invoices_test.rb b/test/integration/registrar_area/invoices_test.rb
deleted file mode 100644
index 91c6afbd8..000000000
--- a/test/integration/registrar_area/invoices_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'test_helper'
-
-class RegistrarAreaInvoicesIntegrationTest < ApplicationIntegrationTest
- setup do
- @invoice = invoices(:one)
- sign_in users(:api_bestnames)
- end
-
- def test_downloads_invoice
- assert_equal 1, @invoice.number
-
- get download_registrar_invoice_path(@invoice)
-
- assert_response :ok
- assert_equal 'application/pdf', response.headers['Content-Type']
- assert_equal "attachment; filename=\"invoice-1.pdf\"; filename*=UTF-8''invoice-1.pdf", response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-end
diff --git a/test/integration/registrar_area/settings/balance_auto_reload_test.rb b/test/integration/registrar_area/settings/balance_auto_reload_test.rb
deleted file mode 100644
index 1a2c3f835..000000000
--- a/test/integration/registrar_area/settings/balance_auto_reload_test.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'test_helper'
-
-class RegistrarAreaSettingsBalanceAutoReloadIntegrationTest < ActionDispatch::IntegrationTest
- include Devise::Test::IntegrationHelpers
-
- setup do
- @registrar = registrars(:bestnames)
- sign_in users(:api_bestnames)
- end
-
- def test_updates_balance_auto_reload_setting
- amount = 100
- threshold = 10
- assert_nil @registrar.settings['balance_auto_reload']
-
- patch registrar_settings_balance_auto_reload_path, params: { type: { amount: amount,
- threshold: threshold } }
- @registrar.reload
-
- assert_equal amount, @registrar.settings['balance_auto_reload']['type']['amount']
- assert_equal threshold, @registrar.settings['balance_auto_reload']['type']['threshold']
- end
-
- def test_disables_balance_auto_reload_setting
- @registrar.update!(settings: { balance_auto_reload: { amount: 'any', threshold: 'any' } })
-
- delete registrar_settings_balance_auto_reload_path
- @registrar.reload
-
- assert_nil @registrar.settings['balance_auto_reload']
- end
-end
\ No newline at end of file
diff --git a/test/integration/repp/v1/accounts/activities_list_test.rb b/test/integration/repp/v1/accounts/activities_list_test.rb
index 2038815a1..5cc5c47a4 100644
--- a/test/integration/repp/v1/accounts/activities_list_test.rb
+++ b/test/integration/repp/v1/accounts/activities_list_test.rb
@@ -7,6 +7,9 @@ class ReppV1AccountsActivitiesListTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_account_activities
@@ -67,4 +70,19 @@ class ReppV1AccountsActivitiesListTest < ActionDispatch::IntegrationTest
assert_equal @user.registrar.cash_account.activities.count, json[:data][:activities].length
assert_equal json[:data][:activities][0][:description], activity.description
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get repp_v1_accounts_path, headers: @auth_headers
+ get repp_v1_accounts_path, headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/accounts/balance_test.rb b/test/integration/repp/v1/accounts/balance_test.rb
index 3fd25f3e7..de41da26d 100644
--- a/test/integration/repp/v1/accounts/balance_test.rb
+++ b/test/integration/repp/v1/accounts/balance_test.rb
@@ -8,9 +8,12 @@ class ReppV1BalanceTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
-
+
def test_can_query_balance
get '/repp/v1/accounts/balance', headers: @auth_headers
@@ -49,5 +52,20 @@ class ReppV1BalanceTest < ActionDispatch::IntegrationTest
assert trans[:created_at].to_date.to_s(:db) >= started_from
assert trans[:created_at].to_date.to_s(:db) >= end_to
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/accounts/balance', headers: @auth_headers
+ get '/repp/v1/accounts/balance', headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
end
diff --git a/test/integration/repp/v1/accounts/details_test.rb b/test/integration/repp/v1/accounts/details_test.rb
index 30acb5eb6..b643c60e2 100644
--- a/test/integration/repp/v1/accounts/details_test.rb
+++ b/test/integration/repp/v1/accounts/details_test.rb
@@ -7,6 +7,9 @@ class ReppV1AccountsDetailsTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_account_details
@@ -19,4 +22,19 @@ class ReppV1AccountsDetailsTest < ActionDispatch::IntegrationTest
assert_equal @user.registrar.billing_email, json[:data][:account][:billing_email]
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/accounts/details', headers: @auth_headers
+ get '/repp/v1/accounts/details', headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/accounts/switch_user_test.rb b/test/integration/repp/v1/accounts/switch_user_test.rb
index a860fb162..2299f2bf5 100644
--- a/test/integration/repp/v1/accounts/switch_user_test.rb
+++ b/test/integration/repp/v1/accounts/switch_user_test.rb
@@ -7,6 +7,9 @@ class ReppV1AccountsSwitchUserTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_switches_to_linked_api_user
@@ -48,4 +51,27 @@ class ReppV1AccountsSwitchUserTest < ActionDispatch::IntegrationTest
assert_response :bad_request
assert_equal 'Cannot switch to unlinked user', json[:message]
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ new_user = users(:api_goodnames)
+ new_user.update(identity_code: '1234')
+ request_body = {
+ account: {
+ new_user_id: new_user.id,
+ },
+ }
+
+ put '/repp/v1/accounts/switch_user', headers: @auth_headers, params: request_body
+ put '/repp/v1/accounts/switch_user', headers: @auth_headers, params: request_body
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/accounts/update_auto_reload_balance_test.rb b/test/integration/repp/v1/accounts/update_auto_reload_balance_test.rb
index 11a8d08ba..253cd6b0b 100644
--- a/test/integration/repp/v1/accounts/update_auto_reload_balance_test.rb
+++ b/test/integration/repp/v1/accounts/update_auto_reload_balance_test.rb
@@ -7,6 +7,9 @@ class ReppV1AccountsUpdateAutoReloadBalanceTest < ActionDispatch::IntegrationTes
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_updates_auto_reload_balance
@@ -66,4 +69,45 @@ class ReppV1AccountsUpdateAutoReloadBalanceTest < ActionDispatch::IntegrationTes
assert_nil @user.registrar.settings['balance_auto_reload']
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ amount = 100
+ threshold = 10
+ request_body = {
+ type: {
+ amount: amount,
+ threshold: threshold,
+ },
+ }
+
+ post '/repp/v1/accounts/update_auto_reload_balance', headers: @auth_headers,
+ params: request_body
+ post '/repp/v1/accounts/update_auto_reload_balance', headers: @auth_headers,
+ params: request_body
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/accounts/disable_auto_reload_balance', headers: @auth_headers
+ get '/repp/v1/accounts/disable_auto_reload_balance', headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/accounts/update_details_test.rb b/test/integration/repp/v1/accounts/update_details_test.rb
index c1275ddeb..a9293605d 100644
--- a/test/integration/repp/v1/accounts/update_details_test.rb
+++ b/test/integration/repp/v1/accounts/update_details_test.rb
@@ -7,6 +7,9 @@ class ReppV1AccountsUpdateDetailsTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_updates_details
@@ -27,4 +30,26 @@ class ReppV1AccountsUpdateDetailsTest < ActionDispatch::IntegrationTest
assert_equal(request_body[:account][:billing_email], @user.registrar.billing_email)
assert_equal(request_body[:account][:iban], @user.registrar.iban)
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ request_body = {
+ account: {
+ billing_email: 'donaldtrump@yandex.ru',
+ iban: 'GB331111111111111111',
+ },
+ }
+
+ put '/repp/v1/accounts', headers: @auth_headers, params: request_body
+ put '/repp/v1/accounts', headers: @auth_headers, params: request_body
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/contacts/check_test.rb b/test/integration/repp/v1/contacts/check_test.rb
index 6fc716638..1da629320 100644
--- a/test/integration/repp/v1/contacts/check_test.rb
+++ b/test/integration/repp/v1/contacts/check_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_code_based_check_returns_true_for_available_contact
@@ -27,4 +30,20 @@ class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest
assert_equal contact.code, json[:data][:contact][:code]
assert_equal false, json[:data][:contact][:available]
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ contact = contacts(:jack)
+ get "/repp/v1/contacts/check/#{contact.code}", headers: @auth_headers
+ get "/repp/v1/contacts/check/#{contact.code}", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/contacts/create_test.rb b/test/integration/repp/v1/contacts/create_test.rb
index af1ca0fbf..3d0c2f646 100644
--- a/test/integration/repp/v1/contacts/create_test.rb
+++ b/test/integration/repp/v1/contacts/create_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_creates_new_contact
@@ -153,4 +156,32 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
contact = Contact.find_by(code: json[:data][:contact][:code])
assert contact.legal_documents.any?
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ request_body = {
+ contact: {
+ name: 'Donald Trump',
+ phone: '+372.51111112',
+ email: 'donald@trumptower.com',
+ ident: {
+ ident_type: 'priv',
+ ident_country_code: 'EE',
+ ident: '39708290069',
+ },
+ },
+ }
+
+ post '/repp/v1/contacts', headers: @auth_headers, params: request_body
+ post '/repp/v1/contacts', headers: @auth_headers, params: request_body
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/contacts/delete_test.rb b/test/integration/repp/v1/contacts/delete_test.rb
index 07438d8af..e585e0962 100644
--- a/test/integration/repp/v1/contacts/delete_test.rb
+++ b/test/integration/repp/v1/contacts/delete_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsDeleteTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_deletes_unassociated_contact
@@ -44,4 +47,19 @@ class ReppV1ContactsDeleteTest < ActionDispatch::IntegrationTest
assert_response :not_found
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ delete "/repp/v1/contacts/#{contacts(:invalid_email).code}", headers: @auth_headers
+ delete "/repp/v1/contacts/#{contacts(:john).code}", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/contacts/list_test.rb b/test/integration/repp/v1/contacts/list_test.rb
index 979d3ea40..56b909459 100644
--- a/test/integration/repp/v1/contacts/list_test.rb
+++ b/test/integration/repp/v1/contacts/list_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_registrar_contacts
@@ -79,4 +82,19 @@ class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
assert_equal @user.registrar.contacts.count, json[:data][:contacts].length
assert_equal json[:data][:contacts][0][:code], contact.code
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get repp_v1_contacts_path, headers: @auth_headers
+ get repp_v1_contacts_path, headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/contacts/search_test.rb b/test/integration/repp/v1/contacts/search_test.rb
index ceeefc7be..dfbed9cee 100644
--- a/test/integration/repp/v1/contacts/search_test.rb
+++ b/test/integration/repp/v1/contacts/search_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsSearchTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_searches_all_contacts_by_id
@@ -40,4 +43,18 @@ class ReppV1ContactsSearchTest < ActionDispatch::IntegrationTest
assert json[:data].is_a? Array
assert_equal json[:data].length, 0
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/contacts/search', headers: @auth_headers, params: { query: '000' }
+
+ assert_raise Shunter::ThrottleError do
+ get '/repp/v1/contacts/search', headers: @auth_headers, params: { query: '000' }
+ end
+
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/contacts/show_test.rb b/test/integration/repp/v1/contacts/show_test.rb
index 496935ab6..8a79ccfdd 100644
--- a/test/integration/repp/v1/contacts/show_test.rb
+++ b/test/integration/repp/v1/contacts/show_test.rb
@@ -7,6 +7,9 @@ class ReppV1ContactsShowTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_error_when_not_found
@@ -42,4 +45,21 @@ class ReppV1ContactsShowTest < ActionDispatch::IntegrationTest
assert_equal 2303, json[:code]
assert_equal 'Object does not exist', json[:message]
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ contact = @user.registrar.contacts.first
+
+ get repp_v1_contact_path(id: contact.code), headers: @auth_headers
+ get repp_v1_contact_path(id: contact.code), headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/contacts/update_test.rb b/test/integration/repp/v1/contacts/update_test.rb
index e75ce4188..d51602c32 100644
--- a/test/integration/repp/v1/contacts/update_test.rb
+++ b/test/integration/repp/v1/contacts/update_test.rb
@@ -8,6 +8,9 @@ class ReppV1ContactsUpdateTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_updates_contact
@@ -118,4 +121,25 @@ class ReppV1ContactsUpdateTest < ActionDispatch::IntegrationTest
assert_equal 2308, json[:code]
assert_equal 'Ident update is not allowed. Consider creating new contact object', json[:message]
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ request_body = {
+ "contact": {
+ "email": "donaldtrump@yandex.ru"
+ }
+ }
+
+ put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
+ put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ 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 510d09f62..56439a908 100644
--- a/test/integration/repp/v1/domains/bulk_renew_test.rb
+++ b/test/integration/repp/v1/domains/bulk_renew_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_renews_domains
@@ -129,6 +132,30 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
assert_equal 'Invalid renew period', json[:message]
end
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ payload = {
+ "domains": [
+ 'shop.test',
+ 'airport.test',
+ 'library.test'
+ ],
+ "renew_period": "1y"
+ }
+
+ post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
+ post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
private
def set_status_for_domain(domain, statuses)
diff --git a/test/integration/repp/v1/domains/contacts_test.rb b/test/integration/repp/v1/domains/contacts_test.rb
index 17f8f1f6b..87b916811 100644
--- a/test/integration/repp/v1/domains/contacts_test.rb
+++ b/test/integration/repp/v1/domains/contacts_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_shows_existing_domain_contacts
@@ -22,6 +25,21 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
assert_equal @domain.tech_contacts.length, json[:data][:tech_contacts].length
end
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers
+ get "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_can_add_new_admin_contacts
new_contact = contacts(:john)
refute @domain.admin_contacts.find_by(code: new_contact.code).present?
@@ -71,7 +89,7 @@ class ReppV1DomainsContactsTest < ActionDispatch::IntegrationTest
def test_can_remove_tech_contacts
Spy.on_instance_method(Actions::DomainUpdate, :validate_email).and_return(true)
-
+
contact = contacts(:john)
payload = { contacts: [ { code: contact.code, type: 'tech' } ] }
post "/repp/v1/domains/#{@domain.name}/contacts", headers: @auth_headers, params: payload
diff --git a/test/integration/repp/v1/domains/dnssec_test.rb b/test/integration/repp/v1/domains/dnssec_test.rb
index 6835e2600..46e239fbf 100644
--- a/test/integration/repp/v1/domains/dnssec_test.rb
+++ b/test/integration/repp/v1/domains/dnssec_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_shows_dnssec_keys_associated_with_domain
@@ -24,13 +27,11 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
{ flags: '256',
alg: '14',
protocol: '3',
- public_key: 'dGVzdA=='
- }
- ]
+ public_key: 'dGVzdA==' },
+ ],
}
post "/repp/v1/domains/#{@domain.name}/dnssec", params: payload, headers: @auth_headers
- json = JSON.parse(response.body, symbolize_names: true)
get "/repp/v1/domains/#{@domain.name}/dnssec", headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
@@ -45,9 +46,8 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
{ flags: '256',
alg: '14',
protocol: '3',
- public_key: 'dGVzdA=='
- }
- ]
+ public_key: 'dGVzdA==' },
+ ],
}
post "/repp/v1/domains/#{@domain.name}/dnssec", params: payload, headers: @auth_headers
@@ -67,7 +67,7 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
end
def test_creates_dnssec_key_with_every_algo
- algos = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}
+ algos = Dnskey::ALGORITHMS
algos_to_check = %w[15 16]
assert (algos & algos_to_check) == algos_to_check
@@ -79,9 +79,8 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
{ flags: '256',
alg: alg,
protocol: '3',
- public_key: 'dGVzdA=='
- }
- ]
+ public_key: 'dGVzdA==' },
+ ],
}
post "/repp/v1/domains/#{@domain.name}/dnssec", params: payload, headers: @auth_headers
@@ -105,13 +104,11 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
{ flags: '256',
alg: '14',
protocol: '3',
- public_key: 'dGVzdA=='
- }
- ]
+ public_key: 'dGVzdA==' },
+ ],
}
post "/repp/v1/domains/#{@domain.name}/dnssec", params: payload, headers: @auth_headers
- json = JSON.parse(response.body, symbolize_names: true)
assert @domain.dnskeys.any?
@@ -126,4 +123,19 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
assert @domain.dnskeys.empty?
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get "/repp/v1/domains/#{@domain.name}/dnssec", headers: @auth_headers
+ get "/repp/v1/domains/#{@domain.name}/dnssec", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/domains/list_test.rb b/test/integration/repp/v1/domains/list_test.rb
index 205017a6c..3699927db 100644
--- a/test/integration/repp/v1/domains/list_test.rb
+++ b/test/integration/repp/v1/domains/list_test.rb
@@ -7,6 +7,9 @@ class ReppV1DomainsListTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_registrar_domains
@@ -92,4 +95,19 @@ class ReppV1DomainsListTest < ActionDispatch::IntegrationTest
assert_equal @user.registrar.domains.count, json[:data][:domains].length
assert_equal json[:data][:domains][0][:name], domain.name
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get repp_v1_domains_path, headers: @auth_headers
+ get repp_v1_domains_path, headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/domains/nameservers_test.rb b/test/integration/repp/v1/domains/nameservers_test.rb
index 780e889c1..3ff85260e 100644
--- a/test/integration/repp/v1/domains/nameservers_test.rb
+++ b/test/integration/repp/v1/domains/nameservers_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsNameserversTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_can_add_new_nameserver
@@ -30,6 +33,21 @@ class ReppV1DomainsNameserversTest < ActionDispatch::IntegrationTest
assert_equal payload[:nameservers][0][:ipv6], @domain.nameservers.last.ipv6
end
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get "/repp/v1/domains/#{@domain.name}/nameservers", headers: @auth_headers
+ get "/repp/v1/domains/#{@domain.name}/nameservers", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_can_remove_existing_nameserver
payload = {
nameservers: [
diff --git a/test/integration/repp/v1/domains/statuses_test.rb b/test/integration/repp/v1/domains/statuses_test.rb
index 271752ae3..ee2cb445b 100644
--- a/test/integration/repp/v1/domains/statuses_test.rb
+++ b/test/integration/repp/v1/domains/statuses_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsStatusesTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_client_hold_can_be_added
@@ -79,4 +82,18 @@ class ReppV1DomainsStatusesTest < ActionDispatch::IntegrationTest
assert_equal 2306, json[:code]
end
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ put repp_v1_domain_status_path(domain_id: @domain.name, id: DomainStatus::CLIENT_HOLD), headers: @auth_headers
+ put repp_v1_domain_status_path(domain_id: @domain.name, id: DomainStatus::CLIENT_HOLD), headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/domains/transfer_info_test.rb b/test/integration/repp/v1/domains/transfer_info_test.rb
index a3b8fe874..64fd8ed10 100644
--- a/test/integration/repp/v1/domains/transfer_info_test.rb
+++ b/test/integration/repp/v1/domains/transfer_info_test.rb
@@ -7,6 +7,9 @@ class ReppV1DomainsTransferInfoTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@domain = domains(:shop)
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_can_query_domain_info
@@ -51,4 +54,22 @@ class ReppV1DomainsTransferInfoTest < ActionDispatch::IntegrationTest
assert_response :ok
assert_equal 1000, json[:code]
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ headers = @auth_headers
+ headers['Auth-Code'] = @domain.transfer_code
+
+ get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
+ get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/domains/transfer_test.rb b/test/integration/repp/v1/domains/transfer_test.rb
index 5854de195..fdcbe41d7 100644
--- a/test/integration/repp/v1/domains/transfer_test.rb
+++ b/test/integration/repp/v1/domains/transfer_test.rb
@@ -8,6 +8,9 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
@domain = domains(:hospital)
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_transfers_scoped_domain
@@ -152,4 +155,20 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
assert_not @domain.registrar == @user.registrar
end
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ payload = { transfer: { transfer_code: @domain.transfer_code } }
+ post "/repp/v1/domains/#{@domain.name}/transfer", headers: @auth_headers, params: payload
+ post "/repp/v1/domains/#{@domain.name}/transfer", headers: @auth_headers, params: payload
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
end
diff --git a/test/integration/repp/v1/invoices/add_credit_test.rb b/test/integration/repp/v1/invoices/add_credit_test.rb
index fe250de7d..a6dd541f4 100644
--- a/test/integration/repp/v1/invoices/add_credit_test.rb
+++ b/test/integration/repp/v1/invoices/add_credit_test.rb
@@ -24,6 +24,8 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
message: 'success'
}
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").to_return(status: 200, body: msg2.to_json, headers: {})
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
teardown do
@@ -101,4 +103,39 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
assert_response :bad_request
assert_equal "Amount is too small. Minimum deposit is #{Setting.minimum_deposit} EUR", json[:message]
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ request_body = {
+ invoice: {
+ amount: 100,
+ description: 'Add credit',
+ },
+ }
+ Setting.registry_vat_prc = 0.1
+ ENV['billing_system_integrated'] = 'true'
+
+ if Feature.billing_system_integrated?
+ invoice_n = Invoice.order(number: :desc).last.number
+ stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
+ .to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
+ stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
+ .to_return(status: 200, body: '', headers: {})
+ end
+
+ post '/repp/v1/invoices/add_credit', headers: @auth_headers,
+ params: request_body
+ post '/repp/v1/invoices/add_credit', headers: @auth_headers,
+ params: request_body
+
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/invoices/cancel_test.rb b/test/integration/repp/v1/invoices/cancel_test.rb
index 1041d1d1f..0d7d3a585 100644
--- a/test/integration/repp/v1/invoices/cancel_test.rb
+++ b/test/integration/repp/v1/invoices/cancel_test.rb
@@ -41,4 +41,4 @@ class ReppV1InvoicesCancelTest < ActionDispatch::IntegrationTest
invoice.reload
assert_not invoice.cancelled?
end
-end
\ No newline at end of file
+end
diff --git a/test/integration/repp/v1/invoices/download_test.rb b/test/integration/repp/v1/invoices/download_test.rb
index cbb9de585..fe2e9233d 100644
--- a/test/integration/repp/v1/invoices/download_test.rb
+++ b/test/integration/repp/v1/invoices/download_test.rb
@@ -7,6 +7,9 @@ class ReppV1InvoicesDownloadTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_invoice_as_pdf
@@ -19,4 +22,21 @@ class ReppV1InvoicesDownloadTest < ActionDispatch::IntegrationTest
assert_equal "attachment; filename=\"Invoice-2.pdf\"; filename*=UTF-8''Invoice-2.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ invoice = @user.registrar.invoices.first
+
+ get "/repp/v1/invoices/#{invoice.id}/download", headers: @auth_headers
+ get "/repp/v1/invoices/#{invoice.id}/download", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/invoices/list_test.rb b/test/integration/repp/v1/invoices/list_test.rb
index 5dfe2d53f..35fa7256a 100644
--- a/test/integration/repp/v1/invoices/list_test.rb
+++ b/test/integration/repp/v1/invoices/list_test.rb
@@ -7,6 +7,9 @@ class ReppV1InvoicesListTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_registrar_invoices
@@ -82,4 +85,19 @@ class ReppV1InvoicesListTest < ActionDispatch::IntegrationTest
assert_equal (@user.registrar.invoices.count - offset), json[:data][:invoices].length
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get repp_v1_invoices_path, headers: @auth_headers
+ get repp_v1_invoices_path, headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/invoices/send_test.rb b/test/integration/repp/v1/invoices/send_test.rb
index 77fe9997f..565ac27ff 100644
--- a/test/integration/repp/v1/invoices/send_test.rb
+++ b/test/integration/repp/v1/invoices/send_test.rb
@@ -7,6 +7,9 @@ class ReppV1InvoicesSendTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_sends_invoice_to_recipient
@@ -36,4 +39,30 @@ class ReppV1InvoicesSendTest < ActionDispatch::IntegrationTest
assert_equal 'Invoice no. 1', email.subject
assert email.attachments['invoice-1.pdf']
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ invoice = invoices(:one)
+ recipient = 'donaldtrump@yandex.ru'
+ request_body = {
+ invoice: {
+ id: invoice.id,
+ recipient: recipient,
+ },
+ }
+ post "/repp/v1/invoices/#{invoice.id}/send_to_recipient", headers: @auth_headers,
+ params: request_body
+ post "/repp/v1/invoices/#{invoice.id}/send_to_recipient", headers: @auth_headers,
+ params: request_body
+
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/invoices/show_test.rb b/test/integration/repp/v1/invoices/show_test.rb
index 74feb42ac..4f26f4b11 100644
--- a/test/integration/repp/v1/invoices/show_test.rb
+++ b/test/integration/repp/v1/invoices/show_test.rb
@@ -7,6 +7,9 @@ class ReppV1InvoicesShowTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_error_when_not_found
@@ -30,4 +33,21 @@ class ReppV1InvoicesShowTest < ActionDispatch::IntegrationTest
assert_equal invoice.id, json[:data][:invoice][:id]
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ invoice = @user.registrar.invoices.first
+
+ get repp_v1_invoice_path(id: invoice.id), headers: @auth_headers
+ get repp_v1_invoice_path(id: invoice.id), headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/registrar/auth/check_info_test.rb b/test/integration/repp/v1/registrar/auth/check_info_test.rb
index 03563d273..154e8e258 100644
--- a/test/integration/repp/v1/registrar/auth/check_info_test.rb
+++ b/test/integration/repp/v1/registrar/auth/check_info_test.rb
@@ -7,6 +7,9 @@ class ReppV1RegistrarAuthCheckInfoTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_returns_valid_user_auth_values
@@ -35,4 +38,19 @@ class ReppV1RegistrarAuthCheckInfoTest < ActionDispatch::IntegrationTest
assert_response :unauthorized
assert_equal json[:message], 'Invalid authorization information'
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/registrar/auth', headers: @auth_headers
+ get '/repp/v1/registrar/auth', headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/repp/v1/registrar/auth/tara_callback_test.rb b/test/integration/repp/v1/registrar/auth/tara_callback_test.rb
index e39e24078..918fce9cc 100644
--- a/test/integration/repp/v1/registrar/auth/tara_callback_test.rb
+++ b/test/integration/repp/v1/registrar/auth/tara_callback_test.rb
@@ -43,4 +43,4 @@ class ReppV1RegistrarAuthTaraCallbackTest < ActionDispatch::IntegrationTest
assert_response :unauthorized
assert_equal 'No such user', json[:message]
end
-end
\ No newline at end of file
+end
diff --git a/test/integration/repp/v1/registrar/notifications_test.rb b/test/integration/repp/v1/registrar/notifications_test.rb
index 2677d393b..6eb6f9898 100644
--- a/test/integration/repp/v1/registrar/notifications_test.rb
+++ b/test/integration/repp/v1/registrar/notifications_test.rb
@@ -7,6 +7,9 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_all_unreaded_poll_messages
@@ -20,6 +23,22 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest
assert_equal json[:data].last[:text], notification.last.text
end
+ def test_all_notifications_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).all
+ get "/repp/v1/registrar/notifications/all_notifications", headers: @auth_headers
+ get "/repp/v1/registrar/notifications/all_notifications", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_gets_latest_unread_poll_message
notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).first
get "/repp/v1/registrar/notifications", headers: @auth_headers
@@ -31,6 +50,22 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest
assert_equal notification.text, json[:data][:text]
end
+ def test_index_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).first
+ get "/repp/v1/registrar/notifications", headers: @auth_headers
+ get "/repp/v1/registrar/notifications", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_can_read_specific_notification_by_id
notification = @user.registrar.notifications.order(created_at: :desc).second
@@ -43,6 +78,23 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest
assert_equal notification.text, json[:data][:text]
end
+ def test_show_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ notification = @user.registrar.notifications.order(created_at: :desc).second
+
+ get "/repp/v1/registrar/notifications/#{notification.id}", headers: @auth_headers
+ get "/repp/v1/registrar/notifications/#{notification.id}", headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+
def test_can_mark_notification_as_read
@auth_headers['Content-Type'] = 'application/json'
notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).first
diff --git a/test/integration/repp/v1/registrar/summary_test.rb b/test/integration/repp/v1/registrar/summary_test.rb
index 97797990a..bd58d8e97 100644
--- a/test/integration/repp/v1/registrar/summary_test.rb
+++ b/test/integration/repp/v1/registrar/summary_test.rb
@@ -7,6 +7,9 @@ class ReppV1RegistrarSummaryTest < ActionDispatch::IntegrationTest
token = "Basic #{token}"
@auth_headers = { 'Authorization' => token }
+
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter&.clear!
end
def test_checks_user_summary_info
@@ -40,4 +43,19 @@ class ReppV1RegistrarSummaryTest < ActionDispatch::IntegrationTest
assert_nil json[:data][:notification]
assert_nil json[:data][:notifications_count]
end
-end
\ No newline at end of file
+
+ def test_returns_error_response_if_throttled
+ ENV["shunter_default_threshold"] = '1'
+ ENV["shunter_enabled"] = 'true'
+
+ get '/repp/v1/registrar/summary', headers: @auth_headers
+ get '/repp/v1/registrar/summary', headers: @auth_headers
+ json = JSON.parse(response.body, symbolize_names: true)
+
+ assert_response :bad_request
+ assert_equal json[:code], 2502
+ assert response.body.include?(Shunter.default_error_message)
+ ENV["shunter_default_threshold"] = '10000'
+ ENV["shunter_enabled"] = 'false'
+ end
+end
diff --git a/test/integration/registrar_area/xml_consoles_test.rb b/test/integration/repp/v1/registrar/xml_console_test.rb
similarity index 73%
rename from test/integration/registrar_area/xml_consoles_test.rb
rename to test/integration/repp/v1/registrar/xml_console_test.rb
index 443abfb78..db37dbebc 100644
--- a/test/integration/registrar_area/xml_consoles_test.rb
+++ b/test/integration/repp/v1/registrar/xml_console_test.rb
@@ -1,24 +1,35 @@
require 'test_helper'
-class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest
- setup do
- sign_in users(:api_bestnames)
- end
+class ReppV1RegistrarXmlConsoleTest < ActionDispatch::IntegrationTest
+ def setup
+ @user = users(:api_bestnames)
+ token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
+ token = "Basic #{token}"
- def test_check_schema_path
- post registrar_xml_console_path, params: { frame: payload },
- headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
-
- assert_response :ok
+ @auth_headers = { 'Authorization' => token }
+ adapter = ENV['shunter_default_adapter'].constantize.new
+ adapter&.clear!
end
def test_load_schema_path
- get load_xml_registrar_xml_console_path, params: { obj: 'domain', epp_action: 'update' }
+ get load_xml_repp_v1_registrar_xml_console_path, params: { obj: 'domain', epp_action: 'update' },
+ headers: @auth_headers
assert_response :ok
- assert_equal update_payload, response.body
+ json = JSON.parse(response.body, symbolize_names: true)
+ assert_equal update_payload, json[:data][:xml]
end
+ # TO BE REFACTORED
+ # def test_check_schema_path
+ # @auth_headers['Content-Type'] = 'application/json'
+ # params = { xml_console: { payload: payload } }
+ # post repp_v1_registrar_xml_console_path, params: params.to_json,
+ # headers: @auth_headers
+
+ # assert_response :ok
+ # end
+
private
def payload
@@ -36,21 +47,6 @@ class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest
XML
end
- def wrong_payload
- <<~XML
-
-
-
-
-
- auction.test
-
-
-
-
- XML
- end
-
def update_payload
<<~XML
@@ -109,4 +105,4 @@ class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest
XML
end
-end
+end
\ No newline at end of file
diff --git a/test/interactions/email_check_test.rb b/test/interactions/email_check_test.rb
index 4e77a5bee..0c704ba72 100644
--- a/test/interactions/email_check_test.rb
+++ b/test/interactions/email_check_test.rb
@@ -95,4 +95,46 @@ class EmailCheckTest < ActiveSupport::TestCase
assert_equal @contact.validation_events.count, 1
assert @contact.validation_events.last.success
end
+
+ def test_should_remove_old_record_if_validation_pass_the_limit
+ trumail_results = OpenStruct.new(success: false,
+ email: @contact.email,
+ domain: "box.tests",
+ errors: {:mx=>"target host(s) not found"})
+
+ action = Actions::EmailCheck.new(email: @contact.email,
+ validation_eventable: @contact,
+ check_level: 'mx')
+
+ action.stub :check_email, trumail_results do
+ 4.times do
+ action.call
+ end
+ end
+
+ assert_equal @contact.validation_events.count, 3
+ end
+
+ def test_should_remove_old_record_if_multiple_contacts_has_the_same_email
+ contact_two = contacts(:william)
+ contact_two.update(email: @contact.email)
+ contact_two.reload
+ trumail_results = OpenStruct.new(success: false,
+ email: @contact.email,
+ domain: "box.tests",
+ errors: {:mx=>"target host(s) not found"})
+
+ action = Actions::EmailCheck.new(email: @contact.email,
+ validation_eventable: @contact,
+ check_level: 'mx')
+
+ action.stub :check_email, trumail_results do
+ 4.times do
+ action.call
+ end
+ end
+
+ assert_equal @contact.validation_events.count, 3
+ assert_equal contact_two.validation_events.count, 3
+ end
end
diff --git a/test/interactions/force_delete_email/base_test.rb b/test/interactions/force_delete_email/base_test.rb
index c3f688678..ffca7b3c5 100644
--- a/test/interactions/force_delete_email/base_test.rb
+++ b/test/interactions/force_delete_email/base_test.rb
@@ -1,18 +1,92 @@
require 'test_helper'
class BaseTest < ActiveSupport::TestCase
- def test_hold_domains_force_delete_email
- domain = domains(:shop)
- domain.update!(statuses: [DomainStatus::SERVER_HOLD])
- domain.update!(expire_time: Time.zone.now + 1.year)
+ setup do
+ @domain = domains(:shop)
+ @domain_airport = domains(:airport)
+ end
- registrant = domain.registrant
- registrant.update!(email: "#{registrant.email.split('@').first}@#{domain.name}")
+ def test_hold_domains_force_delete_email
+ @domain.update!(statuses: [DomainStatus::SERVER_HOLD])
+ @domain.update!(expire_time: Time.zone.now + 1.year)
+
+ registrant = @domain.registrant
+ registrant.update!(email: "#{registrant.email.split('@').first}@#{@domain.name}")
Domains::ForceDeleteEmail::Base.run(email: registrant.email)
- domain.reload
+ @domain.reload
- assert_not domain.force_delete_scheduled?
+ assert_not @domain.force_delete_scheduled?
+ end
+
+ def test_more_that_year_until_valid_to_date
+ refute @domain_airport.force_delete_scheduled?
+ @domain_airport.update!(valid_to: Time.zone.now + 3.years + 1.month + 1.day)
+ @domain_airport.reload
+ prepare_contact
+
+ contact = @domain_airport.admin_contacts.first
+
+ Domains::ForceDeleteEmail::Base.run(email: contact.email)
+ @domain_airport.reload
+
+ assert @domain_airport.force_delete_scheduled?
+ assert @domain_airport.valid_to > Time.zone.now + 1.year
+ assert_equal @domain_airport.force_delete_start.to_date, (Time.zone.now + 1.month + 1.day).to_date
+ assert_equal @domain_airport.force_delete_date, (@domain_airport.force_delete_start +
+ Setting.expire_warning_period.days +
+ Setting.redemption_grace_period.days).to_date
+ end
+
+ def test_more_that_year_until_valid_to_date_but_month_is_previous
+ refute @domain_airport.force_delete_scheduled?
+ @domain_airport.update!(valid_to: Time.zone.now + 3.years - 1.month - 4.days)
+ @domain_airport.reload
+ prepare_contact
+
+ contact = @domain_airport.admin_contacts.first
+
+ Domains::ForceDeleteEmail::Base.run(email: contact.email)
+ @domain_airport.reload
+
+ assert @domain_airport.force_delete_scheduled?
+ assert @domain_airport.valid_to > Time.zone.now + 1.year
+ assert_equal @domain_airport.force_delete_start.to_date, (Time.zone.now + 1.year - 1.month - 4.days).to_date
+ assert_equal @domain_airport.force_delete_date, (@domain_airport.force_delete_start +
+ Setting.expire_warning_period.days +
+ Setting.redemption_grace_period.days).to_date
+ end
+
+ def test_should_send_poll_message_about_45_days_to_registrar
+ refute @domain_airport.force_delete_scheduled?
+ @domain_airport.update!(valid_to: Time.zone.now + 3.years - 1.month - 4.days)
+ @domain_airport.reload
+ prepare_contact
+
+ contact = @domain_airport.admin_contacts.first
+
+ assert_difference -> { @domain_airport.registrar.notifications.count } do
+ Domains::ForceDeleteEmail::Base.run(email: contact.email)
+ end
+
+ @domain_airport.reload
+ end
+
+ private
+
+ def prepare_contact
+ assert_not @domain_airport.force_delete_scheduled?
+ email = '~@internet.ee'
+
+ contact = @domain_airport.admin_contacts.first
+ contact.update_attribute(:email, email)
+ (ValidationEvent::VALID_EVENTS_COUNT_THRESHOLD).times do
+ contact.verify_email
+ end
+ contact.reload
+
+ refute contact.validation_events.last.success?
+ assert contact.need_to_start_force_delete?
end
end
diff --git a/test/jobs/outzone_invalid_email_domains_job_test.rb b/test/jobs/outzone_invalid_email_domains_job_test.rb
new file mode 100644
index 000000000..688494183
--- /dev/null
+++ b/test/jobs/outzone_invalid_email_domains_job_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class OutzoneInvalidEmailDomainsJobTest < ActiveJob::TestCase
+ include ActionMailer::TestHelper
+
+ setup do
+ ActionMailer::Base.deliveries.clear
+ @domain = domains(:airport)
+ end
+
+ def test_set_outzone_datetime_for_fd_domains_by_invalid_emails
+ @domain.update(valid_to: Time.zone.now + 3.years)
+ @domain.reload
+
+ assert_nil @domain.outzone_at
+
+ @domain.schedule_force_delete(type: :soft)
+ @domain.force_delete_data = {"template_name"=>"invalid_email", "force_delete_type"=>"soft"}
+ @domain.save
+
+ OutzoneInvalidEmailDomainsJob.perform_now
+ @domain.reload
+
+ assert @domain.force_delete_scheduled?
+ assert @domain.valid_to > Time.zone.now + 1.year
+ assert_equal @domain.outzone_at, @domain.force_delete_start + Setting.expire_warning_period.day
+ end
+end
diff --git a/test/lib/shunter/shunter_base_test.rb b/test/lib/shunter/shunter_base_test.rb
new file mode 100644
index 000000000..5645f8cec
--- /dev/null
+++ b/test/lib/shunter/shunter_base_test.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require "test_helper"
+require "action_controller"
+require "pry"
+
+class ShunterBaseTest < Minitest::Test
+ ENV["shunter_enabled"] = 'true'
+
+ def test_throttling_works_on_inclusion
+ ENV["shunter_default_adapter"] = "Shunter::Adapters::Memory"
+ ENV["shunter_default_threshold"] = "100"
+ adapter = ENV["shunter_default_adapter"].constantize.new
+ adapter.clear!
+
+ TestKlass.new.throttle do
+ TestKlass.new.test
+ end
+ end
+
+ class TestKlass < ::ActionController::Base
+ THROTTLED_ACTIONS = %i[test].freeze
+ include Shunter::Integration::Throttle
+
+ def test
+ "test"
+ end
+
+ def throttled_user
+ @throttled_user ||= OpenStruct.new(id: 1)
+ end
+ end
+end
diff --git a/test/models/auction_test.rb b/test/models/auction_test.rb
index 5df7166b2..3f2a6932e 100644
--- a/test/models/auction_test.rb
+++ b/test/models/auction_test.rb
@@ -28,6 +28,51 @@ class AuctionTest < ActiveSupport::TestCase
assert @auction.started?
end
+ def test_auction_with_no_bids_dont_have_any_restriction
+ @auction.update(status: :no_bids)
+ @auction.reload
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
+ refute res
+ end
+
+ def test_auction_with_domain_registered_dont_have_any_restriction
+ @auction.update(status: :domain_registered)
+ @auction.reload
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
+ refute res
+ end
+
+ def test_auction_with_started_has_restriction
+ @auction.update(status: :started)
+ @auction.reload
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(@auction.domain)
+ assert res
+ end
+
+ def test_blocked_domain_has_restriction
+ blocked_domain = blocked_domains(:one)
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(blocked_domain.name)
+ assert res
+ end
+
+ def test_dispute_domain_has_restriction
+ dispute_domain = disputes(:active)
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(dispute_domain.domain_name)
+ assert res
+ end
+
+ def test_exist_domain_has_restriction
+ domain = domains(:shop)
+
+ res = Auction.domain_exists_in_blocked_disputed_and_registered?(domain.name)
+ assert res
+ end
+
def test_pending
domain_name = DNS::DomainName.new('auction.test')
assert_equal 'auction.test', @auction.domain
diff --git a/test/models/depp_contact_test.rb b/test/models/depp_contact_test.rb
deleted file mode 100644
index 12f7c3b4f..000000000
--- a/test/models/depp_contact_test.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require 'test_helper'
-require 'helpers/phone_format_helper_test'
-
-class DeppContactTest < ActiveSupport::TestCase
- include PhoneFormatHelperTest
-
- setup do
- @depp_contact = Depp::Contact.new
- end
-
- def test_validates_phone_format
- assert_phone_format(@depp_contact)
- 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 7032a1f91..c333b12df 100644
--- a/test/models/domain/force_delete_test.rb
+++ b/test/models/domain/force_delete_test.rb
@@ -457,8 +457,6 @@ class ForceDeleteTest < ActionMailer::TestCase
domain.reload
assert_nil domain.status_notes[DomainStatus::FORCE_DELETE]
- notification = domain.registrar.notifications.last(2).first
- assert notification.text.include? asserted_text
assert_not domain.force_delete_scheduled?
end
diff --git a/test/models/epp/response/result/code_test.rb b/test/models/epp/response/result/code_test.rb
index a78c92d3a..8e424aa70 100644
--- a/test/models/epp/response/result/code_test.rb
+++ b/test/models/epp/response/result/code_test.rb
@@ -1,5 +1,11 @@
require 'test_helper'
+class Hash
+ def contain?(other)
+ self.merge(other) == self
+ end
+end
+
class EppResponseResultCodeTest < ActiveSupport::TestCase
def test_creates_code_by_key
key = :completed_successfully
@@ -84,10 +90,10 @@ class EppResponseResultCodeTest < ActiveSupport::TestCase
2306 => 'Parameter value policy error',
2308 => 'Data management policy violation',
2400 => 'Command failed',
- 2501 => 'Authentication error; server closing connection',
- 2502 => 'Session limit exceeded; server closing connection'
+ 2501 => 'Authentication error; server closing connection'
}
- assert_equal descriptions, Epp::Response::Result::Code.default_descriptions
+
+ assert Epp::Response::Result::Code.default_descriptions.contain? descriptions
end
def test_equality
diff --git a/test/models/inactive_contacts_test.rb b/test/models/inactive_contacts_test.rb
index a88be5350..9b4523473 100644
--- a/test/models/inactive_contacts_test.rb
+++ b/test/models/inactive_contacts_test.rb
@@ -3,7 +3,8 @@ require 'test_helper'
class InactiveContactsTest < ActiveSupport::TestCase
def test_archives_inactive_contacts
contact_mock = Minitest::Mock.new
- contact_mock.expect(:archive, nil, [{verified: false}])
+ # contact_mock.expect(:archive, nil, [{verified: false}])
+ def contact_mock.archive(verified: false); nil; end
contact_mock.expect(:id, 'id')
contact_mock.expect(:code, 'code')
diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb
index 4059720c9..fb60c88fc 100644
--- a/test/models/registrant_user_test.rb
+++ b/test/models/registrant_user_test.rb
@@ -87,8 +87,11 @@ class RegistrantUserTest < ActiveSupport::TestCase
company = Company.new('acme', 'ace')
company_register = Minitest::Mock.new
- company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
- citizen_country_code: 'USA' }])
+ def company_register.representation_rights(citizen_personal_code: '1234', citizen_country_code: 'USA')
+ [Company.new('acme', 'ace')]
+ end
+ # company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
+ # citizen_country_code: 'USA' }])
assert_equal [company], @user.companies(company_register)
company_register.verify
diff --git a/test/system/registrar_area/account_activities_test.rb b/test/system/registrar_area/account_activities_test.rb
deleted file mode 100644
index 08ffe447f..000000000
--- a/test/system/registrar_area/account_activities_test.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAccountActivitiesTest < ApplicationSystemTestCase
- setup do
- @registrar = registrars(:bestnames)
- sign_in users(:api_bestnames)
- end
-
- def test_show_account_activity_page
- account_activities(:one).update(sum: "123.00")
- visit registrar_account_activities_path
- assert_text 'Account activity'
- end
-
- def test_download_account_activity
- now = Time.zone.parse('2010-07-05 08:00')
- travel_to now
- account_activities(:one).update(sum: "123.00")
-
- get registrar_account_activities_path(format: :csv)
-
- assert_response :ok
- assert_equal "text/csv", response.headers['Content-Type']
- assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv),
- response.headers['Content-Disposition']
- assert_not_empty response.body
- end
-
- def test_search_account_activity_with_invalid_date
- account_activities(:one).update(description: "Description of activity one",
- sum: "123.00",
- activity_type: "create",
- created_at: Time.zone.parse('2021-07-05 10:00'))
-
- visit registrar_account_activities_path
-
- find('#q_activity_type_in').click
- find(:option, "Renew").select_option
- fill_in('q_created_at_lteq', with: '2021-12--')
- find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]").click
-
- assert_text 'Description of activity renew_cash'
- end
-end
diff --git a/test/system/registrar_area/account_test.rb b/test/system/registrar_area/account_test.rb
deleted file mode 100644
index 708f8dc8f..000000000
--- a/test/system/registrar_area/account_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAccountTest < ApplicationSystemTestCase
- setup do
- @registrar = registrars(:bestnames)
- sign_in users(:api_bestnames)
- end
-
- def test_updates_account
- new_billing_email = 'new@registrar.test'
- new_iban = 'GB77BARC20201530093459'
- assert_not_equal new_billing_email, @registrar.billing_email
- assert_not_equal new_iban, @registrar.iban
-
- visit registrar_account_path
- click_on 'Edit'
-
- fill_in 'Billing email', with: new_billing_email
- fill_in 'IBAN', with: new_iban
- click_on 'Save changes'
-
- assert_text 'Your account has been updated'
- assert_text new_billing_email
- assert_text new_iban
- end
-end
\ No newline at end of file
diff --git a/test/system/registrar_area/add_deposits_test.rb b/test/system/registrar_area/add_deposits_test.rb
deleted file mode 100644
index 3ca7691ce..000000000
--- a/test/system/registrar_area/add_deposits_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'application_system_test_case'
-
-class AddDepositsTest < ApplicationSystemTestCase
- include ActionMailer::TestHelper
-
- setup do
- sign_in users(:api_bestnames)
- @invoice = invoices(:one)
-
- ActionMailer::Base.deliveries.clear
- end
-end
diff --git a/test/system/registrar_area/base_test.rb b/test/system/registrar_area/base_test.rb
deleted file mode 100644
index 2529b009a..000000000
--- a/test/system/registrar_area/base_test.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaBaseTestTest < ApplicationSystemTestCase
- setup do
- @original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled
- end
-
- teardown do
- Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist
- end
-
- def test_user_cannot_access_without_ip_address_being_whitelisted
- Setting.registrar_ip_whitelist_enabled = true
- WhiteIp.delete_all
-
- visit new_registrar_user_session_url
-
- assert_text 'Access denied from IP 127.0.0.1'
- assert_no_button 'Login'
- end
-
- def test_user_can_access_when_ip_is_whitelisted
- white_ips(:one).update!(ipv4: '127.0.0.1', interfaces: [WhiteIp::REGISTRAR])
- Setting.registrar_ip_whitelist_enabled = true
-
- visit new_registrar_user_session_url
-
- assert_no_text 'Access denied from IP 127.0.0.1'
- assert_button 'Login'
- end
-
- def test_user_can_access_when_ip_is_whitelisted_with_subnet
- white_ips(:one).update!(ipv4: '127.0.0.1/32', interfaces: [WhiteIp::REGISTRAR])
- Setting.registrar_ip_whitelist_enabled = true
-
- visit new_registrar_user_session_url
-
- assert_no_text 'Access denied from IP 127.0.0.1'
- assert_button 'Login'
- end
-
- def test_user_can_access_when_ip_is_not_whitelisted_and_whitelist_is_disabled
- Setting.registrar_ip_whitelist_enabled = false
- WhiteIp.delete_all
-
- visit new_registrar_user_session_url
-
- assert_no_text 'Access denied from IP 127.0.0.1'
- assert_button 'Login'
- end
-end
diff --git a/test/system/registrar_area/billing/balance_top_up_test.rb b/test/system/registrar_area/billing/balance_top_up_test.rb
deleted file mode 100644
index 3dfeb5a26..000000000
--- a/test/system/registrar_area/billing/balance_top_up_test.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require 'application_system_test_case'
-
-class BalanceTopUpTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_bestnames)
- @original_registry_vat_rate = Setting.registry_vat_prc
-
- eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
- Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
- Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
- end
-
- teardown do
- Setting.registry_vat_prc = @original_registry_vat_rate
- end
-
- def test_creates_new_invoice
- invoice_n = Invoice.order(number: :desc).last.number
- stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
- to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
-
- stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response")
- .to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
-
- stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
- .to_return(status: 200, body: "", headers: {})
-
- Setting.registry_vat_prc = 0.1
-
- visit registrar_invoices_url
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '25.5'
-
- assert_difference 'Invoice.count' do
- click_link_or_button 'Add'
- end
-
- invoice = Invoice.last
-
- assert_equal BigDecimal(10), invoice.vat_rate
- assert_equal BigDecimal('28.05'), invoice.total
- assert_text 'Please pay the following invoice'
- end
-end
diff --git a/test/system/registrar_area/bulk_change/admin_contact_test.rb b/test/system/registrar_area/bulk_change/admin_contact_test.rb
deleted file mode 100644
index 8847812cb..000000000
--- a/test/system/registrar_area/bulk_change/admin_contact_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaAdminContactBulkChangeTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_replace_domain_contacts_of_current_registrar
- request_stub = stub_request(:patch, /domains\/admin_contacts/)
- .with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
- basic_auth: ['test_bestnames', 'testtest'])
- .to_return(body: { data: { affected_domains: %w[foo.test bar.test],
- skipped_domains: %w[baz.test qux.test] } }.to_json,
- status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Admin contact'
-
- find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
- find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
- click_on 'Replace admin contacts'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Admin contacts have been successfully replaced'
- assert_text 'Affected domains: foo.test, bar.test'
- assert_text 'Skipped domains: baz.test, qux.test'
- end
-
- def test_fails_gracefully
- stub_request(:patch, /domains\/admin_contacts/)
- .to_return(status: 400,
- body: { message: 'epic fail' }.to_json,
- headers: { 'Content-type' => Mime[:json] })
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Admin contact'
-
- find('.current_admin_contact').fill_in 'Current contact ID', with: 'william-001'
- find('.new_admin_contact').fill_in 'New contact ID', with: 'john-001'
- click_on 'Replace admin contacts'
-
- assert_text 'epic fail'
- assert_field 'Current contact ID', with: 'william-001'
- assert_field 'New contact ID', with: 'john-001'
- end
-end
diff --git a/test/system/registrar_area/bulk_change/bulk_renew_test.rb b/test/system/registrar_area/bulk_change/bulk_renew_test.rb
deleted file mode 100644
index 5e1704afd..000000000
--- a/test/system/registrar_area/bulk_change/bulk_renew_test.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require 'application_system_test_case'
-
-class BulkRenewTest < ApplicationSystemTestCase
- setup do
- @registrar = users(:api_bestnames).registrar
- @price = billing_prices(:renew_one_year)
- end
-
- def test_shows_domain_list
- sign_in users(:api_bestnames)
- travel_to Time.zone.parse('2010-07-05 10:30')
-
- visit new_registrar_bulk_change_url
- click_link('Bulk renew')
- assert_text 'Current balance'
- page.has_css?('#registrar_balance', text:
- ApplicationController.helpers.number_to_currency(@registrar.balance))
-
- select '1 year', from: 'Period'
- click_button 'Filter'
-
- @registrar.domains.pluck(:name).each do |domain_name|
- assert_text domain_name
- end
- end
-
- def test_makes_bulk_renew
- sign_in users(:api_bestnames)
- travel_to Time.zone.parse('2010-07-05 10:30')
-
- req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
- stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
- .to_return(status: 400, body: {
- code: 2304,
- message: "Domain renew error for invalid.test",
- data: {}
- }.to_json)
-
- visit new_registrar_bulk_change_url
- click_link('Bulk renew')
- select '1 year', from: 'Period'
- click_button 'Filter'
- click_button 'Renew'
-
- assert_text 'Domain renew error for invalid.test'
- end
-
- def test_bulk_renew_checks_balance
- sign_in users(:api_bestnames)
- @price.update(price_cents: 99999999)
- travel_to Time.zone.parse('2010-07-05 10:30')
-
- req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
- stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
- .to_return(status: 400, body: {
- code: 2304,
- message: "Not enough funds for renew domains",
- data: {}
- }.to_json)
-
- visit new_registrar_bulk_change_url
- click_link('Bulk renew')
- select '1 year', from: 'Period'
- click_button 'Filter'
- click_button 'Renew'
-
- assert_text 'Not enough funds for renew domains'
-
- end
-end
diff --git a/test/system/registrar_area/bulk_change/bulk_transfer_test.rb b/test/system/registrar_area/bulk_change/bulk_transfer_test.rb
deleted file mode 100644
index 820b1cf96..000000000
--- a/test/system/registrar_area/bulk_change/bulk_transfer_test.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_goodnames)
- end
-
- def test_transfer_multiple_domains_in_bulk
- request_body = { data: { domain_transfers: [{ domain_name: 'shop.test', transfer_code: '65078d5' }] } }
- headers = { 'Content-type' => Mime[:json] }
- request_stub = stub_request(:post, /domains\/transfer/).with(body: request_body,
- headers: headers,
- basic_auth: ['test_goodnames', 'testtest'])
- .to_return(body: { data: { success: [{ type: 'domain_transfer', domain_name: 'shop.test' }],
- failed: []
- } }.to_json, status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Bulk transfer'
- attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
- click_button 'Transfer'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text '1 domains have been successfully transferred'
- end
-
- def test_fail_gracefully
- body = { message: 'epic fail' }.to_json
- headers = { 'Content-type' => Mime[:json] }
- stub_request(:post, /domains\/transfer/).to_return(status: 400, body: body, headers: headers)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Bulk transfer'
- attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
- click_button 'Transfer'
-
- assert_text 'epic fail'
- end
-end
diff --git a/test/system/registrar_area/bulk_change/nameserver_test.rb b/test/system/registrar_area/bulk_change/nameserver_test.rb
deleted file mode 100644
index cfde8e6d1..000000000
--- a/test/system/registrar_area/bulk_change/nameserver_test.rb
+++ /dev/null
@@ -1,185 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_goodnames)
- Capybara.default_max_wait_time = 10
- end
-
- def test_replaces_current_registrar_nameservers
- request_body = { data: { type: 'nameserver',
- id: 'ns1.bestnames.test',
- domains: [],
- attributes: { hostname: 'new-ns.bestnames.test',
- ipv4: %w[192.0.2.55 192.0.2.56],
- ipv6: %w[2001:db8::55 2001:db8::56] } } }
- request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
- headers: { 'Content-type' => Mime[:json] },
- basic_auth: ['test_goodnames', 'testtest'])
- .to_return(body: { data: {
- type: 'nameserver',
- id: 'new-ns.bestnames.test',
- affected_domains: ["airport.test", "shop.test"],
- skipped_domains: []
- }
- }.to_json, status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'Old hostname (optional)', with: 'ns1.bestnames.test'
- fill_in 'New hostname', with: 'new-ns.bestnames.test'
- fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
- fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
- click_on 'Replace/Add nameserver'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Nameserver have been successfully replaced'
- assert_text 'Affected domains: airport.test, shop.test'
- end
-
- def test_fails_gracefully
- stub_request(:put, /registrar\/nameservers/).to_return(status: 400,
- body: { message: 'epic fail' }.to_json,
- headers: { 'Content-type' => Mime[:json] })
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'Old hostname (optional)', with: 'old hostname'
- fill_in 'New hostname', with: 'new hostname'
- fill_in 'ipv4', with: 'ipv4'
- fill_in 'ipv6', with: 'ipv6'
- click_on 'Replace/Add nameserver'
-
- assert_text 'epic fail'
- assert_field 'Old hostname (optional)', with: 'old hostname'
- assert_field 'New hostname', with: 'new hostname'
- assert_field 'ipv4', with: 'ipv4'
- assert_field 'ipv6', with: 'ipv6'
- end
-
- def test_replaces_nameservers_only_for_scoped_domains
- request_body = { data: { type: 'nameserver',
- id: 'ns1.bestnames.test',
- domains: ['shop.test'],
- attributes: { hostname: 'new-ns.bestnames.test',
- ipv4: %w[192.0.2.55 192.0.2.56],
- ipv6: %w[2001:db8::55 2001:db8::56] } } }
- request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
- headers: { 'Content-type' => Mime[:json] },
- basic_auth: ['test_goodnames', 'testtest'])
- .to_return(body: { data: {
- type: 'nameserver',
- id: 'new-ns.bestnames.test',
- affected_domains: ["shop.test"],
- skipped_domains: []}}.to_json, status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'Old hostname (optional)', with: 'ns1.bestnames.test'
- fill_in 'New hostname', with: 'new-ns.bestnames.test'
- fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
- fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
- attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s
-
- click_on 'Replace/Add nameserver'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Nameserver have been successfully replaced'
- assert_text 'Affected domains: shop.test'
- end
-
- def test_replaces_nameservers_with_invalid_domains_list
- nameserver = nameservers(:shop_ns1)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'Old hostname (optional)', with: nameserver.hostname
- fill_in 'New hostname', with: 'new-ns.bestnames.test'
- fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
- fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
- attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'invalid_domains_for_ns_replacement.csv').to_s
-
- assert_no_changes -> { nameserver.hostname } do
- click_on 'Replace/Add nameserver'
- end
-
- assert_current_path registrar_domains_path
- assert_text 'CSV scoped domain list seems empty. Make sure that domains are added and "Domain" header is present.'
- end
-
- def test_adding_current_registrar_nameservers
- request_body = { data: { type: 'nameserver',
- id: '',
- domains: [],
- attributes: { hostname: 'new-ns2.bestnames.test',
- ipv4: %w[192.0.2.55 192.0.2.56],
- ipv6: %w[2001:db8::55 2001:db8::56] } } }
- request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
- headers: { 'Content-type' => Mime[:json] },
- basic_auth: ['test_goodnames', 'testtest'])
- .to_return(body: { data: {
- type: 'nameserver',
- id: 'new-ns2.bestnames.test',
- affected_domains: ["airport.test", "shop.test"],
- skipped_domains: []
- }
- }.to_json, status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'New hostname', with: 'new-ns2.bestnames.test'
- fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
- fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
- click_on 'Replace/Add nameserver'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Nameserver have been successfully added'
- assert_text 'Affected domains: airport.test, shop.test'
- end
-
- def test_adding_nameservers_only_for_scoped_domains
- request_body = { data: { type: 'nameserver',
- id: '',
- domains: ['shop.test'],
- attributes: { hostname: 'new-ns1.bestnames.test',
- ipv4: %w[192.0.2.55 192.0.2.56],
- ipv6: %w[2001:db8::55 2001:db8::56] } } }
- request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
- headers: { 'Content-type' => Mime[:json] },
- basic_auth: ['test_goodnames', 'testtest'])
- .to_return(body: { data: {
- type: 'nameserver',
- id: 'new-ns1.bestnames.test',
- affected_domains: ["shop.test"],
- skipped_domains: []}}.to_json, status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
- click_link 'Nameserver'
-
- fill_in 'New hostname', with: 'new-ns1.bestnames.test'
- fill_in 'ipv4', with: "192.0.2.55\n192.0.2.56"
- fill_in 'ipv6', with: "2001:db8::55\n2001:db8::56"
- attach_file :puny_file, Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_ns_replacement.csv').to_s
-
- click_on 'Replace/Add nameserver'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Nameserver have been successfully added'
- assert_text 'Affected domains: shop.test'
- end
-end
diff --git a/test/system/registrar_area/bulk_change/tech_contact_test.rb b/test/system/registrar_area/bulk_change/tech_contact_test.rb
deleted file mode 100644
index 055ec25ca..000000000
--- a/test/system/registrar_area/bulk_change/tech_contact_test.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_replace_domain_contacts_of_current_registrar
- request_stub = stub_request(:patch, /domains\/contacts/)
- .with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
- basic_auth: ['test_bestnames', 'testtest'])
- .to_return(body: { data: { affected_domains: %w[foo.test bar.test],
- skipped_domains: %w[baz.test qux.test] } }.to_json,
- status: 200)
-
- visit registrar_domains_url
- click_link 'Bulk change'
-
- find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
- find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
- click_on 'Replace technical contacts'
-
- assert_requested request_stub
- assert_current_path registrar_domains_path
- assert_text 'Technical contacts have been successfully replaced'
- assert_text 'Affected domains: foo.test, bar.test'
- assert_text 'Skipped domains: baz.test, qux.test'
- end
-
- def test_fails_gracefully
- stub_request(:patch, /domains\/contacts/)
- .to_return(status: 400,
- body: { message: 'epic fail' }.to_json,
- headers: { 'Content-type' => Mime[:json] })
-
- visit registrar_domains_url
- click_link 'Bulk change'
-
- find('.current_tech_contact').fill_in 'Current contact ID', with: 'william-001'
- find('.new_tech_contact').fill_in 'New contact ID', with: 'john-001'
- click_on 'Replace technical contacts'
-
- assert_text 'epic fail'
- assert_field 'Current contact ID', with: 'william-001'
- assert_field 'New contact ID', with: 'john-001'
- end
-end
diff --git a/test/system/registrar_area/contact_test.rb b/test/system/registrar_area/contact_test.rb
deleted file mode 100644
index 8d156f1b8..000000000
--- a/test/system/registrar_area/contact_test.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaContactTest < ApplicationSystemTestCase
- setup do
- @registrar = registrars(:bestnames)
- @contact = contacts(:john)
- sign_in users(:api_bestnames)
- end
-
- def test_creates_contact_with_invalid_phone
- visit registrar_contacts_path
- click_on 'New'
-
- fill_in 'depp_contact_ident', with: @contact.ident
- fill_in 'depp_contact_name', with: @contact.name
- fill_in 'depp_contact_email', with: @contact.email
- fill_in 'depp_contact_phone', with: '372'
- click_on 'Create'
-
- assert_text 'Phone number must be in +XXX.YYYYYYY format'
- end
-
- def test_updates_contact_with_invalid_phone
- depp_contact = Depp::Contact.new(
- id: @contact.id,
- name: @contact.name,
- code: @contact.code,
- email: @contact.email,
- phone: @contact.phone,
- ident: @contact.ident,
- ident_type: @contact.ident_type,
- ident_country_code: @contact.ident_country_code)
-
- Spy.on(Depp::Contact, :find_by_id).and_return(depp_contact)
-
- visit edit_registrar_contact_path(depp_contact.code)
-
- assert_text "Edit: #{depp_contact.name}"
-
- fill_in 'depp_contact_phone', with: '372'
- click_on 'Save'
-
- assert_text 'Phone number must be in +XXX.YYYYYYY format'
- end
-end
diff --git a/test/system/registrar_area/domains_test.rb b/test/system/registrar_area/domains_test.rb
deleted file mode 100644
index 7a2f5f7f1..000000000
--- a/test/system/registrar_area/domains_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarDomainsTest < ApplicationSystemTestCase
- def test_downloads_domain_list_as_csv
- sign_in users(:api_bestnames)
- travel_to Time.zone.parse('2010-07-05 10:30')
-
- expected_csv = <<-CSV.strip_heredoc
- Domain,Transfer code,Registrant name,Registrant code,Date of expiry
- library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05
- shop.test,65078d5,John,john-001,2010-07-05
- invalid.test,1438d6,any,invalid,2010-07-05
- airport.test,55438j5,John,john-001,2010-07-05
- CSV
-
- visit registrar_domains_url
- click_button 'Download CSV'
- assert_equal "attachment; filename=\"Domains_2010-07-05_10.30.csv\"; filename*=UTF-8''Domains_2010-07-05_10.30.csv", response_headers['Content-Disposition']
- assert_equal expected_csv, page.body
- end
-end
diff --git a/test/system/registrar_area/invoices/list_test.rb b/test/system/registrar_area/invoices/list_test.rb
deleted file mode 100644
index ffab9c202..000000000
--- a/test/system/registrar_area/invoices/list_test.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'application_system_test_case'
-
-class ListInvoicesTest < ApplicationSystemTestCase
- setup do
- @user = users(:api_bestnames)
- @invoice = invoices(:one)
-
- sign_in @user
- end
-
- def test_show_balance
- visit registrar_invoices_path
- assert_text "Your current account balance is 100,00 EUR"
- end
-
- def test_shows_invoice_title
- visit registrar_invoices_path
- assert_text 'Invoice', minimum: 2
- end
-
- def test_shows_invoice_owned_by_current_user
- owning_registrar = registrars(:bestnames)
- assert_equal owning_registrar, @user.registrar
- @invoice.update!(buyer: owning_registrar)
-
- visit registrar_invoices_url
-
- assert_text @invoice.to_s
- end
-
- def test_hides_invoice_owned_by_other_user
- other_registrar = registrars(:goodnames)
- assert_not_equal other_registrar, @user.registrar
- @invoice.update!(buyer: other_registrar)
-
- visit registrar_invoices_url
-
- assert_no_text @invoice.to_s
- end
-end
diff --git a/test/system/registrar_area/invoices/new_invoice_payment_test.rb b/test/system/registrar_area/invoices/new_invoice_payment_test.rb
deleted file mode 100644
index 77050f12a..000000000
--- a/test/system/registrar_area/invoices/new_invoice_payment_test.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'application_system_test_case'
-
-class NewInvoicePaymentTest < ApplicationSystemTestCase
- def setup
- super
- eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
- Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
-
- @original_vat_prc = Setting.registry_vat_prc
- Setting.registry_vat_prc = 0.2
- @user = users(:api_bestnames)
- sign_in @user
- end
-
- def teardown
- super
-
- Setting.registry_vat_prc = @original_vat_prc
- end
-
- def create_invoice_and_visit_its_page
- visit registrar_invoices_path
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '200.00'
- fill_in 'Description', with: 'My first invoice'
- click_link_or_button 'Add'
- end
-end
diff --git a/test/system/registrar_area/invoices/new_test.rb b/test/system/registrar_area/invoices/new_test.rb
deleted file mode 100644
index 16e30aeb7..000000000
--- a/test/system/registrar_area/invoices/new_test.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-require 'application_system_test_case'
-
-class NewInvoiceTest < ApplicationSystemTestCase
- def setup
- super
-
- @user = users(:api_bestnames)
- sign_in @user
-
- eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
- Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
- end
-
- def test_show_balance
- visit registrar_invoices_path
- assert_text "Your current account balance is 100,00 EUR"
- end
-
- def test_create_new_invoice_with_positive_amount
- invoice_n = Invoice.order(number: :desc).last.number
- stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
- to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
-
- stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
- to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
-
- stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
- to_return(status: 200, body: "", headers: {})
-
- visit registrar_invoices_path
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '200.00'
- fill_in 'Description', with: 'My first invoice'
-
- assert_difference 'Invoice.count', 1 do
- click_link_or_button 'Add'
- end
-
- assert_text 'Please pay the following invoice'
- assert_text "Invoice no. #{invoice_n + 3}"
- assert_text 'Subtotal 200,00 €'
- assert_text 'Pay invoice'
- end
-
- def test_create_new_invoice_with_comma_in_number
- invoice_n = Invoice.order(number: :desc).last.number
- stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
- to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
-
- stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
- to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
-
- stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
- to_return(status: 200, body: "", headers: {})
-
- visit registrar_invoices_path
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '200,00'
- fill_in 'Description', with: 'My first invoice'
-
- assert_difference 'Invoice.count', 1 do
- click_link_or_button 'Add'
- end
-
- assert_text 'Please pay the following invoice'
- assert_text "Invoice no. #{invoice_n + 3}"
- assert_text 'Subtotal 200,00 €'
- assert_text 'Pay invoice'
- end
-
- def test_create_new_invoice_fails_when_amount_is_0
- visit registrar_invoices_path
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '0.00'
- fill_in 'Description', with: 'My first invoice'
-
- assert_no_difference 'Invoice.count' do
- click_link_or_button 'Add'
- end
-
- assert_text 'Amount is too small. Minimum deposit is 0.01 EUR'
- end
-
- def test_create_new_invoice_fails_when_amount_is_negative
- visit registrar_invoices_path
- click_link_or_button 'Add deposit'
- fill_in 'Amount', with: '-120.00'
- fill_in 'Description', with: 'My first invoice'
-
- assert_no_difference 'Invoice.count' do
- click_link_or_button 'Add'
- end
-
- assert_text 'Amount is too small. Minimum deposit is 0.01 EUR'
- end
-end
diff --git a/test/system/registrar_area/invoices_test.rb b/test/system/registrar_area/invoices_test.rb
deleted file mode 100644
index 1c6d1d780..000000000
--- a/test/system/registrar_area/invoices_test.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaInvoicesTest < ApplicationSystemTestCase
- include ActionMailer::TestHelper
-
- setup do
- sign_in users(:api_bestnames)
- @invoice = invoices(:one)
-
- ActionMailer::Base.deliveries.clear
- eis_response = OpenStruct.new(body: "{\"payment_link\":\"http://link.test\"}")
- Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
- end
-
- def test_cancels_an_invoice
- Spy.on(EisBilling::SendInvoiceStatus, :send_info).and_return(true)
-
- @invoice.account_activity = nil
- assert @invoice.cancellable?
-
- visit registrar_invoice_url(@invoice)
- click_on 'Cancel'
- @invoice.reload
-
- assert @invoice.cancelled?
- assert_text 'Invoice has been cancelled'
- end
-
- def test_invoice_delivery_form_is_pre_populated_with_billing_email_of_a_registrar
- assert_equal 'billing@bestnames.test', @invoice.buyer.billing_email
- visit new_registrar_invoice_delivery_url(@invoice)
- assert_field 'Recipient', with: 'billing@bestnames.test'
- end
-
- def test_delivers_an_invoice
- visit registrar_invoice_url(@invoice)
- click_on 'Send'
- fill_in 'Recipient', with: 'billing@registrar.test'
- click_on 'Send'
-
- assert_emails 1
- email = ActionMailer::Base.deliveries.first
- assert_equal ['billing@registrar.test'], email.to
- assert_current_path registrar_invoice_path(@invoice)
- assert_text 'Invoice has been sent'
- end
-
- def test_if_invoice_unpaid_and_not_generated_link_comes_then_should_render_no_everypay_link
- invoice = invoices(:unpaid)
- visit registrar_invoice_url(invoice)
-
- assert_text 'No everypay link'
- end
-
- def test_if_invoice_aldready_paid_there_should_not_any_everypay_link
- visit registrar_invoice_url(@invoice)
-
- assert_no_text 'No everypay link'
- assert_no_text 'Everypay link'
- end
-end
diff --git a/test/system/registrar_area/protected_area_test.rb b/test/system/registrar_area/protected_area_test.rb
deleted file mode 100644
index f1be6008d..000000000
--- a/test/system/registrar_area/protected_area_test.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaProtectedAreaTest < ApplicationSystemTestCase
- def test_anonymous_user_is_asked_to_authenticate_when_navigating_to_protected_area
- visit registrar_domains_url
- assert_text 'You need to sign in before continuing'
- assert_current_path new_registrar_user_session_path
- end
-
- def test_authenticated_user_can_access_protected_area
- sign_in users(:api_bestnames)
- visit registrar_domains_url
-
- assert_no_text 'You need to sign in before continuing'
- assert_current_path registrar_domains_path
- end
-
- def test_authenticated_user_is_not_asked_to_authenticate_again
- sign_in users(:api_bestnames)
- visit new_registrar_user_session_url
-
- assert_text 'You are already signed in'
- assert_current_path registrar_root_path
- end
-end
\ No newline at end of file
diff --git a/test/system/registrar_area/settings/balance_auto_reload_test.rb b/test/system/registrar_area/settings/balance_auto_reload_test.rb
deleted file mode 100644
index 066fb6186..000000000
--- a/test/system/registrar_area/settings/balance_auto_reload_test.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaSettingsBalanceAutoReloadTest < ApplicationSystemTestCase
- setup do
- @registrar = registrars(:bestnames)
- @user = users(:api_bestnames)
- sign_in @user
- end
-
- def test_enables_balance_auto_reload
- amount = 100
- threshold = 10
- assert_nil @registrar.settings['balance_auto_reload']
-
- visit registrar_account_path
- click_on 'Enable'
- fill_in 'Amount', with: amount
- fill_in 'Threshold', with: threshold
- click_button 'Save'
-
- assert_current_path registrar_account_path
- assert_text 'Balance Auto-Reload setting has been updated'
-
- # Using `number_to_currency` leads to `expected to find text "Reload 100,00 € when your balance
- # drops to 10,00 €" in "...Reload 100,00 € when your balance drops to 10,00 €...`
- assert_text 'Reload 100,00 € when your balance drops to 10,00 €'
- end
-
- def test_disables_balance_auto_reload
- @registrar.update!(settings: { balance_auto_reload: { type: {} } })
-
- visit registrar_account_path
- click_on 'Disable'
-
- assert_current_path registrar_account_path
- assert_text 'Balance Auto-Reload setting has been disabled'
- end
-
- def test_edits_balance_auto_reload
- @registrar.update!(settings: { balance_auto_reload: { type: { name: 'threshold',
- amount: 100,
- threshold: 10 } } })
-
- visit registrar_account_path
- within '.balance-auto-reload' do
- click_on 'Edit'
- end
- fill_in 'Amount', with: '101'
- fill_in 'Threshold', with: '11'
- click_button 'Save'
-
- assert_current_path registrar_account_path
- assert_text 'Balance Auto-Reload setting has been updated'
- end
-
- def test_form_is_pre_populated_when_editing
- amount = 100
- threshold = 10
- @registrar.update!(settings: { balance_auto_reload: { type: { name: 'threshold',
- amount: amount,
- threshold: threshold } } })
-
- visit edit_registrar_settings_balance_auto_reload_path
-
- assert_field 'Amount', with: amount
- assert_field 'Threshold', with: threshold
- end
-
- def test_user_of_epp_role_cannot_edit_balance_auto_reload_setting
- @user.update!(roles: [ApiUser::EPP])
- visit registrar_account_path
- assert_no_text 'Balance Auto-Reload'
- end
-end
\ No newline at end of file
diff --git a/test/system/registrar_area/sign_in/password_test.rb b/test/system/registrar_area/sign_in/password_test.rb
deleted file mode 100644
index a362e98e3..000000000
--- a/test/system/registrar_area/sign_in/password_test.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaPasswordSignInTest < ApplicationSystemTestCase
- setup do
- @user = users(:api_bestnames)
- end
-
- def test_correct_username_and_password
- login_with_correct_credentials
- assert_text 'Log out'
- assert_current_path registrar_root_path
- end
-
- def test_after_successful_sign_in_super_user_sees_service_message_list
- @user.update!(roles: [ApiUser::SUPER])
- login_with_correct_credentials
- assert_current_path registrar_root_path
- end
-
- def test_after_successful_sign_in_billing_user_sees_account
- @user.update!(roles: [ApiUser::BILLING])
- login_with_correct_credentials
- assert_current_path registrar_account_path
- end
-
- def test_wrong_password
- visit new_registrar_user_session_url
- fill_in 'registrar_user_username', with: @user.username
- fill_in 'registrar_user_password', with: 'wrong'
- click_button 'Login'
-
- assert_text 'No such user'
- assert_current_path new_registrar_user_session_path
- end
-
- def test_inactive_user
- @user.update!(active: false)
- login_with_correct_credentials
-
- assert_text 'User is not active'
- assert_current_path new_registrar_user_session_path
- end
-
- private
-
- def login_with_correct_credentials
- visit new_registrar_user_session_url
- fill_in 'registrar_user_username', with: @user.username
- fill_in 'registrar_user_password', with: 'testtest'
- click_button 'Login'
- end
-end
\ No newline at end of file
diff --git a/test/system/registrar_area/sign_out_test.rb b/test/system/registrar_area/sign_out_test.rb
deleted file mode 100644
index 040836600..000000000
--- a/test/system/registrar_area/sign_out_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaSignOutTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_logout
- visit registrar_root_url
- click_on 'Log out'
-
- assert_text 'Signed out successfully'
- assert_current_path new_registrar_user_session_path
- end
-end
\ No newline at end of file
diff --git a/test/system/registrar_area/tara/tara_users_test.rb b/test/system/registrar_area/tara/tara_users_test.rb
deleted file mode 100644
index 005504043..000000000
--- a/test/system/registrar_area/tara/tara_users_test.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require 'application_system_test_case'
-
-class TaraUsersTest < ApplicationSystemTestCase
- def setup
- super
-
- OmniAuth.config.test_mode = true
- @user = users(:api_bestnames)
-
- @existing_user_hash = {
- 'provider' => 'tara',
- 'uid' => "EE" + @user.identity_code
- }
-
- @new_user_hash = {
- 'provider' => 'tara',
- 'uid' => 'EE51007050604'
- }
- end
-
- def teardown
- super
-
- OmniAuth.config.test_mode = false
- OmniAuth.config.mock_auth['tara'] = nil
- end
-
- def test_existing_user_gets_signed_in
- OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@existing_user_hash)
-
- visit new_registrar_user_session_path
- click_link('Sign in')
-
- 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)
-
- visit new_registrar_user_session_path
- click_link('Sign in')
-
- 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/system/registrar_area/xml_consoles_test.rb b/test/system/registrar_area/xml_consoles_test.rb
deleted file mode 100644
index 51cc362eb..000000000
--- a/test/system/registrar_area/xml_consoles_test.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'application_system_test_case'
-
-class RegistrarAreaXmlConsolesTest < ApplicationSystemTestCase
- setup do
- sign_in users(:api_bestnames)
- end
-
- def test_epp_server_does_not_response
- visit registrar_xml_console_path
- fill_in 'payload', with: schema_example
- click_on 'Send EPP Request'
-
- el = page.find('.CodeRay', visible: :all)
- assert el.text.include? 'CONNECTION ERROR - Is the EPP server running?'
- end
-
- private
-
- def schema_example
- <<~XML
-
-
-
-
-
- auction.test
-
-
-
-
- XML
- end
-end
diff --git a/test/tasks/assign_auction_platform_type_test.rb b/test/tasks/assign_auction_platform_type_test.rb
new file mode 100644
index 000000000..cd0d10917
--- /dev/null
+++ b/test/tasks/assign_auction_platform_type_test.rb
@@ -0,0 +1,27 @@
+require 'test_helper'
+
+class AssignAuctionPlatformTypeTest < ActiveSupport::TestCase
+ setup do
+ @auction_one = auctions(:one)
+ @auction_two = auctions(:idn)
+ end
+
+ def test_output
+ assert_nil @auction_one.platform
+ assert_nil @auction_two.platform
+
+ run_task
+
+ @auction_one.reload
+ @auction_two.reload
+
+ assert_equal @auction_one.platform, "auto"
+ assert_equal @auction_two.platform, "auto"
+ end
+
+ private
+
+ def run_task
+ Rake::Task['auction:assign_platform_type'].execute
+ end
+end