diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7a6b1a0..90e2523dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,46 @@ +20.10.2020 +* ForceDelete mailer now respects option to not notify registrant [#1719](https://github.com/internetee/registry/pull/1719) + +19.10.2020 +* Improved logging for LHV-connect messages [#1712](https://github.com/internetee/registry/issues/1712) +* LHV-connect gem update to handle blank descriptions [#1714](https://github.com/internetee/registry/issues/1714) + +16.10.2020 +* Improved error handling for registrant API comapnies endpoint [#1713](https://github.com/internetee/registry/pull/1713) + +15.10.2020 +* Tara integration for registrant portal [#1698](https://github.com/internetee/registry/pull/1698) + +14.10.2020 +* Added company registration data query to regisrant API [#1708](https://github.com/internetee/registry/issues/1708) +* Fixed domain delete history records in admin [#1710](https://github.com/internetee/registry/issues/1710) + +09.10.2020 +* Fixed pendingUpdate release while forceDelete is set [#1705](https://github.com/internetee/registry/issues/1705) + +08.10.2020 +* Fixed serach in admin history [#1695](https://github.com/internetee/registry/issues/1695) + +06.10.2020 +* Updated Directo gem to fix vat codes for EU and non-EU clients [#1699](https://github.com/internetee/registry/pull/1699) +* Email validation level is now configurable [#1675](https://github.com/internetee/registry/pull/1675) + +01.10.2020 +* Fixed EPP authentication [#1697](https://github.com/internetee/registry/pull/1697) + +30.09.2020 +* Added Tara integration to registrar portal [#1680](https://github.com/internetee/registry/issues/1680) + +28.09.2020 +* Fixed data leakage with shared contacts [#1690](https://github.com/internetee/registry/issues/1690) +* RenewProhoboted status blocks renew [#1693](https://github.com/internetee/registry/issues/1693) + +18.09.2020 +* Updated testing documentation [#1285](https://github.com/internetee/registry/pull/1285) +* Removed mod-epp docs - replaced by epp-proxy [#1284](https://github.com/internetee/registry/pull/1284) +* Removed outdated diagrams [#1073](https://github.com/internetee/registry/pull/1073) +* Removed unused autodoc gems [#1358](https://github.com/internetee/registry/pull/1358) + 16.09.2020 * Refactored orphaned contact archivation process [#956](https://github.com/internetee/registry/issues/956) * Rails update to 6.0.3.3 [#1685](https://github.com/internetee/registry/pull/1685) diff --git a/Gemfile b/Gemfile index 12b826e3c..25c3eafff 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,11 @@ gem 'digidoc_client', github: 'tarmotalu/digidoc_client', ref: '1645e83a5a548addce383f75703b0275c5310c32' +# TARA +gem 'omniauth' +gem 'omniauth-rails_csrf_protection' +gem 'omniauth-tara', github: 'internetee/omniauth-tara' + gem 'epp', github: 'internetee/epp', branch: :master gem 'epp-xml', '1.1.0', github: 'internetee/epp-xml' @@ -63,7 +68,8 @@ gem 'pdfkit' gem 'jquery-ui-rails', '5.0.5' gem 'airbrake' -gem 'company_register', github: 'internetee/company_register', branch: :master +gem 'company_register', github: 'internetee/company_register', + branch: 'master' gem 'e_invoice', github: 'internetee/e_invoice', branch: :master gem 'lhv', github: 'internetee/lhv', branch: 'master' gem 'domain_name' @@ -80,10 +86,7 @@ end group :development, :test do gem 'pry', '0.10.1' - gem 'railroady', '1.3.0' # to generate database diagrams - gem 'autodoc' gem 'puma' - gem 'sdoc', '~> 1.1' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e0dd396a7..c628257a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/internetee/company_register.git - revision: 86d691997aa7def9f86d88f6c92cabb86cd65487 + revision: 4181b2fff9080e2d87d15612561131f9e3fdfb4c branch: master specs: company_register (0.1.0) @@ -9,7 +9,7 @@ GIT GIT remote: https://github.com/internetee/directo.git - revision: e4ba54f601d1815fd8782a196788730d47861e86 + revision: 711ce2d942456ee830b649b03b7141e903a1d86b branch: master specs: directo (1.0.1) @@ -45,13 +45,22 @@ GIT GIT remote: https://github.com/internetee/lhv.git - revision: 1825240b3bf8b262418cc6c8ef7ed1aba386dd7d + revision: 1fb07818369425510a0172ad53bc86e85b6f83cc branch: master specs: lhv (0.1.0) logger nokogiri +GIT + remote: https://github.com/internetee/omniauth-tara.git + revision: cec845ec3794532144c4976104a07e206d759aa6 + specs: + omniauth-tara (0.3.0) + addressable (~> 2.5) + omniauth (~> 1.3) + openid_connect (~> 1.1) + GIT remote: https://github.com/tarmotalu/digidoc_client.git revision: 1645e83a5a548addce383f75703b0275c5310c32 @@ -111,7 +120,7 @@ GEM activerecord (6.0.3.3) activemodel (= 6.0.3.3) activesupport (= 6.0.3.3) - activerecord-import (1.0.5) + activerecord-import (1.0.6) activerecord (>= 3.2) activestorage (6.0.3.3) actionpack (= 6.0.3.3) @@ -126,21 +135,20 @@ GEM zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - airbrake (10.0.5) - airbrake-ruby (~> 4.13) - airbrake-ruby (4.15.0) + aes_key_wrap (1.1.0) + airbrake (11.0.0) + airbrake-ruby (~> 5.0) + airbrake-ruby (5.0.2) rbtree3 (~> 0.5) akami (1.3.1) gyoku (>= 0.4.0) nokogiri - autodoc (0.7.4) - actionpack - activesupport (>= 3.0.0) - rspec - autoprefixer-rails (9.8.4) + attr_required (1.0.1) + autoprefixer-rails (10.0.0.2) execjs - bcrypt (3.1.13) - bootsnap (1.4.6) + bcrypt (3.1.16) + bindata (2.4.8) + bootsnap (1.4.8) msgpack (~> 1.0) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) @@ -170,8 +178,7 @@ GEM i18n_data (~> 0.10.0) sixarm_ruby_unaccent (~> 1.1) unicode_utils (~> 1.4) - crack (0.4.3) - safe_yaml (~> 1.0.0) + crack (0.4.4) crass (1.0.6) daemons (1.3.1) daemons-rails (1.2.1) @@ -180,13 +187,12 @@ GEM data_migrate (6.3.0) rails (>= 5.0) database_cleaner (1.8.5) - devise (4.7.2) + devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.4.4) docile (1.3.2) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -201,7 +207,7 @@ GEM concurrent-ruby (~> 1.0) dry-equalizer (0.3.0) dry-inflector (0.2.0) - dry-logic (1.0.6) + dry-logic (1.0.7) concurrent-ruby (~> 1.0) dry-core (~> 0.2) dry-equalizer (~> 0.2) @@ -220,7 +226,7 @@ GEM thor (~> 0.14) globalid (0.4.2) activesupport (>= 4.2.0) - grape (1.3.3) + grape (1.4.0) activesupport builder dry-types (>= 1.1) @@ -233,6 +239,7 @@ GEM temple (>= 0.8.0) tilt hashdiff (1.0.1) + hashie (4.1.0) hpricot (0.8.6) http-accept (1.7.0) http-cookie (1.0.3) @@ -253,6 +260,10 @@ GEM jquery-ui-rails (5.0.5) railties (>= 3.2.16) json (2.3.1) + json-jwt (1.13.0) + activesupport (>= 4.2) + aes_key_wrap + bindata kaminari (1.2.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.1) @@ -298,7 +309,7 @@ GEM money (~> 6.13.2) railties (>= 3.0) msgpack (1.3.3) - multi_json (1.14.1) + multi_json (1.15.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) mustermann-grape (1.0.1) @@ -308,12 +319,28 @@ GEM nokogiri (1.10.10) mini_portile2 (~> 2.4.0) nori (2.6.0) + omniauth (1.9.1) + hashie (>= 3.4.6) + rack (>= 1.6.2, < 3) + omniauth-rails_csrf_protection (0.1.2) + actionpack (>= 4.2) + omniauth (>= 1.3.1) open4 (1.3.4) + openid_connect (1.2.0) + activemodel + attr_required (>= 1.0.0) + json-jwt (>= 1.5.0) + rack-oauth2 (>= 1.6.1) + swd (>= 1.0.0) + tzinfo + validate_email + validate_url + webfinger (>= 1.0.1) orm_adapter (0.5.0) paper_trail (10.3.1) activerecord (>= 4.2) request_store (~> 1.1) - pdfkit (0.8.4.3.1) + pdfkit (0.8.4.3.2) pg (1.2.2) polyamorous (2.3.2) activerecord (>= 5.2.1) @@ -322,7 +349,7 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) public_suffix (4.0.6) - puma (4.3.5) + puma (5.0.0) nio4r (~> 2.0) que (0.14.3) que-web (0.7.2) @@ -332,11 +359,16 @@ GEM rack (2.2.3) rack-accept (0.4.5) rack (>= 0.4) - rack-protection (2.0.8.1) + rack-oauth2 (1.16.0) + activesupport + attr_required + httpclient + json-jwt (>= 1.11.0) + rack (>= 2.1.0) + rack-protection (2.1.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) - railroady (1.3.0) rails (6.0.3.3) actioncable (= 6.0.3.3) actionmailbox (= 6.0.3.3) @@ -373,8 +405,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rbtree3 (0.6.0) - rdoc (6.2.1) - regexp_parser (1.7.1) + regexp_parser (1.8.0) request_store (1.5.0) rack (>= 1.4) responders (3.0.1) @@ -385,22 +416,8 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.2) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.3) ruby2_keywords (0.0.2) rubyzip (2.3.0) - safe_yaml (1.0.5) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0) @@ -419,8 +436,6 @@ GEM nokogiri (>= 1.8.1) nori (~> 2.4) wasabi (~> 3.4) - sdoc (1.1.0) - rdoc (>= 5.0) select2-rails (3.5.9.3) thor (~> 0.14) selectize-rails (0.12.1) @@ -434,10 +449,10 @@ GEM simplecov-html (0.10.2) simpleidn (0.1.1) unf (~> 0.1.4) - sinatra (2.0.8.1) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.8.1) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) sixarm_ruby_unaccent (1.2.0) slop (3.6.0) @@ -449,11 +464,15 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + swd (1.2.0) + activesupport (>= 3) + attr_required (>= 0.0.5) + httpclient (>= 2.4) temple (0.8.2) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.10) - truemail (1.8.0) + truemail (1.9.1) simpleidn (~> 0.1.1) tzinfo (1.2.7) thread_safe (~> 0.1) @@ -463,10 +482,16 @@ GEM unf_ext unf_ext (0.0.7.7) unicode_utils (1.4.0) + validate_email (0.1.6) + activemodel (>= 3.0) + mail (>= 2.2.5) + validate_url (1.0.13) + activemodel (>= 3.0.0) + public_suffix validates_email_format_of (1.6.3) i18n - warden (1.2.8) - rack (>= 2.0.6) + warden (1.2.9) + rack (>= 2.0.9) wasabi (3.6.1) addressable httpi (~> 2.0) @@ -475,7 +500,10 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - webmock (3.8.3) + webfinger (1.1.0) + activesupport + httpclient (>= 2.4) + webmock (3.9.1) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -495,7 +523,6 @@ PLATFORMS DEPENDENCIES activerecord-import airbrake - autodoc bootsnap (>= 1.1.0) bootstrap-sass (~> 3.4) cancancan @@ -528,6 +555,9 @@ DEPENDENCIES minitest (~> 5.14) money-rails nokogiri + omniauth + omniauth-rails_csrf_protection + omniauth-tara! paper_trail (~> 10.3) pdfkit pg (= 1.2.2) @@ -535,12 +565,10 @@ DEPENDENCIES puma que que-web - railroady (= 1.3.0) rails (~> 6.0) ransack (~> 2.3) rest-client sass-rails - sdoc (~> 1.1) select2-rails (= 3.5.9.3) selectize-rails (= 0.12.1) simplecov (= 0.17.1) diff --git a/README.md b/README.md index 774e35331..04ac79d51 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,8 @@ Documentation ------------- * [EPP documentation](/doc/epp) -* [EPP request-response examples](/doc/epp_examples.md) -* [REPP documentation](/doc/repp_doc.md) -* [Database diagram](/doc/models_complete.svg) -* [Controllers diagram](/doc/controllers_complete.svg) - -### Updating documentation - - AUTODOC=true rspec spec/requests - EPP_DOC=true rspec spec/epp --tag epp --require support/epp_doc.rb --format EppDoc > doc/epp_examples.md +* [EPP request-response examples](/doc/epp-examples.md) +* [REPP documentation](/doc/repp-doc.md) Installation ------------ @@ -47,24 +40,10 @@ Manual demo install and database setup: bundle exec rake bootstrap bundle exec rake assets:precompile -### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS) +### Apache (Debian 7/Ubuntu 14.04 LTS) sudo apt-get install apache2 - sudo apt-get install apache2-threaded-dev # needed to compile mod_epp - wget sourceforge.net/projects/aepps/files/mod_epp/1.10/mod_epp-1.10.tar.gz - tar -xzvf mod_epp-1.10.tar.gz - cd mod_epp-1.10 - -Patch mod_epp for Rack. Beacause Rack multipart parser expects specifically -formatted content boundaries, the mod_epp needs to be modified before building: - - wget https://github.com/internetee/registry/raw/master/doc/patches/mod_epp_1.10-rack-friendly.patch - wget https://raw.githubusercontent.com/domify/registry/master/doc/patches/mod_epp_1.10-frame-size.patch - patch < mod_epp_1.10-rack-friendly.patch - patch < mod_epp_1.10-frame-size.patch - sudo apxs2 -a -c -i mod_epp.c - Enable ssl: sudo a2enmod proxy_http @@ -380,37 +359,6 @@ Be sure to update paths to match your system configuration. - - - Listen 700 - - SSLEngine on - SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL - SSLCertificateFile /etc/apache2/ssl/apache.crt - SSLCertificateKeyFile /etc/apache2/ssl/apache.key - - SSLVerifyClient require - SSLVerifyDepth 1 - SSLCACertificateFile /home/registry/registry/shared/ca/certs/ca.crt.pem - SSLCARevocationPath /home/registry/registry/shared/ca/crl - # Uncomment this when upgrading to apache 2.4: - # SSLCARevocationCheck chain - - RequestHeader set SSL_CLIENT_S_DN_CN "%{SSL_CLIENT_S_DN_CN}s" - RequestHeader set SSL_CLIENT_CERT "%{SSL_CLIENT_CERT}s" - - EPPEngine On - EPPCommandRoot /proxy/command - EPPSessionRoot /proxy/session - EPPErrorRoot /proxy/error - EPPRawFrame raw_frame - - ProxyPass /proxy/ http://localhost:8080/epp/ - - EPPAuthURI implicit - EPPReturncodeHeader X-EPP-Returncode - - ``` Enable epp_ssl and restart apache @@ -426,6 +374,8 @@ All registry demo data can be found at: Initially you can use two type of users: admin users and EPP users. +For using EPP we are strongly recommend to install epp_proxy instead of mod_epp. You can get epp_proxy from https://github.com/internetee/epp_proxy + ### Wkhtmltopdf setup ``` diff --git a/app/controllers/api/v1/registrant/companies_controller.rb b/app/controllers/api/v1/registrant/companies_controller.rb new file mode 100644 index 000000000..d2060276d --- /dev/null +++ b/app/controllers/api/v1/registrant/companies_controller.rb @@ -0,0 +1,52 @@ +require 'serializers/registrant_api/company' + +module Api + module V1 + module Registrant + class CompaniesController < ::Api::V1::Registrant::BaseController + MAX_LIMIT = 200 + MIN_OFFSET = 0 + + def index + result = error_result('limit') if limit > MAX_LIMIT || limit < 1 + result = error_result('offset') if offset < MIN_OFFSET + result ||= companies_result(limit, offset) + + render result + end + + def current_user_companies + [:ok, current_registrant_user.companies] + rescue CompanyRegister::NotAvailableError + [:service_unavailable, []] + end + + def limit + (params[:limit] || MAX_LIMIT).to_i + end + + def offset + (params[:offset] || MIN_OFFSET).to_i + end + + def error_result(attr_name) + { json: { errors: [{ attr_name.to_sym => ['parameter is out of range'] }] }, + status: :bad_request } + end + + def companies_result(limit, offset) + status, all_companies = current_user_companies + @companies = all_companies.drop(offset).first(limit) + + serialized_companies = @companies.map do |item| + country_code = current_registrant_user.country.alpha3 + serializer = ::Serializers::RegistrantApi::Company.new(company: item, + country_code: country_code) + serializer.to_json + end + { json: { companies: serialized_companies }, status: status } + end + end + end + end +end diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index 7d8dbfac1..10f9abacf 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -91,7 +91,7 @@ module Api private def current_user_contacts - current_registrant_user.contacts + current_registrant_user.contacts(representable: false) rescue CompanyRegister::NotAvailableError current_registrant_user.direct_contacts end diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index e3ac81815..99c0ead35 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -343,7 +343,9 @@ module Epp end def epp_session_id - cookies[:session] # Passed by mod_epp https://github.com/mod-epp/mod-epp#requestscript-interface + # Passed by EPP proxy + # https://github.com/internetee/epp_proxy#translation-of-epp-calls + cookies[:session] end def ensure_session_id_passed diff --git a/app/controllers/registrant/sessions_controller.rb b/app/controllers/registrant/sessions_controller.rb index b18a802e6..73b6d52da 100644 --- a/app/controllers/registrant/sessions_controller.rb +++ b/app/controllers/registrant/sessions_controller.rb @@ -1,81 +1,6 @@ class Registrant::SessionsController < Devise::SessionsController layout 'registrant/application' - def login_mid - @user = User.new - end - - def mid - phone = params[:user][:phone] - endpoint = "#{ENV['sk_digi_doc_service_endpoint']}" - client = Digidoc::Client.new(endpoint) - client.logger = Rails.application.config.logger unless Rails.env.test? - - # country_codes = {'+372' => 'EST'} - response = client.authenticate( - phone: "+372#{phone}", - message_to_display: 'Authenticating', - service_name: ENV['sk_digi_doc_service_name'] || 'Testing' - ) - - if response.faultcode - render json: { message: response.detail.message }, status: :unauthorized - return - end - - @user = RegistrantUser.find_or_create_by_mid_data(response) - - if @user.persisted? - session[:user_country] = response.user_country - session[:user_id_code] = response.user_id_code - session[:mid_session_code] = client.session_code - - render json: { - message: t(:confirmation_sms_was_sent_to_your_phone_verification_code_is, { code: response.challenge_id }) - }, status: :ok - else - render json: { message: t(:no_such_user) }, status: :unauthorized - end - end - - def mid_status - endpoint = "#{ENV['sk_digi_doc_service_endpoint']}" - client = Digidoc::Client.new(endpoint) - client.logger = Rails.application.config.logger unless Rails.env.test? - client.session_code = session[:mid_session_code] - auth_status = client.authentication_status - - case auth_status.status - when 'OUTSTANDING_TRANSACTION' - render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok - when 'USER_AUTHENTICATED' - @user = RegistrantUser.find_by(registrant_ident: "#{session[:user_country]}-#{session[:user_id_code]}") - - sign_in(:registrant_user, @user) - flash[:notice] = t(:welcome) - flash.keep(:notice) - render js: "window.location = '#{registrant_root_path}'" - when 'NOT_VALID' - render json: { message: t(:user_signature_is_invalid) }, status: :bad_request - when 'EXPIRED_TRANSACTION' - render json: { message: t(:session_timeout) }, status: :bad_request - when 'USER_CANCEL' - render json: { message: t(:user_cancelled) }, status: :bad_request - when 'MID_NOT_READY' - render json: { message: t(:mid_not_ready) }, status: :bad_request - when 'PHONE_ABSENT' - render json: { message: t(:phone_absent) }, status: :bad_request - when 'SENDING_ERROR' - render json: { message: t(:sending_error) }, status: :bad_request - when 'SIM_ERROR' - render json: { message: t(:sim_error) }, status: :bad_request - when 'INTERNAL_ERROR' - render json: { message: t(:internal_error) }, status: :bad_request - else - render json: { message: t(:internal_error) }, status: :bad_request - end - end - private def after_sign_in_path_for(_resource_or_scope) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index df90ea57b..e413c4feb 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -49,102 +49,6 @@ class Registrar end end - def id_card - self.resource = warden.authenticate!(auth_options) - - restricted_ip = Authorization::RestrictedIP.new(request.ip) - ip_allowed = restricted_ip.can_access_registrar_area?(resource.registrar) - - unless ip_allowed - render plain: t('registrar.authorization.ip_not_allowed', ip: request.ip) - warden.logout(:registrar_user) - return - end - - set_flash_message!(:notice, :signed_in) - sign_in(resource_name, resource) - yield resource if block_given? - respond_with resource, location: after_sign_in_path_for(resource) - end - - def login_mid - @user = User.new - end - - def mid - phone = params[:user][:phone] - endpoint = "#{ENV['sk_digi_doc_service_endpoint']}" - client = Digidoc::Client.new(endpoint) - client.logger = Rails.application.config.logger unless Rails.env.test? - - # country_codes = {'+372' => 'EST'} - phone.gsub!('+372', '') - response = client.authenticate( - phone: "+372#{phone}", - message_to_display: 'Authenticating', - service_name: ENV['sk_digi_doc_service_name'] || 'Testing' - ) - - if response.faultcode - render json: { message: response.detail.message }, status: :unauthorized - return - end - - if Setting.registrar_ip_whitelist_enabled - @user = find_user_by_idc_and_allowed(response.user_id_code) - else - @user = find_user_by_idc(response.user_id_code) - end - - if @user.persisted? - session[:user_id_code] = response.user_id_code - session[:mid_session_code] = client.session_code - - render json: { - message: t(:confirmation_sms_was_sent_to_your_phone_verification_code_is, { code: response.challenge_id }) - }, status: :ok - else - render json: { message: t(:no_such_user) }, status: :unauthorized - end - end - - def mid_status - endpoint = "#{ENV['sk_digi_doc_service_endpoint']}" - client = Digidoc::Client.new(endpoint) - client.logger = Rails.application.config.logger unless Rails.env.test? - client.session_code = session[:mid_session_code] - auth_status = client.authentication_status - - case auth_status.status - when 'OUTSTANDING_TRANSACTION' - render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok - when 'USER_AUTHENTICATED' - @user = find_user_by_idc_and_allowed(session[:user_id_code]) - sign_in(:registrar_user, @user) - flash[:notice] = t(:welcome) - flash.keep(:notice) - render js: "window.location = '#{after_sign_in_path_for(@user)}'" - when 'NOT_VALID' - render json: { message: t(:user_signature_is_invalid) }, status: :bad_request - when 'EXPIRED_TRANSACTION' - render json: { message: t(:session_timeout) }, status: :bad_request - when 'USER_CANCEL' - render json: { message: t(:user_cancelled) }, status: :bad_request - when 'MID_NOT_READY' - render json: { message: t(:mid_not_ready) }, status: :bad_request - when 'PHONE_ABSENT' - render json: { message: t(:phone_absent) }, status: :bad_request - when 'SENDING_ERROR' - render json: { message: t(:sending_error) }, status: :bad_request - when 'SIM_ERROR' - render json: { message: t(:sim_error) }, status: :bad_request - when 'INTERNAL_ERROR' - render json: { message: t(:internal_error) }, status: :bad_request - else - render json: { message: t(:internal_error) }, status: :bad_request - end - end - private def depp_controller? diff --git a/app/controllers/sso/tara_controller.rb b/app/controllers/sso/tara_controller.rb new file mode 100644 index 000000000..37c8ab608 --- /dev/null +++ b/app/controllers/sso/tara_controller.rb @@ -0,0 +1,40 @@ +module Sso + class TaraController < ApplicationController + skip_authorization_check + + def registrant_callback + user = RegistrantUser.find_or_create_by_omniauth_data(user_hash) + callback(user, registrar: false) + end + + def registrar_callback + user = ApiUser.from_omniauth(user_hash) + callback(user, registrar: true) + end + + # rubocop:disable Style/AndOr + def callback(user, registrar: true) + session[:omniauth_hash] = user_hash + (show_error(registrar: registrar) and return) unless user + + flash[:notice] = t(:signed_in_successfully) + sign_in_and_redirect(registrar ? :registrar_user : :registrant_user, user) + end + # rubocop:enable Style/AndOr + + def cancel + redirect_to root_path, notice: t(:sign_in_cancelled) + end + + def show_error(registrar: true) + path = registrar ? new_registrar_user_session_url : new_registrant_user_session_url + redirect_to path, alert: t(:no_such_user) + end + + private + + def user_hash + request.env['omniauth.auth'] + end + end +end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index d7b264495..61dd12387 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -2,7 +2,7 @@ require 'open3' class ApiUser < User include EppErrors - devise :database_authenticatable, :trackable, :timeoutable, :id_card_authenticatable, + devise :database_authenticatable, :trackable, :timeoutable, authentication_keys: [:username] def epp_code_map @@ -47,12 +47,6 @@ class ApiUser < User self.active = true unless saved_change_to_active? end - class << self - def find_by_id_card(id_card) - find_by(identity_code: id_card.personal_code) - end - end - def to_s username end diff --git a/app/models/concerns/job/force_delete_notify.rb b/app/models/concerns/job/force_delete_notify.rb index 658c7a315..bc291354e 100644 --- a/app/models/concerns/job/force_delete_notify.rb +++ b/app/models/concerns/job/force_delete_notify.rb @@ -15,7 +15,7 @@ module Concerns domain.registrar.notifications.create!(text: I18n.t('grace_period_started_domain', domain_name: domain.name, date: domain.force_delete_start)) - send_mail(domain) + send_mail(domain) if domain.template_name.present? domain.update(contact_notification_sent_date: Time.zone.today) end diff --git a/app/models/contact.rb b/app/models/contact.rb index 0eb7fccbd..9dc1e34a2 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -210,10 +210,13 @@ class Contact < ApplicationRecord ) end - def registrant_user_contacts(registrant_user) - registrant_user_direct_contacts(registrant_user) - .or(registrant_user_company_contacts(registrant_user)) - .or(registrant_user_indirect_contacts(registrant_user)) + def registrant_user_contacts(registrant_user, representable: true) + represented_contacts = registrant_user_direct_contacts(registrant_user) + .or(registrant_user_company_contacts(registrant_user)) + + return represented_contacts if representable + + represented_contacts.or(registrant_user_indirect_contacts(registrant_user)) end def registrant_user_direct_contacts(registrant_user) diff --git a/app/models/domain.rb b/app/models/domain.rb index e57117bc2..391c9c030 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -306,11 +306,7 @@ class Domain < ApplicationRecord end def renewable? - blocking_statuses = [DomainStatus::DELETE_CANDIDATE, DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_TRANSFER, DomainStatus::DISPUTED, - DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE, - DomainStatus::PENDING_DELETE_CONFIRMATION] - return false if statuses.include_any? blocking_statuses + return false unless renew_blocking_statuses.empty? return true unless Setting.days_to_renew_domain_before_expire != 0 # if you can renew domain at days_to_renew before domain expiration @@ -321,6 +317,15 @@ class Domain < ApplicationRecord true end + def renew_blocking_statuses + disallowed = [DomainStatus::DELETE_CANDIDATE, DomainStatus::PENDING_RENEW, + DomainStatus::PENDING_TRANSFER, DomainStatus::CLIENT_RENEW_PROHIBITED, + DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE, + DomainStatus::PENDING_DELETE_CONFIRMATION, DomainStatus::SERVER_RENEW_PROHIBITED] + + (statuses & disallowed) + end + def notify_registrar(message_key) registrar.notifications.create!( text: "#{I18n.t(message_key)}: #{name}", @@ -484,7 +489,7 @@ class Domain < ApplicationRecord end def pending_update? - statuses.include?(DomainStatus::PENDING_UPDATE) && !statuses.include?(DomainStatus::FORCE_DELETE) + statuses.include?(DomainStatus::PENDING_UPDATE) end # depricated not used, not valid diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3ed26f0e1..530e54a0f 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -581,11 +581,14 @@ class Epp::Domain < Domain save(validate: false) end + ### RENEW ### + def renew(cur_exp_date, period, unit = 'y') @is_renewal = true validate_exp_dates(cur_exp_date) - add_epp_error('2105', nil, nil, I18n.t('object_is_not_eligible_for_renewal')) unless renewable? + add_renew_epp_errors unless renewable? + return false if errors.any? period = period.to_i @@ -613,6 +616,13 @@ class Epp::Domain < Domain save end + def add_renew_epp_errors + if renew_blocking_statuses.any? && !renewable? + add_epp_error('2304', 'status', renew_blocking_statuses, + I18n.t('object_status_prohibits_operation')) + end + end + ### TRANSFER ### def transfer(frame, action, current_user) diff --git a/app/models/id_card.rb b/app/models/id_card.rb deleted file mode 100644 index 0e3c11bb3..000000000 --- a/app/models/id_card.rb +++ /dev/null @@ -1,6 +0,0 @@ -class IdCard - attr_accessor :first_name - attr_accessor :last_name - attr_accessor :personal_code - attr_accessor :country_code -end \ No newline at end of file diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index e7ce9cc3b..c0addb5cd 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -1,7 +1,7 @@ class RegistrantUser < User attr_accessor :idc_data - devise :trackable, :timeoutable, :id_card_authenticatable + devise :trackable, :timeoutable def ability @ability ||= Ability.new(self) @@ -22,8 +22,8 @@ class RegistrantUser < User citizen_country_code: country.alpha3) end - def contacts - Contact.registrant_user_contacts(self) + def contacts(representable: true) + Contact.registrant_user_contacts(self, representable: representable) end def direct_contacts @@ -66,23 +66,19 @@ class RegistrantUser < User find_or_create_by_user_data(user_data) end - def find_or_create_by_mid_data(response) - user_data = { first_name: response.user_givenname, last_name: response.user_surname, - ident: response.user_id_code, country_code: response.user_country } + def find_or_create_by_omniauth_data(omniauth_hash) + uid = omniauth_hash['uid'] + identity_code = uid.slice(2..-1) + country_code = uid.slice(0..1) + first_name = omniauth_hash.dig('info', 'first_name') + last_name = omniauth_hash.dig('info', 'last_name') + + user_data = { first_name: first_name, last_name: last_name, + ident: identity_code, country_code: country_code } find_or_create_by_user_data(user_data) end - def find_by_id_card(id_card) - registrant_ident = "#{id_card.country_code}-#{id_card.personal_code}" - username = [id_card.first_name, id_card.last_name].join("\s") - - user = find_or_initialize_by(registrant_ident: registrant_ident) - user.username = username - user.save! - user - end - private def find_or_create_by_user_data(user_data = {}) diff --git a/app/models/user.rb b/app/models/user.rb index 6b16bd508..18ab410d0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,4 +11,11 @@ class User < ApplicationRecord "#{self.id}-#{self.class}: #{self.username}" end + def self.from_omniauth(omniauth_hash) + uid = omniauth_hash['uid'] + identity_code = uid.slice(2..-1) + # country_code = uid.slice(0..1) + + find_by(identity_code: identity_code) + end end diff --git a/app/views/admin/domain_versions/archive.haml b/app/views/admin/domain_versions/archive.haml index 9fdf8b000..f813f5eb3 100644 --- a/app/views/admin/domain_versions/archive.haml +++ b/app/views/admin/domain_versions/archive.haml @@ -57,7 +57,7 @@ - if version - attributes = only_present_fields(version, Domain) - domain = Domain.new(attributes) - - attach_existing_fields(version, domain) + - attach_existing_fields(version, domain) unless version.event == 'destroy' %tr %td= link_to(domain.name, admin_domain_version_path(version.id)) @@ -67,7 +67,7 @@ - else - contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first - if contact.nil? && ver = ContactVersion.where(item_id: domain.registrant_id).last - - contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}){|(k,v), o| o.public_send("#{k}=", v.last) } )) + - contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}) {|(k,v), o| o[k] = v.last })) = contact.try(:name) = " ".html_safe = "(#{t(:deleted)})" diff --git a/app/views/admin/domain_versions/show.haml b/app/views/admin/domain_versions/show.haml index cb95f231c..11f70599f 100644 --- a/app/views/admin/domain_versions/show.haml +++ b/app/views/admin/domain_versions/show.haml @@ -1,6 +1,6 @@ - present_fields = only_present_fields(@version, Domain) - domain = Domain.new(present_fields) -- attach_existing_fields(@version, domain) +- attach_existing_fields(@version, domain) unless @version.event == 'destroy' - if @version - children = HashWithIndifferentAccess.new(@version.children) diff --git a/app/views/registrant/sessions/login_mid.haml b/app/views/registrant/sessions/login_mid.haml deleted file mode 100644 index 318e19033..000000000 --- a/app/views/registrant/sessions/login_mid.haml +++ /dev/null @@ -1,40 +0,0 @@ -.row - .form-signin.col-md-4.center-block.text-center - %h2.form-signin-heading.text-center= t '.header' - %hr - = form_for @user, url: registrant_mid_path, html: {class: 'form-signin'} do |f| - = f.text_field :phone, class: 'form-control', - placeholder: t(:phone_no), autocomplete: 'off', required: true - %button.btn.btn-lg.btn-primary.btn-block.js-login{:type => 'submit'}= t '.submit_btn' - - - if ['development', 'alpha'].include?(Rails.env) - %div.text-center - 00007, 60000007, 00000766 - -:coffee - load_listener = -> - $('.js-login').attr('disabled', false) - - status_interval = null - mid_status = () -> - status_interval = setInterval((-> - $.post('/registrant/login/mid_status').fail((data) -> - clearInterval(status_interval) - flash_alert(data.responseJSON.message) - $('.js-login').attr('disabled', false) - ) - ), 1000) - - $('.js-login').on 'click', (e) -> - e.preventDefault(); - $(this).attr('disabled', true) - - $.post($('form').attr('action'), $('form').serialize()).done((data) -> - if data.message - flash_notice(data.message) - mid_status() - ).fail((data) -> - flash_alert(data.responseJSON.message) - $('.js-login').attr('disabled', false) - ) - window.addEventListener 'load', load_listener diff --git a/app/views/registrant/sessions/new.html.erb b/app/views/registrant/sessions/new.html.erb index a3203e83a..9f7af3254 100644 --- a/app/views/registrant/sessions/new.html.erb +++ b/app/views/registrant/sessions/new.html.erb @@ -8,11 +8,6 @@ <%= t '.hint' %>
- <%= link_to '/registrant/login/mid' do %> - <%= image_tag 'mid.gif' %> - <% end %> - <%= link_to registrant_id_card_sign_in_path, method: :post do %> - <%= image_tag 'id_card.gif' %> - <% end %> + <%= link_to t(:sign_in), "/auth/rant_tara", method: :post, class: 'btn btn-lg btn-primary btn-block' %> - \ No newline at end of file + diff --git a/app/views/registrar/sessions/login_mid.haml b/app/views/registrar/sessions/login_mid.haml deleted file mode 100644 index 7ee604209..000000000 --- a/app/views/registrar/sessions/login_mid.haml +++ /dev/null @@ -1,40 +0,0 @@ -.row - .form-signin.col-md-4.center-block.text-center - %h2.form-signin-heading.text-center= t '.header' - %hr - = form_for @user, url: registrar_mid_path, html: {class: 'form-signin'} do |f| - = f.text_field :phone, class: 'form-control', - placeholder: t(:phone_no), autocomplete: 'off', required: true - %button.btn.btn-lg.btn-primary.btn-block.js-login{:type => 'submit'}= t '.submit_btn' - - - if ['development', 'alpha'].include?(Rails.env) - %div.text-center - 00007, 60000007, 00000766 - -:coffee - load_listener = -> - $('.js-login').attr('disabled', false) - - status_interval = null - mid_status = () -> - status_interval = setInterval((-> - $.post('/registrar/login/mid_status').fail((data) -> - clearInterval(status_interval) - flash_alert(data.responseJSON.message) - $('.js-login').attr('disabled', false) - ) - ), 1000) - - $('.js-login').on 'click', (e) -> - e.preventDefault(); - $(this).attr('disabled', true) - - $.post($('form').attr('action'), $('form').serialize()).done((data) -> - if data.message - flash_notice(data.message) - mid_status() - ).fail((data) -> - flash_alert(data.responseJSON.message) - $('.js-login').attr('disabled', false) - ) - window.addEventListener 'load', load_listener diff --git a/app/views/registrar/sessions/new.html.erb b/app/views/registrar/sessions/new.html.erb index 8056b07c8..2ce0b0f1a 100644 --- a/app/views/registrar/sessions/new.html.erb +++ b/app/views/registrar/sessions/new.html.erb @@ -19,12 +19,10 @@
- <%= link_to '/registrar/login/mid', id: 'login-with-mobile-id-btn' do %> - <%= image_tag 'mid.gif' %> - <% end %> - - <%= link_to registrar_id_card_sign_in_path, method: :post do %> - <%= image_tag 'id_card.gif' %> - <% end %> +
+

<%= t('.sign_in_with_identity_document') %>

+

<%= t('.identity_document_text')%>

+ <%= link_to t(:sign_in), "/auth/tara", method: :post, class: 'btn btn-lg btn-primary btn-block' %> +
- \ No newline at end of file + diff --git a/app/views/registrar/tara/callback.html.erb b/app/views/registrar/tara/callback.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/application.yml.sample b/config/application.yml.sample index 237617be3..228bce037 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -159,6 +159,20 @@ lhv_dev_mode: 'false' epp_session_timeout_seconds: '300' contact_archivation_log_file_dir: +tara_host: 'tara-test.ria.ee' +tara_issuer: 'https://tara-test.ria.ee' +tara_identifier: 'identifier' +tara_secret: 'secret' +tara_redirect_uri: 'redirect_url' +tara_keys: "{\"kty\":\"RSA\",\"kid\":\"de6cc4\",\"n\":\"jWwAjT_03ypme9ZWeSe7c-jY26NO50Wo5I1LBnPW2JLc0dPMj8v7y4ehiRpClYNTaSWcLd4DJmlKXDXXudEUWwXa7TtjBFJfzlZ-1u0tDvJ-H9zv9MzO7UhUFytztUEMTrtStdhGbzkzdEZZCgFYeo2i33eXxzIR1nGvI05d9Y-e_LHnNE2ZKTa89BC7ZiCXq5nfAaCgQna_knh4kFAX-KgiPRAtsiDHcAWKcBY3qUVcb-5XAX8p668MlGLukzsh5tFkQCbJVyNtmlbIHdbGvVHPb8C0H3oLYciv1Fjy_tS1lO7OT_cb3GVp6Ql-CG0uED_8pkpVtfsGRviub4_ElQ\",\"e\":\"AQAB\"}" + +tara_rant_identifier: 'identifier' +tara_rant_secret: 'secret' +tara_rant_redirect_uri: 'redirect_uri' + +default_email_validation_type: 'regex' + + # Since the keys for staging are absent from the repo, we need to supply them separate for testing. test: payments_seb_bank_certificate: 'test/fixtures/files/seb_bank_cert.pem' diff --git a/config/environments/production.rb b/config/environments/production.rb index 6e13ea1f7..e1966d6ba 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -43,7 +43,7 @@ Rails.application.configure do # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = false # Use the lowest log level to ensure availability of diagnostic information # when problems arise. diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 10f937f40..eb0465796 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -9,7 +9,7 @@ Devise.setup do |config| # Devise will use the `secret_key_base` as its `secret_key` # by default. You can change it below and use your own secret key. config.secret_key = ENV['devise_secret'] - + # ==> Controller configuration # Configure the parent class to the devise controllers. # config.parent_controller = 'DeviseController' @@ -280,10 +280,4 @@ Devise.setup do |config| # When using OmniAuth, Devise cannot automatically set OmniAuth path, # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = '/my_engine/users/auth' - - require 'devise/models/id_card_authenticatable' - require 'devise/strategies/id_card_authenticatable' - - routes = [nil, :new, :destroy] - config.add_module :id_card_authenticatable, strategy: true, route: { session: routes } end diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 000000000..e3e0d644b --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,76 @@ +OpenIDConnect.logger = Rails.logger +OpenIDConnect.debug! + +OmniAuth.config.on_failure = Proc.new { |env| + OmniAuth::FailureEndpoint.new(env).redirect_to_failure +} + +OmniAuth.config.logger = Rails.logger +# Block GET requests to avoid exposing self to CVE-2015-9284 +OmniAuth.config.allowed_request_methods = [:post] + +signing_keys = ENV['tara_keys'] +issuer = ENV['tara_issuer'] +host = ENV['tara_host'] +identifier = ENV['tara_identifier'] +secret = ENV['tara_secret'] +redirect_uri = ENV['tara_redirect_uri'] + +registrant_identifier = ENV['tara_rant_identifier'] +registrant_secret = ENV['tara_rant_secret'] +registrant_redirect_uri = ENV['tara_rant_redirect_uri'] + +Rails.application.config.middleware.use OmniAuth::Builder do + provider "tara", { + callback_path: '/registrar/open_id/callback', + name: 'tara', + scope: ['openid'], + state: Proc.new{ SecureRandom.hex(10) }, + client_signing_alg: :RS256, + client_jwk_signing_key: signing_keys, + send_scope_to_token_endpoint: false, + send_nonce: true, + issuer: issuer, + + client_options: { + scheme: 'https', + host: host, + + authorization_endpoint: '/oidc/authorize', + token_endpoint: '/oidc/token', + userinfo_endpoint: nil, # Not implemented + jwks_uri: '/oidc/jwks', + + # Registry + identifier: identifier, + secret: secret, + redirect_uri: redirect_uri, + }, + } + + provider "tara", { + callback_path: '/registrant/open_id/callback', + name: 'rant_tara', + scope: ['openid'], + client_signing_alg: :RS256, + client_jwk_signing_key: signing_keys, + send_scope_to_token_endpoint: false, + send_nonce: true, + issuer: issuer, + + client_options: { + scheme: 'https', + host: host, + + authorization_endpoint: '/oidc/authorize', + token_endpoint: '/oidc/token', + userinfo_endpoint: nil, # Not implemented + jwks_uri: '/oidc/jwks', + + # Registry + identifier: registrant_identifier, + secret: registrant_secret, + redirect_uri: registrant_redirect_uri, + }, + } +end diff --git a/config/initializers/truemail.rb b/config/initializers/truemail.rb index f4517fbc0..ecab32ced 100644 --- a/config/initializers/truemail.rb +++ b/config/initializers/truemail.rb @@ -28,7 +28,10 @@ Truemail.configure do |config| # Optional parameter. You can predefine default validation type for # Truemail.validate('email@email.com') call without with-parameter # Available validation types: :regex, :mx, :smtp - if Rails.env.production? + if ENV['default_email_validation_type'].present? && + %w[regex mx smtp].include?(ENV['default_email_validation_type']) + config.default_validation_type = ENV['default_email_validation_type'].to_sym + elsif Rails.env.production? config.default_validation_type = :mx else config.default_validation_type = :regex diff --git a/config/locales/account_activities.en.yml b/config/locales/account_activities.en.yml index 41863219f..648549f8f 100644 --- a/config/locales/account_activities.en.yml +++ b/config/locales/account_activities.en.yml @@ -2,4 +2,4 @@ en: activerecord: attributes: account_activity: - created_at: Receipt date \ No newline at end of file + created_at: Receipt date diff --git a/config/locales/en.yml b/config/locales/en.yml index 9c5b98a1b..8b7b4f0fa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -295,6 +295,8 @@ en: authentication_error: 'Authentication error' + sign_in_cancelled: "Sign in cancelled" + transfer_requested: 'Transfer requested.' message_was_not_found: 'Message was not found' only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}' @@ -658,3 +660,5 @@ en: ipv6: IPv6 reference_no: Reference number iban: IBAN + sign_in: "Sign in" + signed_in_successfully: "Signed in successfully" diff --git a/config/locales/registrant/sessions.en.yml b/config/locales/registrant/sessions.en.yml index 3032382c1..7d4c16da9 100644 --- a/config/locales/registrant/sessions.en.yml +++ b/config/locales/registrant/sessions.en.yml @@ -2,11 +2,7 @@ en: registrant: sessions: new: - header: Log in + header: Sign in with identity document hint: >- - Access currently available only to Estonian citizens and e-residents with Estonian ID-card - or Mobile-ID. - - login_mid: - header: Log in with mobile-id - submit_btn: Login \ No newline at end of file + Sign in using Estonian (incl. e-residents) ID card, mobile ID, + Bank link or other EU citizen's electronic ID supported by EIDAS. diff --git a/config/locales/registrar/sessions.en.yml b/config/locales/registrar/sessions.en.yml index f74f74bc9..63274d7cd 100644 --- a/config/locales/registrar/sessions.en.yml +++ b/config/locales/registrar/sessions.en.yml @@ -4,6 +4,14 @@ en: new: header_html: Eesti Interneti SA
Registrar Portal submit_btn: Login + sign_in_with_identity_document: "Sign in with identity document" + identity_document_text: | + Sign in using Estonian (incl. e-residents) ID card, mobile ID, + Bank link or other EU citizen's electronic ID supported by EIDAS. login_mid: header: Log in with mobile-id submit_btn: Login + tara: + callback: + header_html: "Eesti Interneti SA
Registrar Portal" + submit_btn: Login diff --git a/config/locales/tara.en.yml b/config/locales/tara.en.yml new file mode 100644 index 000000000..ff37e8ff7 --- /dev/null +++ b/config/locales/tara.en.yml @@ -0,0 +1,14 @@ +en: + auth: + tara: + tampering: "Tampering detected. Sign in cancelled." + + callback: + title: "Create a user" + errors: "prohibited this user from being saved" + + form: + contact_data: "Contact Data" + data_from_identity_document: "Data from identity document" + new_password: "New password" + sign_up: "Sign up" diff --git a/config/locales/tara.et.yml b/config/locales/tara.et.yml new file mode 100644 index 000000000..a4ccaf6dd --- /dev/null +++ b/config/locales/tara.et.yml @@ -0,0 +1,14 @@ +et: + auth: + tara: + tampering: "Avastatud urkimine. Sisselogimine tühistatud." + + callback: + title: "Loo kasutaja" + errors: "seda kasutajat ei saa salvestada" + + form: + contact_data: "Kontaktandmed" + data_from_identity_document: "Andmed elektroonselt isikutunnistuselt" + new_password: "Uus salasõna" + sign_up: "Registreeru" diff --git a/config/routes.rb b/config/routes.rb index 9938403e7..54b68de60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,10 +61,12 @@ Rails.application.routes.draw do resource :registry_lock, only: %i[create destroy] end resources :contacts, only: %i[index show update], param: :uuid + resources :companies, only: %i[index] end resources :auctions, only: %i[index show update], param: :uuid resources :bounces, only: %i[create] + end match '*all', controller: 'cors', action: 'cors_preflight_check', via: [:options], @@ -77,17 +79,6 @@ Rails.application.routes.draw do devise_for :users, path: '', class_name: 'ApiUser', skip: %i[sessions] - devise_scope :registrar_user do - get 'login/mid' => 'sessions#login_mid' - post 'login/mid' => 'sessions#mid' - post 'login/mid_status' => 'sessions#mid_status' - - # /registrar/id path is hardcoded in Apache config for authentication with Estonian ID-card - post 'id' => 'sessions#id_card', as: :id_card_sign_in - - post 'mid' => 'sessions#mid' - end - resources :invoices, except: %i[new create edit update destroy] do resource :delivery, controller: 'invoices/delivery', only: %i[new create] @@ -164,6 +155,22 @@ Rails.application.routes.draw do post 'sessions', to: 'registrar/sessions#create', as: :registrar_user_session delete 'sign_out', to: 'registrar/sessions#destroy', as: :destroy_registrar_user_session + + # TARA + match '/open_id/callback', via: %i[get post], to: 'sso/tara#registrar_callback' + match '/open_id/cancel', via: %i[get post delete], to: 'sso/tara#cancel' + end + end + + scope :registrant do + devise_scope :registrant_user do + get 'sign_in', to: 'registrant/sessions#new', as: :new_registrant_user_session + post 'sessions', to: 'registrant/sessions#create', as: :registrant_user_session + delete 'sign_out', to: 'registrant/sessions#destroy', as: :destroy_registrant_user_session + + # TARA + match '/open_id/callback', via: %i[get post], to: 'sso/tara#registrant_callback' + match '/open_id/cancel', via: %i[get post delete], to: 'sso/tara#cancel' end end @@ -172,19 +179,9 @@ Rails.application.routes.draw do # POST /registrant/sign_in is not used devise_for :users, path: '', class_name: 'RegistrantUser' - devise_scope :registrant_user do - get 'login/mid' => 'sessions#login_mid' - post 'login/mid' => 'sessions#mid' - post 'login/mid_status' => 'sessions#mid_status' - post 'mid' => 'sessions#mid' - - # /registrant/id path is hardcoded in Apache config for authentication with Estonian ID-card - # Client certificate is asked only on login form submission, therefore the path must be different from the one in - # `new_registrant_user_session_path` route, in case some other auth type will be implemented - post 'id' => 'sessions#create', as: :id_card_sign_in - end resources :registrars, only: :show + # resources :companies, only: :index resources :domains, only: %i[index show] do resources :contacts, only: %i[show edit update] member do diff --git a/doc/controllers_brief.svg b/doc/controllers_brief.svg deleted file mode 100644 index a33c36bb8..000000000 --- a/doc/controllers_brief.svg +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -controllers_diagram - - -_diagram_info -Controllers diagram -Date: Jul 08 2015 - 13:40 -Migration version: 20150707103801 -Generated by RailRoady 1.3.0 -http://railroady.prestonlee.com - - -RegistrantController - -RegistrantController - - -Epp::DomainsController - -Epp::DomainsController - - -Epp::SessionsController - -Epp::SessionsController - - -Epp::PollsController - -Epp::PollsController - - -Epp::ContactsController - -Epp::ContactsController - - -Epp::ErrorsController - -Epp::ErrorsController - - -RegistrarController - -RegistrarController - - -Admin::DomainsController - -Admin::DomainsController - - -Admin::DelayedJobsController - -Admin::DelayedJobsController - - -Admin::WhiteIpsController - -Admin::WhiteIpsController - - -Admin::ZonefilesController - -Admin::ZonefilesController - - -Admin::SettingsController - -Admin::SettingsController - - -Admin::ApiUsersController - -Admin::ApiUsersController - - -Admin::SessionsController - -Admin::SessionsController - - -Admin::DomainVersionsController - -Admin::DomainVersionsController - - -Admin::ContactsController - -Admin::ContactsController - - -Admin::CertificatesController - -Admin::CertificatesController - - -Admin::BankStatementsController - -Admin::BankStatementsController - - -Admin::BankTransactionsController - -Admin::BankTransactionsController - - -Admin::BlockedDomainsController - -Admin::BlockedDomainsController - - -Admin::DashboardsController - -Admin::DashboardsController - - -Admin::RegistrarsController - -Admin::RegistrarsController - - -Admin::ReppLogsController - -Admin::ReppLogsController - - -Admin::InvoicesController - -Admin::InvoicesController - - -Admin::AdminUsersController - -Admin::AdminUsersController - - -Admin::EppLogsController - -Admin::EppLogsController - - -Admin::LegalDocumentsController - -Admin::LegalDocumentsController - - -ApplicationController - -ApplicationController - - -Registrar::DomainsController - -Registrar::DomainsController - - -Registrar::SessionsController - -Registrar::SessionsController - - -Registrar::PollsController - -Registrar::PollsController - - -Registrar::DepositsController - -Registrar::DepositsController - - -Registrar::ContactsController - -Registrar::ContactsController - - -Registrar::DeppController - -Registrar::DeppController - - -Registrar::NameserversController - -Registrar::NameserversController - - -Registrar::XmlConsolesController - -Registrar::XmlConsolesController - - -Registrar::InvoicesController - -Registrar::InvoicesController - - -Registrar::AccountActivitiesController - -Registrar::AccountActivitiesController - - -Registrant::DomainsController - -Registrant::DomainsController - - -Registrant::SessionsController - -Registrant::SessionsController - - -Registrant::DomainUpdateConfirmsController - -Registrant::DomainUpdateConfirmsController - - -Registrant::WhoisController - -Registrant::WhoisController - - -Registrant::DomainDeleteConfirmsController - -Registrant::DomainDeleteConfirmsController - - - diff --git a/doc/controllers_complete.svg b/doc/controllers_complete.svg deleted file mode 100644 index 892593e1a..000000000 --- a/doc/controllers_complete.svg +++ /dev/null @@ -1,614 +0,0 @@ - - - - - - -controllers_diagram - - -_diagram_info -Controllers diagram -Date: Jul 08 2015 - 13:40 -Migration version: 20150707103801 -Generated by RailRoady 1.3.0 -http://railroady.prestonlee.com - - -RegistrantController - -RegistrantController - -head_title_sufix - - -_layout - - -Epp::DomainsController - -Epp::DomainsController - -check -create -delete -info -renew -transfer -update - - -_layout -balance_ok? -find_domain -find_password -status_editing_disabled -validate_check -validate_create -validate_delete -validate_info -validate_renew -validate_transfer -validate_update - - -Epp::SessionsController - -Epp::SessionsController - -hello -ip_white? -login -login_params -logout -parsed_frame - - -_layout - - -Epp::PollsController - -Epp::PollsController - -poll - - -_layout -validate_poll - - -Epp::ContactsController - -Epp::ContactsController - -check -create -delete -info -renew -update - - -_layout -contact_org_disabled -fax_disabled -find_contact -find_password -status_editing_disabled -validate_check -validate_create -validate_delete -validate_info -validate_update - - -Epp::ErrorsController - -Epp::ErrorsController - -error - - -_layout - - -RegistrarController - -RegistrarController - - - -_layout - - -Admin::DomainsController - -Admin::DomainsController - -edit -index -set_force_delete -show -unset_force_delete -update - - -_layout -build_associations -domain_params -ignore_empty_statuses -set_domain - - -Admin::DelayedJobsController - -Admin::DelayedJobsController - -index - - -_layout - - -Admin::WhiteIpsController - -Admin::WhiteIpsController - -create -destroy -edit -new -show -update - - -_layout -set_registrar -white_ip_params - - -Admin::ZonefilesController - -Admin::ZonefilesController - -create - - -_layout - - -Admin::SettingsController - -Admin::SettingsController - -create -index -show -update - - -_layout -casted_settings -set_setting_group -setting_group_params - - -Admin::ApiUsersController - -Admin::ApiUsersController - -create -destroy -edit -index -new -show -update - - -_layout -api_user_params -set_api_user - - -Admin::SessionsController - -Admin::SessionsController - -create -login - - -_layout - - -Admin::DomainVersionsController - -Admin::DomainVersionsController - -index - - -_layout - - -Admin::ContactsController - -Admin::ContactsController - -index -search - - -_layout -set_contact - - -Admin::CertificatesController - -Admin::CertificatesController - -create -destroy -download_crt -download_csr -new -revoke -show -sign - - -_layout -certificate_params -set_api_user -set_certificate - - -Admin::BankStatementsController - -Admin::BankStatementsController - -bind_invoices -create -create_from_import -download_import_file -import -index -new -show - - -_layout -bank_statement_params -set_bank_statement - - -Admin::BankTransactionsController - -Admin::BankTransactionsController - -bind -create -new -update - - -_layout -bank_transaction_params - - -Admin::BlockedDomainsController - -Admin::BlockedDomainsController - -create -index - - -_layout - - -Admin::DashboardsController - -Admin::DashboardsController - -show - - -_layout - - -Admin::RegistrarsController - -Admin::RegistrarsController - -create -destroy -edit -index -new -search -update - - -_layout -registrar_params -set_registrar - - -Admin::ReppLogsController - -Admin::ReppLogsController - -index -show - - -_layout - - -Admin::InvoicesController - -Admin::InvoicesController - -cancel -create -index -new -show - - -_layout -deposit_params - - -Admin::AdminUsersController - -Admin::AdminUsersController - -create -destroy -edit -index -new -show -update - - -_layout -admin_user_params -set_user - - -Admin::EppLogsController - -Admin::EppLogsController - -index -show - - -_layout - - -Admin::LegalDocumentsController - -Admin::LegalDocumentsController - -show - - -_layout - - -ApplicationController - -ApplicationController - - - -_layout - - -Registrar::DomainsController - -Registrar::DomainsController - -check -create -delete -destroy -edit -index -info -new -renew -transfer -update - - -_layout -init_contacts_autocomplete_map -init_domain - - -Registrar::SessionsController - -Registrar::SessionsController - -create -id -login -login_mid -mid -mid_status - - -_layout -role_base_root_url - - -Registrar::PollsController - -Registrar::PollsController - -confirm_transfer -destroy -show - - -_layout -init_epp_xml - - -Registrar::DepositsController - -Registrar::DepositsController - -create -new - - -_layout -deposit_params - - -Registrar::ContactsController - -Registrar::ContactsController - -create -delete -destroy -edit -index -new -show -update - - -_layout -init_epp_contact - - -Registrar::DeppController - -Registrar::DeppController - -authenticate_user -depp_controller? -depp_current_user -response_ok? - - -_layout - - -Registrar::NameserversController - -Registrar::NameserversController - - - -_layout - - -Registrar::XmlConsolesController - -Registrar::XmlConsolesController - -create -load_xml -show - - -_layout - - -Registrar::InvoicesController - -Registrar::InvoicesController - -cancel -download_pdf -forward -index -show - - -_layout -set_invoice - - -Registrar::AccountActivitiesController - -Registrar::AccountActivitiesController - -index - - -_layout - - -Registrant::DomainsController - -Registrant::DomainsController - -index - - -_layout - - -Registrant::SessionsController - -Registrant::SessionsController - -find_user_by_idc -id -login -login_mid -mid -mid_status - - -_layout - - -Registrant::DomainUpdateConfirmsController - -Registrant::DomainUpdateConfirmsController - -show -update - - -_layout - - -Registrant::WhoisController - -Registrant::WhoisController - -index - - -_layout - - -Registrant::DomainDeleteConfirmsController - -Registrant::DomainDeleteConfirmsController - -show -update - - -_layout - - - diff --git a/doc/models_brief.svg b/doc/models_brief.svg deleted file mode 100644 index 57012f0d5..000000000 --- a/doc/models_brief.svg +++ /dev/null @@ -1,1268 +0,0 @@ - - - - - - -models_diagram - - -_diagram_info -Models diagram -Date: Jul 08 2015 - 13:41 -Migration version: 20150707103801 -Generated by RailRoady 1.3.0 -http://railroady.prestonlee.com - - -WhoisRecord - -WhoisRecord - - -RegistrantUser - -RegistrantUser - - -UserVersion - -UserVersion - - -RegistrantUser->UserVersion - - - -versions - - -ReservedDomain - -ReservedDomain - - -ReservedDomainVersion - -ReservedDomainVersion - - -ReservedDomain->ReservedDomainVersion - - - -versions - - -WhiteIpVersion - -WhiteIpVersion - - -VersionAssociation - -VersionAssociation - - -WhiteIpVersion->VersionAssociation - - - - - -NameserverVersion - -NameserverVersion - - -NameserverVersion->VersionAssociation - - - - - -UserVersion->VersionAssociation - - - - - -DnskeyVersion - -DnskeyVersion - - -DnskeyVersion->VersionAssociation - - - - - -BlockedDomainVersion - -BlockedDomainVersion - - -BlockedDomainVersion->VersionAssociation - - - - - -SettingVersion - -SettingVersion - - -SettingVersion->VersionAssociation - - - - - -CertificateVersion - -CertificateVersion - - -CertificateVersion->VersionAssociation - - - - - -AccountVersion - -AccountVersion - - -AccountVersion->VersionAssociation - - - - - -MessageVersion - -MessageVersion - - -MessageVersion->VersionAssociation - - - - - -ReservedDomainVersion->VersionAssociation - - - - - -AccountActivityVersion - -AccountActivityVersion - - -AccountActivityVersion->VersionAssociation - - - - - -BankStatementVersion - -BankStatementVersion - - -BankStatementVersion->VersionAssociation - - - - - -DomainContactVersion - -DomainContactVersion - - -DomainContactVersion->VersionAssociation - - - - - -ContactVersion - -ContactVersion - - -ContactVersion->VersionAssociation - - - - - -BankTransactionVersion - -BankTransactionVersion - - -BankTransactionVersion->VersionAssociation - - - - - -InvoiceItemVersion - -InvoiceItemVersion - - -InvoiceItemVersion->VersionAssociation - - - - - -LegalDocumentVersion - -LegalDocumentVersion - - -LegalDocumentVersion->VersionAssociation - - - - - -RegistrarVersion - -RegistrarVersion - - -RegistrarVersion->VersionAssociation - - - - - -DomainVersion - -DomainVersion - - -DomainVersion->VersionAssociation - - - - - -InvoiceVersion - -InvoiceVersion - - -InvoiceVersion->VersionAssociation - - - - - -ApiUser - -ApiUser - - -ApiUser->UserVersion - - - -versions - - -Certificate - -Certificate - - -ApiUser->Certificate - - - - - -BankTransaction - -BankTransaction - - -BankTransaction->BankTransactionVersion - - - -versions - - -AccountActivity - -AccountActivity - - -BankTransaction->AccountActivity - - - - - -Dnskey - -Dnskey - - -Dnskey->DnskeyVersion - - - -versions - - -Dnskey->DnskeyVersion - - - -versions - - -Dnskey->DnskeyVersion - - - -versions - - -AdminDomainContact - -AdminDomainContact - - -AdminDomainContact->DomainContactVersion - - - -versions - - -Setting - -Setting - - -Setting->SettingVersion - - - -versions - - -Message - -Message - - -Message->MessageVersion - - - -versions - - -Contact - -Contact - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Domain - -Domain - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -ContactStatus - -ContactStatus - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -DomainContact - -DomainContact - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -LegalDocument - -LegalDocument - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -DomainTransfer - -DomainTransfer - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -TechDomainContact - -TechDomainContact - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Nameserver - -Nameserver - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -DomainStatus - -DomainStatus - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Ability - -Ability - - -Registrar - -Registrar - - -Registrar->WhoisRecord - - - - - -Registrar->WhoisRecord - - - - - -Registrar->RegistrarVersion - - - -versions - - -Registrar->RegistrarVersion - - - -versions - - -Registrar->ApiUser - - - - - -Registrar->ApiUser - - - - - -Registrar->Message - - - - - -Registrar->Message - - - - - -Registrar->Contact - - - - - -Registrar->Contact - - - - - -Registrar->Domain - - - - - -Registrar->Domain - - - - - -Account - -Account - - -Registrar->Account - - - - - -Registrar->Account - - - - - -Registrar->Nameserver - - - - - -Registrar->Nameserver - - - - - -Invoice - -Invoice - - -Registrar->Invoice - - - - - -Registrar->Invoice - - - - - -WhiteIp - -WhiteIp - - -Registrar->WhiteIp - - - - - -Registrar->WhiteIp - - - - - -BlockedDomain - -BlockedDomain - - -BlockedDomain->BlockedDomainVersion - - - -versions - - -User - -User - - -User->UserVersion - - - -versions - - -User->UserVersion - - - -versions - - -RegistrantVerification - -RegistrantVerification - - -TechDomainContact->DomainContactVersion - - - -versions - - -AccountActivity->AccountActivityVersion - - - -versions - - -Account->AccountVersion - - - -versions - - -Account->AccountActivity - - - - - -EppSession - -EppSession - - -InvoiceItem - -InvoiceItem - - -InvoiceItem->InvoiceItemVersion - - - -versions - - -Nameserver->NameserverVersion - - - -versions - - -Deposit - -Deposit - - -Certificate->CertificateVersion - - - -versions - - -Object - -Object - - -Invoice->InvoiceVersion - - - -versions - - -Invoice->InvoiceVersion - - - -versions - - -Invoice->AccountActivity - - - - - -Invoice->AccountActivity - - - - - -Invoice->InvoiceItem - - - - - -Invoice->InvoiceItem - - - - - -BankStatement - -BankStatement - - -BankStatement->BankStatementVersion - - - -versions - - -BankStatement->BankTransaction - - - - - -DomainContact->DomainContactVersion - - - -versions - - -Registrant - -Registrant - - -Registrant->ContactVersion - - - -versions - - -Registrant->Domain - - - - - -Registrant->Domain - - - -registrant_domains - - -Registrant->ContactStatus - - - -statuses - - -Registrant->DomainContact - - - - - -Registrant->LegalDocument - - - - - -WhiteIp->WhiteIpVersion - - - -versions - - -AdminUser - -AdminUser - - -AdminUser->UserVersion - - - -versions - - -LegalDocument->LegalDocumentVersion - - - -versions - - - diff --git a/doc/models_complete.svg b/doc/models_complete.svg deleted file mode 100644 index c41283153..000000000 --- a/doc/models_complete.svg +++ /dev/null @@ -1,1982 +0,0 @@ - - - - - - -models_diagram - - -_diagram_info -Models diagram -Date: Jul 08 2015 - 13:42 -Migration version: 20150707103801 -Generated by RailRoady 1.3.0 -http://railroady.prestonlee.com - - -WhoisRecord - -WhoisRecord - -id :integer -domain_id :integer -name :string -body :text -json :json -created_at :datetime -updated_at :datetime -registrar_id :integer - - -RegistrantUser - -RegistrantUser - -id :integer -username :string -password :string -created_at :datetime -updated_at :datetime -email :string -sign_in_count :integer -current_sign_in_at :datetime -last_sign_in_at :datetime -current_sign_in_ip :inet -last_sign_in_ip :inet -identity_code :string -roles :string -creator_str :string -updator_str :string -country_code :string -registrar_id :integer -active :boolean -type :string -registrant_ident :string -encrypted_password :string -remember_created_at :datetime -failed_attempts :integer -locked_at :datetime - - -UserVersion - -UserVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -RegistrantUser->UserVersion - - - -versions - - -ReservedDomain - -ReservedDomain - -id :integer -name :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -ReservedDomainVersion - -ReservedDomainVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -ReservedDomain->ReservedDomainVersion - - - -versions - - -WhiteIpVersion - -WhiteIpVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -VersionAssociation - -VersionAssociation - - -WhiteIpVersion->VersionAssociation - - - - - -NameserverVersion - -NameserverVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -NameserverVersion->VersionAssociation - - - - - -UserVersion->VersionAssociation - - - - - -DnskeyVersion - -DnskeyVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -DnskeyVersion->VersionAssociation - - - - - -BlockedDomainVersion - -BlockedDomainVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -BlockedDomainVersion->VersionAssociation - - - - - -SettingVersion - -SettingVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -SettingVersion->VersionAssociation - - - - - -CertificateVersion - -CertificateVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -CertificateVersion->VersionAssociation - - - - - -AccountVersion - -AccountVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -AccountVersion->VersionAssociation - - - - - -MessageVersion - -MessageVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -MessageVersion->VersionAssociation - - - - - -ReservedDomainVersion->VersionAssociation - - - - - -AccountActivityVersion - -AccountActivityVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -AccountActivityVersion->VersionAssociation - - - - - -BankStatementVersion - -BankStatementVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -BankStatementVersion->VersionAssociation - - - - - -DomainContactVersion - -DomainContactVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -DomainContactVersion->VersionAssociation - - - - - -ContactVersion - -ContactVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -ContactVersion->VersionAssociation - - - - - -BankTransactionVersion - -BankTransactionVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -BankTransactionVersion->VersionAssociation - - - - - -InvoiceItemVersion - -InvoiceItemVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -InvoiceItemVersion->VersionAssociation - - - - - -LegalDocumentVersion - -LegalDocumentVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -LegalDocumentVersion->VersionAssociation - - - - - -RegistrarVersion - -RegistrarVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -RegistrarVersion->VersionAssociation - - - - - -DomainVersion - -DomainVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -nameserver_ids :text -tech_contact_ids :text -admin_contact_ids :text -session :string -children :json - - -DomainVersion->VersionAssociation - - - - - -InvoiceVersion - -InvoiceVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -InvoiceVersion->VersionAssociation - - - - - -ApiUser - -ApiUser - -id :integer -username :string -password :string -created_at :datetime -updated_at :datetime -email :string -sign_in_count :integer -current_sign_in_at :datetime -last_sign_in_at :datetime -current_sign_in_ip :inet -last_sign_in_ip :inet -identity_code :string -roles :string -creator_str :string -updator_str :string -country_code :string -registrar_id :integer -active :boolean -type :string -registrant_ident :string -encrypted_password :string -remember_created_at :datetime -failed_attempts :integer -locked_at :datetime - - -ApiUser->UserVersion - - - -versions - - -Certificate - -Certificate - -id :integer -api_user_id :integer -csr :text -crt :text -creator_str :string -updator_str :string -created_at :datetime -updated_at :datetime -common_name :string -md5 :string -interface :string - - -ApiUser->Certificate - - - - - -BankTransaction - -BankTransaction - -id :integer -bank_statement_id :integer -bank_reference :string -iban :string -currency :string -buyer_bank_code :string -buyer_iban :string -buyer_name :string -document_no :string -description :string -sum :decimal -reference_no :string -paid_at :datetime -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -BankTransaction->BankTransactionVersion - - - -versions - - -AccountActivity - -AccountActivity - -id :integer -account_id :integer -invoice_id :integer -sum :decimal -currency :string -bank_transaction_id :integer -created_at :datetime -updated_at :datetime -description :string -creator_str :string -updator_str :string -activity_type :string - - -BankTransaction->AccountActivity - - - - - -Dnskey - -Dnskey - -id :integer -domain_id :integer -flags :integer -protocol :integer -alg :integer -public_key :text -delegation_signer_id :integer -ds_key_tag :string -ds_alg :integer -ds_digest_type :integer -ds_digest :string -creator_str :string -updator_str :string -legacy_domain_id :integer - - -Dnskey->DnskeyVersion - - - -versions - - -Dnskey->DnskeyVersion - - - -versions - - -Dnskey->DnskeyVersion - - - -versions - - -AdminDomainContact - -AdminDomainContact - -id :integer -contact_id :integer -domain_id :integer -created_at :datetime -updated_at :datetime -contact_code_cache :string -creator_str :string -updator_str :string -type :string -legacy_domain_id :integer -legacy_contact_id :integer - - -AdminDomainContact->DomainContactVersion - - - -versions - - -Setting - -Setting - -id :integer -var :string -value :text -thing_id :integer -thing_type :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -Setting->SettingVersion - - - -versions - - -Message - -Message - -id :integer -registrar_id :integer -body :string -attached_obj_type :string -attached_obj_id :string -queued :boolean -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -Message->MessageVersion - - - -versions - - -Contact - -Contact - -id :integer -code :string -phone :string -email :string -fax :string -created_at :datetime -updated_at :datetime -ident :string -ident_type :string -auth_info :string -name :string -org_name :string -registrar_id :integer -creator_str :string -updator_str :string -ident_country_code :string -city :string -street :text -zip :string -country_code :string -state :string -legacy_id :integer -statuses :string - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Contact->ContactVersion - - - -versions - - -Domain - -Domain - -id :integer -name :string -registrar_id :integer -registered_at :datetime -status :string -valid_to :datetime -registrant_id :integer -transfer_code :string -created_at :datetime -updated_at :datetime -name_dirty :string -name_puny :string -period :integer -period_unit :string -creator_str :string -updator_str :string -legacy_id :integer -legacy_registrar_id :integer -legacy_registrant_id :integer -outzone_at :datetime -delete_at :datetime -registrant_verification_asked_at :datetime -registrant_verification_token :string -pending_json :json -force_delete_at :datetime -statuses :string - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -Contact->Domain - - - - - -Contact->Domain - - - -registrant_domains - - -ContactStatus - -ContactStatus - -id :integer -value :string -description :string -contact_id :integer -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -Contact->ContactStatus - - - -statuses - - -DomainContact - -DomainContact - -id :integer -contact_id :integer -domain_id :integer -created_at :datetime -updated_at :datetime -contact_code_cache :string -creator_str :string -updator_str :string -type :string -legacy_domain_id :integer -legacy_contact_id :integer - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -Contact->DomainContact - - - - - -LegalDocument - -LegalDocument - -id :integer -document_type :string -documentable_id :integer -documentable_type :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string -path :string - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Contact->LegalDocument - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->WhoisRecord - - - - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->DomainVersion - - - -versions - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->Dnskey - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->AdminDomainContact - - - - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -Domain->Contact - - - -admin_contacts - - -Domain->Contact - - - -tech_contacts - - -DomainTransfer - -DomainTransfer - -id :integer -domain_id :integer -status :string -transfer_requested_at :datetime -transferred_at :datetime -old_registrar_id :integer -new_registrar_id :integer -created_at :datetime -updated_at :datetime -wait_until :datetime -creator_str :string -updator_str :string - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -Domain->DomainTransfer - - - - - -TechDomainContact - -TechDomainContact - -id :integer -contact_id :integer -domain_id :integer -created_at :datetime -updated_at :datetime -contact_code_cache :string -creator_str :string -updator_str :string -type :string -legacy_domain_id :integer -legacy_contact_id :integer - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Domain->TechDomainContact - - - - - -Nameserver - -Nameserver - -id :integer -hostname :string -ipv4 :string -created_at :datetime -updated_at :datetime -ipv6 :string -domain_id :integer -creator_str :string -updator_str :string -legacy_domain_id :integer - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->Nameserver - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -Domain->DomainContact - - - - - -DomainStatus - -DomainStatus - -id :integer -domain_id :integer -description :string -value :string -creator_str :string -updator_str :string -legacy_domain_id :integer - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->DomainStatus - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Domain->LegalDocument - - - - - -Ability - -Ability - - - - -Registrar - -Registrar - -id :integer -name :string -reg_no :string -vat_no :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string -phone :string -email :string -billing_email :string -country_code :string -state :string -city :string -street :string -zip :string -code :string -url :string -legacy_id :integer -reference_no :string - - -Registrar->WhoisRecord - - - - - -Registrar->WhoisRecord - - - - - -Registrar->RegistrarVersion - - - -versions - - -Registrar->RegistrarVersion - - - -versions - - -Registrar->ApiUser - - - - - -Registrar->ApiUser - - - - - -Registrar->Message - - - - - -Registrar->Message - - - - - -Registrar->Contact - - - - - -Registrar->Contact - - - - - -Registrar->Domain - - - - - -Registrar->Domain - - - - - -Account - -Account - -id :integer -registrar_id :integer -account_type :string -balance :decimal -created_at :datetime -updated_at :datetime -currency :string -creator_str :string -updator_str :string - - -Registrar->Account - - - - - -Registrar->Account - - - - - -Registrar->Nameserver - - - - - -Registrar->Nameserver - - - - - -Invoice - -Invoice - -id :integer -created_at :datetime -updated_at :datetime -due_date :datetime -payment_term :string -currency :string -description :string -reference_no :string -vat_rate :decimal -paid_at :datetime -seller_id :integer -seller_name :string -seller_reg_no :string -seller_iban :string -seller_bank :string -seller_swift :string -seller_vat_no :string -seller_country_code :string -seller_state :string -seller_street :string -seller_city :string -seller_zip :string -seller_phone :string -seller_url :string -seller_email :string -seller_contact_name :string -buyer_id :integer -buyer_name :string -buyer_reg_no :string -buyer_country_code :string -buyer_state :string -buyer_street :string -buyer_city :string -buyer_zip :string -buyer_phone :string -buyer_url :string -buyer_email :string -creator_str :string -updator_str :string -number :integer -cancelled_at :datetime -total :decimal - - -Registrar->Invoice - - - - - -Registrar->Invoice - - - - - -WhiteIp - -WhiteIp - -id :integer -registrar_id :integer -ipv4 :string -ipv6 :string -interface :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -Registrar->WhiteIp - - - - - -Registrar->WhiteIp - - - - - -BlockedDomain - -BlockedDomain - -id :integer -names :string -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -BlockedDomain->BlockedDomainVersion - - - -versions - - -User - -User - -id :integer -username :string -password :string -created_at :datetime -updated_at :datetime -email :string -sign_in_count :integer -current_sign_in_at :datetime -last_sign_in_at :datetime -current_sign_in_ip :inet -last_sign_in_ip :inet -identity_code :string -roles :string -creator_str :string -updator_str :string -country_code :string -registrar_id :integer -active :boolean -type :string -registrant_ident :string -encrypted_password :string -remember_created_at :datetime -failed_attempts :integer -locked_at :datetime - - -User->UserVersion - - - -versions - - -User->UserVersion - - - -versions - - -RegistrantVerification - -RegistrantVerification - -id :integer -domain_name :string -verification_token :string -created_at :datetime -updated_at :datetime -action :string -domain_id :integer -action_type :string - - -TechDomainContact->DomainContactVersion - - - -versions - - -AccountActivity->AccountActivityVersion - - - -versions - - -Account->AccountVersion - - - -versions - - -Account->AccountActivity - - - - - -EppSession - -EppSession - -id :integer -session_id :string -data :text -created_at :datetime -updated_at :datetime -registrar_id :integer - - -InvoiceItem - -InvoiceItem - -id :integer -invoice_id :integer -description :string -unit :string -amount :integer -price :decimal -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -InvoiceItem->InvoiceItemVersion - - - -versions - - -Nameserver->NameserverVersion - - - -versions - - -Deposit - -Deposit - - - - -Certificate->CertificateVersion - - - -versions - - -Object - -Object - - - - -Invoice->InvoiceVersion - - - -versions - - -Invoice->InvoiceVersion - - - -versions - - -Invoice->AccountActivity - - - - - -Invoice->AccountActivity - - - - - -Invoice->InvoiceItem - - - - - -Invoice->InvoiceItem - - - - - -BankStatement - -BankStatement - -id :integer -bank_code :string -iban :string -import_file_path :string -queried_at :datetime -created_at :datetime -updated_at :datetime -creator_str :string -updator_str :string - - -BankStatement->BankStatementVersion - - - -versions - - -BankStatement->BankTransaction - - - - - -DomainContact->DomainContactVersion - - - -versions - - -Registrant - -Registrant - -id :integer -code :string -phone :string -email :string -fax :string -created_at :datetime -updated_at :datetime -ident :string -ident_type :string -auth_info :string -name :string -org_name :string -registrar_id :integer -creator_str :string -updator_str :string -ident_country_code :string -city :string -street :text -zip :string -country_code :string -state :string -legacy_id :integer -statuses :string - - -Registrant->ContactVersion - - - -versions - - -Registrant->Domain - - - - - -Registrant->Domain - - - -registrant_domains - - -Registrant->ContactStatus - - - -statuses - - -Registrant->DomainContact - - - - - -Registrant->LegalDocument - - - - - -WhiteIp->WhiteIpVersion - - - -versions - - -AdminUser - -AdminUser - -id :integer -username :string -password :string -created_at :datetime -updated_at :datetime -email :string -sign_in_count :integer -current_sign_in_at :datetime -last_sign_in_at :datetime -current_sign_in_ip :inet -last_sign_in_ip :inet -identity_code :string -roles :string -creator_str :string -updator_str :string -country_code :string -registrar_id :integer -active :boolean -type :string -registrant_ident :string -encrypted_password :string -remember_created_at :datetime -failed_attempts :integer -locked_at :datetime - - -AdminUser->UserVersion - - - -versions - - -LegalDocument->LegalDocumentVersion - - - -versions - - - diff --git a/doc/patches/mod_epp_1.10-frame-size.patch b/doc/patches/mod_epp_1.10-frame-size.patch deleted file mode 100644 index aa346b5c7..000000000 --- a/doc/patches/mod_epp_1.10-frame-size.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- mod_epp.h 2015-03-27 15:30:20.027130050 +0200 -+++ mod_epp_new.h 2015-03-27 15:30:38.499130269 +0200 -@@ -60,7 +60,7 @@ - #endif - - #define EPP_TCP_HEADER_SIZE 4 /* just one longword */ --#define EPP_MAX_FRAME_SIZE 65536 /* don't accept larger xml data blocks */ -+#define EPP_MAX_FRAME_SIZE 15728640 /* don't accept larger xml data blocks (8MB + 30% base64 + xml + savings)*/ - #define TRIDSIZE 128 /* actually, it should be 3 to 64 chars, - but due to unicode we'll give it more room. */ - diff --git a/doc/patches/mod_epp_1.10-rack-friendly.patch b/doc/patches/mod_epp_1.10-rack-friendly.patch deleted file mode 100644 index 648477da0..000000000 --- a/doc/patches/mod_epp_1.10-rack-friendly.patch +++ /dev/null @@ -1,37 +0,0 @@ - mod_epp.c | 2 +- - mod_epp.h | 8 ++++---- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/mod_epp.c b/mod_epp.c -index 8b1ba6f..66e46d8 100644 ---- a/mod_epp.c -+++ b/mod_epp.c -@@ -756,7 +756,7 @@ sprintf(content_length, "%lu", strlen(EPP_CONTENT_FRAME_CGI) - strlen(conf->raw_frame) - + er->orig_xml_size) : 0)); - --apr_table_set(r->headers_in, "Content-Type", "multipart/form-data; boundary=--BOUNDARY--"); -+apr_table_set(r->headers_in, "Content-Type", EPP_CONTENT_TYPE_CGI); - apr_table_set(r->headers_in, "Content-Length", content_length); - apr_table_set(r->headers_in, "Cookie", er->ur->cookie); - -diff --git a/mod_epp.h b/mod_epp.h -index e72d980..5e99bad 100644 ---- a/mod_epp.h -+++ b/mod_epp.h -@@ -96,10 +96,10 @@ module AP_MODULE_DECLARE_DATA epp_module; - #define EPP_DEFAULT_RC_HEADER "X-EPP-Returncode" - - --#define EPP_CONTENT_TYPE_CGI "multipart/form-data; boundary=--BOUNDARY--" --#define EPP_CONTENT_FRAME_CGI "----BOUNDARY--\r\nContent-Disposition: form-data; name=\"frame\"\r\n\r\n" --#define EPP_CONTENT_RAW_CGI "\r\n----BOUNDARY--\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n" --#define EPP_CONTENT_CLTRID_CGI "\r\n----BOUNDARY--\r\nContent-Disposition: form-data; name=\"clTRID\"\r\n\r\n" -+#define EPP_CONTENT_TYPE_CGI "multipart/form-data; boundary=--BOUNDARY" -+#define EPP_CONTENT_FRAME_CGI "----BOUNDARY\r\nContent-Disposition: form-data; name=\"frame\"\r\n\r\n" -+#define EPP_CONTENT_RAW_CGI "\r\n----BOUNDARY\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n" -+#define EPP_CONTENT_CLTRID_CGI "\r\n----BOUNDARY\r\nContent-Disposition: form-data; name=\"clTRID\"\r\n\r\n" - #define EPP_CONTENT_POSTFIX_CGI "\r\n----BOUNDARY--\r\n" - - /* - diff --git a/doc/registrant-api/v1/companies.md b/doc/registrant-api/v1/companies.md new file mode 100644 index 000000000..2804a63c8 --- /dev/null +++ b/doc/registrant-api/v1/companies.md @@ -0,0 +1,34 @@ +## GET /api/v1/registrant/companies +Returns list of companies registered in business register for the current registrant. + + +#### Parameters + +| Field name | Required | Type | Allowed values | Description | +| ---------- | -------- | ---- | -------------- | ----------- | +| limit | false | Integer | [1..200] | How many companies to show | +| offset | false | Integer | | Company number to start at | + +#### Request +``` +GET /api/v1/registrant/companies?limit=1 HTTP/1.1 +Accept: application/json +Authorization: Bearer Z2l0bGFiOmdoeXQ5ZTRmdQ== +Content-Type: application/json +``` + +#### Response +``` +HTTP/1.1 200 +Content-Type: application/json + +{ + "companies":[ + { + "name":"ACME Ltd", + "registry_no":"37605030299", + "country_code":"EE" + } + ] +} +``` diff --git a/doc/testing.md b/doc/testing.md index 81f208edd..efa534887 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -1,4 +1,4 @@ -Testing +Testing local project without docker container ------- Setup test databases: @@ -10,108 +10,17 @@ Run basic test (no EPP tests): rake -Testing EPP -=========== +Testing using docker container +------- -In order to test EPP, you have to configure apache to handle EPP request correctly. +It's strongly recommended to test/debug registry application using docker containers from https://github.com/internetee/docker-images . +For doing so first setup containers as per docker images documentation (https://github.com/internetee/docker-images/blob/master/README.MD), then in docker images directory run the following: -### Apache site config + docker-compose run registry bundle exec rake RAILS_ENV=test COVERAGE=true -First you should have mod_epp installed, please follow main README for doing it. - -Apache site config for autotest, add file to /etc/apache2/sites-enabled/epp-autotest.conf - -```apache - - Listen 701 - - SSLEngine on - SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL - SSLCertificateFile /etc/apache2/ssl/apache.crt - SSLCertificateKeyFile /etc/apache2/ssl/apache.key - - SSLVerifyClient optional_no_ca - - EPPEngine On - EPPCommandRoot /proxy/command - EPPSessionRoot /proxy/session - EPPErrorRoot /proxy/error - EPPRawFrame raw_frame - - ProxyPass /proxy/ http://localhost:8989/epp/ - - EPPAuthURI implicit - EPPReturncodeHeader X-EPP-Returncode - - -``` - - - -* Run all tests with temp server running automatically on port 8989: - - rake test - - -Manual debugging -================ - -### Apache mod_epp manual debugging - -Debugging Apache mod_epp without Registry app. - - sudo apt-get install apache2-dbg - -Includes htpasswd command to generate authentication files - - sudo apt-get install apache2-utils - -For manual debugging purposes, standalone CGI scripts can be used: -This needs a static greeting file, so you will have to make /var/www writable. - -```apache - - - Options ExecCGI - SetHandler cgi-script - - - Listen 1700 - - - EPPEngine On - EPPCommandRoot /cgi-bin/epp/command - EPPSessionRoot /cgi-bin/epp/session - EPPErrorRoot /cgi-bin/epp/error - - Alias /cgi-bin/epp/session/hello /var/www/html/epp/session-hello - - Alias /cgi-bin/epp/session/login /usr/lib/cgi-bin/epp/session-login - Alias /cgi-bin/epp/session/logout /usr/lib/cgi-bin/epp/session-logout - Alias /cgi-bin/epp/error/schema /usr/lib/cgi-bin/epp/error-schema - Alias /cgi-bin/epp/command/create /usr/lib/cgi-bin/epp/create - Alias /cgi-bin/epp/command/info /usr/lib/cgi-bin/epp/info - - EPPAuthURI /epp/auth/login - - AuthType Basic - AuthName "EPP" - AuthUserFile /etc/apache2/htpasswd - require valid-user - - - -``` - - sudo a2enmod cgi - sudo a2enmod authn_file # will be used for non implicit authentication URIs - sudo htpasswd -c /etc/apache2/htpasswd test - Type "test" when prompted - cd /usr/lib/cgi-bin - mkdir epp - -Copy the files from $mod_epp/examples/cgis to /usr/lib/cgi-bin/epp +To run single test: + docker-compose run registry bundle exec rails test RAILS_ENV=test COVERAGE=true Allowed testing email list ========================== diff --git a/lib/devise/models/id_card_authenticatable.rb b/lib/devise/models/id_card_authenticatable.rb deleted file mode 100644 index 53bad663f..000000000 --- a/lib/devise/models/id_card_authenticatable.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Devise - module Models - # Devise fails without this module (and model: false does not help) - module IdCardAuthenticatable - end - end -end \ No newline at end of file diff --git a/lib/devise/strategies/id_card_authenticatable.rb b/lib/devise/strategies/id_card_authenticatable.rb deleted file mode 100644 index ec26bb4d9..000000000 --- a/lib/devise/strategies/id_card_authenticatable.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Devise - module Strategies - class IdCardAuthenticatable < Devise::Strategies::Authenticatable - def valid? - env['SSL_CLIENT_S_DN_CN'].present? - end - - def authenticate! - resource = mapping.to - user = resource.find_by_id_card(id_card) - - if user - success!(user) - else - fail - end - end - - private - - def id_card - id_card = IdCard.new - id_card.first_name = first_name - id_card.last_name = last_name - id_card.personal_code = personal_code - id_card.country_code = country_code - id_card - end - - def first_name - env['SSL_CLIENT_S_DN_CN'].split(',').second.force_encoding('utf-8') - end - - def last_name - env['SSL_CLIENT_S_DN_CN'].split(',').first.force_encoding('utf-8') - end - - def personal_code - env['SSL_CLIENT_S_DN_CN'].split(',').last - end - - def country_code - env['SSL_CLIENT_I_DN_C'] - end - end - end -end - -Warden::Strategies.add(:id_card_authenticatable, Devise::Strategies::IdCardAuthenticatable) \ No newline at end of file diff --git a/lib/serializers/registrant_api/company.rb b/lib/serializers/registrant_api/company.rb new file mode 100644 index 000000000..d0d914cd7 --- /dev/null +++ b/lib/serializers/registrant_api/company.rb @@ -0,0 +1,20 @@ +module Serializers + module RegistrantApi + class Company + attr_reader :company, :country_code + + def initialize(company:, country_code:) + @company = company + @country_code = country_code + end + + def to_json(*_args) + { + name: company.company_name, + registry_no: company.registration_number, + country_code: @country_code, + } + end + end + end +end diff --git a/lib/tasks/invoices/process_payments.rake b/lib/tasks/invoices/process_payments.rake index 3e02a8838..edf6609b9 100644 --- a/lib/tasks/invoices/process_payments.rake +++ b/lib/tasks/invoices/process_payments.rake @@ -23,6 +23,9 @@ namespace :invoices do end if incoming_transactions.any? + log 'Got incoming transactions' + log incoming_transactions + bank_statement = BankStatement.new(bank_code: Setting.registry_bank_code, iban: Setting.registry_iban) @@ -41,8 +44,15 @@ namespace :invoices do transaction.autobind_invoice end end + else + log 'Got no incoming transactions parsed, aborting' end puts "Transactions processed: #{incoming_transactions.size}" end + + def log(msg) + @log ||= Logger.new(STDOUT) + @log.info(msg) + end end diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 0173d56dd..4d45738bd 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -78,6 +78,18 @@ identical_to_william: auth_info: 5ab865 uuid: c0a191d5-3793-4f0b-8f85-491612d0293e +registrar_ltd: + name: Registrar Ltd + email: registrar@inbox.test + phone: '+555.555' + ident: 1234567890 + ident_type: org + registrar: goodnames + ident_country_code: US + code: registrarltd-001 + auth_info: e2c441 + uuid: 28b65455-6f1a-49fd-961c-0758886dbd76 + invalid: name: any code: invalid diff --git a/test/integration/api/registrant/registrant_api_companies_test.rb b/test/integration/api/registrant/registrant_api_companies_test.rb new file mode 100644 index 000000000..4f23aeac1 --- /dev/null +++ b/test/integration/api/registrant/registrant_api_companies_test.rb @@ -0,0 +1,44 @@ +$VERBOSE=nil +require 'test_helper' +require 'auth_token/auth_token_creator' + +class RegistrantApiCompaniesTest < ApplicationIntegrationTest + def setup + super + + @contact = contacts(:john) + @user = users(:registrant) + @auth_headers = { 'HTTP_AUTHORIZATION' => auth_token } + end + + def test_accepts_limit_and_offset_parameters + contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US') + + get '/api/v1/registrant/companies', params: { 'limit' => 1, 'offset' => 0 }, + headers: @auth_headers + response_json = JSON.parse(response.body, symbolize_names: true) + assert_equal(200, response.status) + assert_equal(1, response_json.values.flatten.count) + + get '/api/v1/registrant/companies', headers: @auth_headers + response_json = JSON.parse(response.body, symbolize_names: true) + assert_equal(@user.companies.size, response_json.count) + end + + def test_format + contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US') + get '/api/v1/registrant/companies', headers: @auth_headers + response_json = JSON.parse(response.body, symbolize_names: true) + assert_equal(1, response_json.count) + assert response_json.is_a?(Hash) + assert_equal(:companies, response_json.keys.first) + end + + private + + def auth_token + token_creator = AuthTokenCreator.create_with_defaults(@user) + hash = token_creator.token_in_hash + "Bearer #{hash[:access_token]}" + end +end diff --git a/test/integration/api/registrant/registrant_api_contacts_test.rb b/test/integration/api/registrant/registrant_api_contacts_test.rb index af57c1c1a..191222764 100644 --- a/test/integration/api/registrant/registrant_api_contacts_test.rb +++ b/test/integration/api/registrant/registrant_api_contacts_test.rb @@ -12,7 +12,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest def test_root_accepts_limit_and_offset_parameters contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US') - assert_equal 4, @user.contacts.size + assert_equal 4, @user.contacts(representable: false).size get '/api/v1/registrant/contacts', params: { 'limit' => 1, 'offset' => 0 }, headers: @auth_headers @@ -22,7 +22,7 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest get '/api/v1/registrant/contacts', headers: @auth_headers response_json = JSON.parse(response.body, symbolize_names: true) - assert_equal(@user.contacts.size, response_json.count) + assert_equal(@user.contacts(representable: false).size, response_json.count) end def test_get_contact_details_by_uuid diff --git a/test/integration/api/v1/registrant/contacts/list_test.rb b/test/integration/api/v1/registrant/contacts/list_test.rb index a42aca694..2389019f1 100644 --- a/test/integration/api/v1/registrant/contacts/list_test.rb +++ b/test/integration/api/v1/registrant/contacts/list_test.rb @@ -35,7 +35,7 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token } response_json = JSON.parse(response.body, symbolize_names: true) - assert_equal @user.contacts.count, response_json.size + assert_equal @user.contacts(representable: false).count, response_json.size assert_includes response_json.map{ |hash| hash[:code] }, @contact.code end diff --git a/test/integration/epp/domain/renew/base_test.rb b/test/integration/epp/domain/renew/base_test.rb index 541aab2a8..9a61e1470 100644 --- a/test/integration/epp/domain/renew/base_test.rb +++ b/test/integration/epp/domain/renew/base_test.rb @@ -167,4 +167,36 @@ class EppDomainRenewBaseTest < EppTestCase end assert_epp_response :parameter_value_policy_error end + + def test_fails_if_domain_has_renewal_prohibited_statuses + travel_to Time.zone.parse('2010-07-05') + domain = domains(:shop) + domain.statuses << DomainStatus::SERVER_RENEW_PROHIBITED + domain.save + + original_valid_to = domain.valid_to + default_renewal_period = 1.year + + request_xml = <<-XML + + + + + + #{domain.name} + #{domain.expire_time.to_date} + 1 + + + + + XML + + post epp_renew_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + domain.reload + + assert_epp_response :object_status_prohibits_operation + assert_equal original_valid_to, domain.valid_to + end end diff --git a/test/integration/epp/login/credentials_test.rb b/test/integration/epp/login/credentials_test.rb index a62579766..0f7dac97c 100644 --- a/test/integration/epp/login/credentials_test.rb +++ b/test/integration/epp/login/credentials_test.rb @@ -31,7 +31,7 @@ class EppLoginCredentialsTest < EppTestCase end def test_already_logged_in - assert true # Handled by mod_epp + assert true # Handled by EPP proxy end def test_wrong_credentials diff --git a/test/integration/registrant_area/sign_in/id_card_test.rb b/test/integration/registrant_area/sign_in/id_card_test.rb deleted file mode 100644 index fe6c8a7ef..000000000 --- a/test/integration/registrant_area/sign_in/id_card_test.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'test_helper' - -class RegistrantAreaIdCardSignInTest < ApplicationIntegrationTest - setup do - allow_business_registry_component_reach_server - end - - def test_succeeds - post registrant_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234', - 'SSL_CLIENT_I_DN_C' => 'US' } - follow_redirect! - - assert_response :ok - assert_equal registrant_root_path, path - assert_not_nil controller.current_registrant_user - end - - def test_fails_when_certificate_is_absent - post registrant_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' } - - assert_response :ok - assert_equal registrant_id_card_sign_in_path, path - assert_nil controller.current_registrant_user - end - - private - - def allow_business_registry_component_reach_server - WebMock.allow_net_connect! - end -end \ No newline at end of file diff --git a/test/integration/registrar_area/sign_in/id_card_test.rb b/test/integration/registrar_area/sign_in/id_card_test.rb deleted file mode 100644 index 1441c90ca..000000000 --- a/test/integration/registrar_area/sign_in/id_card_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'test_helper' - -class RegistrarAreaIdCardSignInTest < ApplicationIntegrationTest - setup do - @user = users(:api_bestnames) - @original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled - end - - teardown do - Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist - end - - def test_signs_in_a_user_when_id_card_owner_is_found - assert_equal '1234', @user.identity_code - - post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234' } - follow_redirect! - - assert_response :ok - assert_equal registrar_root_path, path - assert_not_nil controller.current_registrar_user - end - - def test_does_not_sign_in_a_user_when_id_card_owner_is_not_found - post registrar_id_card_sign_in_path, - headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,unacceptable-personal-code' } - - assert_nil controller.current_registrar_user - assert_equal registrar_id_card_sign_in_path, path - assert_includes response.body, 'Failed to Login' - end - - def test_does_not_sign_in_a_user_when_id_card_owner_is_found_but_ip_is_not_allowed - allow_access_to_sign_in_page - assert_equal '127.0.0.1', white_ips(:one).ipv4 - assert_equal '1234', @user.identity_code - - Setting.registrar_ip_whitelist_enabled = true - - post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234', - 'REMOTE_ADDR' => '127.0.0.2' } - - assert_equal registrar_id_card_sign_in_path, path - assert_equal 'Access denied from IP 127.0.0.2', response.body - - get registrar_root_path - assert_redirected_to new_registrar_user_session_path - end - - def test_does_not_sign_in_a_user_when_certificate_is_absent - post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' } - - assert_nil controller.current_registrar_user - assert_equal registrar_id_card_sign_in_path, path - end - - private - - def allow_access_to_sign_in_page - another_registrar_white_ip = white_ips(:one).dup - another_registrar_white_ip.ipv4 = '127.0.0.2' - another_registrar_white_ip.registrar = registrars(:goodnames) - another_registrar_white_ip.save! - end -end \ No newline at end of file diff --git a/test/lib/devise/strategies/id_card_authenticatable_test.rb b/test/lib/devise/strategies/id_card_authenticatable_test.rb deleted file mode 100644 index e194ccaac..000000000 --- a/test/lib/devise/strategies/id_card_authenticatable_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'test_helper' - -class IdCardAuthenticatableTest < ActiveSupport::TestCase - def test_valid_when_id_card_data_is_present_in_env - strategy = Devise::Strategies::IdCardAuthenticatable.new({ 'SSL_CLIENT_S_DN_CN' => 'some' }) - assert strategy.valid? - end - - def test_not_valid_when_id_card_data_is_absent_in_env - strategy = Devise::Strategies::IdCardAuthenticatable.new({}) - assert_not strategy.valid? - end -end \ No newline at end of file diff --git a/test/mailers/domain_delete_mailer_test.rb b/test/mailers/domain_delete_mailer_test.rb index ae060921f..b65ba5d2e 100644 --- a/test/mailers/domain_delete_mailer_test.rb +++ b/test/mailers/domain_delete_mailer_test.rb @@ -73,7 +73,7 @@ class DomainDeleteMailerTest < ActionMailer::TestCase assert_emails 1 assert_equal ['legal@registry.test'], email.from - assert_equal @domain.force_delete_contact_emails, email.to + assert @domain.force_delete_contact_emails.sort == email.to.sort assert_equal 'Domeen shop.test on kustutusmenetluses' \ ' / Domain shop.test is in deletion process' \ ' / Домен shop.test в процессе удаления', email.subject diff --git a/test/models/api_user_test.rb b/test/models/api_user_test.rb index ecbff5cbb..525e6c264 100644 --- a/test/models/api_user_test.rb +++ b/test/models/api_user_test.rb @@ -52,17 +52,6 @@ class ApiUserTest < ActiveSupport::TestCase assert ApiUser.new.active? end - def test_finds_user_by_id_card - id_card = IdCard.new - id_card.personal_code = 'one' - - @user.update!(identity_code: 'one') - assert_equal @user, ApiUser.find_by_id_card(id_card) - - @user.update!(identity_code: 'another') - assert_nil ApiUser.find_by_id_card(id_card) - end - def test_verifies_pki_status certificate = certificates(:api) diff --git a/test/models/domain/force_delete_test.rb b/test/models/domain/force_delete_test.rb index e3818c484..ad91ccfec 100644 --- a/test/models/domain/force_delete_test.rb +++ b/test/models/domain/force_delete_test.rb @@ -242,4 +242,14 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase assert_not_includes(@domain.statuses, asserted_status) end + + def test_force_delete_does_not_affect_pending_update_check + @domain.schedule_force_delete(type: :soft) + @domain.reload + + @domain.statuses << DomainStatus::PENDING_UPDATE + + assert @domain.force_delete_scheduled? + assert @domain.pending_update? + end end diff --git a/test/models/domain_cron_test.rb b/test/models/domain_cron_test.rb index 5b3b0120e..0224b1a61 100644 --- a/test/models/domain_cron_test.rb +++ b/test/models/domain_cron_test.rb @@ -39,6 +39,21 @@ class DomainCronTest < ActiveSupport::TestCase assert_emails 1 end + def does_not_deliver_forced_email_if_template_empty + Setting.redemption_grace_period = 30 + + @domain.update(valid_to: Time.zone.parse('2012-08-05')) + assert_not @domain.force_delete_scheduled? + travel_to Time.zone.parse('2010-07-05') + @domain.schedule_force_delete(type: :soft) + @domain.reload + @domain.update(template_name: nil) + travel_to Time.zone.parse('2010-08-06') + DomainCron.start_client_hold + + assert_emails 0 + end + def test_does_not_sets_hold_if_already_set Setting.redemption_grace_period = 30 @@ -52,4 +67,26 @@ class DomainCronTest < ActiveSupport::TestCase assert_emails 0 end + + def test_cleans_expired_pendings_when_force_delete_active + Setting.expire_pending_confirmation = 0 + + # Set force delete + @domain.schedule_force_delete(type: :soft) + @domain.reload + + @domain.statuses << DomainStatus::PENDING_UPDATE + # Set domain registrant change that's expired + @domain.update!(registrant_verification_asked_at: Time.zone.now, + registrant_verification_token: 'test', + statuses: @domain.statuses) + + assert @domain.pending_update? + @domain.reload + + DomainCron.clean_expired_pendings + @domain.reload + + assert_not @domain.pending_update? + end end diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index b4a1d7b47..a943be6ef 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -431,6 +431,19 @@ class DomainTest < ActiveSupport::TestCase assert_equal created_at, domain.registered_at end + def test_not_renewable_if_renew_prohibited + assert @domain.renewable? + + @domain.statuses << DomainStatus::SERVER_RENEW_PROHIBITED + assert_not @domain.renewable? + + @domain.statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED) + assert @domain.renewable? + + @domain.statuses << DomainStatus::CLIENT_RENEW_PROHIBITED + assert_not @domain.renewable? + end + private def valid_domain diff --git a/test/models/registrant_user/registrant_user_creation_test.rb b/test/models/registrant_user/registrant_user_creation_test.rb index 42fb0e0f6..5ed680795 100644 --- a/test/models/registrant_user/registrant_user_creation_test.rb +++ b/test/models/registrant_user/registrant_user_creation_test.rb @@ -26,13 +26,4 @@ class RegistrantUserCreationTest < ActiveSupport::TestCase user = User.find_by(registrant_ident: 'EE-37710100070') assert_equal('JOHN SMITH', user.username) end - - def test_find_or_create_by_mid_data_creates_a_user - user_data = OpenStruct.new(user_country: 'EE', user_id_code: '37710100070', - user_givenname: 'JOHN', user_surname: 'SMITH') - - RegistrantUser.find_or_create_by_mid_data(user_data) - user = User.find_by(registrant_ident: 'EE-37710100070') - assert_equal('JOHN SMITH', user.username) - end end diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb index 78b9ef901..c61f095f2 100644 --- a/test/models/registrant_user_test.rb +++ b/test/models/registrant_user_test.rb @@ -30,34 +30,6 @@ class RegistrantUserTest < ActiveSupport::TestCase assert_equal Country.new('US'), user.country end - def test_finding_by_id_card_creates_new_user_upon_first_sign_in - assert_not_equal 'US-5555', @user.registrant_ident - id_card = IdCard.new - id_card.first_name = 'John' - id_card.last_name = 'Doe' - id_card.personal_code = '5555' - id_card.country_code = 'US' - - assert_difference 'RegistrantUser.count' do - RegistrantUser.find_by_id_card(id_card) - end - - user = RegistrantUser.last - assert_equal 'US-5555', user.registrant_ident - assert_equal 'John Doe', user.username - end - - def test_finding_by_id_card_reuses_existing_user_upon_subsequent_id_card_sign_ins - @user.update!(registrant_ident: 'US-5555') - id_card = IdCard.new - id_card.personal_code = '5555' - id_card.country_code = 'US' - - assert_no_difference 'RegistrantUser.count' do - RegistrantUser.find_by_id_card(id_card) - end - end - def test_queries_company_register_for_associated_companies assert_equal 'US-1234', @user.registrant_ident @@ -92,4 +64,4 @@ class RegistrantUserTest < ActiveSupport::TestCase assert_equal %w(shop airport), @user.administered_domains end end -end \ No newline at end of file +end diff --git a/test/system/registrant_area/domains/list_test.rb b/test/system/registrant_area/domains/list_test.rb index 805b130de..3cbf477da 100644 --- a/test/system/registrant_area/domains/list_test.rb +++ b/test/system/registrant_area/domains/list_test.rb @@ -28,6 +28,20 @@ class RegistrantAreaDomainListTest < ApplicationSystemTestCase assert_no_text 'metro.test' end + def test_only_shows_direct_relation_and_or_company_domains + # case https://github.com/internetee/registry/issues/1690 + tech_contact = contacts(:registrar_ltd) + + # All domains share the same tech contact object + Domain.all.each do |domain| + DomainContact.create(domain: domain, contact: tech_contact, type: TechDomainContact) + end + + visit registrant_domains_url + assert_no_text 'Company register is unavailable.' + assert_no_text 'metro.test' + end + def test_notification_when_company_register_is_unavailable CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do visit registrant_domains_url @@ -54,4 +68,4 @@ class RegistrantAreaDomainListTest < ApplicationSystemTestCase assert_text 'shop.test' end -end \ No newline at end of file +end diff --git a/test/system/registrant_area/tara/tara_users_test.rb b/test/system/registrant_area/tara/tara_users_test.rb new file mode 100644 index 000000000..5020616d4 --- /dev/null +++ b/test/system/registrant_area/tara/tara_users_test.rb @@ -0,0 +1,51 @@ +require 'application_system_test_case' + +class RegistrantAreaTaraUsersTest < ApplicationSystemTestCase + def setup + super + + OmniAuth.config.test_mode = true + @registrant = users(:registrant) + + @existing_user_hash = { + 'provider' => 'rant_tara', + 'uid' => "US1234", + 'info': { 'first_name': 'Registrant', 'last_name': 'User' } + } + + @new_user_hash = { + 'provider' => 'rant_tara', + 'uid' => 'EE51007050604', + 'info': { 'first_name': 'New Registrant', 'last_name': 'User'} + } + end + + def teardown + super + + OmniAuth.config.test_mode = false + OmniAuth.config.mock_auth['rant_tara'] = nil + end + + def test_existing_user_gets_signed_in + OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@existing_user_hash) + + visit new_registrant_user_session_path + click_link('Sign in') + + assert_text('Signed in successfully') + end + + def test_new_user_is_created_and_signed_in + OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@new_user_hash) + + assert_difference 'RegistrantUser.count' do + visit new_registrant_user_session_path + click_link('Sign in') + + assert_equal 'New Registrant User', RegistrantUser.last.username + assert_equal 'EE-51007050604', RegistrantUser.last.registrant_ident + assert_text('Signed in successfully') + end + end +end diff --git a/test/system/registrar_area/sign_in/mobile_id_test.rb b/test/system/registrar_area/sign_in/mobile_id_test.rb deleted file mode 100644 index 171172b2c..000000000 --- a/test/system/registrar_area/sign_in/mobile_id_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'application_system_test_case' - -class RegistrarAreaMobileIDSignInTest < JavaScriptApplicationSystemTestCase - def setup - super - WebMock.allow_net_connect! - - @user = users(:api_bestnames) - @user.identity_code = '1234' - @user.save - end - - def test_valid_phone_number - mock_client = Minitest::Mock.new - mock_client.expect(:authenticate, - OpenStruct.new(user_id_code: '1234', challenge_id: '1234'), - [{ phone: "+3721234", - message_to_display: "Authenticating", - service_name: "Testimine" }]) - mock_client.expect(:session_code, 1234) - - Digidoc::Client.stub(:new, mock_client) do - visit new_registrar_user_session_path - - click_on 'login-with-mobile-id-btn' - - fill_in 'user[phone]', with: '1234' - click_button 'Login' - - flash_message = page.find('div.bg-success') - assert_equal('Confirmation sms was sent to your phone. Verification code is 1234.', - flash_message.text) - end - end -end diff --git a/test/system/registrar_area/tara/tara_users_test.rb b/test/system/registrar_area/tara/tara_users_test.rb new file mode 100644 index 000000000..a2defd715 --- /dev/null +++ b/test/system/registrar_area/tara/tara_users_test.rb @@ -0,0 +1,45 @@ +require 'application_system_test_case' + +class TaraUsersTest < ApplicationSystemTestCase + def setup + super + + OmniAuth.config.test_mode = true + @user = users(:api_bestnames) + + @existing_user_hash = { + 'provider' => 'tara', + 'uid' => "EE" + @user.identity_code + } + + @new_user_hash = { + 'provider' => 'tara', + 'uid' => 'EE51007050604' + } + end + + def teardown + super + + OmniAuth.config.test_mode = false + OmniAuth.config.mock_auth['tara'] = nil + end + + def test_existing_user_gets_signed_in + OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@existing_user_hash) + + visit new_registrar_user_session_path + click_link('Sign in') + + assert_text('Signed in successfully') + end + + def test_nonexisting_user_gets_error_message + OmniAuth.config.mock_auth[:tara] = OmniAuth::AuthHash.new(@new_user_hash) + + visit new_registrar_user_session_path + click_link('Sign in') + + assert_text('No such user') + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6e1b10c88..459d4f8f5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -27,10 +27,10 @@ Rake::Task.clear Rails.application.load_tasks class CompanyRegisterClientStub - Company = Struct.new(:registration_number) + Company = Struct.new(:registration_number, :company_name) def representation_rights(citizen_personal_code:, citizen_country_code:) - [Company.new('1234567')] + [Company.new('1234567', 'ACME Ltd')] end end