Merge branch 'master' into 1928-move-whois-db-change-management-from-rest-whois-project-to-registry

This commit is contained in:
OlegPhenomenon 2021-05-13 11:01:36 +03:00 committed by GitHub
commit beeb67ad23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 844 additions and 493 deletions

View file

@ -1,3 +1,28 @@
10.05.2021
* Domain update confirmation fix [#1975](https://github.com/internetee/registry/pull/1975)
* Bump bootsnap to 1.7.5 [#1970](https://github.com/internetee/registry/pull/1970)
* Bump truemail to 2.4.1 [#1971](https://github.com/internetee/registry/pull/1971)
* Bump devise to 4.8.0 [#1972](https://github.com/internetee/registry/pull/1972)
* Bump iso8601 to 0.13.0 [#1973](https://github.com/internetee/registry/pull/1973)
* Bump puma to 5.3.0 [#1974](https://github.com/internetee/registry/pull/1974)
06.05.2021
* List all unread polls option for REPP [#1936](https://github.com/internetee/registry/pull/1936)
* Bump Rails to 6.1.3.1 [#1962](https://github.com/internetee/registry/pull/1962)
* Bump mimemagic to 0.4.3 [](https://github.com/internetee/registry/pull/1960)
03.05.2021
* Imporved error handling on invalid XML over EPP [#1952](https://github.com/internetee/registry/pull/1952)
* Bump bootsnap to 1.7.4 [#1963](https://github.com/internetee/registry/pull/1963)
* Bump truemail to 2.4.0 [#1964](https://github.com/internetee/registry/pull/1964)
30.04.2021
* Fixed error message on oversized legaldocs [#1880](https://github.com/internetee/registry/issues/1880)
29.04.2021
* Admin is able to cancel invoice payments [#1937](https://github.com/internetee/registry/issues/1937)
* Bump nokogiri to 1.11.3 [#1920](https://github.com/internetee/registry/pull/1920)
26.04.2021 26.04.2021
* Disputed status is removed on registrant change and status added to schema [#1927](https://github.com/internetee/registry/issues/1927) * Disputed status is removed on registrant change and status added to schema [#1927](https://github.com/internetee/registry/issues/1927)
* Bounce list record is removed one there are no active contacts with the address [#1912](https://github.com/internetee/registry/issues/1912) * Bounce list record is removed one there are no active contacts with the address [#1912](https://github.com/internetee/registry/issues/1912)

12
Gemfile
View file

@ -4,10 +4,10 @@ source 'https://rubygems.org'
gem 'active_interaction', '~> 4.0' gem 'active_interaction', '~> 4.0'
gem 'apipie-rails', '~> 0.5.18' gem 'apipie-rails', '~> 0.5.18'
gem 'bootsnap', '>= 1.1.0', require: false gem 'bootsnap', '>= 1.1.0', require: false
gem 'iso8601', '0.12.1' # for dates and times gem 'iso8601', '0.13.0' # for dates and times
gem 'mime-types-data' gem 'mime-types-data'
gem 'mimemagic', '0.3.10' gem 'mimemagic', '0.4.3'
gem 'rails', '~> 6.0' gem 'rails', '~> 6.1.3.2'
gem 'rest-client' gem 'rest-client'
gem 'uglifier' gem 'uglifier'
@ -20,12 +20,12 @@ gem 'paper_trail', '~> 12.0'
gem 'pg', '1.2.3' gem 'pg', '1.2.3'
# 1.8 is for Rails < 5.0 # 1.8 is for Rails < 5.0
gem 'ransack', '~> 2.3' gem 'ransack', '~> 2.3'
gem 'truemail', '~> 2.3' # validates email by regexp, mail server existence and address existence gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696 gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696
# 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server # 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server
# https://github.com/huacnlee/rails-settings-cached/issues/165 # https://github.com/huacnlee/rails-settings-cached/issues/165
gem 'nokogiri', '~> 1.11.0' gem 'nokogiri', '~> 1.11.3'
# style # style
gem 'bootstrap-sass', '~> 3.4' gem 'bootstrap-sass', '~> 3.4'
@ -37,7 +37,7 @@ gem 'kaminari'
gem 'sass-rails' gem 'sass-rails'
gem 'select2-rails', '4.0.13' # for autocomplete gem 'select2-rails', '4.0.13' # for autocomplete
gem 'cancancan' gem 'cancancan'
gem 'devise', '~> 4.7' gem 'devise', '~> 4.8'
# registry specfic # registry specfic
gem 'data_migrate', '~> 7.0' gem 'data_migrate', '~> 7.0'

View file

@ -76,65 +76,69 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (6.0.3.6) actioncable (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.6) actionmailbox (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
activejob (= 6.0.3.6) activejob (= 6.1.3.2)
activerecord (= 6.0.3.6) activerecord (= 6.1.3.2)
activestorage (= 6.0.3.6) activestorage (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
mail (>= 2.7.1) mail (>= 2.7.1)
actionmailer (6.0.3.6) actionmailer (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
actionview (= 6.0.3.6) actionview (= 6.1.3.2)
activejob (= 6.0.3.6) activejob (= 6.1.3.2)
activesupport (= 6.1.3.2)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (6.0.3.6) actionpack (6.1.3.2)
actionview (= 6.0.3.6) actionview (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
rack (~> 2.0, >= 2.0.8) rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.6) actiontext (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
activerecord (= 6.0.3.6) activerecord (= 6.1.3.2)
activestorage (= 6.0.3.6) activestorage (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (6.0.3.6) actionview (6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_interaction (4.0.0) active_interaction (4.0.0)
activemodel (>= 5, < 7) activemodel (>= 5, < 7)
activejob (6.0.3.6) activejob (6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (6.0.3.6) activemodel (6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
activerecord (6.0.3.6) activerecord (6.1.3.2)
activemodel (= 6.0.3.6) activemodel (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
activerecord-import (1.0.8) activerecord-import (1.0.8)
activerecord (>= 3.2) activerecord (>= 3.2)
activestorage (6.0.3.6) activestorage (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
activejob (= 6.0.3.6) activejob (= 6.1.3.2)
activerecord (= 6.0.3.6) activerecord (= 6.1.3.2)
activesupport (= 6.1.3.2)
marcel (~> 1.0.0) marcel (~> 1.0.0)
activesupport (6.0.3.6) mini_mime (~> 1.0.2)
activesupport (6.1.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 1.6, < 2)
minitest (~> 5.1) minitest (>= 5.1)
tzinfo (~> 1.1) tzinfo (~> 2.0)
zeitwerk (~> 2.2, >= 2.2.2) zeitwerk (~> 2.3)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
aes_key_wrap (1.1.0) aes_key_wrap (1.1.0)
@ -164,7 +168,7 @@ GEM
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16) bcrypt (3.1.16)
bindata (2.4.8) bindata (2.4.8)
bootsnap (1.7.3) bootsnap (1.7.5)
msgpack (~> 1.0) msgpack (~> 1.0)
bootstrap-sass (3.4.1) bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1) autoprefixer-rails (>= 5.2.1)
@ -211,7 +215,7 @@ GEM
activerecord (>= 5.a) activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0) database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1) database_cleaner-core (2.0.1)
devise (4.7.3) devise (4.8.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
railties (>= 4.1.0) railties (>= 4.1.0)
@ -249,7 +253,7 @@ GEM
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
i18n_data (0.11.0) i18n_data (0.11.0)
isikukood (0.1.2) isikukood (0.1.2)
iso8601 (0.12.1) iso8601 (0.13.0)
jmespath (1.4.0) jmespath (1.4.0)
jquery-rails (4.4.0) jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
@ -286,10 +290,10 @@ GEM
mime-types (3.3.1) mime-types (3.3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225) mime-types-data (3.2021.0225)
mimemagic (0.3.10) mimemagic (0.4.3)
nokogiri (~> 1) nokogiri (~> 1)
rake rake
mini_mime (1.1.0) mini_mime (1.0.3)
mini_portile2 (2.5.1) mini_portile2 (2.5.1)
minitest (5.14.4) minitest (5.14.4)
monetize (1.9.4) monetize (1.9.4)
@ -307,10 +311,10 @@ GEM
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.5.7) nio4r (2.5.7)
nokogiri (1.11.0) nokogiri (1.11.3)
mini_portile2 (~> 2.5.0) mini_portile2 (~> 2.5.0)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.11.0-x86_64-linux) nokogiri (1.11.3-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
nori (2.6.0) nori (2.6.0)
omniauth (1.9.1) omniauth (1.9.1)
@ -339,7 +343,7 @@ GEM
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
public_suffix (4.0.6) public_suffix (4.0.6)
puma (5.2.2) puma (5.3.0)
nio4r (~> 2.0) nio4r (~> 2.0)
que (0.14.3) que (0.14.3)
que-web (0.7.2) que-web (0.7.2)
@ -358,32 +362,32 @@ GEM
rack rack
rack-test (1.1.0) rack-test (1.1.0)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rails (6.0.3.6) rails (6.1.3.2)
actioncable (= 6.0.3.6) actioncable (= 6.1.3.2)
actionmailbox (= 6.0.3.6) actionmailbox (= 6.1.3.2)
actionmailer (= 6.0.3.6) actionmailer (= 6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
actiontext (= 6.0.3.6) actiontext (= 6.1.3.2)
actionview (= 6.0.3.6) actionview (= 6.1.3.2)
activejob (= 6.0.3.6) activejob (= 6.1.3.2)
activemodel (= 6.0.3.6) activemodel (= 6.1.3.2)
activerecord (= 6.0.3.6) activerecord (= 6.1.3.2)
activestorage (= 6.0.3.6) activestorage (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
bundler (>= 1.3.0) bundler (>= 1.15.0)
railties (= 6.0.3.6) railties (= 6.1.3.2)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0) rails-html-sanitizer (1.3.0)
loofah (~> 2.3) loofah (~> 2.3)
railties (6.0.3.6) railties (6.1.3.2)
actionpack (= 6.0.3.6) actionpack (= 6.1.3.2)
activesupport (= 6.0.3.6) activesupport (= 6.1.3.2)
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0) thor (~> 1.0)
rake (13.0.3) rake (13.0.3)
ransack (2.4.2) ransack (2.4.2)
activerecord (>= 5.2.4) activerecord (>= 5.2.4)
@ -459,12 +463,11 @@ GEM
httpclient (>= 2.4) httpclient (>= 2.4)
temple (0.8.2) temple (0.8.2)
thor (1.1.0) thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10) tilt (2.0.10)
truemail (2.3.4) truemail (2.4.1)
simpleidn (~> 0.2.1) simpleidn (~> 0.2.1)
tzinfo (1.2.9) tzinfo (2.0.4)
thread_safe (~> 0.1) concurrent-ruby (~> 1.0)
uglifier (4.2.0) uglifier (4.2.0)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unf (0.1.4) unf (0.1.4)
@ -527,7 +530,7 @@ DEPENDENCIES
daemons-rails (= 1.2.1) daemons-rails (= 1.2.1)
data_migrate (~> 7.0) data_migrate (~> 7.0)
database_cleaner database_cleaner
devise (~> 4.7) devise (~> 4.8)
digidoc_client! digidoc_client!
directo! directo!
dnsruby (~> 1.61) dnsruby (~> 1.61)
@ -538,16 +541,16 @@ DEPENDENCIES
figaro (~> 1.2) figaro (~> 1.2)
haml (~> 5.0) haml (~> 5.0)
isikukood isikukood
iso8601 (= 0.12.1) iso8601 (= 0.13.0)
jquery-rails jquery-rails
jquery-ui-rails (= 6.0.1) jquery-ui-rails (= 6.0.1)
kaminari kaminari
lhv! lhv!
mime-types-data mime-types-data
mimemagic (= 0.3.10) mimemagic (= 0.4.3)
minitest (~> 5.14) minitest (~> 5.14)
money-rails money-rails
nokogiri (~> 1.11.0) nokogiri (~> 1.11.3)
omniauth omniauth
omniauth-rails_csrf_protection omniauth-rails_csrf_protection
omniauth-tara! omniauth-tara!
@ -558,7 +561,7 @@ DEPENDENCIES
puma puma
que que
que-web que-web
rails (~> 6.0) rails (~> 6.1.3.2)
ransack (~> 2.3) ransack (~> 2.3)
rest-client rest-client
rexml rexml
@ -568,7 +571,7 @@ DEPENDENCIES
sidekiq sidekiq
simplecov (= 0.17.1) simplecov (= 0.17.1)
simpleidn (= 0.2.1) simpleidn (= 0.2.1)
truemail (~> 2.3) truemail (~> 2.4)
uglifier uglifier
validates_email_format_of (= 1.6.3) validates_email_format_of (= 1.6.3)
webdrivers webdrivers
@ -577,4 +580,4 @@ DEPENDENCIES
wkhtmltopdf-binary (~> 0.12.5.1) wkhtmltopdf-binary (~> 0.12.5.1)
BUNDLED WITH BUNDLED WITH
2.2.15 2.2.17

View file

@ -396,10 +396,9 @@ sudo apt-get install libxext-dev libxrender1 fontconfig
* [Testing](/doc/testing.md) * [Testing](/doc/testing.md)
### Travis CI ### Github Actions CI
* Travis is configured to build against master and staging branches by default. * Github Actions CI is configured to build all the PRs.
* Notification emails are sent to committer by default.
### EPP web client ### EPP web client

View file

@ -34,7 +34,7 @@ module Admin
params[:admin_user].delete(:password) if params[:admin_user][:password].blank? params[:admin_user].delete(:password) if params[:admin_user][:password].blank?
params[:admin_user].delete(:password_confirmation) if params[:admin_user][:password_confirmation].blank? params[:admin_user].delete(:password_confirmation) if params[:admin_user][:password_confirmation].blank?
if @admin_user.update_attributes(admin_user_params) if @admin_user.update(admin_user_params)
flash[:notice] = I18n.t('record_updated') flash[:notice] = I18n.t('record_updated')
redirect_to [:admin, @admin_user] redirect_to [:admin, @admin_user]
else else

View file

@ -40,7 +40,6 @@ module Admin
def create def create
@price = ::Billing::Price.new(price_params) @price = ::Billing::Price.new(price_params)
if @price.save if @price.save
flash[:notice] = t('.created') flash[:notice] = t('.created')
redirect_to_index redirect_to_index
@ -50,7 +49,7 @@ module Admin
end end
def update def update
if @price.update_attributes(price_params) if @price.update(price_params.compact_blank)
flash[:notice] = t('.updated') flash[:notice] = t('.updated')
redirect_to_index redirect_to_index
else else
@ -81,7 +80,11 @@ module Admin
valid_to valid_to
] ]
params.require(:price).permit(*allowed_params) allowed = params.require(:price).permit(*allowed_params)
if allowed[:duration]
allowed[:duration] = ActiveSupport::Duration.build(allowed[:duration].to_i)
end
allowed
end end
def search_params def search_params
@ -104,8 +107,7 @@ module Admin
end end
def durations def durations
durations = ::Billing::Price::durations ::Billing::Price::durations
durations.collect { |duration| [duration.sub('mon', 'month'), duration] }
end end
def statuses def statuses

View file

@ -20,6 +20,18 @@ module Admin
end end
end end
def cancel_paid
invoice_id = params[:invoice_id]
invoice = Invoice.find(invoice_id)
if account_activity_with_negative_sum(invoice)
flash[:notice] = t(:payment_was_cancelled)
else
flash[:alert] = t(:failed_to_payment_cancel)
end
redirect_to admin_invoices_path
end
def index def index
@q = Invoice.includes(:account_activity).search(params[:q]) @q = Invoice.includes(:account_activity).search(params[:q])
@q.sorts = 'number desc' if @q.sorts.empty? @q.sorts = 'number desc' if @q.sorts.empty?
@ -43,5 +55,21 @@ module Admin
def deposit_params def deposit_params
params.require(:deposit).permit(:amount, :description, :registrar_id) params.require(:deposit).permit(:amount, :description, :registrar_id)
end end
def account_activity_with_negative_sum(invoice)
account_activity = AccountActivity.find_by(invoice_id: invoice.id)
account_activity_dup = account_activity.dup
account_activity_dup.sum = -account_activity.sum.to_i
account_activity_dup.save
account_activity.update(invoice_id: nil)
account_activity_dup.update(invoice_id: nil)
mark_cancelled_payment_order(invoice)
account_activity.save && account_activity_dup.save
end
def mark_cancelled_payment_order(invoice)
payment_order = invoice.payment_orders.last
payment_order.update(notes: 'Cancelled')
end
end end
end end

View file

@ -23,30 +23,29 @@ module Epp
rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error
before_action :set_paper_trail_whodunnit before_action :set_paper_trail_whodunnit
skip_before_action :validate_against_schema
protected protected
def respond_with_command_failed_error(exception) def respond_with_command_failed_error(exception)
epp_errors << { epp_errors.add(:epp_errors,
code: '2400', code: '2400',
msg: 'Command failed', message: 'Command failed')
}
handle_errors handle_errors
log_exception(exception) log_exception(exception)
end end
def respond_with_object_does_not_exist_error def respond_with_object_does_not_exist_error
epp_errors << { epp_errors.add(:epp_errors,
code: '2303', code: '2303',
msg: 'Object does not exist', msg: 'Object does not exist')
}
handle_errors handle_errors
end end
def respond_with_authorization_error def respond_with_authorization_error
epp_errors << { epp_errors.add(:epp_errors,
code: '2201', code: '2201',
msg: 'Authorization error', msg: 'Authorization error')
}
handle_errors handle_errors
end end
@ -61,10 +60,9 @@ module Epp
def validate_against_schema def validate_against_schema
return if %w[hello error].include?(params[:action]) return if %w[hello error].include?(params[:action])
schema.validate(params[:nokogiri_frame]).each do |error| schema.validate(params[:nokogiri_frame]).each do |error|
epp_errors << { epp_errors.add(:epp_errors,
code: 2001, code: 2001,
msg: error msg: error)
}
end end
handle_errors and return if epp_errors.any? handle_errors and return if epp_errors.any?
end end
@ -92,30 +90,17 @@ module Epp
# ERROR + RESPONSE HANDLING # ERROR + RESPONSE HANDLING
def epp_errors def epp_errors
@errors ||= [] @errors ||= ActiveModel::Errors.new(self)
end end
def handle_errors(obj = nil) def handle_errors(obj = nil)
@errors ||= [] @errors ||= ActiveModel::Errors.new(self)
if obj if obj
obj.construct_epp_errors obj.construct_epp_errors
@errors += obj.errors[:epp_errors] obj.errors.each { |error| @errors.import error }
end end
if params[:parsed_frame].at_css('update')
@errors.each_with_index do |errors, index|
if errors[:code] == '2304' &&
errors[:value].present? &&
errors[:value][:val] == DomainStatus::SERVER_DELETE_PROHIBITED &&
errors[:value][:obj] == 'status'
@errors[index][:value][:val] = DomainStatus::PENDING_UPDATE
end
end
end
@errors.uniq!
render_epp_response '/epp/error' render_epp_response '/epp/error'
end end
@ -132,10 +117,9 @@ module Epp
return true return true
end end
epp_errors << { epp_errors.add(:epp_errors,
msg: 'Parameter value policy error. Allowed only Latin characters.', msg: 'Parameter value policy error. Allowed only Latin characters.',
code: '2306' code: '2306')
}
handle_errors and return false handle_errors and return false
end end
@ -179,10 +163,12 @@ module Epp
else else
missing = el.present? ? el.text.blank? : true missing = el.present? ? el.text.blank? : true
end end
epp_errors << { next unless missing
epp_errors.add(:epp_errors,
code: '2003', code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: "#{full_selector} [#{attr}]") message: I18n.t('errors.messages.required_parameter_missing',
} if missing key: "#{full_selector} [#{attr}]"))
end end
missing ? false : el # return last selector if it was present missing ? false : el # return last selector if it was present
@ -200,25 +186,23 @@ module Epp
attribute = element[attribute_selector] attribute = element[attribute_selector]
unless attribute unless attribute
epp_errors << { epp_errors.add(:epp_errors,
code: '2003', code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: attribute_selector) msg: I18n.t('errors.messages.required_parameter_missing',
} key: attribute_selector))
return return
end end
return if options[:values].include?(attribute) return if options[:values].include?(attribute)
if options[:policy] if options[:policy]
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: I18n.t('attribute_is_invalid', attribute: attribute_selector) msg: I18n.t('attribute_is_invalid', attribute: attribute_selector))
}
else else
epp_errors << { epp_errors.add(:epp_errors,
code: '2004', code: '2004',
msg: I18n.t('parameter_value_range_error', key: attribute_selector) msg: I18n.t('parameter_value_range_error', key: attribute_selector))
}
end end
end end
@ -230,30 +214,29 @@ module Epp
attribute = element[attribute_selector] attribute = element[attribute_selector]
return if (attribute && options[:values].include?(attribute)) || !attribute return if (attribute && options[:values].include?(attribute)) || !attribute
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: I18n.t('attribute_is_invalid', attribute: attribute_selector) msg: I18n.t('attribute_is_invalid', attribute: attribute_selector))
}
end end
def exactly_one_of(*selectors) def exactly_one_of(*selectors)
full_selectors = create_full_selectors(*selectors) full_selectors = create_full_selectors(*selectors)
return if element_count(*full_selectors, use_prefix: false) == 1 return if element_count(*full_selectors, use_prefix: false) == 1
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: I18n.t(:exactly_one_parameter_required, params: full_selectors.join(' OR ')) msg: I18n.t(:exactly_one_parameter_required,
} params: full_selectors.join(' OR ')))
end end
def mutually_exclusive(*selectors) def mutually_exclusive(*selectors)
full_selectors = create_full_selectors(*selectors) full_selectors = create_full_selectors(*selectors)
return if element_count(*full_selectors, use_prefix: false) <= 1 return if element_count(*full_selectors, use_prefix: false) <= 1
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: I18n.t(:mutally_exclusive_params, params: full_selectors.join(', ')) msg: I18n.t(:mutally_exclusive_params,
} params: full_selectors.join(', ')))
end end
def optional(selector, *validations) def optional(selector, *validations)
@ -264,8 +247,8 @@ module Epp
validations.each do |x| validations.each do |x|
validator = "#{x.first[0]}_validator".camelize.constantize validator = "#{x.first[0]}_validator".camelize.constantize
err = validator.validate_epp(selector.split(' ').last, value) result = validator.validate_epp(selector.split(' ').last, value)
epp_errors << err if err epp_errors.add(:epp_errors, result) if result
end end
end end
@ -296,10 +279,11 @@ module Epp
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
attributes.each do |x| attributes.each do |x|
epp_errors << { next if has_attribute(ph, x)
epp_errors.add(:epp_errors,
code: '2003', code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) msg: I18n.t('errors.messages.required_parameter_missing', key: x.last))
} unless has_attribute(ph, x)
end end
epp_errors.empty? epp_errors.empty?
end end
@ -354,10 +338,9 @@ module Epp
def enforce_epp_session_timeout def enforce_epp_session_timeout
if epp_session.timed_out? if epp_session.timed_out?
epp_errors << { epp_errors.add(:epp_errors,
code: '2201', code: '2201',
msg: 'Authorization error: Session timeout', msg: 'Authorization error: Session timeout')
}
handle_errors handle_errors
epp_session.destroy! epp_session.destroy!
else else

View file

@ -55,13 +55,13 @@ module Epp
def renew def renew
authorize! :renew, Epp::Contact authorize! :renew, Epp::Contact
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') } epp_errors.add(:epp_errors, code: '2101', msg: t(:'errors.messages.unimplemented_command'))
handle_errors handle_errors
end end
def transfer def transfer
authorize! :transfer, Epp::Contact authorize! :transfer, Epp::Contact
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') } epp_errors.add(:epp_errors, code: '2101', msg: t(:'errors.messages.unimplemented_command'))
handle_errors handle_errors
end end
@ -72,9 +72,10 @@ module Epp
end end
def action_call_response(action:) def action_call_response(action:)
# rubocop:disable Style/AndOr unless action.call
(handle_errors(@contact) and return) unless action.call handle_errors(@contact)
# rubocop:enable Style/AndOr return
end
if opt_addr? if opt_addr?
@response_code = 1100 @response_code = 1100
@ -134,24 +135,16 @@ module Epp
ident = params[:parsed_frame].css('ident') ident = params[:parsed_frame].css('ident')
if ident.present? && ident.attr('type').blank? if ident.present? && ident.attr('type').blank?
epp_errors << { epp_errors.add(:epp_errors,
code: '2003', code: '2003',
msg: I18n.t('errors.messages.required_ident_attribute_missing', key: 'type') msg: I18n.t('errors.messages.required_ident_attribute_missing', key: 'type'))
}
end end
if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank? if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank?
epp_errors << { epp_errors.add(:epp_errors,
code: '2003', code: '2003',
msg: I18n.t('errors.messages.required_ident_attribute_missing', key: 'cc') msg: I18n.t('errors.messages.required_ident_attribute_missing', key: 'cc'))
}
end end
# if ident.present? && ident.attr('cc').blank?
# epp_errors << {
# code: '2003',
# msg: I18n.t('errors.messages.required_ident_attribute_missing', key: 'cc')
# }
# end
contact_org_disabled contact_org_disabled
fax_disabled fax_disabled
status_editing_disabled status_editing_disabled
@ -178,28 +171,25 @@ module Epp
return true if ENV['contact_org_enabled'] == 'true' return true if ENV['contact_org_enabled'] == 'true'
return true if params[:parsed_frame].css('postalInfo org').text.blank? return true if params[:parsed_frame].css('postalInfo org').text.blank?
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]" msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]")
}
end end
def fax_disabled def fax_disabled
return true if ENV['fax_enabled'] == 'true' return true if ENV['fax_enabled'] == 'true'
return true if params[:parsed_frame].css('fax').text.blank? return true if params[:parsed_frame].css('fax').text.blank?
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: "#{I18n.t(:contact_fax_error)}: fax [fax]" msg: "#{I18n.t(:contact_fax_error)}: fax [fax]")
}
end end
def status_editing_disabled def status_editing_disabled
return true if Setting.client_status_editing_enabled return true if Setting.client_status_editing_enabled
return true if params[:parsed_frame].css('status').empty? return true if params[:parsed_frame].css('status').empty?
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]" msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
}
end end
def address_given? def address_given?

View file

@ -44,7 +44,10 @@ module Epp
update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame], update_params = ::Deserializers::Xml::DomainUpdate.new(params[:parsed_frame],
registrar_id).call registrar_id).call
action = Actions::DomainUpdate.new(@domain, update_params, false) action = Actions::DomainUpdate.new(@domain, update_params, false)
(handle_errors(@domain) and return) unless action.call unless action.call
handle_errors(@domain)
return
end
pending = @domain.epp_pending_update.present? pending = @domain.epp_pending_update.present?
render_epp_response("/epp/domains/success#{'_pending' if pending}") render_epp_response("/epp/domains/success#{'_pending' if pending}")
@ -90,10 +93,9 @@ module Epp
action = params[:parsed_frame].css('transfer').first[:op] action = params[:parsed_frame].css('transfer').first[:op]
if @domain.non_transferable? if @domain.non_transferable?
epp_errors << { epp_errors.add(:epp_errors,
code: '2304', code: '2304',
msg: I18n.t(:object_status_prohibits_operation), msg: I18n.t(:object_status_prohibits_operation))
}
handle_errors handle_errors
return return
end end
@ -102,10 +104,9 @@ module Epp
wrong_transfer_code = provided_transfer_code != @domain.transfer_code wrong_transfer_code = provided_transfer_code != @domain.transfer_code
if wrong_transfer_code if wrong_transfer_code
epp_errors << { epp_errors.add(:epp_errors,
code: '2202', code: '2202',
msg: 'Invalid authorization information', msg: 'Invalid authorization information')
}
handle_errors handle_errors
return return
end end
@ -120,10 +121,9 @@ module Epp
if @domain_transfer if @domain_transfer
render_epp_response '/epp/domains/transfer' render_epp_response '/epp/domains/transfer'
else else
epp_errors << { epp_errors.add(:epp_errors,
code: '2303', code: '2303',
msg: I18n.t('no_transfers_found') msg: I18n.t('no_transfers_found'))
}
handle_errors handle_errors
end end
end end
@ -184,11 +184,10 @@ module Epp
def validate_transfer def validate_transfer
# period element is disabled for now # period element is disabled for now
if params[:parsed_frame].css('period').any? if params[:parsed_frame].css('period').any?
epp_errors << { epp_errors.add(:epp_errors,
code: '2307', code: '2307',
msg: I18n.t(:unimplemented_object_service), msg: I18n.t(:unimplemented_object_service),
value: { obj: 'period' } value: { obj: 'period' })
}
end end
requires 'transfer > transfer' requires 'transfer > transfer'
@ -217,10 +216,9 @@ module Epp
return true if Setting.client_status_editing_enabled return true if Setting.client_status_editing_enabled
return true if check_client_hold return true if check_client_hold
return true if params[:parsed_frame].css('status').empty? return true if params[:parsed_frame].css('status').empty?
epp_errors << { epp_errors.add(:epp_errors,
code: '2306', code: '2306',
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]" msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
}
end end
def check_client_hold def check_client_hold
@ -232,17 +230,15 @@ module Epp
@domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit) @domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit)
if @domain_pricelist.try(:price) # checking if price list is not found if @domain_pricelist.try(:price) # checking if price list is not found
if current_user.registrar.balance < @domain_pricelist.price.amount if current_user.registrar.balance < @domain_pricelist.price.amount
epp_errors << { epp_errors.add(:epp_errors,
code: '2104', code: '2104',
msg: I18n.t('billing_failure_credit_balance_low') msg: I18n.t('billing_failure_credit_balance_low'))
}
return false return false
end end
else else
epp_errors << { epp_errors.add(:epp_errors,
code: '2104', code: '2104',
msg: I18n.t(:active_price_missing_for_this_operation) msg: I18n.t(:active_price_missing_for_this_operation))
}
return false return false
end end
true true

View file

@ -3,7 +3,12 @@ module Epp
skip_authorization_check skip_authorization_check
def error def error
epp_errors << { code: params[:code], msg: params[:msg] } epp_errors.add(:epp_errors, code: params[:code], msg: params[:msg])
render_epp_response '/epp/error'
end
def command_handler
epp_errors.add(:epp_errors, code: '2000', msg: 'Unknown command')
render_epp_response '/epp/error' render_epp_response '/epp/error'
end end
end end

View file

@ -43,11 +43,11 @@ module Epp
@notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID']) @notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
unless @notification unless @notification
epp_errors << { epp_errors.add(:epp_errors,
code: '2303', code: '2303',
msg: I18n.t('message_was_not_found'), msg: I18n.t('message_was_not_found'),
value: { obj: 'msgID', val: params[:parsed_frame].css('poll').first['msgID'] } value: { obj: 'msgID',
} val: params[:parsed_frame].css('poll').first['msgID'] })
handle_errors and return handle_errors and return
end end

View file

@ -20,10 +20,10 @@ module Epp
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path'])) server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
if client_md5 != server_md5 if client_md5 != server_md5
epp_errors << { msg = 'Authentication error; server closing connection (certificate is not valid)'
msg: 'Authentication error; server closing connection (certificate is not valid)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
@ -32,56 +32,56 @@ module Epp
if !Rails.env.development? && (!webclient_request && @api_user) if !Rails.env.development? && (!webclient_request && @api_user)
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
request.env['HTTP_SSL_CLIENT_S_DN_CN']) request.env['HTTP_SSL_CLIENT_S_DN_CN'])
epp_errors << { msg = 'Authentication error; server closing connection (certificate is not valid)'
msg: 'Authentication error; server closing connection (certificate is not valid)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
end end
if success && !@api_user if success && !@api_user
epp_errors << { msg = 'Authentication error; server closing connection (API user not found)'
msg: 'Authentication error; server closing connection (API user not found)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
if success && !@api_user.try(:active) if success && !@api_user.try(:active)
epp_errors << { msg = 'Authentication error; server closing connection (API user is not active)'
msg: 'Authentication error; server closing connection (API user is not active)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
if success && @api_user.cannot?(:create, :epp_login) if success && @api_user.cannot?(:create, :epp_login)
epp_errors << { msg = 'Authentication error; server closing connection (API user does not have epp role)'
msg: 'Authentication error; server closing connection (API user does not have epp role)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
if success && !ip_white? if success && !ip_white?
epp_errors << { msg = 'Authentication error; server closing connection (IP is not whitelisted)'
msg: 'Authentication error; server closing connection (IP is not whitelisted)', epp_errors.add(:epp_errors,
code: '2501' msg: msg,
} code: '2501')
success = false success = false
end end
if success && EppSession.limit_reached?(@api_user.registrar) if success && EppSession.limit_reached?(@api_user.registrar)
epp_errors << { msg = 'Session limit exceeded; server closing connection (connection limit reached)'
msg: 'Session limit exceeded; server closing connection (connection limit reached)', epp_errors.add(:epp_errors,
code: '2502', msg: msg,
} code: '2502')
success = false success = false
end end
@ -98,10 +98,9 @@ module Epp
already_authenticated = EppSession.exists?(session_id: epp_session_id) already_authenticated = EppSession.exists?(session_id: epp_session_id)
if already_authenticated if already_authenticated
epp_errors << { epp_errors.add(:epp_errors,
msg: 'Command use error; Already authenticated', msg: 'Command use error; Already authenticated',
code: 2002, code: 2002)
}
handle_errors handle_errors
return return
end end
@ -127,10 +126,9 @@ module Epp
def logout def logout
unless signed_in? unless signed_in?
epp_errors << { epp_errors.add(:epp_errors,
code: 2201, code: 2201,
msg: 'Authorization error' msg: 'Authorization error')
}
handle_errors handle_errors
return return
end end

View file

@ -5,7 +5,7 @@ class Registrar
def new def new
authorize! :manage, :repp authorize! :manage, :repp
@expire_date = Time.zone.now.to_date @expire_date = Time.zone.now.to_date
render file: 'registrar/bulk_change/new', locals: { active_tab: default_tab } render 'registrar/bulk_change/new', locals: { active_tab: default_tab }
end end
def bulk_renew def bulk_renew
@ -21,7 +21,7 @@ class Registrar
flash[:notice] = nil flash[:notice] = nil
end end
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew } render 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew }
end end
private private
@ -45,7 +45,7 @@ class Registrar
redirect_to registrar_domains_url redirect_to registrar_domains_url
else else
@error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message] @error = response.code == '404' ? 'Contact(s) not found' : parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: active_tab } render 'registrar/bulk_change/new', locals: { active_tab: active_tab }
end end
end end

View file

@ -43,9 +43,11 @@ class Registrar
send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8" send_data raw_csv, filename: 'contacts.csv', type: "#{Mime[:csv]}; charset=utf-8"
end end
format.pdf do format.pdf do
view = ActionView::Base.new(ActionController::Base.view_paths, contacts: contacts) raw_html = ApplicationController.render(
view.class_eval { include ::ApplicationHelper } template: 'registrar/contacts/list_pdf',
raw_html = view.render(file: 'registrar/contacts/list_pdf', layout: false) assigns: { contacts: contacts },
formats: [:html]
)
raw_pdf = contacts.pdf(raw_html) raw_pdf = contacts.pdf(raw_html)
send_data raw_pdf, filename: 'contacts.pdf' send_data raw_pdf, filename: 'contacts.pdf'

View file

@ -36,7 +36,7 @@ class Registrar
redirect_to registrar_domains_url redirect_to registrar_domains_url
else else
@api_errors = parsed_response[:message] @api_errors = parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer } render 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer }
end end
else else
params[:request] = true # EPP domain:transfer "op" attribute params[:request] = true # EPP domain:transfer "op" attribute

View file

@ -27,7 +27,7 @@ class Registrar
flash: { notice: compose_notice_message(parsed_response) }) flash: { notice: compose_notice_message(parsed_response) })
else else
@api_errors = parsed_response[:message] @api_errors = parsed_response[:message]
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver } render 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
end end
end end

View file

@ -17,10 +17,10 @@ module Repp
@response = { code: 2303, message: 'Object does not exist' } @response = { code: 2303, message: 'Object does not exist' }
render(json: @response, status: :not_found) render(json: @response, status: :not_found)
rescue ActionController::ParameterMissing, Apipie::ParamMissing => e rescue ActionController::ParameterMissing, Apipie::ParamMissing => e
@response = { code: 2003, message: e } @response = { code: 2003, message: e.message.gsub(/\n/, '. ') }
render(json: @response, status: :bad_request) render(json: @response, status: :bad_request)
rescue Apipie::ParamInvalid => e rescue Apipie::ParamInvalid => e
@response = { code: 2005, message: e } @response = { code: 2005, message: e.message.gsub(/\n/, '. ') }
render(json: @response, status: :bad_request) render(json: @response, status: :bad_request)
ensure ensure
create_repp_log create_repp_log
@ -60,40 +60,28 @@ module Repp
end end
def epp_errors def epp_errors
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
end end
def handle_errors(obj = nil, update: false) def handle_errors(obj = nil)
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
obj&.construct_epp_errors if obj
@epp_errors += obj.errors[:epp_errors] if obj obj.construct_epp_errors
obj.errors.each { |error| @epp_errors.import error }
format_epp_errors if update end
@epp_errors.uniq!
render_epp_error render_epp_error
end end
def format_epp_errors
@epp_errors.each_with_index do |error, index|
blocked_by_delete_prohibited?(error, index)
end
end
def blocked_by_delete_prohibited?(error, index)
if error[:code] == 2304 && error[:value][:val] == DomainStatus::SERVER_DELETE_PROHIBITED &&
error[:value][:obj] == 'status'
@epp_errors[index][:value][:val] = DomainStatus::PENDING_UPDATE
end
end
def render_epp_error(status = :bad_request, data = {}) def render_epp_error(status = :bad_request, data = {})
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
@epp_errors << { code: 2304, msg: 'Command failed' } if data != {} @epp_errors.add(:epp_errors, msg: 'Command failed', code: '2304') if data != {}
@response = { code: @epp_errors[0][:code].to_i, message: @epp_errors[0][:msg], data: data } error_options = @epp_errors.errors.uniq
.select { |error| error.options[:code].present? }[0].options
@response = { code: error_options[:code].to_i, message: error_options[:msg], data: data }
render(json: @response, status: status) render(json: @response, status: status)
end end

View file

@ -6,7 +6,9 @@ module Repp
super super
unless @new_contact.identical_to?(@current_contact) unless @new_contact.identical_to?(@current_contact)
@epp_errors << { code: 2304, msg: 'Admin contacts must be identical' } @epp_errors.add(:epp_errors,
msg: 'Admin contacts must be identical',
code: '2304')
end end
return handle_errors if @epp_errors.any? return handle_errors if @epp_errors.any?

View file

@ -15,8 +15,12 @@ module Repp
end end
def update def update
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
@epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid? return unless @new_contact.invalid?
@epp_errors.add(:epp_errors,
msg: 'New contact must be valid',
code: '2304')
end end
private private

View file

@ -50,7 +50,9 @@ module Repp
super super
if @new_contact == @current_contact if @new_contact == @current_contact
@epp_errors << { code: 2304, msg: 'New contact must be different from current' } @epp_errors.add(:epp_errors,
msg: 'New contact must be different from current',
code: '2304')
end end
return handle_errors if @epp_errors.any? return handle_errors if @epp_errors.any?

View file

@ -29,8 +29,8 @@ module Repp
renew = run_bulk_renew_task(@domains, bulk_renew_params[:renew_period]) renew = run_bulk_renew_task(@domains, bulk_renew_params[:renew_period])
return render_success(data: { updated_domains: @domains.map(&:name) }) if renew.valid? return render_success(data: { updated_domains: @domains.map(&:name) }) if renew.valid?
@epp_errors << { code: 2002, msg = renew.errors.keys.map { |k, _v| renew.errors[k] }.join(', ')
msg: renew.errors.keys.map { |k, _v| renew.errors[k] }.join(', ') } @epp_errors.add(:epp_errors, msg: msg, code: '2002')
handle_errors handle_errors
end end
@ -41,20 +41,20 @@ module Repp
end end
def validate_renew_period def validate_renew_period
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
periods = Depp::Domain::PERIODS.map { |p| p[1] } periods = Depp::Domain::PERIODS.map { |p| p[1] }
return if periods.include? bulk_renew_params[:renew_period] return if periods.include? bulk_renew_params[:renew_period]
@epp_errors << { code: 2005, msg: 'Invalid renew period' } @epp_errors.add(:epp_errors, msg: 'Invalid renew period', code: '2005')
end end
def select_renewable_domains def select_renewable_domains
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
if bulk_renew_params[:domains].instance_of?(Array) if bulk_renew_params[:domains].instance_of?(Array)
@domains = bulk_renew_domains @domains = bulk_renew_domains
else else
@epp_errors << { code: 2005, msg: 'Domains attribute must be an array' } @epp_errors.add(:epp_errors, msg: 'Domains attribute must be an array', code: '2005')
end end
return handle_errors if @epp_errors.any? return handle_errors if @epp_errors.any?
@ -73,12 +73,16 @@ module Repp
end end
def bulk_renew_domains def bulk_renew_domains
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
domains = [] domains = []
bulk_renew_params[:domains].each do |idn| bulk_renew_params[:domains].each do |idn|
domain = Epp::Domain.find_by(name: idn) domain = Epp::Domain.find_by(name: idn)
domains << domain if domain domains << domain if domain
@epp_errors << { code: 2304, msg: "Object does not exist: #{idn}" } unless domain next if domain
@epp_errors.add(:epp_errors,
msg: "Object does not exist: #{idn}",
code: '2304')
end end
domains domains

View file

@ -114,7 +114,6 @@ module Repp
transfer_params[:domain_transfers].each do |transfer| transfer_params[:domain_transfers].each do |transfer|
initiate_transfer(transfer) initiate_transfer(transfer)
end end
render_success(data: { success: @successful, failed: @errors }) render_success(data: { success: @successful, failed: @errors })
end end
@ -151,7 +150,7 @@ module Repp
@successful << { type: 'domain_transfer', domain_name: domain.name } @successful << { type: 'domain_transfer', domain_name: domain.name }
else else
@errors << { type: 'domain_transfer', domain_name: domain.name, @errors << { type: 'domain_transfer', domain_name: domain.name,
errors: domain.errors[:epp_errors] } errors: domain.errors.where(:epp_errors).first.options }
end end
end end
@ -187,7 +186,7 @@ module Repp
end end
def set_authorized_domain def set_authorized_domain
@epp_errors ||= [] @epp_errors ||= ActiveModel::Errors.new(self)
@domain = domain_from_url_hash @domain = domain_from_url_hash
end end
@ -195,7 +194,9 @@ module Repp
return if @domain.registrar == current_user.registrar return if @domain.registrar == current_user.registrar
return if @domain.transfer_code.eql?(request.headers['Auth-Code']) return if @domain.transfer_code.eql?(request.headers['Auth-Code'])
@epp_errors << { code: 2202, msg: I18n.t('errors.messages.epp_authorization_error') } @epp_errors.add(:epp_errors,
code: 2202,
msg: I18n.t('errors.messages.epp_authorization_error'))
handle_errors handle_errors
end end

View file

@ -18,6 +18,24 @@ module Repp
render_success(data: data) render_success(data: data)
end end
api :GET, '/repp/v1/registrar/notifications/all_notifications'
desc 'Get the all unread poll messages'
def all_notifications
records = current_user.unread_notifications.order('created_at DESC').all
@notification = records.limit(limit).offset(offset)
# rubocop:disable Style/AndOr
render_success(data: nil) and return unless @notification
# rubocop:enable Style/AndOr
data = @notification.as_json(only: %i[id text attached_obj_id attached_obj_type])
message = 'Command completed successfully.'\
" Returning #{@notification.count} out of #{records.count}."\
' Use URL parameters :limit and :offset to list other messages if needed.'
render_success(data: data, message: message)
end
api :GET, '/repp/v1/registrar/notifications/:notification_id' api :GET, '/repp/v1/registrar/notifications/:notification_id'
desc 'Get a specific poll message' desc 'Get a specific poll message'
def show def show
@ -45,6 +63,18 @@ module Repp
def set_notification def set_notification
@notification = current_user.unread_notifications.find(params[:id]) @notification = current_user.unread_notifications.find(params[:id])
end end
def limit
index_params[:limit] || 200
end
def offset
index_params[:offset] || 0
end
def index_params
params.permit(:limit, :offset)
end
end end
end end
end end

View file

@ -62,7 +62,7 @@ module ApplicationHelper
if model.updator.kind_of?(RegistrantUser) if model.updator.kind_of?(RegistrantUser)
model.updator model.updator
else else
link_to(model.updator, ['admin', model.updator]) link_to(model.updator, [:admin, model.updator])
end end
end end

View file

@ -0,0 +1,32 @@
module SortedCountryHelper
def all_country_options(selected = nil)
quick_options = options_for_select(quick_list, selected: selected)
# no double select
selected = quick_list.map(&:second).include?(selected) ? '' : selected
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
selected: selected, disabled: ['---'])
quick_options + all_options
end
def quick_list
[
%w[Estonia EE],
%w[Finland FI],
%w[Latvia LV],
%w[Lithuania LT],
['Russian Federation', 'RU'],
%w[Sweden SE],
['United States', 'US'],
]
end
def all_sorted
Country.all.sort_by(&:name)
end
def all_sorted_truncated
all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
end
end

View file

@ -13,8 +13,8 @@ module Actions
end end
def call def call
return unless domain_exists? return false unless domain_exists?
return unless valid_transfer_code? return false unless valid_transfer_code?
run_validations run_validations

View file

@ -41,7 +41,7 @@ module Domains
end end
def manage_errors(task) def manage_errors(task)
task.errors.each { |k, v| errors.add(k, v) } unless task.valid? task.errors.each { |task_error| errors.import task_error } unless task.valid?
errors.add(:domain, I18n.t('not_enough_funds')) unless task.result errors.add(:domain, I18n.t('not_enough_funds')) unless task.result
end end

View file

@ -20,12 +20,14 @@ module Domains
def calculate_total_price def calculate_total_price
@total_price = 0 @total_price = 0
domains.each do |domain| domains.each do |domain|
task = Domains::CheckBalance::SingleDomain.run(domain: domain, task = Domains::CheckBalance::SingleDomain.run(domain: domain, operation: 'renew',
operation: 'renew', period: period, unit: unit)
period: period,
unit: unit)
task.valid? ? @total_price += task.result : errors.merge!(task.errors) if task.valid?
@total_price += task.result
else
task.errors.each { |task_error| errors.import task_error }
end
end end
end end
end end

View file

@ -29,11 +29,17 @@ module Domains
end end
def assign_domain_update_meta def assign_domain_update_meta
user = ApiUser.find_by(id: domain.pending_json['current_user_id']) user = ApiUser.find_by(id: user_id) if user_id.present? && user_id.is_a?(String)
domain.upid = user.registrar.id if user.present? && user.registrar domain.upid = user.registrar.id if user.present? && user.registrar
domain.up_date = Time.zone.now domain.up_date = Time.zone.now
end end
private
def user_id
@user_id ||= domain.pending_json.dig('current_user_id')
end
end end
end end
end end

View file

@ -1,5 +1,6 @@
class BankTransaction < ApplicationRecord class BankTransaction < ApplicationRecord
include Versions include Versions
include TransactionPaidInvoices
belongs_to :bank_statement belongs_to :bank_statement
has_one :account_activity has_one :account_activity
@ -17,16 +18,6 @@ class BankTransaction < ApplicationRecord
account_activity.invoice account_activity.invoice
end end
def invoice
return unless registrar
@invoice ||= registrar.invoices
.order(created_at: :asc)
.unpaid
.non_cancelled
.find_by(total: sum)
end
def registrar def registrar
@registrar ||= Invoice.find_by(reference_no: parsed_ref_number)&.buyer @registrar ||= Invoice.find_by(reference_no: parsed_ref_number)&.buyer
end end

View file

@ -1,5 +1,6 @@
module Billing module Billing
class Price < ApplicationRecord class Price < ApplicationRecord
attribute :duration, :interval
include Billing::Price::Expirable include Billing::Price::Expirable
include Versions include Versions
@ -8,33 +9,37 @@ module Billing
validates :price, :valid_from, :operation_category, :duration, presence: true validates :price, :valid_from, :operation_category, :duration, presence: true
validates :operation_category, inclusion: { in: Proc.new { |price| price.class.operation_categories } } validates :operation_category, inclusion: { in: Proc.new { |price| price.class.operation_categories } }
validates :duration, inclusion: { in: Proc.new { |price| price.class.durations } } validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } }, if: :should_validate_duration?
alias_attribute :effect_time, :valid_from alias_attribute :effect_time, :valid_from
alias_attribute :expire_time, :valid_to alias_attribute :expire_time, :valid_to
monetize :price_cents, allow_nil: true, numericality: { greater_than_or_equal_to: 0 } monetize :price_cents, allow_nil: true, numericality: { greater_than_or_equal_to: 0 }
after_initialize :init_values after_initialize :init_values
def should_validate_duration?
new_record? || duration_changed?
end
def self.operation_categories def self.operation_categories
%w[create renew] %w[create renew]
end end
def self.durations def self.durations
[ {
'3 mons', '3 months' => 3.months,
'6 mons', '6 months' => 6.months,
'9 mons', '9 months' => 9.months,
'1 year', '1 year' => 1.year,
'2 years', '2 years' => 2.years,
'3 years', '3 years' => 3.years,
'4 years', '4 years' => 4.years,
'5 years', '5 years' => 5.years,
'6 years', '6 years' => 6.years,
'7 years', '7 years' => 7.years,
'8 years', '8 years' => 8.years,
'9 years', '9 years' => 9.years,
'10 years', '10 years' => 10.years,
] }
end end
def self.statuses def self.statuses

View file

@ -1,38 +1,45 @@
module EppErrors module EppErrors
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do
attr_accessor :epp_errors
end
def construct_epp_errors def construct_epp_errors
epp_errors = [] epp_errors = ActiveModel::Errors.new(self)
errors.messages.each do |attr, errors| errors.each do |error|
attr = attr.to_s.split('.')[0].to_sym attr = error.attribute.to_s.split('.')[0].to_sym
next if attr == :epp_errors next if attr == :epp_errors
if self.class.reflect_on_association(attr) if self.class.reflect_on_association(attr)
epp_errors << collect_child_errors(attr) collect_child_errors(attr).each do |child_error|
epp_errors.import child_error
end
end end
if self.class.reflect_on_aggregation(attr) if self.class.reflect_on_aggregation(attr)
aggregation = send(attr) aggregation = send(attr)
epp_errors << collect_aggregation_errors(aggregation) collect_aggregation_errors(aggregation).each do |aggregation_error|
epp_errors.import aggregation_error
end
next next
end end
collect_parent_errors(attr, error.message).each do |parent_error|
epp_errors << collect_parent_errors(attr, errors) epp_errors.import parent_error
end end
end
errors.add(:epp_errors, epp_errors) epp_errors.each { |epp_error| errors.import epp_error }
errors[:epp_errors].flatten! errors
end end
def collect_parent_errors(attr, errors) def collect_parent_errors(attr, errors)
errors = [errors] if errors.is_a?(String) errors = [errors] if errors.is_a?(String)
epp_errors = [] epp_errors = ActiveModel::Errors.new(self)
errors.each do |err| errors.each do |err|
code, value = find_epp_code_and_value(err) code, value = find_epp_code_and_value(err)
next unless code next unless code
msg = attr.to_sym == :base ? err : "#{err} [#{attr}]" msg = attr.to_sym == :base ? err : "#{err} [#{attr}]"
epp_errors << { code: code, msg: msg, value: value } epp_errors.add(attr, code: code, msg: msg, value: value)
end end
epp_errors epp_errors
end end
@ -40,20 +47,24 @@ module EppErrors
def collect_child_errors(attr) def collect_child_errors(attr)
macro = self.class.reflect_on_association(attr).macro macro = self.class.reflect_on_association(attr).macro
multi = [:has_and_belongs_to_many, :has_many] multi = [:has_and_belongs_to_many, :has_many]
# single = [:belongs_to, :has_one]
epp_errors = [] epp_errors = ActiveModel::Errors.new(self)
if multi.include?(macro)
send(attr).each do |x| send(attr).each do |x|
x.errors.messages.each do |attribute, errors| x.errors.each do |error|
epp_errors << x.collect_parent_errors(attribute, errors) x.collect_parent_errors(error.attribute, error.message).each do |parent_error|
epp_errors.import parent_error
end
end
end
end end
end if multi.include?(macro)
epp_errors epp_errors
end end
def collect_aggregation_errors(aggregation) def collect_aggregation_errors(aggregation)
epp_errors = [] epp_errors = ActiveModel::Errors.new(self)
aggregation.errors.details.each do |attr, error_details| aggregation.errors.details.each do |attr, error_details|
error_details.each do |error_detail| error_details.each do |error_detail|
@ -69,7 +80,7 @@ module EppErrors
message = "#{aggregation.model_name.human} #{message.camelize(:lower)}" message = "#{aggregation.model_name.human} #{message.camelize(:lower)}"
end end
epp_errors << { code: epp_code, msg: message } epp_errors.add(attr, code: epp_code, msg: message)
end end
end end
end end
@ -105,11 +116,20 @@ module EppErrors
end end
def add_epp_error(code, obj, val, msg) def add_epp_error(code, obj, val, msg)
errors[:epp_errors] ||= []
t = errors.generate_message(*msg) if msg.is_a?(Array) t = errors.generate_message(*msg) if msg.is_a?(Array)
t = msg if msg.is_a?(String) t = msg if msg.is_a?(String)
err = { code: code, msg: t } err = { code: code, msg: t }
val = check_for_status(code, obj, val)
err[:value] = { val: val, obj: obj } if val.present? err[:value] = { val: val, obj: obj } if val.present?
errors[:epp_errors] << err self.errors.add(:epp_errors, err)
end
def check_for_status(code, obj, val)
if code == '2304' && val.present? && val == DomainStatus::SERVER_DELETE_PROHIBITED &&
obj == 'status'
DomainStatus::PENDING_UPDATE
else
val
end
end end
end end

View file

@ -40,8 +40,8 @@ module Registrar::BookKeeping
def fetch_invoice_lines(activity, lines) def fetch_invoice_lines(activity, lines)
price = load_price(activity) price = load_price(activity)
if price.duration.include? 'year' if price.duration.in_years.to_i >= 1
price.duration.to_i.times do |duration| price.duration.in_years.to_i.times do |duration|
lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json lines << new_monthly_invoice_line(activity: activity, duration: duration + 1).as_json
end end
else else
@ -67,9 +67,9 @@ module Registrar::BookKeeping
end end
def finalize_invoice_line(line, price:, activity:, duration:) def finalize_invoice_line(line, price:, activity:, duration:)
yearly = price.duration.include?('year') yearly = price.duration.in_years.to_i >= 1
line['price'] = yearly ? (price.price.amount / price.duration.to_i) : price.price.amount line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount
line['description'] = description_in_language(price: price, yearly: yearly) line['description'] = description_in_language(price: price, yearly: yearly)
if duration.present? if duration.present?
@ -90,7 +90,7 @@ module Registrar::BookKeeping
locale_string = "registrar.invoice_#{timeframe_string}_product_description" locale_string = "registrar.invoice_#{timeframe_string}_product_description"
I18n.with_locale(language == 'en' ? 'en' : 'et') do I18n.with_locale(language == 'en' ? 'en' : 'et') do
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.to_i) I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.in_years.to_i)
end end
end end

View file

@ -0,0 +1,37 @@
module TransactionPaidInvoices
extend ActiveSupport::Concern
def invoice
return unless registrar
@invoice ||= registrar.invoices
.order(created_at: :asc)
.unpaid
.non_cancelled
.find_by(total: sum)
end
def non_canceled?
paid_invoices = registrar.invoices
.order(created_at: :asc)
.non_cancelled
.where(total: sum)
paid_invoices.any? do |invoice|
return true if invoice.paid? && fresh_admin_paid_invoice(invoice)
end
end
private
def fresh_admin_paid_invoice(invoice)
check_for_date_paid_invoice(invoice) && does_invoice_created_by_admin?(invoice)
end
def check_for_date_paid_invoice(invoice)
invoice.account_activity.created_at > Time.zone.today - 2.days
end
def does_invoice_created_by_admin?(invoice)
invoice.account_activity.creator_str&.include? 'Admin'
end
end

View file

@ -60,19 +60,19 @@ class Dnskey < ApplicationRecord
def validate_algorithm def validate_algorithm
return if alg.blank? return if alg.blank?
return if ALGORITHMS.include?(alg.to_s) return if ALGORITHMS.include?(alg.to_s)
errors.add(:alg, :invalid, values: ALGORITHMS.join(', ')) errors.add(:alg, :invalid, values: "Valid algorithms are: #{ALGORITHMS.join(', ')}")
end end
def validate_protocol def validate_protocol
return if protocol.blank? return if protocol.blank?
return if PROTOCOLS.include?(protocol.to_s) return if PROTOCOLS.include?(protocol.to_s)
errors.add(:protocol, :invalid, values: PROTOCOLS.join(', ')) errors.add(:protocol, :invalid, values: "Valid protocols are: #{PROTOCOLS.join(', ')}")
end end
def validate_flags def validate_flags
return if flags.blank? return if flags.blank?
return if FLAGS.include?(flags.to_s) return if FLAGS.include?(flags.to_s)
errors.add(:flags, :invalid, values: FLAGS.join(', ')) errors.add(:flags, :invalid, values: "Valid flags are: #{FLAGS.join(', ')}")
end end
def generate_digest def generate_digest

View file

@ -14,9 +14,7 @@ class Invoice
private private
def invoice_html def invoice_html
view = ActionView::Base.new(ActionController::Base.view_paths, invoice: invoice) ApplicationController.render(template: 'invoice/pdf', assigns: { invoice: invoice })
view.class_eval { include ApplicationHelper }
view.render(file: 'invoice/pdf', layout: false)
end end
end end
end end

View file

@ -1,6 +1,7 @@
class LegalDocument < ApplicationRecord class LegalDocument < ApplicationRecord
include EppErrors include EppErrors
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
MAX_BODY_SIZE = 8.megabytes
if ENV['legal_document_types'].present? if ENV['legal_document_types'].present?
TYPES = ENV['legal_document_types'].split(',').map(&:strip) TYPES = ENV['legal_document_types'].split(',').map(&:strip)
@ -20,14 +21,19 @@ class LegalDocument < ApplicationRecord
def epp_code_map def epp_code_map
{ {
'2306' => [ '2308' => [
[:body, :length] %i[body length_more_than],
%i[body length_less_than],
] ]
} }
end end
def val_body_length def val_body_length
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE if body.nil? || body.size < MIN_BODY_SIZE
errors.add(:body, :length_more_than)
elsif body.size > MAX_BODY_SIZE
errors.add(:body, :length_less_than)
end
end end
def save_to_filesystem def save_to_filesystem

View file

@ -1,40 +0,0 @@
class SortedCountry
class << self
include ActionView::Helpers
def all_options(selected = nil)
quick_options = options_for_select(quick_list, selected: selected)
# no double select
selected = quick_list.map(&:second).include?(selected) ? '' : selected
all_options = options_for_select([['---', '---']] + all_sorted_truncated,
selected: selected, disabled: ['---'])
quick_options + all_options
end
private
def quick_list
@quick_list ||=
[
%w[Estonia EE],
%w[Finland FI],
%w[Latvia LV],
%w[Lithuania LT],
['Russian Federation', 'RU'],
%w[Sweden SE],
['United States', 'US']
]
end
def all_sorted
@all_sorted ||= Country.all.sort_by(&:name)
end
def all_sorted_truncated
@all_sorted_truncated ||=
all_sorted.map { |country| [country.name.truncate(26), country.alpha2] }
end
end
end

View file

@ -35,7 +35,7 @@
.col-md-4.control-label .col-md-4.control-label
= f.label :country_code, t(:country), class: 'required' = f.label :country_code, t(:country), class: 'required'
.col-md-8 .col-md-8
= f.select :country_code, SortedCountry.all_options(f.object.country_code), {}, required: true, class: 'form-control' = f.select :country_code, ApplicationController.helpers.all_country_options(f.object.country_code), {}, required: true, class: 'form-control'
%hr %hr
.form-group .form-group
.col-md-4.control-label .col-md-4.control-label

View file

@ -1,6 +1,6 @@
<tr class="price"> <tr class="price">
<td><%= link_to price.zone_name, edit_admin_price_path(price), class: 'edit-price-btn' %></td> <td><%= link_to price.zone_name, edit_admin_price_path(price), class: 'edit-price-btn' %></td>
<td><%= price.duration.sub('mons', 'months') %></td> <td><%= price.duration %></td>
<td><%= price.operation_category %></td> <td><%= price.operation_category %></td>
<td><%= number_to_currency price.price %></td> <td><%= number_to_currency price.price %></td>
<td><%= l price.valid_from, format: :date %></td> <td><%= l price.valid_from, format: :date %></td>

View file

@ -28,7 +28,7 @@
.col-md-3 .col-md-3
.form-group .form-group
= label_tag t(:country) = label_tag t(:country)
= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } = 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' }
.col-md-6 .col-md-6
.form-group .form-group
= label_tag t(:contact_type) = label_tag t(:contact_type)

View file

@ -6,6 +6,10 @@
%h1.text-right.text-center-xs %h1.text-right.text-center-xs
- if @invoice.unpaid? - if @invoice.unpaid?
= link_to(t(:payment_received), new_admin_bank_statement_path(invoice_id: @invoice.id), class: 'btn btn-default') = link_to(t(:payment_received), new_admin_bank_statement_path(invoice_id: @invoice.id), class: 'btn btn-default')
- if @invoice.paid? and !@invoice.cancelled?
= link_to(t(:cancel_payment), cancel_paid_admin_invoices_path(invoice_id: @invoice.id), method: 'post', data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning')
= link_to(t('.download_btn'), download_admin_invoice_path(@invoice), class: 'btn btn-default') = link_to(t('.download_btn'), download_admin_invoice_path(@invoice), class: 'btn btn-default')
= link_to(t('.deliver_btn'), new_admin_invoice_delivery_path(@invoice), class: 'btn btn-default') = link_to(t('.deliver_btn'), new_admin_invoice_delivery_path(@invoice), class: 'btn btn-default')
- if @invoice.cancellable? - if @invoice.cancellable?

View file

@ -49,7 +49,7 @@
</div> </div>
<div class="col-md-7"> <div class="col-md-7">
<%= f.select :address_country_code, <%= f.select :address_country_code,
SortedCountry.all_options(f.object.address_country_code), {}, ApplicationController.helpers.all_country_options(f.object.address_country_code), {},
required: true, class: 'form-control' %> required: true, class: 'form-control' %>
<span class="help-block"><%= t '.country_hint' %></span> <span class="help-block"><%= t '.country_hint' %></span>
</div> </div>

View file

@ -1,6 +1,9 @@
xml.epp_head do xml.epp_head do
xml.response do xml.response do
@errors.each do |x| @errors.each do |error|
x = error&.options
next if x.empty? || x == { value: nil }
xml.result('code' => x[:code]) do xml.result('code' => x[:code]) do
xml.msg(x[:msg], 'lang' => 'en') xml.msg(x[:msg], 'lang' => 'en')
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize

View file

@ -40,7 +40,7 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="form-group"> <div class="form-group">
<%= label_tag t(:country) %> <%= label_tag t(:country) %>
<%= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } %> <%= 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' } %>
</div> </div>
</div> </div>

View file

@ -31,6 +31,6 @@
= f.label :country_code, t(:country) + '*' = f.label :country_code, t(:country) + '*'
.col-md-7 .col-md-7
- country_selected = f.object.persisted? ? f.object.country_code : 'EE' - country_selected = f.object.persisted? ? f.object.country_code : 'EE'
= f.select(:country_code, SortedCountry.all_options(country_selected), = f.select(:country_code, SApplicationController.helpers.all_country_options(country_selected),
{ include_blank: true }, required: true) { include_blank: true }, required: true)

View file

@ -19,7 +19,7 @@
= Country.new(f.object.ident_country_code).try(:to_s) = Country.new(f.object.ident_country_code).try(:to_s)
= " [#{f.object.ident_country_code}]" = " [#{f.object.ident_country_code}]"
- else - else
= f.select(:ident_country_code, SortedCountry.all_options(country_selected), {}, = f.select(:ident_country_code, ApplicationController.helpers.all_country_options(country_selected), {},
class: 'js-ident-country-code', required: true) class: 'js-ident-country-code', required: true)
.form-group .form-group

View file

@ -138,7 +138,8 @@ en:
legal_document: legal_document:
attributes: attributes:
body: body:
length: 'Parameter value policy error: legalDocument size should be more than 3kB' length_more_than: 'Parameter value policy error: Legaldoc size is less than minimum allowed size of 3kB'
length_less_than: 'Parameter value policy error: Legaldoc size exceeds maximum allowed size of 8mB'
attributes: attributes:
@ -293,6 +294,9 @@ en:
record_deleted: 'Record deleted' record_deleted: 'Record deleted'
failed_to_delete_record: 'Failed to delete record' failed_to_delete_record: 'Failed to delete record'
payment_was_cancelled: 'Payment was cancelled'
failed_to_payment_cancel: 'Failed to payment cancel'
authentication_error: 'Authentication error' authentication_error: 'Authentication error'
sign_in_cancelled: "Sign in cancelled" sign_in_cancelled: "Sign in cancelled"
@ -601,6 +605,7 @@ en:
no_transfers_found: 'No transfers found' no_transfers_found: 'No transfers found'
parameter_value_range_error: 'Parameter value range error: %{key}' parameter_value_range_error: 'Parameter value range error: %{key}'
payment_received: 'Payment received' payment_received: 'Payment received'
cancel_payment: 'Cancel Payment'
api_user_not_found: 'API user not found' api_user_not_found: 'API user not found'
notes: Notes notes: Notes
active_price_for_this_operation_is: 'Active price for this operation is %{price}' active_price_for_this_operation_is: 'Active price for this operation is %{price}'

View file

@ -36,6 +36,7 @@ Rails.application.routes.draw do
post 'command/poll', to: 'polls#poll', as: 'poll', constraints: EppConstraint.new(:poll) post 'command/poll', to: 'polls#poll', as: 'poll', constraints: EppConstraint.new(:poll)
get 'error/:command', to: 'errors#error' get 'error/:command', to: 'errors#error'
get 'error', to: 'errors#command_handler'
end end
namespace :repp do namespace :repp do
@ -54,7 +55,11 @@ Rails.application.routes.draw do
resources :auctions, only: %i[index] resources :auctions, only: %i[index]
resources :retained_domains, only: %i[index] resources :retained_domains, only: %i[index]
namespace :registrar do namespace :registrar do
resources :notifications, only: [:index, :show, :update] resources :notifications, only: [:index, :show, :update] do
collection do
get '/all_notifications', to: 'notifications#all_notifications'
end
end
resources :nameservers do resources :nameservers do
collection do collection do
put '/', to: 'nameservers#update' put '/', to: 'nameservers#update'
@ -231,6 +236,9 @@ Rails.application.routes.draw do
end end
resources :invoices, except: %i[edit update destroy] do resources :invoices, except: %i[edit update destroy] do
collection do
post ':id/cancel_paid', to: 'invoices#cancel_paid', as: 'cancel_paid'
end
resource :delivery, controller: 'invoices/delivery', only: %i[new create] resource :delivery, controller: 'invoices/delivery', only: %i[new create]
member do member do

View file

@ -541,6 +541,7 @@ ALTER SEQUENCE public.certificates_id_seq OWNED BY public.certificates.id;
-- --
CREATE TABLE public.contact_requests ( CREATE TABLE public.contact_requests (
id integer NOT NULL, id integer NOT NULL,
whois_record_id integer NOT NULL, whois_record_id integer NOT NULL,
secret character varying NOT NULL, secret character varying NOT NULL,
@ -552,6 +553,7 @@ CREATE TABLE public.contact_requests (
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
message_id character varying message_id character varying
); );
@ -573,7 +575,6 @@ CREATE SEQUENCE public.contact_requests_id_seq
ALTER SEQUENCE public.contact_requests_id_seq OWNED BY public.contact_requests.id; ALTER SEQUENCE public.contact_requests_id_seq OWNED BY public.contact_requests.id;
-- --
-- Name: contacts; Type: TABLE; Schema: public; Owner: - -- Name: contacts; Type: TABLE; Schema: public; Owner: -
-- --

View file

@ -39,11 +39,13 @@ namespace :invoices do
reference_no: incoming_transaction.payment_reference_number, reference_no: incoming_transaction.payment_reference_number,
description: incoming_transaction.payment_description } description: incoming_transaction.payment_description }
transaction = bank_statement.bank_transactions.create!(transaction_attributes) transaction = bank_statement.bank_transactions.create!(transaction_attributes)
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
unless transaction.non_canceled?
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
transaction.autobind_invoice transaction.autobind_invoice
end end
end end
end
else else
log 'Got no incoming transactions parsed, aborting' log 'Got no incoming transactions parsed, aborting'
end end

View file

@ -1,5 +1,5 @@
create_one_month: create_one_month:
duration: 3 mons duration: 3 months
price_cents: 100 price_cents: 100
operation_category: create operation_category: create
valid_from: 2010-07-05 valid_from: 2010-07-05
@ -7,7 +7,7 @@ create_one_month:
zone: one zone: one
renew_one_month: renew_one_month:
duration: 1 mons duration: 1 month
price_cents: 100 price_cents: 100
operation_category: renew operation_category: renew
valid_from: 2010-07-05 valid_from: 2010-07-05

View file

@ -4,6 +4,23 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
setup do setup do
@invoice = invoices(:one) @invoice = invoices(:one)
sign_in users(:admin) sign_in users(:admin)
@account = accounts(:cash)
@registrar = registrars(:bestnames)
end
def test_cancel_paid_invoice
@invoice.account_activity.update(sum: 10)
assert @invoice.paid?
assert_equal @registrar.balance, 100
assert_no_difference 'Invoice.count' do
assert_difference 'AccountActivity.count' do
post cancel_paid_admin_invoices_path(id: @invoice.id) + "?invoice_id=#{@invoice.id}"
end
end
assert_equal @registrar.balance, 90
end end
def test_create_new_invoice def test_create_new_invoice

View file

@ -75,7 +75,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
data: { success: [], data: { success: [],
failed: [{ type: "domain_transfer", failed: [{ type: "domain_transfer",
domain_name: "shop.test", domain_name: "shop.test",
errors: [{:code=>"2304", :msg=>"Object status prohibits operation"}] }], errors: {:code=>"2304", :msg=>"Object status prohibits operation"} }],
}}), }}),
JSON.parse(response.body, symbolize_names: true) JSON.parse(response.body, symbolize_names: true)
end end

View file

@ -100,7 +100,7 @@ class APINameserversPutTest < ApplicationIntegrationTest
assert_response 400 assert_response 400
assert_equal ({ code: 2003, assert_equal ({ code: 2003,
message: 'param is missing or the value is empty: hostname' }), message: 'param is missing or the value is empty: hostname. Did you mean? hostname' }),
JSON.parse(response.body, symbolize_names: true) JSON.parse(response.body, symbolize_names: true)
end end

View file

@ -34,6 +34,26 @@ class EppBaseTest < EppTestCase
end end
end end
def test_additional_error
get '/epp/error', params: { frame: valid_request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :unknown_command
end
def test_error_with_unknown_command
invalid_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epsdp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
</epp>
XML
get '/epp/error', params: { frame: invalid_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :unknown_command
end
def test_validates_request_xml def test_validates_request_xml
invalid_xml = <<-XML invalid_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -43,7 +63,7 @@ class EppBaseTest < EppTestCase
post valid_command_path, params: { frame: invalid_xml }, post valid_command_path, params: { frame: invalid_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :syntax_error assert_epp_response :required_parameter_missing
end end
def test_anonymous_user def test_anonymous_user

View file

@ -46,6 +46,108 @@ class EppDomainCreateBaseTest < EppTestCase
assert_epp_response :parameter_value_syntax_error assert_epp_response :parameter_value_syntax_error
end end
def test_too_small_legal_document
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :data_management_policy_violation
end
def test_too_big_legal_document
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
bignum_legaldoc = Base64.encode64('t' * (LegalDocument::MAX_BODY_SIZE + 1)).gsub(/\n/,"")
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{bignum_legaldoc}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :data_management_policy_violation
error_description = 'Legaldoc size exceeds maximum allowed size of 8mB'
assert response.body.include? error_description
end
def test_upper_limit_of_value_legal_document
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
bignum_legaldoc = 't' * LegalDocument::MAX_BODY_SIZE
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{bignum_legaldoc}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :completed_successfully
end
def test_not_registers_domain_without_legaldoc def test_not_registers_domain_without_legaldoc
now = Time.zone.parse('2010-07-05') now = Time.zone.parse('2010-07-05')

View file

@ -92,7 +92,10 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
end end
def test_throws_error_when_not_enough_balance def test_throws_error_when_not_enough_balance
billing_prices(:renew_one_year).update(price_cents: 99999999) price = Billing::Price.last
price.price_cents = 99999999
price.save(validate: false)
payload = { payload = {
"domains": [ "domains": [
'invalid.test', 'invalid.test',
@ -106,7 +109,7 @@ class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
assert_response :bad_request assert_response :bad_request
assert_equal 2002, json[:code] assert_equal 2002, json[:code]
assert_equal 'Domain Billing failure - credit balance low', json[:message] assert_equal 'Billing failure - credit balance low', json[:message]
end end
end end

View file

@ -78,7 +78,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
assert_equal 1000, json[:code] assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message] assert_equal 'Command completed successfully', json[:message]
assert_equal 'Object status prohibits operation', json[:data][:failed][0][:errors][0][:msg] assert_equal 'Object status prohibits operation', json[:data][:failed][0][:errors][:msg]
@domain.reload @domain.reload
@ -100,7 +100,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
assert_equal 1000, json[:code] assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message] assert_equal 'Command completed successfully', json[:message]
assert_equal "Invalid authorization information", json[:data][:failed][0][:errors][0][:msg] assert_equal "Invalid authorization information", json[:data][:failed][0][:errors][:msg]
end end
def test_does_not_transfer_domain_to_same_registrar def test_does_not_transfer_domain_to_same_registrar
@ -121,7 +121,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
assert_equal 1000, json[:code] assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message] assert_equal 'Command completed successfully', json[:message]
assert_equal 'Domain already belongs to the querying registrar', json[:data][:failed][0][:errors][0][:msg] assert_equal 'Domain already belongs to the querying registrar', json[:data][:failed][0][:errors][:msg]
@domain.reload @domain.reload
@ -146,7 +146,7 @@ class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
assert_equal 1000, json[:code] assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message] assert_equal 'Command completed successfully', json[:message]
assert_equal 'Object is not eligible for transfer', json[:data][:failed][0][:errors][0][:msg] assert_equal 'Object is not eligible for transfer', json[:data][:failed][0][:errors][:msg]
@domain.reload @domain.reload

View file

@ -9,6 +9,17 @@ class ReppV1RegistrarNotificationsTest < ActionDispatch::IntegrationTest
@auth_headers = { 'Authorization' => token } @auth_headers = { 'Authorization' => token }
end end
def test_all_unreaded_poll_messages
notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).all
get "/repp/v1/registrar/notifications/all_notifications", headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
assert_response :ok
assert_equal notification.count, json[:data].count
assert_equal json[:data].first[:text], notification.first.text
assert_equal json[:data].last[:text], notification.last.text
end
def test_gets_latest_unread_poll_message def test_gets_latest_unread_poll_message
notification = @user.registrar.notifications.where(read: false).order(created_at: :desc).first 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

View file

@ -13,8 +13,9 @@ class ActiveJobQueuingTest < ActiveJob::TestCase
def test_job_retried_after_error def test_job_retried_after_error
assert_no_enqueued_jobs assert_no_enqueued_jobs
assert_raises StandardError do
assert_performed_jobs 3 do assert_performed_jobs 3 do
assert_raises StandardError do
TestRetriedJob.perform_later TestRetriedJob.perform_later
end end
end end

View file

@ -110,7 +110,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
def test_multi_year_purchases_have_duration_assigned def test_multi_year_purchases_have_duration_assigned
activity = account_activities(:one) activity = account_activities(:one)
price = billing_prices(:create_one_year) price = billing_prices(:create_one_year)
price.update(duration: '3 years') price.update(duration: 3.years)
activity.update(activity_type: 'create', price: price) activity.update(activity_type: 'create', price: price)
response = <<-XML response = <<-XML
@ -157,7 +157,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
activity = account_activities(:one) activity = account_activities(:one)
price = billing_prices(:create_one_year) price = billing_prices(:create_one_year)
price.update(duration: '3 years') price.update(duration: 3.years)
activity.update(activity_type: 'create', price: price) activity.update(activity_type: 'create', price: price)
# Creating account activity for second action # Creating account activity for second action

View file

@ -127,6 +127,29 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
assert @domain.statuses.include? DomainStatus::DISPUTED assert @domain.statuses.include? DomainStatus::DISPUTED
end end
def test_works_id_current_user_id_broken
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n </extdata>\n" \
" </extension>\n <clTRID>20alla-1594199756</clTRID>\n </command>\n</epp>\n"
parsed_frame = Deserializers::Xml::DomainUpdate.new(Nokogiri::XML(epp_xml), @domain.registrar.id).call
@domain.pending_json['frame'] = parsed_frame
@domain.pending_json['current_user_id'] = { key: 'some_value'}
@domain.update(pending_json: @domain.pending_json)
@domain.update(statuses: [DomainStatus::DELETE_CANDIDATE, DomainStatus::DISPUTED])
assert_nothing_raised do
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
end
@domain.reload
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
assert @domain.statuses.include? DomainStatus::DELETE_CANDIDATE
assert @domain.statuses.include? DomainStatus::DISPUTED
end
def test_clears_pending_update_and_inactive_after_denial def test_clears_pending_update_and_inactive_after_denial
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \ epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \ " <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \

View file

@ -65,7 +65,7 @@ class Billing::PriceTest < ActiveSupport::TestCase
price.duration = 'invalid' price.duration = 'invalid'
assert price.invalid? assert price.invalid?
price.duration = Billing::Price.durations.first price.duration = Billing::Price.durations.values.first
assert price.valid? assert price.valid?
end end
@ -75,21 +75,21 @@ class Billing::PriceTest < ActiveSupport::TestCase
end end
def test_returns_durations def test_returns_durations
durations = [ durations = {
'3 mons', '3 months' => 3.months,
'6 mons', '6 months' => 6.months,
'9 mons', '9 months' => 9.months,
'1 year', '1 year' => 1.year,
'2 years', '2 years'=> 2.years,
'3 years', '3 years'=> 3.years,
'4 years', '4 years'=> 4.years,
'5 years', '5 years'=> 5.years,
'6 years', '6 years'=> 6.years,
'7 years', '7 years'=> 7.years,
'8 years', '8 years'=> 8.years,
'9 years', '9 years'=> 9.years,
'10 years', '10 years'=> 10.years,
] }
assert_equal durations, Billing::Price.durations assert_equal durations, Billing::Price.durations
end end

View file

@ -22,22 +22,22 @@ class DnskeyTest < ActiveSupport::TestCase
def test_invalid_algrorithm def test_invalid_algrorithm
dns = Dnskey.new dns = Dnskey.new
dns.alg = 666 dns.alg = 666
errors = dns.validate_algorithm errors = dns.validate_algorithm.options[:values]
assert_equal errors, ['Valid algorithms are: 3, 5, 6, 7, 8, 10, 13, 14'] assert_equal errors, 'Valid algorithms are: 3, 5, 6, 7, 8, 10, 13, 14'
end end
def test_invalid_protocol def test_invalid_protocol
dns = Dnskey.new dns = Dnskey.new
dns.protocol = 666 dns.protocol = 666
errors = dns.validate_protocol errors = dns.validate_protocol.options[:values]
assert_equal errors, ['Valid protocols are: 3'] assert_equal errors, 'Valid protocols are: 3'
end end
def test_invalid_flags def test_invalid_flags
dns = Dnskey.new dns = Dnskey.new
dns.flags = 666 dns.flags = 666
errors = dns.validate_flags errors = dns.validate_flags.options[:values]
assert_equal errors, ['Valid flags are: 0, 256, 257'] assert_equal errors, 'Valid flags are: 0, 256, 257'
end end
def test_ds_digest_type_one def test_ds_digest_type_one

View file

@ -16,7 +16,7 @@ class RegistrantVerificationTest < ActiveSupport::TestCase
random_action = "random#{rand(100)}" random_action = "random#{rand(100)}"
assert_difference -> { Version::RegistrantVerificationVersion.count } do assert_difference -> { Version::RegistrantVerificationVersion.count } do
registrant_verification.update_attributes!(action: random_action) registrant_verification.update!(action: random_action)
end end
end end

View file

@ -20,7 +20,6 @@ class AdminAreaPricesTest < ApplicationSystemTestCase
fill_in 'Valid from', with: effective_date fill_in 'Valid from', with: effective_date
click_on 'Create price' click_on 'Create price'
assert_text 'Price has been created' assert_text 'Price has been created'
assert_text I18n.localize(effective_date) assert_text I18n.localize(effective_date)
end end

View file

@ -13,6 +13,9 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
total: payment_amount, total: payment_amount,
currency: @payment_currency, currency: @payment_currency,
reference_no: @payment_reference_number) reference_no: @payment_reference_number)
@account_activity = account_activities(:one)
@account = accounts(:cash)
Setting.registry_iban = beneficiary_iban Setting.registry_iban = beneficiary_iban
Lhv::ConnectApi.class_eval do Lhv::ConnectApi.class_eval do
@ -29,6 +32,36 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
end end
end end
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
assert_not @invoice.paid?
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 1.day, creator_str: 'AdminUser')
@invoice.update(account_activity: @account_activity, total: @payment_amount)
assert @invoice.paid?
assert_no_difference 'AccountActivity.count' do
assert_no_difference 'Invoice.count' do
assert_no_difference -> {@account.balance} do
capture_io { run_task }
end
end
end
end
def test_if_invoice_is_overdue_than_48_hours
assert_not @invoice.paid?
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 3.days, creator_str: 'AdminUser')
@invoice.update(account_activity: @account_activity, total: @payment_amount)
assert @invoice.paid?
assert_difference 'AccountActivity.count' do
assert_difference 'Invoice.count' do
capture_io { run_task }
end
end
end
def test_doubles_are_valid def test_doubles_are_valid
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages) assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:bank_account_iban) assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:bank_account_iban)