diff --git a/.codeclimate.yml b/.codeclimate.yml index 4f803baf1..ffcd2856c 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -48,7 +48,6 @@ exclude_patterns: - "config/" - "db/" - "lib/core_monkey_patches/" - - "lib/daemons/" - "lib/gem_monkey_patches/" - "lib/tasks/api_log.rake" - "lib/tasks/bootstrap.rake" diff --git a/Gemfile b/Gemfile index f38931c70..4ba187b94 100644 --- a/Gemfile +++ b/Gemfile @@ -62,13 +62,10 @@ gem 'omniauth-tara', github: 'internetee/omniauth-tara' # gem 'omniauth-tara', path: 'vendor/gems/omniauth-tara' gem 'airbrake' -gem 'daemons-rails', '1.2.1' gem 'epp', github: 'internetee/epp', branch: :master gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: :master gem 'jquery-ui-rails', '6.0.1' gem 'pdfkit' -gem 'que' -gem 'que-web' gem 'sidekiq', '>= 6.4.1' gem 'company_register', github: 'internetee/company_register', diff --git a/Gemfile.lock b/Gemfile.lock index 158e97986..f1908d37c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,10 +202,6 @@ GEM crack (0.4.5) rexml crass (1.0.6) - daemons (1.3.1) - daemons-rails (1.2.1) - daemons - multi_json (~> 1.0) data_migrate (8.0.0) activerecord (>= 5.0) railties (>= 5.0) @@ -227,7 +223,6 @@ GEM domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) erubi (1.10.0) - erubis (2.7.0) execjs (2.7.0) ffi (1.15.0) figaro (1.2.0) @@ -318,9 +313,6 @@ GEM money (~> 6.13.2) railties (>= 3.0) msgpack (1.4.2) - multi_json (1.15.0) - mustermann (1.1.1) - ruby2_keywords (~> 0.0.1) netrc (0.11.0) newrelic-infinite_tracing (8.1.0) grpc (~> 1.34) @@ -353,7 +345,7 @@ GEM paper_trail (12.1.0) activerecord (>= 5.2) request_store (~> 1.1) - pdfkit (0.8.5) + pdfkit (0.8.7) pg (1.4.3) pg_query (2.1.2) google-protobuf (>= 3.17.1) @@ -365,11 +357,6 @@ GEM public_suffix (4.0.6) puma (5.6.4) nio4r (~> 2.0) - que (0.14.3) - que-web (0.7.2) - erubis - que (~> 0.8) - sinatra racc (1.6.0) rack (2.2.4) rack-oauth2 (1.16.0) @@ -378,8 +365,6 @@ GEM httpclient json-jwt (>= 1.11.0) rack (>= 2.1.0) - rack-protection (2.2.0) - rack rack-test (1.1.0) rack (>= 1.0, < 3) rails (6.1.4.1) @@ -427,7 +412,6 @@ 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) @@ -463,11 +447,6 @@ GEM simplecov-html (0.10.2) simpleidn (0.2.1) unf (~> 0.1.4) - sinatra (2.2.0) - mustermann (~> 1.0) - rack (~> 2.2) - rack-protection (= 2.2.0) - tilt (~> 2.0) sixarm_ruby_unaccent (1.2.0) socksify (1.7.1) sprockets (4.0.2) @@ -546,7 +525,6 @@ DEPENDENCIES coffee-rails (>= 5.0) company_register! countries - daemons-rails (= 1.2.1) data_migrate (~> 8.0) database_cleaner devise (~> 4.8) @@ -582,8 +560,6 @@ DEPENDENCIES pghero pry (= 0.14.1) puma - que - que-web rails (~> 6.1.4) ransack (~> 2.6.0) rest-client diff --git a/README.md b/README.md index 2d5b058cc..5fcce9e91 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,6 @@ sudo apt-get install libxext-dev libxrender1 fontconfig ### Deployment * [Application build and update](/doc/application_build_doc.md) -* [Registry que server](/doc/que/README.md) ### Autotesting diff --git a/app/controllers/admin/api_users_controller.rb b/app/controllers/admin/api_users_controller.rb index cbef7def2..9e4111c9f 100644 --- a/app/controllers/admin/api_users_controller.rb +++ b/app/controllers/admin/api_users_controller.rb @@ -17,8 +17,7 @@ module Admin if @api_user.valid? @api_user.save! - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), - notice: t('.created') + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.created') else render 'new' end @@ -35,8 +34,7 @@ module Admin if @api_user.valid? @api_user.save! - redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), - notice: t('.updated') + redirect_to admin_registrar_api_user_path(@api_user.registrar, @api_user), notice: t('.updated') else render 'edit' end @@ -47,8 +45,45 @@ module Admin redirect_to admin_registrar_path(@api_user.registrar), notice: t('.deleted') end + def set_test_date_to_api_user + user_api = User.find(params[:user_api_id]) + + uri = URI.parse((ENV['registry_demo_registrar_api_user_url']) + "?username=#{user_api.username}&identity_code=#{user_api.identity_code}") + + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == "200" + result = JSON.parse(response.body) + demo_user_api = result['user_api'] + + Actions::RecordDateOfTest.record_result_to_api_user(api_user:user_api, + date: demo_user_api['accreditation_date']) unless demo_user_api.empty? + return redirect_to request.referrer, notice: 'User Api found' + else + return redirect_to request.referrer, notice: 'User Api no found or not accriditated yet' + end + + redirect_to request.referrer, notice: 'Something goes wrong' + end + + def remove_test_date_to_api_user + user_api = User.find(params[:user_api_id]) + user_api.accreditation_date = nil + user_api.accreditation_expire_date = nil + user_api.save + + redirect_to request.referrer + end + private + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end + def api_user_params params.require(:api_user).permit(:username, :plain_text_password, :active, :identity_code, { roles: [] }) diff --git a/app/controllers/admin/auctions_controller.rb b/app/controllers/admin/auctions_controller.rb index c1023b705..05bfc239f 100644 --- a/app/controllers/admin/auctions_controller.rb +++ b/app/controllers/admin/auctions_controller.rb @@ -44,7 +44,7 @@ module Admin if auction.save reserved_domain = auction.domain if remove_from_reserved(auction) - flash[:notice] = "Auction #{params[:domain]} created. + flash[:notice] = "Auction #{params[:domain]} created. #{reserved_domain.present? ? 'These domain will be removed from reserved list: ' + reserved_domain : ' '}" else flash[:alert] = 'Something goes wrong' @@ -53,6 +53,18 @@ module Admin redirect_to admin_auctions_path end + def destroy + auction = Auction.find(params[:id]) + + if auction.destroy + flash[:notice] = I18n.t('record_deleted') + else + flash.now[:alert] = I18n.t('failed_to_delete_record') + end + + redirect_to admin_auctions_path + end + def upload_spreadsheet if params[:q].nil? flash[:alert] = 'No file upload! Look at the left of upload button!' diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 707b40654..0b3a8b785 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -2,7 +2,7 @@ module Admin class DomainsController < BaseController DEFAULT_VERSIONS_PER_PAGE = 10 - before_action :set_domain, only: %i[show edit update keep] + before_action :set_domain, only: %i[show edit update download keep] authorize_resource # rubocop:disable Metrics/MethodLength @@ -65,6 +65,11 @@ module Admin .per(DEFAULT_VERSIONS_PER_PAGE) end + def download + filename = "#{@domain.name}.pdf" + send_data @domain.as_pdf, filename: filename + end + def keep @domain.keep redirect_to edit_admin_domain_url(@domain), notice: t('.kept') diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index a803a8e7d..b552a8cb3 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -1,3 +1,5 @@ +require 'net/http' + module Admin class RegistrarsController < BaseController # rubocop:disable Metrics/ClassLength load_and_authorize_resource @@ -55,8 +57,56 @@ module Admin end end + def set_test_date + registrar = Registrar.find(params[:registrar_id]) + + uri = URI.parse((ENV['registry_demo_registrar_results_url']) + "?registrar_name=#{registrar.name}") + + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == "200" + return record_result_for_each_api_user(response: response) + else + return redirect_to request.referer, notice: 'Registrar no found' + end + + redirect_to request.referer, notice: 'Something goes wrong' + end + + def remove_test_date + registrar = Registrar.find(params[:registrar_id]) + registrar.api_users.each do |api| + api.accreditation_date = nil + api.accreditation_expire_date = nil + api.save + end + + redirect_to request.referer + end + private + def record_result_for_each_api_user(response:) + result = JSON.parse(response.body) + registrar_users = result['registrar_users'] + + return redirect_to request.referer, notice: 'Registrar found, but not accreditated yet' if registrar_users.empty? + + registrar_users.each do |api| + a = ApiUser.find_by(username: api['username'], identity_code: api['identity_code']) + Actions::RecordDateOfTest.record_result_to_api_user(api_user: a, date: api['accreditation_date']) unless a.nil? + end + + redirect_to request.referer, notice: 'Registrar found' + end + + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end + def filter_by_status case params[:status] when 'Active' diff --git a/app/controllers/api/v1/accreditation_center/base_controller.rb b/app/controllers/api/v1/accreditation_center/base_controller.rb index 7deb776b9..aebdffd8a 100644 --- a/app/controllers/api/v1/accreditation_center/base_controller.rb +++ b/app/controllers/api/v1/accreditation_center/base_controller.rb @@ -4,23 +4,25 @@ module Api module V1 module AccreditationCenter class BaseController < ActionController::API - rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error - rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error - rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception| - error = {} - error[parameter_missing_exception.param] = ['parameter is required'] - response = { errors: [error] } - render json: response, status: :unprocessable_entity - end + if Feature.allow_accr_endspoints? + rescue_from ActiveRecord::RecordNotFound, with: :show_not_found_error + rescue_from ActiveRecord::RecordInvalid, with: :show_invalid_record_error + rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception| + error = {} + error[parameter_missing_exception.param] = ['parameter is required'] + response = { errors: [error] } + render json: response, status: :unprocessable_entity + end - private + private - def show_not_found_error - render json: { errors: [{ base: ['Not found'] }] }, status: :not_found - end + def show_not_found_error + render json: { errors: [{ base: ['Not found'] }] }, status: :not_found + end - def show_invalid_record_error(exception) - render json: { errors: exception.record.errors }, status: :bad_request + def show_invalid_record_error(exception) + render json: { errors: exception.record.errors }, status: :bad_request + end end end end diff --git a/app/controllers/api/v1/accreditation_center/results_controller.rb b/app/controllers/api/v1/accreditation_center/results_controller.rb new file mode 100644 index 000000000..8a6fd2d51 --- /dev/null +++ b/app/controllers/api/v1/accreditation_center/results_controller.rb @@ -0,0 +1,40 @@ +require 'serializers/repp/contact' + +module Api + module V1 + module AccreditationCenter + class ResultsController < ::Api::V1::AccreditationCenter::BaseController + def show + accr_users = [] + registrar = Registrar.find_by(name: params[:registrar_name]) + + return render json: { errors: 'Registrar not found' }, status: :not_found if registrar.nil? + + registrar.api_users.where.not(accreditation_date: nil).each do |u| + accr_users << u + end + + render json: { code: 1000, registrar_users: accr_users } + end + + def show_api_user + user_api = User.find_by(username: params[:username], identity_code: params[:identity_code]) + + return render json: { errors: 'User not found' }, status: :not_found if user_api.nil? + + return render json: { errors: 'No accreditated yet' }, status: :not_found if user_api.accreditation_date.nil? + + render json: { code: 1000, user_api: user_api } + end + + def list_accreditated_api_users + users = User.where.not(accreditation_date: nil) + + return render json: { errors: 'Accreditated users not found' }, status: :not_found if users.empty? + + render json: { code: 1000, users: users } + end + end + end + end +end diff --git a/app/controllers/api/v1/auctions_controller.rb b/app/controllers/api/v1/auctions_controller.rb index 9a01f4e68..07f4971dc 100644 --- a/app/controllers/api/v1/auctions_controller.rb +++ b/app/controllers/api/v1/auctions_controller.rb @@ -31,6 +31,7 @@ module Api end auction.mark_deadline(params[:registration_deadline]) if params[:registration_deadline] + auction.platform = params[:platform] == 'english' ? :manual : :auto if auction.payment_not_received? || auction.domain_not_registered? update_whois_from_auction(Auction.pending(auction.domain)) diff --git a/app/controllers/eis_billing/payment_status_controller.rb b/app/controllers/eis_billing/payment_status_controller.rb index 4fa626e5d..015eed64a 100644 --- a/app/controllers/eis_billing/payment_status_controller.rb +++ b/app/controllers/eis_billing/payment_status_controller.rb @@ -10,9 +10,7 @@ module EisBilling bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time]) create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status) - - registrar = invoice.buyer - bank.create_activity(registrar, invoice) + bank.bind_invoice(params[:order_reference]) respond_to do |format| format.json do diff --git a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb index cd86ce9ed..c55a561d2 100644 --- a/app/controllers/repp/v1/registrar/accreditation_info_controller.rb +++ b/app/controllers/repp/v1/registrar/accreditation_info_controller.rb @@ -2,35 +2,37 @@ module Repp module V1 module Registrar class AccreditationInfoController < BaseController - api :GET, 'repp/v1/registrar/accreditation/get_info' - desc 'check login user and return data' + if Feature.allow_accr_endspoints? + api :GET, 'repp/v1/registrar/accreditation/get_info' + desc 'check login user and return data' - def index - login = current_user - registrar = current_user.registrar + def index + login = current_user + registrar = current_user.registrar - # rubocop:disable Style/AndOr - render_success(data: nil) and return unless login - # rubocop:enable Style/AndOr + # rubocop:disable Style/AndOr + render_success(data: nil) and return unless login + # rubocop:enable Style/AndOr - data = set_values_to_data(login: login, registrar: registrar) + data = set_values_to_data(login: login, registrar: registrar) - render_success(data: data) - end + render_success(data: data) + end - private + private - def set_values_to_data(login:, registrar:) - data = login.as_json(only: %i[id - username - name - uuid - roles - accreditation_date - accreditation_expire_date]) - data[:registrar_name] = registrar.name - data[:registrar_reg_no] = registrar.reg_no - data + def set_values_to_data(login:, registrar:) + data = login.as_json(only: %i[id + username + name + uuid + roles + accreditation_date + accreditation_expire_date]) + data[:registrar_name] = registrar.name + data[:registrar_reg_no] = registrar.reg_no + data + end end end end diff --git a/app/controllers/repp/v1/registrar/accreditation_results_controller.rb b/app/controllers/repp/v1/registrar/accreditation_results_controller.rb index b58fd3895..3cee7422b 100644 --- a/app/controllers/repp/v1/registrar/accreditation_results_controller.rb +++ b/app/controllers/repp/v1/registrar/accreditation_results_controller.rb @@ -2,79 +2,80 @@ module Repp module V1 module Registrar class AccreditationResultsController < ActionController::API - before_action :authenticate_shared_key + if Feature.allow_accr_endspoints? + before_action :authenticate_shared_key - TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze - EXPIRE_DEADLINE = 15.minutes.freeze + TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze + EXPIRE_DEADLINE = 15.minutes.freeze - api :POST, 'repp/v1/registrar/accreditation/push_results' - desc 'added datetime results' + api :POST, 'repp/v1/registrar/accreditation/push_results' + desc 'added datetime results' - def create - username = params[:accreditation_result][:username] - result = params[:accreditation_result][:result] + def create + username = params[:accreditation_result][:username] + result = params[:accreditation_result][:result] - record_accreditation_result(username, result) if result - rescue ActiveRecord::RecordNotFound - record_not_found(username) - end - - private - - def record_accreditation_result(username, result) - user = ApiUser.find_by(username: username) - - raise ActiveRecord::RecordNotFound if user.nil? - - user.accreditation_date = DateTime.current - user.accreditation_expire_date = user.accreditation_date + EXPIRE_DEADLINE - - if user.save - notify_registrar(user) - notify_admins - render_success(data: { user: user, - result: result, - message: 'Accreditation info successfully added' }) - else - render_failed + record_accreditation_result(username, result) if result + rescue ActiveRecord::RecordNotFound + record_not_found(username) end - end - def notify_registrar(user) - AccreditationCenterMailer.test_was_successfully_passed_registrar(user.registrar.email).deliver_now - end + private - def notify_admins - admin_users_emails = User.all.reject { |u| u.roles.nil? } - .select { |u| u.roles.include? 'admin' }.pluck(:email) + def record_accreditation_result(username, result) + user = ApiUser.find_by(username: username) - return if admin_users_emails.empty? + raise ActiveRecord::RecordNotFound if user.nil? + user.accreditation_date = DateTime.current + user.accreditation_expire_date = user.accreditation_date + EXPIRE_DEADLINE - admin_users_emails.each do |email| - AccreditationCenterMailer.test_was_successfully_passed_admin(email).deliver_now + if user.save + notify_registrar(user) + notify_admins + render_success(data: { user: user, + result: result, + message: 'Accreditation info successfully added' }) + else + render_failed + end end - end - def authenticate_shared_key - api_key = "Basic #{TEMPORARY_SECRET_KEY}" - render_failed unless api_key == request.authorization - end + def notify_registrar(user) + AccreditationCenterMailer.test_was_successfully_passed_registrar(user.registrar.email).deliver_now + end - def record_not_found(username) - @response = { code: 2303, message: "Object '#{username}' does not exist" } - render(json: @response) - end + def notify_admins + admin_users_emails = User.all.reject { |u| u.roles.nil? } + .select { |u| u.roles.include? 'admin' }.pluck(:email) - def render_failed - @response = { code: 2202, message: 'Invalid authorization information' } - render(json: @response, status: :unauthorized) - end + return if admin_users_emails.empty? - def render_success(code: nil, message: nil, data: nil) - @response = { code: code || 1000, message: message || 'Command completed successfully', - data: data || {} } + admin_users_emails.each do |email| + AccreditationCenterMailer.test_was_successfully_passed_admin(email).deliver_now + end + end - render(json: @response, status: :ok) + def authenticate_shared_key + api_key = "Basic #{TEMPORARY_SECRET_KEY}" + render_failed unless api_key == request.authorization + end + + def record_not_found(username) + @response = { code: 2303, message: "Object '#{username}' does not exist" } + render(json: @response) + end + + def render_failed + @response = { code: 2202, message: 'Invalid authorization information' } + render(json: @response, status: :unauthorized) + end + + def render_success(code: nil, message: nil, data: nil) + @response = { code: code || 1000, message: message || 'Command completed successfully', + data: data || {} } + + render(json: @response, status: :ok) + end end end end diff --git a/app/interactions/actions/record_date_of_test.rb b/app/interactions/actions/record_date_of_test.rb new file mode 100644 index 000000000..229929429 --- /dev/null +++ b/app/interactions/actions/record_date_of_test.rb @@ -0,0 +1,13 @@ +module Actions + module RecordDateOfTest + extend self + + TEST_DEADLINE = 1.year.freeze + + def record_result_to_api_user(api_user:, date:) + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + TEST_DEADLINE + api_user.save + end + end +end diff --git a/app/jobs/sync_accredited_users_job.rb b/app/jobs/sync_accredited_users_job.rb new file mode 100644 index 000000000..de95b59c8 --- /dev/null +++ b/app/jobs/sync_accredited_users_job.rb @@ -0,0 +1,27 @@ +class SyncAccreditedUsersJob < ApplicationJob + def perform + uri = URI.parse(ENV['registry_demo_accredited_users_url']) + response = base_get_request(uri: uri, port: ENV['registry_demo_registrar_port']) + + if response.code == '200' + result = JSON.parse(response.body) + result['users'].each do |api| + a = ApiUser.find_by(username: api.username, identity_code: api.identity_code) + Actions::RecordDateOfTest.record_result_to_api_user(a, api.accreditation_date) unless a.nil? + end + else + logger.warn 'User not found' + end + + nil + end + + private + + def base_get_request(uri:, port:) + http = Net::HTTP.new(uri.host, port) + req = Net::HTTP::Get.new(uri.request_uri) + + http.request(req) + end +end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index dc5cff0cc..a15b12a85 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -56,6 +56,16 @@ class ApiUser < User username end + def accredited? + !accreditation_date.nil? + end + + def accreditation_expired? + return false if accreditation_expire_date.nil? + + accreditation_expire_date < Time.zone.now + end + def unread_notifications registrar.notifications.unread end diff --git a/app/models/auction.rb b/app/models/auction.rb index 465a827ec..d1c46d44e 100644 --- a/app/models/auction.rb +++ b/app/models/auction.rb @@ -84,7 +84,9 @@ class Auction < ApplicationRecord end def restart - new_auction = self.class.new(domain: domain) + new_platform = platform.nil? ? :auto : platform + + new_auction = self.class.new(domain: domain, platform: new_platform) new_auction.start end diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index ef2ab3370..bd437fe96 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -88,7 +88,16 @@ class BankTransaction < ApplicationRecord errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match')) if invoice.total != sum end + def parsed_ref_number + reference_no || ref_number_from_description + end + + private + def create_activity(registrar, invoice) + validate_invoice_data(invoice) + return if errors.any? + activity = AccountActivity.new(account: registrar.cash_account, bank_transaction: self, invoice: invoice, sum: invoice.subtotal, currency: currency, description: description, @@ -102,12 +111,6 @@ class BankTransaction < ApplicationRecord end end - def parsed_ref_number - reference_no || ref_number_from_description - end - - private - def reset_pending_registrar_balance_reload(registrar) return unless registrar.settings['balance_auto_reload'] diff --git a/app/models/domain.rb b/app/models/domain.rb index a8fc323a0..e75f5165c 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -743,6 +743,12 @@ class Domain < ApplicationRecord ] end + def as_pdf + domain_html = ApplicationController.render(template: 'domain/pdf', assigns: { domain: self }) + generator = PDFKit.new(domain_html) + generator.to_pdf + end + def registrant_name return registrant.name if registrant diff --git a/app/models/feature.rb b/app/models/feature.rb index 7a0d6d78b..ed7ae12fd 100644 --- a/app/models/feature.rb +++ b/app/models/feature.rb @@ -4,4 +4,18 @@ class Feature ENV['billing_system_integrated'] || false end + # def self.obj_and_extensions_statuses_enabled? + # return false if ENV['obj_and_extensions_prohibited'] == 'false' + # + # ENV['obj_and_extensions_prohibited'] || false + # end + # + # def self.enable_lock_domain_with_new_statuses? + # return false if ENV['enable_lock_domain_with_new_statuses'] == 'false' + # + # ENV['enable_lock_domain_with_new_statuses'] || false + # end + def self.allow_accr_endspoints? + ENV['allow_accr_endspoints'] == 'true' + end end diff --git a/app/models/que_job.rb b/app/models/que_job.rb deleted file mode 100644 index 40ef6a67e..000000000 --- a/app/models/que_job.rb +++ /dev/null @@ -1,3 +0,0 @@ -class QueJob < ApplicationRecord - self.primary_key = 'job_id' -end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 07d7d4795..5d6d7538f 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -190,6 +190,16 @@ class Registrar < ApplicationRecord # rubocop:disable Metrics/ClassLength white_ips.api.include_ip?(ip) end + def accredited? + api_users.any? do |a| + return true unless a.accreditation_date.nil? + end + end + + def accreditation_expired? + api_users.all? { |api| api.accreditation_expired? } + end + # Audit log is needed, therefore no raw SQL def replace_nameservers(hostname, new_attributes, domains: []) transaction do diff --git a/app/views/admin/api_users/_api_user.html.erb b/app/views/admin/api_users/_api_user.html.erb index d8412a519..5c443bfee 100644 --- a/app/views/admin/api_users/_api_user.html.erb +++ b/app/views/admin/api_users/_api_user.html.erb @@ -2,4 +2,16 @@ <%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> <%= link_to api_user.registrar, admin_registrar_path(api_user.registrar) %> <%= api_user.active %> + + + <% if !api_user.accredited? || api_user.accreditation_expired? %> + <%= button_to t(:set_test_btn), + { controller: 'api_users', action: 'set_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-primary'} %> + <% else %> + <%= button_to t(:remove_test_btn), + { controller: 'api_users', action: 'remove_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-danger'} %> + <% end %> + diff --git a/app/views/admin/api_users/index.html.erb b/app/views/admin/api_users/index.html.erb index 40e620954..3564245be 100644 --- a/app/views/admin/api_users/index.html.erb +++ b/app/views/admin/api_users/index.html.erb @@ -10,15 +10,18 @@ - - - + diff --git a/app/views/admin/api_users/show.html.erb b/app/views/admin/api_users/show.html.erb index 05c5651ce..a85957fef 100644 --- a/app/views/admin/api_users/show.html.erb +++ b/app/views/admin/api_users/show.html.erb @@ -6,12 +6,12 @@ + <% end %> @@ -152,4 +153,4 @@ $('#user-form-edit').on("show.bs.modal", function(e) { $(this).find('.modal-body').load(e.relatedTarget.dataset.url); }); - \ No newline at end of file + diff --git a/app/views/admin/base/_menu.haml b/app/views/admin/base/_menu.haml index 92efc2347..f1e855742 100644 --- a/app/views/admin/base/_menu.haml +++ b/app/views/admin/base/_menu.haml @@ -39,7 +39,9 @@ %li= link_to t('.bounced_email_addresses'), admin_bounced_mail_addresses_path %li= link_to t('.epp_log'), admin_epp_logs_path(created_after: 'today') %li= link_to t('.repp_log'), admin_repp_logs_path(created_after: 'today') - %li= link_to t('.que'), '/admin/que' + %li.divider + %li.dropdown-header= t('.tasks') + %li= link_to t('.sidekiq'), admin_sidekiq_web_path %ul.nav.navbar-nav.navbar-right %li= link_to t('.sign_out'), destroy_admin_user_session_path, method: :delete, diff --git a/app/views/admin/domains/show.html.erb b/app/views/admin/domains/show.html.erb index 2b2835429..3055dbca5 100644 --- a/app/views/admin/domains/show.html.erb +++ b/app/views/admin/domains/show.html.erb @@ -6,11 +6,12 @@ + + @@ -58,6 +62,17 @@ <%= content_tag(:span, x[:billing_email]) %> <% end %> + <% end %> diff --git a/app/views/admin/registrars/show/_api_users.html.erb b/app/views/admin/registrars/show/_api_users.html.erb index 2d10b1c56..fddccd9b7 100644 --- a/app/views/admin/registrars/show/_api_users.html.erb +++ b/app/views/admin/registrars/show/_api_users.html.erb @@ -8,6 +8,7 @@ + @@ -16,6 +17,18 @@ + <% end %> diff --git a/app/views/domain/pdf.haml b/app/views/domain/pdf.haml new file mode 100644 index 000000000..517192bef --- /dev/null +++ b/app/views/domain/pdf.haml @@ -0,0 +1,241 @@ +%html{lang: 'et'} + %head + %meta{charset: "utf-8"} + :css + .container { + margin: auto; + font-size: 12px; + } + + .col-md-12 { + + } + + .col-xs-4 { + width: 33%; + } + + .left { + float: left; + } + + .left { + padding-right: 5px; + } + + .right { + float: right; + } + + dt { + float: left; + width: 100px; + clear: left; + text-align: right; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-weight: bold; + line-height: 1.42857; + } + + dd { + margin-left: 120px; + line-height: 1.42857; + } + + table { + width: 100%; + border-collapse: collapse; + font-size: 12px; + } + + th { + text-align: left; + border: 0px; + border-top: 1px solid #DDD; + padding: 6px; + } + + thead th { + border-bottom: 2px solid #DDD; + border-top: 0px; + } + + td { + border-top: 1px solid #DDD; + } + + td { + padding: 6px; + } + + hr { + height: 1px; + border: 0; + color: #DDD; + background-color: #DDD; + } + + .clear { + clear: both; + } + + .pull-down { + margin-top: 30px; + } + + #header { + position: relative; + min-height: 100px; + } + + img { + width: 106px; + height: 102px; + } + + #header-content { + position: absolute; + bottom: 0; + } + + h1 { + margin-bottom: 5px; + } + + #footer { + position: absolute; + bottom: 0px; + width: 99%; + } + + .blue { + color: #0098da; + } + + %body + .container + #header.row + .col-sm-6.left + #header-content + %h1= "#{@domain.name} (#{Time.zone.now.to_date.strftime("%d/%m/%Y")})" + .col-sm-6.right + %img{src: "#{Rails.root}/public/eis-logo-black-et.png"} + .clear + %hr + .row + .col-sm-8.left + %h3 Üldine + %hr + %dl.dl-horizontal + %dt Nimi + %dd= @domain.name + %dt Registreeritud + %dd= @domain.registered_at.to_date.strftime("%d/%m/%Y") + %dt Aegub + %dd= @domain.valid_to.to_date.strftime("%d/%m/%Y") + %dt Registripidaja + %dd= "#{@domain.registrar} #{@domain.registrar.website}" + + .col-sm-4.right + %h3 Registreerija + %hr + %dl.dl-horizontal + %dt.left_25 Nimi + %dd.left_25= @domain.registrant + + %dt.left_25 Isikukood + %dd.left_25= @domain.registrant.ident_human_description + + %dt.left_25 E-mail + %dd.left_25= @domain.registrant.email + + %dt.left_25 Telefon + %dd.left_25= @domain.registrant.phone + + .clear + .row.pull-down + .col-md-12 + %h3 Halduskontaktid + %hr + .table-responsive + %table.table.table-hover.table-condensed + %thead + %tr + %th{class: 'col-xs-3'} Nimi + %th{class: 'col-xs-3'} Isikukood + %th{class: 'col-xs-3'} E-mail + %th{class: 'col-xs-3'} Telefon + %tbody + - @domain.admin_contacts.each do |ac| + %tr + %td= ac.name + %td= ac.ident_human_description + %td= ac.email + %td= ac.phone + + .clear + .row.pull-down + .col-md-12 + %h3 Tehnilised kontaktid + %hr + .table-responsive + %table.table.table-hover.table-condensed + %thead + %tr + %th{class: 'col-xs-3'} Nimi + %th{class: 'col-xs-3'} Isikukood + %th{class: 'col-xs-3'} E-mail + %th{class: 'col-xs-3'} Telefon + %tbody + - @domain.tech_contacts.each do |tc| + %tr + %td= tc.name + %td= tc.ident_human_description + %td= tc.email + %td= tc.phone + + .clear + .row.pull-down + .col-md-12 + %h3 Nimeserverid + %hr + .table-responsive + %table.table.table-hover.table-condensed + %thead + %tr + %th{class: 'col-xs-4'} Hostinimi + %th{class: 'col-xs-4'}= t(:ipv4) + %th{class: 'col-xs-4'}= t(:ipv6) + %tbody + - @domain.nameservers.each do |x| + %tr + %td= x + %td= x.ipv4 + %td= x.ipv6 + .clear + .row.pull-down + .col-md-12 + %h3= t(:dnskeys) + %hr + .table-responsive + %table.table.table-hover.table-condensed + %thead + %tr + %th{class: 'col-xs-1'} Lipp + %th{class: 'col-xs-1'} Protokolli + %th{class: 'col-xs-1'} Algoritm + %th{class: 'col-xs-9'} Avalik võti + %tbody + - @domain.dnskeys.each do |x| + %tr + %td= x.flags + %td= x.protocol + %td= x.alg + %td= x.public_key + #footer + %hr + %p{class: 'blue'} Eesti Interneti SA + %p Paldiski mnt 80, 10617 Tallinn, Estonia T +372 727 1000 E info@internet.ee www.internet.ee + %p Reg. nr 90010019 KMKR EE101286464 diff --git a/app/views/mailers/invoice_mailer/invoice_email.html.erb b/app/views/mailers/invoice_mailer/invoice_email.html.erb index 35f0dbb6e..bab04883f 100644 --- a/app/views/mailers/invoice_mailer/invoice_email.html.erb +++ b/app/views/mailers/invoice_mailer/invoice_email.html.erb @@ -1,4 +1,5 @@ -<%= t(:you_have_a_new_invoice) %> +<%= t(:you_have_a_new_invoice) %>
+<%= t(:monthly_invoice) if @invoice.monthly_invoice %>

<%= t(:sincerely) %>,
<%= Setting.registry_invoice_contact %>
diff --git a/app/views/mailers/invoice_mailer/invoice_email.text.erb b/app/views/mailers/invoice_mailer/invoice_email.text.erb index ab8595474..4c17a410f 100644 --- a/app/views/mailers/invoice_mailer/invoice_email.text.erb +++ b/app/views/mailers/invoice_mailer/invoice_email.text.erb @@ -1,4 +1,5 @@ <%= t(:you_have_a_new_invoice) %> +<%= t(:monthly_invoice) if @invoice.monthly_invoice %> <%= t(:sincerely) %>, <%= Setting.registry_invoice_contact %> diff --git a/config.ru b/config.ru index ec46ca9f1..3ab73beb9 100644 --- a/config.ru +++ b/config.ru @@ -2,12 +2,3 @@ require_relative 'config/environment' run Rails.application - -# turn automatic que temp off -# if defined?(PhusionPassenger) - # PhusionPassenger.on_event(:starting_worker_process) do |forked| - # if forked - # Que.mode = :async - # end - # end -# end diff --git a/config/application.yml.sample b/config/application.yml.sample index b25b09fa8..acc5ab6b4 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -242,4 +242,3 @@ billing_system_integrated: 'true' secret_access_word: 'please-Give-Me-accesS' secret_word: 'this-secret-should-be-change' allow_accr_endspoints: 'true' - diff --git a/config/daemons.yml b/config/daemons.yml deleted file mode 100644 index e5c5f1b0d..000000000 --- a/config/daemons.yml +++ /dev/null @@ -1,9 +0,0 @@ -dir_mode: script -dir: ../../log/que -multiple: true -backtrace: true -monitor: true -ontop: false -app_name: 'que' -user: <%= ENV['QUE_USER'] || 'registry' %> -group: <%= ENV['QUE_GROUP'] || ENV['QUE_USER'] || 'registry' %> diff --git a/config/deploy.rb.sample b/config/deploy.rb.sample index a6f0d179b..501db013f 100644 --- a/config/deploy.rb.sample +++ b/config/deploy.rb.sample @@ -15,7 +15,6 @@ set :deploy_to, '$HOME/registry' set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' -set :que_restart, true set :cron_group, 'registry' # alpha branch, only use for heavy debugging @@ -25,7 +24,6 @@ task :epp do set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' - set :que_restart, false end # alpha branch, only use for heavy debugging @@ -35,7 +33,6 @@ task :registrar do set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' - set :que_restart, false set :cron_group, 'registrar' end @@ -46,7 +43,6 @@ task :registrant do set :repository, 'https://github.com/domify/registry' # dev repo set :branch, 'master' set :rails_env, 'alpha' - set :que_restart, false set :cron_group, 'registrant' end @@ -57,7 +53,6 @@ task :st do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'staging' set :rails_env, 'staging' - set :que_restart, true end # staging @@ -67,7 +62,6 @@ task :eppst do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'staging' set :rails_env, 'staging' - set :que_restart, false set :cron_group, 'epp' end @@ -78,7 +72,6 @@ task :registrarst do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'staging' set :rails_env, 'staging' - set :que_restart, false set :cron_group, 'registrar' end @@ -89,7 +82,6 @@ task :registrantst do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'staging' set :rails_env, 'staging' - set :que_restart, false set :cron_group, 'registrant' end @@ -100,7 +92,6 @@ task :pr do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'master' set :rails_env, 'production' - set :que_restart, true end # production @@ -110,7 +101,6 @@ task :epppr do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'master' set :rails_env, 'production' - set :que_restart, false set :cron_group, 'epp' end @@ -121,7 +111,6 @@ task :registrarpr do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'master' set :rails_env, 'production' - set :que_restart, false set :cron_group, 'registrar' end @@ -132,7 +121,6 @@ task :registrantpr do set :repository, 'https://github.com/internetee/registry' # production repo set :branch, 'master' set :rails_env, 'production' - set :que_restart, false set :cron_group, 'registrant' end @@ -193,9 +181,6 @@ task setup: :environment do queue! %(mkdir -p "#{deploy_to}/shared/import/legal_documents") queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/import/legal_documents") - queue! %(mkdir -p "#{deploy_to}/shared/log/que") - queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/log/que") - queue! %(touch "#{deploy_to}/shared/config/database.yml") deploy do invoke :'git:clone' @@ -217,8 +202,6 @@ task deploy: :environment do invoke :load_commit_hash # TEMP until all servers are updated - queue! %(mkdir -p "#{deploy_to}/shared/log/que") - queue! %(chmod g+rx,u+rwx "#{deploy_to}/shared/log/que") invoke :'deploy:link_shared_paths' invoke :'bundle:install' @@ -233,7 +216,7 @@ task deploy: :environment do end end -# data_migrate=some_data_migration mina deploy env +# data_migrate=some_data_migration mina deploy env desc 'Run data migrations if any set with ENV[data_migrate]' task data_migration: :environment do if ENV['data_migrate'] @@ -258,11 +241,6 @@ task restart: :environment do queue "mkdir -p #{deploy_to}/current/tmp; touch #{deploy_to}/current/tmp/restart.txt" end -desc 'Restart que server' -task que_restart: :environment do - queue "/etc/init.d/que restart" -end - namespace :cron do desc 'Setup cron tasks.' task setup: :environment do diff --git a/config/initializers/que.rb b/config/initializers/que.rb deleted file mode 100644 index 560b1ec1e..000000000 --- a/config/initializers/que.rb +++ /dev/null @@ -1,7 +0,0 @@ -Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| - case value - when Time then value - when String then Time.parse(value) - else raise "Unexpected time class: #{value.class} (#{value.inspect})" - end -end diff --git a/config/locales/admin/api_users.en.yml b/config/locales/admin/api_users.en.yml index 9fde2db14..c09df2ab7 100644 --- a/config/locales/admin/api_users.en.yml +++ b/config/locales/admin/api_users.en.yml @@ -3,6 +3,8 @@ en: api_users: index: header: API users + set_test_btn: Set Test + remove_test_btn: Remove Test new: header: New API user diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index ce59294dd..35e209011 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -6,6 +6,7 @@ en: registrant: Registrant show: + download_btn: Download PDF edit_btn: Edit statuses history_btn: History diff --git a/config/locales/admin/menu.en.yml b/config/locales/admin/menu.en.yml index 8fd8bdc07..1f7f67fe7 100644 --- a/config/locales/admin/menu.en.yml +++ b/config/locales/admin/menu.en.yml @@ -19,4 +19,5 @@ en: mass_actions: Mass actions epp_log: EPP log repp_log: REPP log - que: Que + sidekiq: Sidekiq + tasks: Tasks diff --git a/config/locales/admin/registrars.en.yml b/config/locales/admin/registrars.en.yml index 2f281a3b7..94225dc49 100644 --- a/config/locales/admin/registrars.en.yml +++ b/config/locales/admin/registrars.en.yml @@ -4,6 +4,8 @@ en: index: header: Registrars new_btn: New registrar + set_test_btn: Set Test + remove_test_btn: Remove Test new: header: New registrar @@ -28,6 +30,8 @@ en: api_users: header: API Users new_btn: New API user + set_test_btn: Set Test + remove_test_btn: Remove Test white_ips: header: Whitelisted IPs diff --git a/config/locales/en.yml b/config/locales/en.yml index f15a8a55d..ae5177470 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -440,6 +440,7 @@ en: exDate: 'Valid to' dequeue: 'Dequeue' are_you_sure_you_want_to_delete_domain: 'Are you sure you want to delete domain %{domain}?' + are_you_sure_you_want_to_delete_auction: 'Warning: Are you sure you want to delete this record? Be advised that doing so will remove the record only from registry database and will make the domain available for anyone to register. This will not affect auction system if the auction record is already created there. You will need to delete the record in auction system first to remove the domain from auction.' upload_key: 'Upload key' legal_document: 'Legal document' legal_document_max_size: '(max. 8MB)' @@ -543,6 +544,7 @@ en: bind_manually: 'Bind manually' client: 'Client' you_have_a_new_invoice: 'You have a new invoice.' + monthly_invoice: "Here comes the report with the last month's credit account activities." sincerely: 'Sincerely' expiry: 'Expiry' failed_to_create_crt_csr_already_signed: 'Failed to create certificate: CSR is already signed' @@ -635,6 +637,8 @@ en: registrant_ident: 'Registrant ident' contact_ident: 'Contact ident' results_per_page: 'Results per page' + set_test_btn: Set Test + remove_test_btn: Remove Test nameserver_hostname: 'Nameserver hostname' result_count: zero: 'No results' diff --git a/config/locales/et.yml b/config/locales/et.yml index 6da5860ff..b381259a7 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -14,3 +14,6 @@ et: already_paid: " (juba makstud)" monthly_invoice: " (kuuaruanne)" monthly_invoice_description: 'Kuuaruanne' + you_have_a_new_invoice: 'Teil on uus arve.' + monthly_invoice: "Siit tuleb aruanne möödunud kuul ettemaksukontoga seotud tasuliste toimingutega." + sincerely: 'Lugupidamisega' diff --git a/config/routes.rb b/config/routes.rb index 7ef8474f0..26b57b42b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -176,10 +176,13 @@ Rails.application.routes.draw do namespace :accreditation_center do # At the moment invoice_status endpoint returns only cancelled invoices. But in future logic of this enpoint can change. # And it will need to return invoices of different statuses. I decided to leave the name of the endpoint "invoice_status" - resources :invoice_status, only: [:index] - resource :domains, only: [:show], param: :name - resource :contacts, only: [:show], param: :id + resources :invoice_status, only: [ :index ] + resource :domains, only: [ :show ], param: :name + resource :contacts, only: [ :show ], param: :id + resource :results, only: [ :show ], param: :name # resource :auth, only: [ :index ] + get 'show_api_user', to: 'results#show_api_user' + get 'list_accreditated_api_users', to: 'results#list_accreditated_api_users' get 'auth', to: 'auth#index' end @@ -303,7 +306,7 @@ Rails.application.routes.draw do resources :accounts resources :account_activities - resources :auctions, only: [ :index, :create ] do + resources :auctions, only: %i[index create destroy] do collection do post 'upload_spreadsheet', to: 'auctions#upload_spreadsheet', as: :upload_spreadsheet end @@ -340,6 +343,7 @@ Rails.application.routes.draw do resource :registry_lock, controller: 'domains/registry_lock', only: :destroy member do + get :download patch :keep end end @@ -393,6 +397,13 @@ Rails.application.routes.draw do resources :registrars do resources :api_users, except: %i[index] resources :white_ips + + collection do + post 'set_test_date', to: 'registrars#set_test_date', as: 'set_test_date' + post 'remove_test_date', to: 'registrars#remove_test_date', as: 'remove_test_date' + post 'set_test_date_to_api_user', to: 'api_users#set_test_date_to_api_user', as: 'set_test_date_to_api_user' + post 'remove_test_date_to_api_user', to: 'api_users#remove_test_date_to_api_user', as: 'remove_test_date_to_api_user' + end end resources :contacts do @@ -421,7 +432,6 @@ Rails.application.routes.draw do resources :bounced_mail_addresses, only: %i[index show destroy] authenticate :admin_user do - mount Que::Web, at: 'que' mount Sidekiq::Web, at: 'sidekiq' end end diff --git a/db/migrate/20150611124920_add_que.rb b/db/migrate/20150611124920_add_que.rb index 8e76e456c..3f5aa8284 100644 --- a/db/migrate/20150611124920_add_que.rb +++ b/db/migrate/20150611124920_add_que.rb @@ -1,11 +1,11 @@ class AddQue < ActiveRecord::Migration[6.0] def self.up # The current version as of this migration's creation. - Que.migrate! :version => 3 + # Que.migrate! :version => 3 end def self.down # Completely removes Que's job queue. - Que.migrate! :version => 0 + # Que.migrate! :version => 0 end end diff --git a/db/migrate/20220406085500_remove_que_jobs.rb b/db/migrate/20220406085500_remove_que_jobs.rb new file mode 100644 index 000000000..2d0d2bfa7 --- /dev/null +++ b/db/migrate/20220406085500_remove_que_jobs.rb @@ -0,0 +1,5 @@ +class RemoveQueJobs < ActiveRecord::Migration[6.1] + def change + # drop_table :que_jobs + end +end diff --git a/db/migrate/20220701113409_change_notification_text_type_to_text.rb b/db/migrate/20220701113409_change_notification_text_type_to_text.rb new file mode 100644 index 000000000..79c4b5027 --- /dev/null +++ b/db/migrate/20220701113409_change_notification_text_type_to_text.rb @@ -0,0 +1,5 @@ +class ChangeNotificationTextTypeToText < ActiveRecord::Migration[6.1] + def change + change_column :notifications, :text, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index 03fca59a8..ace0f0198 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2216,7 +2216,7 @@ ALTER SEQUENCE public.nameservers_id_seq OWNED BY public.nameservers.id; CREATE TABLE public.notifications ( id integer NOT NULL, registrar_id integer NOT NULL, - text character varying NOT NULL, + text text NOT NULL, attached_obj_type character varying, attached_obj_id integer, read boolean NOT NULL, @@ -5415,6 +5415,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220413084748'), ('20220504090512'), ('20220524130709'), +('20220701113409'), ('20220818075833'); diff --git a/doc/epp/README.md b/doc/epp/README.md index 23a581635..ec4016ab2 100644 --- a/doc/epp/README.md +++ b/doc/epp/README.md @@ -14,7 +14,7 @@ - [RFC5734 - Transport over TCP](http://tools.ietf.org/html/rfc5734) - [RFC5910 - DNSSEC Mapping](http://tools.ietf.org/html/rfc5910) - [RFC3735 - Guidelines for Extending the EPP](http://tools.ietf.org/html/rfc3735) -- [Change Poll Draft v0.8](https://tools.ietf.org/html/draft-ietf-regext-change-poll-08) +- [RFC8590 - Change Poll](https://www.rfc-editor.org/rfc/rfc8590) ## XML schemas @@ -28,12 +28,10 @@ * [changePoll-1.0.xsd](/lib/schemas/changePoll-1.0.xsd) ### .ee-specific -* [all-ee-1.0.xsd](/lib/schemas/all-ee-1.0.xsd) -* [all-ee-1.1.xsd](/lib/schemas/all-ee-1.1.xsd) +* [all-ee-1.3.xsd](/lib/schemas/all-ee-1.3.xsd) * [eis-1.0.xsd](/lib/schemas/eis-1.0.xsd) * [epp-ee-1.0.xsd](/lib/schemas/epp-ee-1.0.xsd) -* [domain-eis-1.0.xsd](/lib/schemas/domain-eis-1.0.xsd) -* [contact-eis-1.0.xsd](/lib/schemas/contact-eis-1.0.xsd) +* [domain-ee-1.2.xsd](/lib/schemas/domain-ee-1.2.xsd) * [contact-ee-1.1.xsd](/lib/schemas/contact-ee-1.1.xsd) More info about The Extensible Provisioning Protocol (EPP): diff --git a/doc/que/README.md b/doc/que/README.md deleted file mode 100644 index 1fd0ef664..000000000 --- a/doc/que/README.md +++ /dev/null @@ -1,52 +0,0 @@ -Registry que server -=================== - -Que server responsibilites: - -* handle write type of communication between Registrant and Registry -* handle future jobs for Registry -* handle heavy load jobs for Registry - -Installation ------------- - -Que can deploy either separaetly or along to Registry server depends on real load situation. -In both serarious que requires working Registry deployment and full access to Registry databases. - -Installation at deployed server: - - cd /home/registry/registry/current - sudo cp doc/que/que_init_sample /etc/init.d/que # and edit it - sudo chmod +x /etc/init.d/que - sudo /etc/init.d/que # for help and other commands - sudo /etc/init.d/que start # for manual start - sudo update-rc.d que defaults # for start in server boot - -PID files ---------- - -All pid files are at log/que directory. - -Debugging ---------- - -You can run que manually as well for debugging: - - cd /home/registry/registry/current - -For all manual que tasks: - - RAILS_ENV=production bundle exec rake -T que # for all que tasks for manual control - rake que:clear # Clear Que's job table - rake que:drop # Drop Que's job table - rake que:migrate # Migrate Que's job table to the most recent version (creating it if it doesn't exist) - rake que:work # Process Que's jobs using a worker pool - -For all que daemon tasks what inist script uses - - RAILS_ENV=production bundle exec rake -T daemon # for all que daemon tasks what init script uses - rake daemon:que # Start que script - rake daemon:que:restart # Restart que daemon - rake daemon:que:start # Start que daemon - rake daemon:que:status # Status que daemon - rake daemon:que:stop # Stop que daemon diff --git a/doc/que/que_init_sample b/doc/que/que_init_sample deleted file mode 100644 index 28e27e957..000000000 --- a/doc/que/que_init_sample +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: Registry que server -# Required-Start: $all -# Required-Stop: $network $local_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Enable Registry que server -### END INIT INFO - -set -u -set -e - -### CHANGES -APP_HOME="/home/registry/registry" -APP_ROOT="$APP_HOME/current" -QUE_USER=registry # or use some other unprivileged OS user what your registry servers uses -RAILS_ENV=production -RUBY_BUNDLE=/home/$QUE_USER/.rbenv/shims/bundle -QUE_INSTANCES=1 # or as many really needed based on real load info -### END OF CHANGES - -cd $APP_ROOT || exit 1 - -case ${1-help} in -status) - cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE exec lib/daemons/que_ctl status - ;; -start) - echo "$1 que monitor and server" - for i in `seq 1 $QUE_INSTANCES`; do - cd $APP_ROOT && QUE_WORKER_COUNT=1 RAILS_ENV=$RAILS_ENV QUE_USER=$QUE_USER $RUBY_BUNDLE exec rake daemon:que:start - echo 'que instance started' - done - ;; -stop) - echo "$1 que monitor and server" - cd $APP_ROOT && RAILS_ENV=$RAILS_ENV $RUBY_BUNDLE exec lib/daemons/que_ctl stop - ;; -restart) - echo "$1 que monitor and server" - cd $APP_ROOT && RAILS_ENV=$RAILS_ENV QUE_USER=$QUE_USER $RUBY_BUNDLE exec rake daemon:que:restart - ;; -*) - echo >&2 "Usage: $0 " - exit 1 - ;; -esac diff --git a/lib/daemons/daemons b/lib/daemons/daemons deleted file mode 100755 index 42722e47c..000000000 --- a/lib/daemons/daemons +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -results = [] -Dir[File.dirname(__FILE__) + "/*_ctl"].each { |f| results << `ruby #{f} #{ARGV.first}` } -results.delete_if { |result| result.nil? || result.empty? } -puts results.join unless results.empty? diff --git a/lib/daemons/que.rb b/lib/daemons/que.rb deleted file mode 100755 index e246212ba..000000000 --- a/lib/daemons/que.rb +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env ruby - -ENV["RAILS_ENV"] ||= "production" - -root = File.expand_path(File.dirname(__FILE__)) -root = File.dirname(root) until File.exist?(File.join(root, 'config')) -Dir.chdir(root) - -require File.join(root, "config", "environment") - -# from que gem rake task -if defined?(::Rails) && Rails.respond_to?(:application) - # ActiveSupport's dependency autoloading isn't threadsafe, and Que uses - # multiple threads, which means that eager loading is necessary. Rails - # explicitly prevents eager loading when the environment task is invoked, - # so we need to manually eager load the app here. - Rails.application.eager_load! -end - -Que.logger.level = Logger.const_get((ENV['QUE_LOG_LEVEL'] || 'INFO').upcase) -Que.worker_count = 1 -Que.wake_interval = (ENV['QUE_WAKE_INTERVAL'] || 1).to_f -Que.mode = :async - -# When changing how signals are caught, be sure to test the behavior with -# the rake task in tasks/safe_shutdown.rb. - -stop = false -%w( INT ).each do |signal| - trap(signal) { stop = true } -end - -at_exit do - $stdout.puts "Finishing Que's current jobs before exiting..." - Que.worker_count = 0 - Que.mode = :off - $stdout.puts "Que's jobs finished, exiting..." -end - -loop do - sleep 1 - break if stop -end diff --git a/lib/daemons/que_ctl b/lib/daemons/que_ctl deleted file mode 100755 index 9a3da9cd1..000000000 --- a/lib/daemons/que_ctl +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -require 'rubygems' -require 'daemons/rails/config' -config = Daemons::Rails::Config.for_controller(File.expand_path(__FILE__)) -Daemons::Rails.run config[:script], config.to_hash diff --git a/lib/tasks/migrate_jobs.rake b/lib/tasks/migrate_jobs.rake deleted file mode 100644 index a5a4b5bcf..000000000 --- a/lib/tasks/migrate_jobs.rake +++ /dev/null @@ -1,31 +0,0 @@ -namespace :migrate_jobs do - task all: :environment do - QueJob.all.each do |job| - process_que_job(job) - end - end - - task first: :environment do - job = QueJob.first - process_que_job(job) - end - - def process_que_job(que_job) - return unless que_job - - if skip_condition(que_job) - puts "Skipped Que job migration: #{que_job.inspect}" - else - args = que_job.args - time = que_job.run_at - time = Time.zone.now + 1.minute if time < Time.zone.now - - que_job.job_class.constantize.set(wait_until: time).perform_later(*args) - end - end - - def skip_condition(que_job) - que_job.last_error.present? || !(que_job.job_class.constantize < ApplicationJob) || - !(que_job.job_class == 'DomainExpireEmailJob') - end -end diff --git a/test/integration/admin_area/api_users_test.rb b/test/integration/admin_area/api_users_test.rb new file mode 100644 index 000000000..3e0af7bad --- /dev/null +++ b/test/integration/admin_area/api_users_test.rb @@ -0,0 +1,41 @@ +require 'test_helper' + +class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest + include Devise::Test::IntegrationHelpers + + setup do + ENV['registry_demo_registrar_api_user_url'] = 'http://registry.test:3000/api/v1/accreditation_center/show_api_user' + ENV['registry_demo_registrar_port'] = '3000' + @api_user = users(:api_bestnames) + sign_in users(:admin) + end + + def test_set_test_date_to_api_user + # ENV['registry_demo_registrar_api_user_url'] = 'http://testapi.test' + + date = Time.zone.now - 10.minutes + + api_user = @api_user.dup + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + assert_nil @api_user.accreditation_date + assert_equal api_user.accreditation_date, date + + # api_v1_accreditation_center_show_api_user_url + stub_request(:get, "http://registry.test:3000/api/v1/accreditation_center/show_api_user?username=#{@api_user.username}&identity_code=#{@api_user.identity_code}") + .with( + headers: { + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' + } + ) + .to_return(status: 200, body: { code: 200, user_api: api_user }.to_json, headers: {}) + post set_test_date_to_api_user_admin_registrars_path, params: { user_api_id: @api_user.id }, headers: { 'HTTP_REFERER' => root_path } + @api_user.reload + assert_equal @api_user.accreditation_date.to_date, api_user.accreditation_date.to_date + assert_equal @api_user.accreditation_expire_date.to_date, api_user.accreditation_expire_date.to_date + end +end diff --git a/test/integration/admin_area/auction_test.rb b/test/integration/admin_area/auction_test.rb index c51465ab2..54bd64456 100644 --- a/test/integration/admin_area/auction_test.rb +++ b/test/integration/admin_area/auction_test.rb @@ -170,4 +170,15 @@ class AdminAreaAuctionIntegrationTest < ApplicationSystemTestCase find(:id, "reserved-modal", match: :first).click assert_text 'Reserved domains' end + + def test_delete_auction + visit admin_auctions_path + domain = Auction.first + + find(:id, "delete-auction-#{domain.id}", match: :first).click + + assert_raises ActiveRecord::RecordNotFound do + domain.reload + end + end end diff --git a/test/integration/admin_area/domain_show_test.rb b/test/integration/admin_area/domain_show_test.rb new file mode 100644 index 000000000..0e016bf45 --- /dev/null +++ b/test/integration/admin_area/domain_show_test.rb @@ -0,0 +1,18 @@ +require 'test_helper' + +class DomainShowTest < ApplicationIntegrationTest + setup do + @domain = domains(:shop) + sign_in users(:admin) + end + + def test_downloads_domain + filename = "#{@domain.name}.pdf" + get download_admin_domain_path(@domain) + + assert_response :ok + assert_equal 'application/pdf', response.headers['Content-Type'] + assert_equal "attachment; filename=\"#{filename}\"; filename*=UTF-8''#{filename}", response.headers['Content-Disposition'] + assert_not_empty response.body + end +end diff --git a/test/integration/admin_area/registrars_test.rb b/test/integration/admin_area/registrars_test.rb index 552650791..c0753ebba 100644 --- a/test/integration/admin_area/registrars_test.rb +++ b/test/integration/admin_area/registrars_test.rb @@ -4,6 +4,8 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers setup do + ENV['registry_demo_registrar_results_url'] = 'http://registry.test:3000/api/v1/accreditation_center/results' + ENV['registry_demo_registrar_port'] = '3000' @registrar = registrars(:bestnames) sign_in users(:admin) end @@ -17,4 +19,29 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest assert_equal new_iban, @registrar.iban end + + def test_set_test_date + api_user = @registrar.api_users.first.dup + api_user.accreditation_date = Time.zone.now - 10.minutes + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + assert_nil @registrar.api_users.first.accreditation_date + + stub_request(:get, "http://registry.test:3000/api/v1/accreditation_center/results?registrar_name=#{@registrar.name}") + .with( + headers: { + 'Accept' => '*/*', + 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent' => 'Ruby' + } + ) + .to_return(status: 200, body: { code: 200, registrar_users: [api_user] }.to_json, headers: {}) + + post set_test_date_admin_registrars_path, params: { registrar_id: @registrar.id }, headers: { 'HTTP_REFERER' => root_path } + @registrar.reload + + assert_equal @registrar.api_users.first.accreditation_date.to_date, api_user.accreditation_date.to_date + assert_equal @registrar.api_users.first.accreditation_expire_date.to_date, api_user.accreditation_expire_date.to_date + end end diff --git a/test/integration/api/v1/auctions/update_test.rb b/test/integration/api/v1/auctions/update_test.rb index 4e48c0ca5..099c8d529 100644 --- a/test/integration/api/v1/auctions/update_test.rb +++ b/test/integration/api/v1/auctions/update_test.rb @@ -28,7 +28,7 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', 'domain' => 'auction.test', 'status' => Auction.statuses[:awaiting_payment], - 'platform' => nil }), ActiveSupport::JSON.decode(response.body) + 'platform' => "auto" }), ActiveSupport::JSON.decode(response.body) end def test_marks_as_awaiting_payment diff --git a/test/integration/repp/v1/registrar/accreditaion_info_test.rb b/test/integration/repp/v1/registrar/accreditaion_info_test.rb index 4efba5d38..fdb0d8fb0 100644 --- a/test/integration/repp/v1/registrar/accreditaion_info_test.rb +++ b/test/integration/repp/v1/registrar/accreditaion_info_test.rb @@ -1,35 +1,37 @@ require 'test_helper' class ReppV1AccreditationInfoTest < ActionDispatch::IntegrationTest - def setup - @user = users(:api_bestnames) - token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}") - token = "Basic #{token}" + if Feature.allow_accr_endspoints? + def setup + @user = users(:api_bestnames) + token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}") + token = "Basic #{token}" - @auth_headers = { 'Authorization' => token } - end + @auth_headers = { 'Authorization' => token } + end - def test_valid_login - get '/repp/v1/registrar/accreditation/get_info', headers: @auth_headers - json = JSON.parse(response.body, symbolize_names: true) + def test_valid_login + get '/repp/v1/registrar/accreditation/get_info', headers: @auth_headers + json = JSON.parse(response.body, symbolize_names: true) - assert_response :ok - assert_equal json[:data][:username], @user.username - assert json[:data][:roles].include? 'super' - assert_equal json[:data][:registrar_name], 'Best Names' - assert_equal json[:data][:registrar_reg_no], '1234' - end + assert_response :ok + assert_equal json[:data][:username], @user.username + assert json[:data][:roles].include? 'super' + assert_equal json[:data][:registrar_name], 'Best Names' + assert_equal json[:data][:registrar_reg_no], '1234' + end - def test_invalid_login - token = Base64.encode64("#{@user.username}:0066600") - token = "Basic #{token}" + def test_invalid_login + token = Base64.encode64("#{@user.username}:0066600") + token = "Basic #{token}" - auth_headers = { 'Authorization' => token } + auth_headers = { 'Authorization' => token } - get '/repp/v1/registrar/accreditation/get_info', headers: auth_headers - json = JSON.parse(response.body, symbolize_names: true) + get '/repp/v1/registrar/accreditation/get_info', headers: auth_headers + json = JSON.parse(response.body, symbolize_names: true) - assert_response :unauthorized - assert_equal json[:message], 'Invalid authorization information' + assert_response :unauthorized + assert_equal json[:message], 'Invalid authorization information' + end end end diff --git a/test/integration/repp/v1/registrar/accreditation_results_test.rb b/test/integration/repp/v1/registrar/accreditation_results_test.rb index 92c5df37c..cfb12390e 100644 --- a/test/integration/repp/v1/registrar/accreditation_results_test.rb +++ b/test/integration/repp/v1/registrar/accreditation_results_test.rb @@ -1,52 +1,54 @@ require 'test_helper' class ReppV1AccreditationResultsTest < ActionDispatch::IntegrationTest - TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze + if Feature.allow_accr_endspoints? + TEMPORARY_SECRET_KEY = ENV['accreditation_secret'].freeze - def setup - @user = users(:api_bestnames) + def setup + @user = users(:api_bestnames) - token = "Basic #{TEMPORARY_SECRET_KEY}" + token = "Basic #{TEMPORARY_SECRET_KEY}" - @auth_headers = { 'Authorization' => token } - end + @auth_headers = { 'Authorization' => token } + end - def test_should_return_valid_response - post '/repp/v1/registrar/accreditation/push_results', - headers: @auth_headers, - params: {accreditation_result: {username: @user.username, result: true} } - json = JSON.parse(response.body, symbolize_names: true) + def test_should_return_valid_response + post '/repp/v1/registrar/accreditation/push_results', + headers: @auth_headers, + params: {accreditation_result: {username: @user.username, result: true} } + json = JSON.parse(response.body, symbolize_names: true) - assert_response :ok - assert_emails 2 - assert_equal json[:data][:user][:username], @user.username - assert_equal json[:data][:result], "true" - assert_equal json[:data][:message], "Accreditation info successfully added" - end + assert_response :ok + assert_emails 2 + assert_equal json[:data][:user][:username], @user.username + assert_equal json[:data][:result], "true" + assert_equal json[:data][:message], "Accreditation info successfully added" + end - def test_should_return_valid_response_invalid_authorization - post '/repp/v1/registrar/accreditation/push_results', - headers: { 'Authorization' => 'Basic temporary-secret-ke'}, - params: {accreditation_result: {username: @user.username, result: true} } - json = JSON.parse(response.body, symbolize_names: true) + def test_should_return_valid_response_invalid_authorization + post '/repp/v1/registrar/accreditation/push_results', + headers: { 'Authorization' => 'Basic temporary-secret-ke'}, + params: {accreditation_result: {username: @user.username, result: true} } + json = JSON.parse(response.body, symbolize_names: true) - assert_response :unauthorized + assert_response :unauthorized - assert_emails 0 - assert_equal json[:code], 2202 - assert_equal json[:message], 'Invalid authorization information' - end + assert_emails 0 + assert_equal json[:code], 2202 + assert_equal json[:message], 'Invalid authorization information' + end - def test_should_return_valid_response_record_exception - post '/repp/v1/registrar/accreditation/push_results', - headers: @auth_headers, - params: {accreditation_result: { username: "chungachanga", result: true} } - json = JSON.parse(response.body, symbolize_names: true) + def test_should_return_valid_response_record_exception + post '/repp/v1/registrar/accreditation/push_results', + headers: @auth_headers, + params: {accreditation_result: { username: "chungachanga", result: true} } + json = JSON.parse(response.body, symbolize_names: true) - assert_response :ok + assert_response :ok - assert_emails 0 - assert_equal json[:code], 2303 - assert_equal json[:message], "Object 'chungachanga' does not exist" + assert_emails 0 + assert_equal json[:code], 2303 + assert_equal json[:message], "Object 'chungachanga' does not exist" + end end end diff --git a/test/interactions/record_date_of_test_test.rb b/test/interactions/record_date_of_test_test.rb new file mode 100644 index 000000000..b8f228f62 --- /dev/null +++ b/test/interactions/record_date_of_test_test.rb @@ -0,0 +1,22 @@ +require 'test_helper' + +class RecordDateOfTestTest < ActiveSupport::TestCase + setup do + @api_bestname = users(:api_bestnames) + @api_bestname.accreditation_date = Time.zone.now - 10.minutes + @api_bestname.accreditation_expire_date = @api_bestname.accreditation_date + 1.year + @api_bestname.save + end + + def test_should_record_data_to_apiuser + api_goodname = users(:api_goodnames) + + assert_nil api_goodname.accreditation_date + assert_nil api_goodname.accreditation_expire_date + + Actions::RecordDateOfTest.record_result_to_api_user(api_user: api_goodname, date: @api_bestname.accreditation_date) + + assert_equal api_goodname.accreditation_date, @api_bestname.accreditation_date + assert_equal api_goodname.accreditation_expire_date, @api_bestname.accreditation_expire_date + end +end diff --git a/test/models/auction_test.rb b/test/models/auction_test.rb index bdac5c79d..5df7166b2 100644 --- a/test/models/auction_test.rb +++ b/test/models/auction_test.rb @@ -131,6 +131,49 @@ class AuctionTest < ActiveSupport::TestCase assert_not @auction.domain_registrable?('') end + def test_restart_new_auction_should_with_previous_manual_platform + @auction.update(platform: 'manual') + @auction.reload + + assert_equal @auction.platform, 'manual' + + assert_difference 'Auction.count' do + @auction.restart + end + + new_auction = Auction.last + assert_equal new_auction.platform, 'manual' + end + + def test_restart_new_auction_should_with_previous_auto_platform + @auction.update(platform: 'auto') + @auction.reload + + assert_equal @auction.platform, 'auto' + + assert_difference 'Auction.count' do + @auction.restart + end + + new_auction = Auction.last + assert_equal new_auction.platform, 'auto' + end + + def test_restart_new_auction_should_with_auto_if_platform_is_nil + @auction.update(platform: nil) + @auction.reload + + assert_nil @auction.platform + + assert_difference 'Auction.count' do + @auction.restart + end + + new_auction = Auction.last + assert_equal new_auction.platform, 'auto' + end + + def test_restarts_an_auction assert_equal 'auction.test', @auction.domain @@ -142,4 +185,30 @@ class AuctionTest < ActiveSupport::TestCase assert_equal 'auction.test', new_auction.domain assert new_auction.started? end + + def test_auction_restart_should_assign_the_previous_manual_platform + assert_equal 'auction.test', @auction.domain + @auction.update(platform: :manual) + @auction.reload + + assert_difference 'Auction.count' do + @auction.restart + end + + auctions = Auction.where(domain: @auction.domain) + assert_equal auctions.first.platform, auctions.last.platform + end + + def test_auction_restart_should_assign_the_previous_auto_platform + assert_equal 'auction.test', @auction.domain + @auction.update(platform: :auto) + @auction.reload + + assert_difference 'Auction.count' do + @auction.restart + end + + auctions = Auction.where(domain: @auction.domain) + assert_equal auctions.first.platform, auctions.last.platform + end end \ No newline at end of file diff --git a/test/models/bank_transaction_test.rb b/test/models/bank_transaction_test.rb index fbf2fdc59..de1f629b0 100644 --- a/test/models/bank_transaction_test.rb +++ b/test/models/bank_transaction_test.rb @@ -37,8 +37,7 @@ class BankTransactionTest < ActiveSupport::TestCase first_transaction = BankTransaction.new(sum: 10, description: 'Order nr 1 from registrar 1234567 second number 2345678') - - first_transaction.create_activity(another_invoice.buyer, another_invoice) + first_transaction.bind_invoice(another_invoice.number) transaction = BankTransaction.new(sum: 10, description: 'Order nr 1 from registrar 1234567 second number 2345678') diff --git a/test/system/admin_area/api_users_test.rb b/test/system/admin_area/api_users_test.rb index d79434ef6..8f7b73155 100644 --- a/test/system/admin_area/api_users_test.rb +++ b/test/system/admin_area/api_users_test.rb @@ -3,6 +3,7 @@ require 'application_system_test_case' class AdminApiUsersSystemTest < ApplicationSystemTestCase setup do sign_in users(:admin) + @registrar = registrars(:bestnames) end def test_shows_api_user_list @@ -11,4 +12,71 @@ class AdminApiUsersSystemTest < ApplicationSystemTestCase api_user = users(:api_bestnames) assert_link api_user.username, href: admin_registrar_api_user_path(api_user.registrar, api_user) end + + def test_should_display_tests_button_in_api_user + visit admin_api_users_path + + assert_button 'Set Test' + assert_no_button 'Remove Test' + end + + def test_should_display_remove_test_if_there_accreditated_apiuser + date = Time.zone.now - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_api_users_path + + assert_button 'Remove Test' + end + + def test_should_not_display_remove_test_if_api_user_accreditation_date_is_expired + date = Time.zone.now - 1.year - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_api_users_path + + assert_no_button 'Remove' + end + + def test_should_display_tests_button_in_api_user_details + api_user = @registrar.api_users.first + + visit admin_api_user_path(api_user) + assert_button 'Set Test' + assert_no_button 'Remove Test' + end + + def test_should_display_remove_test_in_api_user_details_if_there_accreditated_apiuser + date = Time.zone.now - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_api_user_path(api_user) + + assert_button 'Remove Test' + end + + def test_should_not_display_remove_test_if_api_user_accreditation_date_is_expired_in_api_details + date = Time.zone.now - 1.year - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_api_user_path(api_user) + + assert_no_button 'Remove' + end end diff --git a/test/system/admin_area/registrars_test.rb b/test/system/admin_area/registrars_test.rb index f3ee31020..aa61d10e3 100644 --- a/test/system/admin_area/registrars_test.rb +++ b/test/system/admin_area/registrars_test.rb @@ -93,4 +93,70 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase assert_text 'Language English' assert_text 'billing@bestnames.test' end + + def test_should_display_btn_for_set_test_date + visit admin_registrars_path + + assert_button 'Set Test' + assert_no_button 'Remove Test' + end + + def test_should_display_remove_test_if_there_accreditated_registrars + date = Time.zone.now - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_registrars_path + + assert_button 'Remove Test' + end + + def test_should_not_display_remove_test_if_accreditation_date_is_expired + date = Time.zone.now - 1.year - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_registrars_path + + assert_no_button 'Remove' + end + + def test_should_display_tests_button_in_registrar_deftails + visit admin_registrar_path(@registrar) + + assert_button 'Set Test' + assert_no_button 'Remove Test' + end + + def test_should_display_remove_test_if_there_accreditated_registrars_in_registrar_details + date = Time.zone.now - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_registrar_path(@registrar) + + assert_button 'Remove Test' + end + + def test_should_not_display_remove_test_if_accreditation_date_is_expired_in_registrar_details + date = Time.zone.now - 1.year - 10.minutes + + api_user = @registrar.api_users.first + api_user.accreditation_date = date + api_user.accreditation_expire_date = api_user.accreditation_date + 1.year + api_user.save + + visit admin_registrar_path(@registrar) + + assert_no_button 'Remove' + end end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index 98a7d0f39..0cd407f84 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,7 +4,6 @@ if ENV['COVERAGE'] add_filter '/app/models/version/' add_filter '/lib/action_controller/' add_filter '/lib/core_monkey_patches/' - add_filter '/lib/daemons/' add_filter '/lib/gem_monkey_patches/' add_filter '/lib/tasks/' end
+ <%= sort_link(@q, 'username') %> + <%= sort_link(@q, 'registrar_name', Registrar.model_name.human) %> + <%= sort_link(@q, 'active', ApiUser.human_attribute_name(:active)) %> + Test status +
<%= auction.registration_code %> <%= auction.registration_deadline %> <%= auction.platform.nil? ? 'auto' : auction.platform %><%= link_to(t(:delete), admin_auction_path(auction), method: :delete, data: { confirm: t(:are_you_sure_you_want_to_delete_auction) }, class: 'btn btn-danger', id: "delete-auction-#{auction.id}") %>
<%= t(:emails) %> + Test status +
+ <% if !x.accredited? || x.accreditation_expired? %> + <%= button_to t('.set_test_btn'), + { controller: 'registrars', action: 'set_test_date', registrar_id: x.id}, + { method: :post, class: 'btn btn-primary'} %> + <% else %> + <%= button_to t('.remove_test_btn'), + { controller: 'registrars', action: 'remove_test_date', registrar_id: x.id}, + { method: :post, class: 'btn btn-danger'} %> + <% end %> +
<%= ApiUser.human_attribute_name :username %> <%= ApiUser.human_attribute_name :active %>Test Results
<%= link_to api_user, admin_registrar_api_user_path(api_user.registrar, api_user) %> <%= api_user.active %> + + <% if !api_user.accredited? || api_user.accreditation_expired? %> + <%= button_to t('.set_test_btn'), + { controller: 'api_users', action: 'set_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-primary'} %> + <% else %> + <%= button_to t('.remove_test_btn'), + { controller: 'api_users', action: 'remove_test_date_to_api_user', user_api_id: api_user.id }, + { method: :post, class: 'btn btn-danger'} %> + <% end %> +