From 2b7efa70a57e46a78d8f56e51f27867345d43cac Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 16 Oct 2017 09:09:53 +0300 Subject: [PATCH 01/16] Remove gitlab docker remnants --- doc/docker/apache2/epp-tester.conf | 18 ------------- doc/docker/apache2/epp.conf | 21 --------------- doc/docker/apache2/registry-test.conf | 39 --------------------------- doc/docker/apache2/registry.conf | 17 ------------ doc/docker/ssh/authorized_keys | 3 --- 5 files changed, 98 deletions(-) delete mode 100644 doc/docker/apache2/epp-tester.conf delete mode 100644 doc/docker/apache2/epp.conf delete mode 100644 doc/docker/apache2/registry-test.conf delete mode 100644 doc/docker/apache2/registry.conf delete mode 100755 doc/docker/ssh/authorized_keys diff --git a/doc/docker/apache2/epp-tester.conf b/doc/docker/apache2/epp-tester.conf deleted file mode 100644 index 140785385..000000000 --- a/doc/docker/apache2/epp-tester.conf +++ /dev/null @@ -1,18 +0,0 @@ -Listen 8888 - - ServerName registry.gitlab.eu - ServerAdmin info@gitlab.eu - - PassengerEnabled on - RailsEnv production - DocumentRoot /home/app/epp-tester/current/public - - ErrorLog /var/log/apache2/epp-tester.error.log - LogLevel info ssl:warn - CustomLog /var/log/apache2/epp-tester.access.log combined - - - Require all granted - Options -MultiViews - - diff --git a/doc/docker/apache2/epp.conf b/doc/docker/apache2/epp.conf deleted file mode 100644 index 33ef057aa..000000000 --- a/doc/docker/apache2/epp.conf +++ /dev/null @@ -1,21 +0,0 @@ - - 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 optional_no_ca - - EPPEngine On - EPPCommandRoot /proxy/command - EPPSessionRoot /proxy/session - EPPErrorRoot /proxy/error - - ProxyPass /proxy/ http://localhost:80/epp/ - - EPPAuthURI implicit - EPPReturncodeHeader X-EPP-Returncode - - diff --git a/doc/docker/apache2/registry-test.conf b/doc/docker/apache2/registry-test.conf deleted file mode 100644 index dc4b0cc26..000000000 --- a/doc/docker/apache2/registry-test.conf +++ /dev/null @@ -1,39 +0,0 @@ -Listen 81 - - ServerAdmin info@gitlab.eu - - PassengerEnabled on - RailsEnv test - DocumentRoot /home/app/registry-test/public - - ErrorLog /var/log/apache2/registry-test.error.log - LogLevel info ssl:warn - CustomLog /var/log/apache2/registry-test.access.log combined - - - Require all granted - Options -MultiViews - - - - - 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 - - ProxyPass /proxy/ http://localhost:81/epp/ - - EPPAuthURI implicit - EPPReturncodeHeader X-EPP-Returncode - - diff --git a/doc/docker/apache2/registry.conf b/doc/docker/apache2/registry.conf deleted file mode 100644 index b01ec745d..000000000 --- a/doc/docker/apache2/registry.conf +++ /dev/null @@ -1,17 +0,0 @@ - - ServerName registry.gitlab.eu - ServerAdmin info@gitlab.eu - - PassengerEnabled on - RailsEnv production - DocumentRoot /home/app/registry/current/public - - ErrorLog /var/log/apache2/registry.error.log - LogLevel info ssl:warn - CustomLog /var/log/apache2/registry.access.log combined - - - Require all granted - Options -MultiViews - - diff --git a/doc/docker/ssh/authorized_keys b/doc/docker/ssh/authorized_keys deleted file mode 100755 index 9266ca452..000000000 --- a/doc/docker/ssh/authorized_keys +++ /dev/null @@ -1,3 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAz+n4Sln0oxme+9hyrgPud9k0C00Nm0T2YufHcQUAdtJssCfeKp2qo/gy0LmOXTB8efyavFn4NW2GZs8gxJ0BV5GoHLmnERAWDOi/wg3KLl4r/ei+HQX6Po/V7WOMHWzKPSSGtqW7cZc1g0y2ci571ZUmgEBoGoGPfoQToGEn2yV4hQmHIjbwtfNNCHx/i12DCoJnD+3cIvhHf4FbZRBW9Wu0I24iqLcxLOAwGWVsnzi0OqN+rj3DenPQfjcPhSsmTu+8mn2AIwMxWeLZSslEYfyBeo9dLBntj3dnxWpw/MJEfMmWgWKGqMaVGB731ZWDOrRrzgl5+s24YBv9LyYWyQ== -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXF8qkkQg8We6c2eCRQTuQUAffuDcYijlnVNAH0V7eUMxKC/9aPIhHaM9JVY4exXDVEQOK0+KsF6twTtewK8XBFfHXcOV3k+11KOJ1LsfphQIbwS9Qufw2maxCWJHxQwKGViGLqePuecQhfQ3UAVXZ1ZO7qGrLB9JBlRimbItJsG3F2o1T7pJAMucf+zCv5KmMeeddDyhAg2ufQHnuPKIMAgr4XH/TD4mg5tqORXCdk/2apuqUz35WqAyRNt/J66bTJOJ39QJv50cyT6/Bb74MNfJSejsM5EUnKF4Nq7edR8F8tlnXmL/wvvVs81oHywCnMqP8eEISLumy1nhNpgbn martin@gitlab.eu -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC13V94raEKiCzg4sACsIFxiHPcRSUryUHxXpcyHMi7OJvTtszOPR3hZnB36c0NxnznD0t3rH2n5vIX+tBmX+JND7bvM+YKgTGcGN+HvS08nSsvwHLie/UAHkWy/4xFvyKnq8MIZtYxkPdIGph6hFMr5LljJu05V08hZF09HutBsjXw5wmZRUJoD/Jl0FO/pf6WxH1VHjhz0kGuM8VREU2SC8uzV1AIZ86zsaxJld1m0doyt+arnJkPYgjXHHpu/IWzIHYjbVo5W8JmYagDCYxaPHN7EesHAEzFi1LDtq1aIrqWrczKaJGSryxSba6pnYiK69MTojF/SAXMsJ1u5q1P andres.kesk@gmail.com From 6425828a8da89852d74bffca7c37fc3fe0f0edbc Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 16 Oct 2017 16:02:46 +0300 Subject: [PATCH 02/16] Clarify gem usage --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2f7587fc9..1c2032252 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,6 @@ source 'https://rubygems.org' # core gem 'SyslogLogger', '2.0', require: 'syslog/logger' -gem 'hashie-forbidden_attributes', '0.1.1' gem 'iso8601', '0.8.6' # for dates and times gem 'rails', '4.2.7.1' # when update, all initializers eis_custom files needs check/update gem 'rest-client' @@ -60,6 +59,7 @@ gem 'devise', '3.5.4' # authenitcation # rest api gem 'grape', '0.12.0' +gem 'hashie-forbidden_attributes', '0.1.1' # For grape, https://github.com/ruby-grape/grape#rails gem 'jbuilder', '2.2.16' # json api # registry specfic From d520b5b157aaf8d4d0a83a97e9ce48b2c1b4b2c9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 22 Oct 2017 23:57:11 +0300 Subject: [PATCH 03/16] Revert "Revert "Registry 569"" This reverts commit 4786dbb --- .codeclimate.yml | 1 + .reek | 1168 +++++++++++++++++ Gemfile | 1 + Gemfile.lock | 4 + app/controllers/admin/contacts_controller.rb | 5 + app/controllers/epp_controller.rb | 3 - .../registrar/contacts_controller.rb | 5 + app/models/concerns/epp_errors.rb | 31 + app/models/contact.rb | 65 +- app/models/contact/ident.rb | 74 ++ app/models/epp/contact.rb | 66 +- app/models/epp/response.rb | 22 + app/models/epp/response/result.rb | 28 + app/models/registrar.rb | 1 - .../contact/ident/mismatch_validator.rb | 20 + .../contact/ident/national_id_validator.rb | 22 + .../contact/ident/reg_no_validator.rb | 21 + app/views/admin/contacts/index.haml | 4 +- app/views/registrar/contacts/index.haml | 4 +- .../initializers/eis_custom_active_model.rb | 20 - .../initializers/eis_custom_active_record.rb | 8 - config/initializers/eis_custom_flash.rb | 31 - config/locales/contacts.en.yml | 15 + config/locales/en.yml | 30 +- config/locales/epp/contacts.en.yml | 8 + config/locales/idents.yml | 11 + doc/epp/contact.md | 4 +- doc/models_brief.svg | 14 - doc/models_complete.svg | 14 - lib/tasks/dev.rake | 2 + lib/validators/e164_validator.rb | 12 + lib/validators/iso31661_alpha2_validator.rb | 11 + lib/validators/iso8601_validator.rb | 13 + lib/validators/phone_validator.rb | 8 +- spec/features/admin/contacts/list_spec.rb | 12 + spec/features/registrar/contacts/list_spec.rb | 15 + spec/lib/validators/e164.rb | 29 + spec/lib/validators/iso31661_alpha2.rb | 17 + spec/lib/validators/iso8601.rb | 17 + spec/models/contact/contact_phone_spec.rb | 33 + spec/models/contact/ident_spec.rb | 227 ++++ spec/models/contact_spec.rb | 117 +- spec/models/epp/response/result_spec.rb | 21 + spec/models/registrar_spec.rb | 8 - spec/rails_helper.rb | 4 +- .../requests/epp/contact/create/ident_spec.rb | 289 ++++ .../requests/epp/contact/update/ident_spec.rb | 196 +++ spec/support/matchers/epp/have_result.rb | 37 + spec/support/requests/epp_helpers.rb | 4 + .../contact/ident/mismatch_validator_spec.rb | 13 + 50 files changed, 2462 insertions(+), 323 deletions(-) create mode 100644 app/models/contact/ident.rb create mode 100644 app/models/epp/response.rb create mode 100644 app/models/epp/response/result.rb create mode 100644 app/validators/contact/ident/mismatch_validator.rb create mode 100644 app/validators/contact/ident/national_id_validator.rb create mode 100644 app/validators/contact/ident/reg_no_validator.rb delete mode 100644 config/initializers/eis_custom_active_model.rb delete mode 100644 config/initializers/eis_custom_active_record.rb delete mode 100644 config/initializers/eis_custom_flash.rb create mode 100644 config/locales/idents.yml create mode 100644 lib/validators/e164_validator.rb create mode 100644 lib/validators/iso31661_alpha2_validator.rb create mode 100644 lib/validators/iso8601_validator.rb create mode 100644 spec/features/admin/contacts/list_spec.rb create mode 100644 spec/features/registrar/contacts/list_spec.rb create mode 100644 spec/lib/validators/e164.rb create mode 100644 spec/lib/validators/iso31661_alpha2.rb create mode 100644 spec/lib/validators/iso8601.rb create mode 100644 spec/models/contact/contact_phone_spec.rb create mode 100644 spec/models/contact/ident_spec.rb create mode 100644 spec/models/epp/response/result_spec.rb create mode 100644 spec/requests/epp/contact/create/ident_spec.rb create mode 100644 spec/requests/epp/contact/update/ident_spec.rb create mode 100644 spec/support/matchers/epp/have_result.rb create mode 100644 spec/validators/contact/ident/mismatch_validator_spec.rb diff --git a/.codeclimate.yml b/.codeclimate.yml index 03f849185..5345c2571 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -27,6 +27,7 @@ engines: - HACK rubocop: enabled: true + channel: rubocop-0-49 reek: enabled: true checks: diff --git a/.reek b/.reek index d94291666..060f76785 100644 --- a/.reek +++ b/.reek @@ -1,3 +1,1171 @@ exclude_paths: - db/migrate/ - db/data/ +UncommunicativeModuleName: + exclude: + - Repp::AccountV1 + - Repp::ContactV1 + - Repp::DomainV1 +UncommunicativeVariableName: + exclude: + - Repp::DomainV1 + - Admin::AccountActivitiesController + - Admin::AdminUsersController + - Admin::ApiUsersController + - Admin::BankStatementsController + - Admin::Billing::PricesController + - Admin::BlockedDomainsController + - Admin::ContactVersionsController + - Admin::ContactVersionsController#index + - Admin::ContactsController + - Admin::DomainVersionsController + - Admin::DomainVersionsController#index + - Admin::DomainsController + - Admin::DomainsController#build_associations + - Admin::EppLogsController + - Admin::InvoicesController + - Admin::InvoicesController#create + - Admin::KeyrelaysController + - Admin::MailTemplatesController + - Admin::RegistrarsController + - Admin::ReppLogsController + - Admin::ReservedDomainsController + - Admin::SettingsController#casted_settings + - Admin::SettingsController#create + - Epp::DomainsController#renew + - Epp::DomainsController#update + - Epp::SessionsController#connection_limit_ok? + - Epp::SessionsController#login + - EppController + - EppController#create_full_selectors + - EppController#optional + - EppController#xml_attrs_present? + - Registrant::DomainsController + - Registrar::AccountActivitiesController + - Registrar::ContactsController + - Registrar::ContactsController#download_list + - Registrar::ContactsController#index + - Registrar::DeppController#response_ok? + - Registrar::DomainsController + - Registrar::DomainsController#index + - Registrar::DomainsController#search_contacts + - Registrar::InvoicesController + - ContactMailer#email_updated + - Ability#billing + - Ability#epp + - AccountActivity#to_csv + - AccountActivity#types_for_select + - ApiUser#api_pki_ok? + - ApiUser#registrar_pki_ok? + - BankLink::Request#calc_mac + - BankLink::Response#validate_cancel + - BankLink::Response#validate_success + - BankStatement#import_th6_file + - BlockedDomain#generate_json + - Concerns::Domain::ForceDelete#cancel_force_delete + - EppErrors#add_epp_error + - EppErrors#collect_child_errors + - EppErrors#find_epp_code_and_value + - Versions::ClassMethods#all_versions_for + - Contact + - Contact#all_domains + - Contact#all_registrant_domains + - Contact#manage_emails + - Contact#search_by_query + - Contact#status_notes_array= + - Depp::Contact#construct_create_disclosure_xml + - Depp::Contact#extract_disclosure_hash + - Depp::Contact#extract_info_disclosure + - Depp::Contact#find_by_id + - Depp::Contact#handle_errors + - Depp::Contact#type_string + - Depp::Domain#construct_params_from_server_data + - Depp::Domain#create_contacts_hash + - Depp::Domain#create_dnskeys_hash + - Depp::Domain#create_nameservers_hash + - Depp::Domain#default_params + - Depp::User#initialize + - Depp::User#request + - Depp::User#validate_existance_in_server + - Directo#self.send_monthly_invoices + - DNS::Zone#self.generate_zonefile + - Dnskey#bin_to_hex + - Dnskey#generate_ds_key_tag + - Dnskey#int_to_hex + - Domain#admin_status_update + - Domain#delegated_nameservers + - Domain#name_in_wire_format + - Domain#parent_valid? + - Domain#status_notes_array= + - Domain#subordinate_nameservers + - DomainCron#self.destroy_delete_candidates + - DomainMailModel#admins + - Epp::Contact#attrs_from + - Epp::Contact#check_availability + - Epp::Domain#check_availability + - Epp::Domain#copy_and_transfer_contact + - Epp::Domain#domain_contact_attrs_from + - Epp::Domain#domain_status_list_from + - Epp::Domain#domain_statuses_attrs + - Epp::Domain#nameservers_from + - Epp::Domain#parse_period_unit_from_frame + - Epp::Domain#transfer_domain_contacts + - Epp::Domain#validate_contacts + - Invoice#cancel_overdue_invoices + - Legacy::Db + - LegalDocument#save_to_filesystem + - Nameserver#replace_hostname_ends + - RegistrantUser#find_or_create_by_idc_data + - RegistrantUser#find_or_create_by_mid_data + - Registrar + - Registrar#search_by_query + - ReservedDomain#generate_json + - WhoisRecord#generate_json + - UniquenessMultiValidator#validate_each + - Registry::Application + - ActiveRecord::Base + - Ransack::Adapters::ActiveRecord::Context#evaluate + - EppConstraint#matches? + - Iptable#counter_update +DuplicateMethodCall: + exclude: + - Admin::AccountActivitiesController#index + - Admin::AccountActivitiesController#set_default_dates + - Admin::AdminUsersController#update + - Admin::ApiUsersController#update + - Admin::BankStatementsController#download_import_file + - Admin::Billing::PricesController#index + - Admin::BlockedDomainsController#delete + - Admin::BlockedDomainsController#index + - Admin::CertificatesController#create + - Admin::CertificatesController#set_certificate + - Admin::ContactVersionsController#index + - Admin::ContactVersionsController#show + - Admin::ContactsController#index + - Admin::ContactsController#normalize_search_parameters + - Admin::DomainVersionsController#index + - Admin::DomainVersionsController#show + - Admin::DomainsController#build_associations + - Admin::DomainsController#index + - Admin::DomainsController#normalize_search_parameters + - Admin::DomainsController#schedule_force_delete + - Admin::EppLogsController#index + - Admin::EppLogsController#set_default_dates + - Admin::LegalDocumentsController#show + - Admin::PendingDeletesController#destroy + - Admin::PendingDeletesController#update + - Admin::PendingUpdatesController#destroy + - Admin::PendingUpdatesController#update + - Admin::ReppLogsController#index + - Admin::ReppLogsController#set_default_dates + - Admin::ReservedDomainsController#delete + - Admin::ReservedDomainsController#index + - Admin::SessionsController#create + - Admin::SettingsController#casted_settings + - Admin::ZonefilesController#create + - ApplicationController#comma_support_for + - Epp::ContactsController#validate_create + - Epp::DomainsController#create + - Epp::DomainsController#delete + - Epp::DomainsController#renew + - Epp::DomainsController#transfer + - Epp::DomainsController#update + - Epp::KeyrelaysController#keyrelay + - Epp::PollsController#ack_poll + - Epp::PollsController#poll + - Epp::PollsController#req_poll + - Epp::SessionsController#connection_limit_ok? + - Epp::SessionsController#ip_white? + - Epp::SessionsController#login + - Epp::SessionsController#login_params + - EppController#current_user + - EppController#handle_errors + - EppController#iptables_counter_update + - EppController#latin_only + - EppController#optional + - EppController#update_epp_session + - EppController#write_to_epp_log + - Registrant::DomainDeleteConfirmsController#update + - Registrant::DomainUpdateConfirmsController#update + - Registrant::DomainsController#domain_verification_url + - Registrant::DomainsController#download_list + - Registrant::DomainsController#get_confirm_path + - Registrant::DomainsController#index + - Registrant::DomainsController#normalize_search_parameters + - Registrant::SessionsController#id + - Registrant::SessionsController#mid + - Registrant::SessionsController#mid_status + - Registrant::WhoisController#index + - Registrar::AccountActivitiesController#index + - Registrar::BaseController#check_ip + - Registrar::ContactsController#download_list + - Registrar::ContactsController#index + - Registrar::ContactsController#normalize_search_parameters + - Registrar::ContactsController#update + - Registrar::DomainsController#check + - Registrar::DomainsController#destroy + - Registrar::DomainsController#index + - Registrar::DomainsController#info + - Registrar::DomainsController#normalize_search_parameters + - Registrar::DomainsController#renew + - Registrar::DomainsController#search_contacts + - Registrar::DomainsController#transfer + - Registrar::DomainsController#update + - Registrar::InvoicesController#index + - Registrar::InvoicesController#normalize_search_parameters + - Registrar::PaymentsController#back + - Registrar::SessionsController#create + - Registrar::SessionsController#mid + - Registrar::SessionsController#mid_status + - ApplicationHelper#changing_css_class + - ApplicationHelper#creator_link + - ApplicationHelper#custom_sort_link + - ApplicationHelper#unstable_env + - ApplicationHelper#updator_link + - Registrant::ApplicationHelper#pagination_details + - Registrar::ApplicationHelper#pagination_details + - DomainDeleteConfirmJob#raise_errors! + - DomainDeleteConfirmJob#run + - DomainUpdateConfirmJob#raise_errors! + - DomainUpdateConfirmJob#run + - UpdateWhoisRecordJob#update_domain + - ApplicationMailer#whitelist_blocked? + - DomainExpireMailer#expired + - DomainMailer#compose_from + - DomainMailer#delete_confirmation + - DomainMailer#pending_delete_expired_notification + - DomainMailer#pending_delete_rejected_notification + - InvoiceMailer#invoice_email + - Ability#epp + - Ability#initialize + - BankLink::Request#fields + - BankLink::Response#initialize + - BankStatement#import_th6_file + - BankStatement#parse_th6_row + - BankStatement#status + - Billing::Price#self.effective + - Billing::Price#self.valid + - BusinessRegistryCache#fetch_by_ident_and_cc + - BusinessRegistryCache#purge + - Certificate#parse_metadata + - Certificate#reload_apache + - Certificate#revoke! + - Certificate#status + - Certificate#update_id_crl + - Certificate#update_registry_crl + - EppErrors#add_epp_error + - UserEvents#cr_id + - Versions#user_from_id_role_username + - Versions::ClassMethods#all_versions_for + - Contact#all_domains + - Contact#all_registrant_domains + - Contact#destroy_orphans + - Contact#domain_names_with_roles + - Contact#generate_code + - Contact#related_domain_descriptions + - Contact#val_ident_valid_format? + - Deposit#validate_amount + - Depp::Contact#construct_check_hash_from_data + - Depp::Contact#construct_create_disclosure_xml + - Depp::Contact#extension_xml + - Depp::Contact#extract_info_disclosure + - Depp::Contact#find_by_id + - Depp::Contact#new_from_params + - Depp::Contact#update_attributes + - Depp::Domain#confirm_transfer + - Depp::Domain#construct_custom_params_hash + - Depp::Domain#construct_edit_hash + - Depp::Domain#construct_ext_edit_hash + - Depp::Domain#construct_params_from_server_data + - Depp::Domain#create + - Depp::Domain#create_contacts_hash + - Depp::Domain#create_dnskeys_hash + - Depp::Domain#create_key_data_hash + - Depp::Domain#create_nameservers_hash + - Depp::Domain#default_params + - Depp::Domain#renew + - Depp::Keyrelay#keyrelay + - Depp::User#repp_request + - Depp::User#validate_existance_in_server + - Directo#self.dump_result_to_db + - Directo#self.load_price + - Directo#self.send_monthly_invoices + - Directo#self.send_receipts + - DNS::Zone#self.generate_zonefile + - Dnskey#generate_digest + - Domain#manage_automatic_statuses + - Domain#parent_valid? + - Domain#pending_registrant + - Domain#renewable? + - Domain#set_graceful_expired + - DomainCron#self.clean_expired_pendings + - DomainCron#self.delete_legal_doc_duplicates + - DomainCron#self.destroy_delete_candidates + - DomainCron#self.start_expire_period + - DomainCron#self.start_redemption_grace_period + - DomainMailModel#registrant_pending + - DomainMailModel#subject + - DomainMailModel#verification_token + - Epp::Contact#attrs_from + - Epp::Contact#legal_document_attrs + - Epp::Contact#status_list_from + - Epp::Contact#update_attributes + - Epp::Domain#apply_pending_update! + - Epp::Domain#attrs_from + - Epp::Domain#dnskeys_attrs + - Epp::Domain#domain_contact_attrs_from + - Epp::Domain#domain_status_list_from + - Epp::Domain#new_from_epp + - Epp::Domain#parse_legal_document_from_frame + - Epp::Domain#query_transfer + - Epp::Domain#renew + - Epp::Domain#transfer_domain_contacts + - Epp::Domain#update + - Epp::Domain#validate_contacts + - Epp::Domain#validate_exp_dates + - Invoice#cancel_overdue_invoices + - Invoice#set_invoice_number + - LegalDocument#save_to_filesystem + - LegalDocument#self.remove_duplicates + - Nameserver#replace_hostname_ends + - Setting#self.params_errors + - Setting#self.reload_settings! + - Soap::Arireg#associated_businesses + - Soap::Arireg#body + - Soap::Arireg#debug + - Soap::Arireg#initialize + - WhoisRecord#generate_json + - DomainPresenter#delete_date + - DomainPresenter#force_delete_date + - DomainPresenter#on_hold_date + - DomainNameValidator#validate_each + - DomainNameValidator#validate_format + - DurationIso8601Validator#validate_each + - UniquenessMultiValidator#validate_each + - ActionView::Helpers::FormBuilder#label + - ActionDispatch::Flash#call + - Rack::Request#trusted_proxy? + - Ransack::Adapters::ActiveRecord::Context#evaluate + - DeviseCustomFailure#redirect_url + - EppConstraint#matches? + - PhoneValidator#validate_each +InstanceVariableAssumption: + exclude: + - Admin::AccountActivitiesController + - Admin::AdminUsersController + - Admin::ApiUsersController + - Admin::BankStatementsController + - Admin::BankTransactionsController + - Admin::Billing::PricesController + - Admin::BlockedDomainsController + - Admin::CertificatesController + - Admin::ContactVersionsController + - Admin::ContactsController + - Admin::DNS::ZonesController + - Admin::DomainVersionsController + - Admin::DomainsController + - Admin::EppLogsController + - Admin::InvoicesController + - Admin::KeyrelaysController + - Admin::LegalDocumentsController + - Admin::MailTemplatesController + - Admin::PendingDeletesController + - Admin::PendingUpdatesController + - Admin::RegistrarsController + - Admin::ReppLogsController + - Admin::ReservedDomainsController + - Admin::SessionsController + - Admin::SettingsController + - Admin::WhiteIpsController + - Admin::ZonefilesController + - Epp::ContactsController + - Epp::DomainsController + - Epp::KeyrelaysController + - Epp::PollsController + - Epp::SessionsController + - EppController + - Registrant::ContactsController + - Registrant::DomainDeleteConfirmsController + - Registrant::DomainUpdateConfirmsController + - Registrant::DomainsController + - Registrant::RegistrarsController + - Registrant::SessionsController + - Registrar::AccountActivitiesController + - Registrar::ContactsController + - Registrar::DepositsController + - Registrar::DeppController + - Registrar::DomainsController + - Registrar::InvoicesController + - Registrar::PaymentsController + - Registrar::PollsController + - Registrar::SessionsController + - DefaultFormBuilder + - ContactMailer + - DomainMailer + - InvoiceMailer + - ApiUser + - BankTransaction + - Certificate + - Contact + - Deposit + - Depp::Contact + - Domain + - DomainContact + - WhoisRecord + - ActiveModel::Errors + - ActionDispatch::Flash + - Ransack::Adapters::ActiveRecord::Context +IrresponsibleModule: + exclude: + - Admin::AccountActivitiesController + - Admin::AdminUsersController + - Admin::ApiUsersController + - Admin::BankStatementsController + - Admin::BankTransactionsController + - Admin::Billing::PricesController + - Admin::BlockedDomainsController + - Admin::CertificatesController + - Admin::ContactVersionsController + - Admin::ContactsController + - Admin::DashboardsController + - Admin::DelayedJobsController + - Admin::DNS::ZonesController + - Admin::DomainVersionsController + - Admin::DomainsController + - Admin::EppLogsController + - Admin::InvoicesController + - Admin::KeyrelaysController + - Admin::LegalDocumentsController + - Admin::MailTemplatesController + - Admin::PendingDeletesController + - Admin::PendingUpdatesController + - Admin::RegistrarsController + - Admin::ReppLogsController + - Admin::ReservedDomainsController + - Admin::SessionsController + - Admin::SettingsController + - Admin::WhiteIpsController + - Admin::ZonefilesController + - AdminController + - ApplicationController + - Epp::ContactsController + - Epp::DomainsController + - Epp::ErrorsController + - Epp::KeyrelaysController + - Epp::PollsController + - Epp::SessionsController + - EppController + - Registrant::ContactsController + - Registrant::DomainDeleteConfirmsController + - Registrant::DomainUpdateConfirmsController + - Registrant::DomainsController + - Registrant::RegistrarsController + - Registrant::SessionsController + - Registrant::WhoisController + - RegistrantController + - Registrar::AccountActivitiesController + - Registrar::BaseController + - Registrar::ContactsController + - Registrar::DashboardController + - Registrar::DepositsController + - Registrar::DeppController + - Registrar::DomainsController + - Registrar::InvoicesController + - Registrar::KeyrelaysController + - Registrar::PaymentsController + - Registrar::PollsController + - Registrar::SessionsController + - Registrar::XmlConsolesController + - ApplicationHelper + - DefaultFormBuilder + - FormHelper + - FormTagHelper + - Registrant::ApplicationHelper + - Registrar::ApplicationHelper + - DomainDeleteConfirmEmailJob + - DomainDeleteConfirmJob + - DomainDeleteForcedEmailJob + - DomainDeleteJob + - DomainExpireEmailJob + - DomainUpdateConfirmJob + - RegenerateRegistrarWhoisesJob + - RegistrantChangeConfirmEmailJob + - RegistrantChangeExpiredEmailJob + - RegistrantChangeNoticeEmailJob + - UpdateWhoisRecordJob + - ApplicationMailer + - ContactMailer + - DomainDeleteMailer + - DomainExpireMailer + - DomainMailer + - InvoiceMailer + - RegistrantChangeMailer + - Ability + - Account + - AccountActivity + - AdminDomainContact + - AdminUser + - ApiLog::EppLog + - ApiLog::ReppLog + - ApiUser + - BankLink::Base + - BankLink::Request + - BankLink::Response + - BankStatement + - BankTransaction + - Billing::Price + - Billing + - BlockedDomain + - Certificate + - Concerns::Billing::Price::Expirable + - DisableHtml5Validation + - Concerns::Domain::Activatable + - Concerns::Domain::Deletable + - Concerns::Domain::Expirable + - Concerns::Domain::ForceDelete + - EppErrors + - UserEvents + - VersionSession + - Versions::ClassMethods + - Contact + - Counter + - Deposit + - Depp::Contact + - Depp::Domain + - Depp::Keyrelay + - Depp::User + - Directo + - DNS::Zone + - DNS + - Dnskey + - DomainContact + - DomainCron + - DomainMailModel + - DomainStatus + - DomainTransfer + - Epp::Contact + - EppSession + - Invoice + - InvoiceItem + - Keyrelay + - Legacy::Db + - Legacy::Object + - Legacy::ObjectHistory + - Legacy::ObjectState + - Legacy::Registrar + - LegalDocument + - Message + - Nameserver + - Registrant + - RegistrantUser + - Registrar + - ReservedDomain + - Setting + - Soap::Arireg + - Soap::Arireg::NotAvailableError + - TechDomainContact + - User + - WhiteIp + - WhoisRecord + - DomainPresenter + - RegistrantPresenter + - Registrar::DomainListCSVPresenter + - RegistrarPresenter + - RegistrantChange + - DateTimeIso8601Validator + - DomainNameValidator + - DomainNameserverValidator + - DurationIso8601Validator + - ObjectCountValidator + - UniquenessMultiValidator + - PaperSession + - Array + - ActionView::Helpers::FormBuilder + - ActiveModel::Errors + - ActionDispatch::Flash + - Rack::Request + - Ransack::Adapters::ActiveRecord::Context + - DeviseCustomFailure + - EppConstraint + - Builder::XmlMarkup + - VersionGenerator + - Iptable + - SortedCountry + - EmailValidator + - PhoneValidator + - FakeDeppContact + - Features::SessionHelpers + - CapybaraViewMacros + - Matchers::EPP::Code + - Requests::EPPHelpers + - Requests::SessionHelpers +NilCheck: + exclude: + - Admin::AccountActivitiesController#set_default_dates + - Admin::EppLogsController#set_default_dates + - Admin::ReppLogsController#set_default_dates + - ApplicationController#user_log_str + - EppController#requires + - ApplicationHelper#env_style + - Registrant::ApplicationHelper#env_style + - Registrar::ApplicationHelper#env_style + - UserEvents#cr_id + - Depp::Contact#handle_errors + - Directo#self.send_receipts + - DomainMailModel#format + - LegalDocument#val_body_length + - Soap::Arireg#body + - Soap::Arireg#country_code_3 + - Soap::Arireg#initialize + - ActionDispatch::Flash#call +TooManyStatements: + exclude: + - initialize + - Admin::AccountActivitiesController#index + - Admin::AdminUsersController#update + - Admin::BankTransactionsController#create + - Admin::Billing::PricesController#index + - Admin::CertificatesController#create + - Admin::ContactVersionsController#index + - Admin::ContactVersionsController#show + - Admin::ContactsController#index + - Admin::ContactsController#normalize_search_parameters + - Admin::DomainVersionsController#index + - Admin::DomainVersionsController#show + - Admin::DomainsController#index + - Admin::DomainsController#normalize_search_parameters + - Admin::DomainsController#schedule_force_delete + - Admin::DomainsController#update + - Admin::EppLogsController#index + - Admin::InvoicesController#create + - Admin::InvoicesController#forward + - Admin::RegistrarsController#create + - Admin::ReppLogsController#index + - Admin::SessionsController#create + - Admin::SettingsController#casted_settings + - Admin::SettingsController#create + - Admin::WhiteIpsController#create + - Epp::ContactsController#create + - Epp::ContactsController#update + - Epp::ContactsController#validate_create + - Epp::ContactsController#validate_update + - Epp::DomainsController#balance_ok? + - Epp::DomainsController#create + - Epp::DomainsController#delete + - Epp::DomainsController#info + - Epp::DomainsController#renew + - Epp::DomainsController#transfer + - Epp::DomainsController#update + - Epp::DomainsController#validate_create + - Epp::DomainsController#validate_transfer + - Epp::PollsController#req_poll + - Epp::SessionsController#login + - EppController#catch_epp_errors + - EppController#element_count + - EppController#handle_errors + - EppController#optional + - EppController#optional_attribute + - EppController#requires + - EppController#requires_attribute + - EppController#update_epp_session + - EppController#validate_request + - EppController#write_to_epp_log + - Registrant::DomainDeleteConfirmsController#update + - Registrant::DomainUpdateConfirmsController#update + - Registrant::DomainsController#domain_verification_url + - Registrant::DomainsController#domains + - Registrant::DomainsController#download_list + - Registrant::DomainsController#index + - Registrant::DomainsController#normalize_search_parameters + - Registrant::SessionsController#id + - Registrant::SessionsController#mid + - Registrant::SessionsController#mid_status + - Registrar::AccountActivitiesController#index + - Registrar::BaseController#check_ip + - Registrar::ContactsController#download_list + - Registrar::ContactsController#index + - Registrar::ContactsController#normalize_search_parameters + - Registrar::DepositsController#create + - Registrar::DomainsController#destroy + - Registrar::DomainsController#index + - Registrar::DomainsController#normalize_search_parameters + - Registrar::DomainsController#search_contacts + - Registrar::DomainsController#update + - Registrar::InvoicesController#forward + - Registrar::InvoicesController#index + - Registrar::InvoicesController#normalize_search_parameters + - Registrar::KeyrelaysController#create + - Registrar::PaymentsController#back + - Registrar::SessionsController#create + - Registrar::SessionsController#mid + - Registrar::SessionsController#mid_status + - ApplicationHelper#ident_for + - DomainDeleteConfirmJob#run + - DomainDeleteJob#run + - DomainUpdateConfirmJob#run + - UpdateWhoisRecordJob#run + - ApplicationMailer#whitelist_blocked? + - ContactMailer#email_updated + - DomainDeleteMailer#forced + - DomainExpireMailer#expired + - DomainMailer#compose_from + - DomainMailer#pending_delete_rejected_notification + - InvoiceMailer#invoice_email + - RegistrantChangeMailer#confirm + - RegistrantChangeMailer#notice + - Ability#admin + - Ability#epp + - AccountActivity#to_csv + - ApiUser#api_pki_ok? + - ApiUser#registrar_pki_ok? + - BankLink::Request#fields + - BankLink::Response#complete_payment + - BankStatement#import_th6_file + - BankTransaction#autobind_invoice + - BankTransaction#bind_invoice + - BusinessRegistryCache#fetch_by_ident_and_cc + - Certificate#parse_md_from_string + - Certificate#parse_metadata + - Certificate#revoke! + - Certificate#sign! + - Certificate#status + - Concerns::Domain::ForceDelete#cancel_force_delete + - Concerns::Domain::ForceDelete#schedule_force_delete + - EppErrors#add_epp_error + - EppErrors#collect_child_errors + - EppErrors#collect_parent_errors + - EppErrors#construct_epp_errors + - EppErrors#construct_msg_args_and_value + - EppErrors#find_epp_code_and_value + - UserEvents#cr_id + - Versions::ClassMethods#all_versions_for + - Contact#all_domains + - Contact#all_registrant_domains + - Contact#destroy_and_clean + - Contact#destroy_orphans + - Contact#domain_names_with_roles + - Contact#filter_by_states + - Contact#generate_code + - Contact#manage_emails + - Contact#related_domain_descriptions + - Contact#statuses + - Contact#validate_html + - Depp::Contact#construct_check_hash_from_data + - Depp::Contact#construct_create_disclosure_xml + - Depp::Contact#extension_xml + - Depp::Contact#extract_info_disclosure + - Depp::Contact#handle_errors + - Depp::Contact#save + - Depp::Contact#update_attributes + - Depp::Domain#construct_edit_hash + - Depp::Domain#construct_ext_edit_hash + - Depp::Domain#construct_params_from_server_data + - Depp::Domain#create + - Depp::Domain#create_dnskeys_hash + - Depp::Domain#create_nameservers_hash + - Depp::Domain#default_params + - Depp::Domain#transfer + - Depp::User#repp_request + - Depp::User#validate_existance_in_server + - Directo#self.send_monthly_invoices + - Directo#self.send_receipts + - DNS::Zone#self.generate_zonefile + - Dnskey#generate_digest + - Dnskey#generate_ds_key_tag + - Domain#children_log + - Domain#clean_pendings! + - Domain#clean_pendings_lowlevel + - Domain#manage_automatic_statuses + - Domain#name_in_wire_format + - Domain#pending_delete! + - Domain#pending_update! + - Domain#pricelist + - DomainCron#self.clean_expired_pendings + - DomainCron#self.destroy_delete_candidates + - DomainCron#self.start_expire_period + - DomainCron#self.start_redemption_grace_period + - DomainMailModel#domain_info + - DomainTransfer#approve_as_client + - Epp::Contact#add_legal_file_to_new + - Epp::Contact#attrs_from + - Epp::Contact#check_availability + - Epp::Contact#status_list_from + - Epp::Contact#statuses_attrs + - Epp::Contact#update_attributes + - Epp::Domain#add_legal_file_to_new + - Epp::Domain#apply_pending_delete! + - Epp::Domain#apply_pending_update! + - Epp::Domain#approve_transfer + - Epp::Domain#attrs_from + - Epp::Domain#check_availability + - Epp::Domain#copy_and_transfer_contact + - Epp::Domain#destroy_attrs + - Epp::Domain#dnskeys_attrs + - Epp::Domain#domain_contact_attrs_from + - Epp::Domain#domain_status_list_from + - Epp::Domain#domain_statuses_attrs + - Epp::Domain#epp_destroy + - Epp::Domain#keyrelay + - Epp::Domain#manage_permissions + - Epp::Domain#nameservers_attrs + - Epp::Domain#nameservers_from + - Epp::Domain#new_from_epp + - Epp::Domain#query_transfer + - Epp::Domain#reject_transfer + - Epp::Domain#renew + - Epp::Domain#transfer + - Epp::Domain#transfer_domain_contacts + - Epp::Domain#update + - Epp::Domain#validate_contacts + - Invoice#cancel + - Invoice#cancel_overdue_invoices + - Invoice#set_invoice_number + - LegalDocument#save_to_filesystem + - LegalDocument#self.remove_duplicates + - Nameserver#replace_hostname_ends + - RegistrantUser#find_or_create_by_idc_data + - Registrar#generate_iso_11649_reference_no + - Soap::Arireg#associated_businesses + - WhoisRecord#generate_json + - Registrar::DomainListCSVPresenter#domain_to_row + - DomainNameValidator#validate_format + - DomainNameserverValidator#validate_each + - DurationIso8601Validator#validate + - UniquenessMultiValidator#validate_each + - ActionDispatch::Flash#call + - Ransack::Adapters::ActiveRecord::Context#evaluate + - EppConstraint#matches? + - Iptable#counter_update + - fill_form +TooManyInstanceVariables: + exclude: + - Admin::BankStatementsController + - Admin::DomainsController + - Admin::MailTemplatesController + - Epp::ContactsController + - Epp::DomainsController + - EppController + - Registrar::DomainsController + - DomainDeleteMailer + - RegistrantChangeMailer +UtilityFunction: + exclude: + - Admin::Billing::PricesController#durations + - Admin::Billing::PricesController#operation_categories + - Admin::Billing::PricesController#statuses + - Admin::Billing::PricesController#zones + - ApplicationController#user_log_str + - Epp::ContactsController#address_processing? + - EppController#has_attribute + - Registrant::DomainsController#get_confirm_path + - Registrant::SessionsController#find_user_by_idc + - Registrar::ContactsController#address_processing? + - Registrar::PaymentsController#banks + - Registrar::SessionsController#find_user_by_idc + - ApplicationHelper#changing_css_class + - ApplicationHelper#ident_for + - ApplicationHelper#legal_document_types + - ApplicationHelper#plain_username + - ApplicationHelper#unstable_env + - DomainDeleteConfirmEmailJob#logger + - DomainDeleteForcedEmailJob#logger + - DomainExpireEmailJob#run + - RegenerateRegistrarWhoisesJob#run + - RegistrantChangeConfirmEmailJob#logger + - RegistrantChangeExpiredEmailJob#logger + - RegistrantChangeNoticeEmailJob#logger + - UpdateWhoisRecordJob#delete_domain + - UpdateWhoisRecordJob#delete_reserved + - UpdateWhoisRecordJob#update_domain + - UpdateWhoisRecordJob#update_reserved + - ApplicationMailer#format + - ContactMailer#address_processing + - RegistrantChangeMailer#address_processing + - EppErrors#construct_msg_args_and_value + - Versions#user_from_id_role_username + - Depp::Keyrelay#expiry + - Epp::Domain#copy_and_transfer_contact + - Epp::Domain#nameservers_from + - Epp::Domain::DnsSecKeys#mark + - Epp::Domain::DnsSecKeys#xm_copy + - Invoice#pdf + - Soap::Arireg#extract + - Soap::Arireg#items + - Registrar::DomainListCSVPresenter#domain_to_row + - Rack::Request#trusted_proxy? + - PhoneValidator#zeros_only? + - Requests::EPPHelpers#have_code_of + - Requests::EPPHelpers#valid_legal_document +FeatureEnvy: + exclude: + - Admin::SettingsController#casted_settings + - ApplicationHelper#creator_link + - ApplicationHelper#updator_link + - FormHelper#legal_document_field + - FormHelper#money_field + - FormTagHelper#legal_document_field_tag + - DomainDeleteConfirmEmailJob#log + - DomainDeleteConfirmEmailJob#run + - DomainDeleteConfirmJob#raise_errors! + - DomainDeleteConfirmJob#run + - DomainDeleteForcedEmailJob#log + - DomainDeleteForcedEmailJob#run + - DomainDeleteJob#run + - DomainUpdateConfirmJob#raise_errors! + - DomainUpdateConfirmJob#run + - RegistrantChangeConfirmEmailJob#log + - RegistrantChangeConfirmEmailJob#run + - RegistrantChangeExpiredEmailJob#log + - RegistrantChangeExpiredEmailJob#run + - RegistrantChangeNoticeEmailJob#log + - RegistrantChangeNoticeEmailJob#run + - ApplicationMailer#whitelist_blocked? + - DomainExpireMailer#filter_invalid_emails + - AccountActivity#to_csv + - ApiUser#api_pki_ok? + - ApiUser#find_by_idc_data + - ApiUser#registrar_pki_ok? + - BankLink::Base#prepend_size + - BankLink::Request#fields + - BankStatement#parse_th6_row + - BusinessRegistryCache#fetch_by_ident_and_cc + - EppErrors#collect_parent_errors + - Contact#all_domains + - Contact#all_registrant_domains + - Contact#destroy_orphans + - Contact#domain_names_with_roles + - Contact#filter_by_states + - Contact#search_by_query + - Contact#statuses + - Depp::Contact#construct_check_hash_from_data + - Depp::Contact#find_by_id + - Depp::Contact#handle_errors + - Depp::Contact#new_from_params + - Depp::Domain#construct_params_from_server_data + - Depp::Domain#create + - Depp::Domain#create_dnskeys_hash + - Depp::Domain#renew + - Depp::Domain#transfer + - Depp::Keyrelay#keyrelay + - Depp::User#repp_request + - DomainMailModel#format + - Epp::Contact#attach_legal_document + - Epp::Contact#attrs_from + - Epp::Contact#check_availability + - Epp::Contact#ident_attrs + - Epp::Contact#status_list_from + - Epp::Domain#attach_legal_document + - Epp::Domain#attrs_from + - Epp::Domain#destroy_attrs + - Epp::Domain#domain_contact_attrs_from + - Epp::Domain#domain_status_list_from + - Epp::Domain#transfer_domain_contacts + - LegalDocument#calc_checksum + - Nameserver#find_by_hash_params + - RegistrantUser#find_or_create_by_idc_data + - RegistrantUser#find_or_create_by_mid_data + - Registrar#debit! + - Registrar#search_by_query + - ReservedDomain#new_password_for + - Soap::Arireg#country_code_3 + - WhoisRecord#generate_json + - RegistrantPresenter#domain_names_with_roles + - ActionDispatch::Flash#call + - Ransack::Adapters::ActiveRecord::Context#evaluate + - EppConstraint#matches? + - Requests::SessionHelpers#sign_in_to_epp_area +TooManyMethods: + exclude: + - Epp::ContactsController + - Epp::DomainsController + - EppController + - Contact + - Depp::Contact + - Depp::Domain + - Domain + - DomainMailModel + - Epp::Domain + - Invoice + - Registrar +RepeatedConditional: + exclude: + - Epp::DomainsController + - EppController + - Registrar::DomainsController + - DomainMailer + - BankTransaction + - Certificate + - Contact + - Depp::Contact + - Domain + - DomainCron + - Epp::Domain + - Invoice + - RegistrantVerification +ManualDispatch: + exclude: + - EppController#has_attribute + - EppController#validate_request + - ActionView::Helpers::FormBuilder#label + - ActionDispatch::Flash#call + - Ransack::Adapters::ActiveRecord::Context#evaluate +NestedIterators: + exclude: + - Registrar::DomainsController#index + - AccountActivity#to_csv + - EppErrors#collect_child_errors + - EppErrors#find_epp_code_and_value + - Versions::ClassMethods#all_versions_for + - Contact#destroy_orphans + - Contact#to_csv + - Depp::Contact#extract_info_disclosure + - Depp::Domain#create_nameservers_hash + - Directo#self.send_monthly_invoices + - Directo#self.send_receipts + - Domain#name_in_wire_format + - Domain#self.to_csv + - Epp::Domain#nameservers_from + - LegalDocument#self.remove_duplicates + - Nameserver#replace_hostname_ends + - RegistrantPresenter#domain_names_with_roles + - UniquenessMultiValidator#validate_each +UnusedParameters: + exclude: + - Registrar::PollsController#show#@data.css +PrimaDonnaMethod: + exclude: + - DomainDeleteConfirmJob + - DomainUpdateConfirmJob + - Certificate + - Contact + - Domain + - Epp::Domain + - EppSession + - RegistrantVerification + - Registrar +BooleanParameter: + exclude: + - ApplicationMailer#delivery_off? + - Directo#self.send_monthly_invoices + - Epp::Contact#attrs_from + - Epp::Domain#update +ControlParameter: + exclude: + - ApplicationMailer#delivery_off? + - Ability#initialize + - EppErrors#find_epp_code_and_value + - Depp::Contact#extension_xml + - Directo#self.send_monthly_invoices + - Domain#registrant_delete_confirmable? + - Domain#registrant_update_confirmable? + - Epp::Contact#attrs_from + - Epp::Contact#statuses_attrs + - Epp::Domain#authenticate + - Epp::Domain#dnskeys_attrs + - Epp::Domain#domain_contact_attrs_from + - Epp::Domain#domain_statuses_attrs + - Epp::Domain#nameservers_attrs + - Epp::Domain#transfer + - Epp::Domain#update + - Legacy::Object#self.instance_method_already_implemented? + - Legacy::ObjectHistory#self.instance_method_already_implemented? + - RegistrantUser#find_or_create_by_idc_data +LongParameterList: + exclude: + - ContactMailer#email_updated + - DomainDeleteMailer#forced + - RegistrantChangeMailer#confirm + - RegistrantChangeMailer#notice + - EppErrors#add_epp_error + - Contact#all_registrant_domains +DataClump: + exclude: + - DomainMailer + - Epp::Domain +Attribute: + exclude: + - ApiUser#registrar_typeahead + - BankLink::Request#controller + - BankLink::Request#invoice + - BankLink::Request#type + - BankLink::Response#invoice + - BankLink::Response#params + - BankLink::Response#type + - BankStatement#th6_file + - Versions#version_loader + - Contact#deliver_emails + - Contact#domain_transfer + - Contact#domains_present + - Contact#legal_document_id + - Counter#value + - Deposit#amount + - Deposit#description + - Deposit#registrar + - Deposit#registrar_id + - Depp::Contact#city + - Depp::Contact#code + - Depp::Contact#country_code + - Depp::Contact#email + - Depp::Contact#id + - Depp::Contact#ident + - Depp::Contact#ident_country_code + - Depp::Contact#ident_type + - Depp::Contact#legal_document + - Depp::Contact#name + - Depp::Contact#org_name + - Depp::Contact#password + - Depp::Contact#phone + - Depp::Contact#state + - Depp::Contact#statuses + - Depp::Contact#street + - Depp::Contact#zip + - Depp::Domain#current_user + - Depp::Domain#epp_xml + - Depp::Domain#name + - Depp::Keyrelay#current_user + - Depp::Keyrelay#epp_xml + - Depp::User#password + - Depp::User#pki + - Depp::User#tag + - Domain#deliver_emails + - Domain#epp_pending_delete + - Domain#epp_pending_update + - Domain#is_admin + - Domain#legal_document_id + - Domain#registrant_typeahead + - Domain#reserved_pw + - Domain#roles + - Domain#update_me + - DomainContact#value_typeahead + - Epp::Domain#is_renewal + - Epp::Domain#is_transfer + - Invoice#billing_email + - LegalDocument#body + - RegistrantUser#idc_data + - Soap::Arireg#host + - Soap::Arireg#password + - Soap::Arireg#username + - Soap::Arireg#wsdl + - Soap::Arireg::NotAvailableError#json + - User#phone + - PaperSession#session +TooManyConstants: + exclude: + - Certificate + - Contact + - DomainStatus + - DomainTransfer +UncommunicativeParameterName: + exclude: + - Counter#next + - Counter#prev + - Depp::Domain#array_difference + - Dnskey#bin_to_hex + - Dnskey#hex_to_bin + - Dnskey#int_to_hex +UncommunicativeMethodName: + exclude: + - Nameserver#val_ipv4 + - Nameserver#val_ipv6 + - Soap::Arireg#country_code_3 + - WhiteIp#validate_ipv4_and_ipv6 diff --git a/Gemfile b/Gemfile index 2f7587fc9..0e170ed73 100644 --- a/Gemfile +++ b/Gemfile @@ -104,6 +104,7 @@ gem 'activerecord-import', '0.7.0' # for inserting dummy data # for generating pdf gem 'pdfkit', '0.6.2' gem 'jquery-ui-rails', '5.0.5' +gem 'active_model-errors_details' # Backport from Rails 5, https://github.com/rails/rails/pull/18322 group :development do gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index bd372118f..d10114e87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,9 @@ GEM erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) + active_model-errors_details (1.3.1) + activemodel (>= 3.2.13, < 5.0.0) + activesupport activejob (4.2.7.1) activesupport (= 4.2.7.1) globalid (>= 0.3.0) @@ -489,6 +492,7 @@ PLATFORMS DEPENDENCIES SyslogLogger (= 2.0) + active_model-errors_details activerecord-import (= 0.7.0) airbrake autodoc diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index e930a511f..6402d09ae 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -2,6 +2,7 @@ module Admin class ContactsController < BaseController load_and_authorize_resource before_action :set_contact, only: [:show] + helper_method :ident_types def index params[:q] ||= {} @@ -79,5 +80,9 @@ module Admin params[:q][:created_at_lteq] = ca_cache end + + def ident_types + Contact::Ident.types + end end end diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 4a0a0d9d0..8eb6fbc96 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -152,9 +152,6 @@ class EppController < ApplicationController code: '1', msg: 'handle_errors was executed when there were actually no errors' } - # rubocop:disable Rails/Output - puts "FULL MESSAGE: #{obj.errors.full_messages} #{obj.errors.inspect}" if Rails.env.test? - # rubocop: enable Rails/Output end @errors.uniq! diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index b927df1a8..4d0de5389 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -2,6 +2,7 @@ class Registrar class ContactsController < DeppController before_action :init_epp_contact helper_method :address_processing? + helper_method :ident_types def index authorize! :view, Depp::Contact @@ -140,5 +141,9 @@ class Registrar def address_processing? Contact.address_processing? end + + def ident_types + Contact::Ident.types + end end end diff --git a/app/models/concerns/epp_errors.rb b/app/models/concerns/epp_errors.rb index cf3824260..7395732ca 100644 --- a/app/models/concerns/epp_errors.rb +++ b/app/models/concerns/epp_errors.rb @@ -11,6 +11,12 @@ module EppErrors epp_errors << collect_child_errors(attr) end + if self.class.reflect_on_aggregation(attr) + aggregation = send(attr) + epp_errors << collect_aggregation_errors(aggregation) + next + end + epp_errors << collect_parent_errors(attr, errors) end @@ -46,6 +52,31 @@ module EppErrors epp_errors end + def collect_aggregation_errors(aggregation) + epp_errors = [] + + aggregation.errors.details.each do |attr, error_details| + error_details.each do |error_detail| + aggregation.class.epp_code_map.each do |epp_code, attr_to_error| + epp_code_found = attr_to_error.any? { |i| i == [attr, error_detail[:error]] } + + next unless epp_code_found + + message = aggregation.errors.generate_message(attr, error_detail[:error], error_detail) + message = aggregation.errors.full_message(attr, message) + + if attr != :base + message = "#{aggregation.model_name.human} #{message.camelize(:lower)}" + end + + epp_errors << { code: epp_code, msg: message } + end + end + end + + epp_errors + end + def find_epp_code_and_value(msg) epp_code_map.each do |code, values| values.each do |x| diff --git a/app/models/contact.rb b/app/models/contact.rb index 1c723161d..f04a16032 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -19,27 +19,22 @@ class Contact < ActiveRecord::Base accepts_nested_attributes_for :legal_documents - validates :name, :phone, :email, :ident, :ident_type, presence: true + validates :name, :email, presence: true validates :street, :city, :zip, :country_code, presence: true, if: 'self.class.address_processing?' - validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/, phone: true + validates :phone, presence: true, e164: true, phone: true validates :email, format: /@/ validates :email, email_format: { message: :invalid }, if: proc { |c| c.email_changed? } - validates :ident, - format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format }, - if: proc { |c| c.ident_type == 'birthday' } - validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }, on: :create + validates :code, uniqueness: { message: :epp_id_taken }, format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, length: { maximum: 100, message: :too_long_contact_code } + validates_associated :identifier - validate :val_ident_type - validate :val_ident_valid_format? validate :validate_html validate :validate_country_code - validate :validate_ident_country_code after_initialize do self.status_notes = {} if status_notes.nil? @@ -49,8 +44,15 @@ class Contact < ActiveRecord::Base before_validation :to_upcase_country_code before_validation :strip_email before_create :generate_auth_info - before_update :manage_emails + + composed_of :identifier, + class_name: 'Contact::Ident', + constructor: proc { |code, type, country_code| Contact::Ident.new(code: code, + type: type, + country_code: country_code) }, + mapping: [%w[ident code], %w[ident_type type], %w[ident_country_code country_code]] + def manage_emails return nil unless email_changed? return nil unless deliver_emails == true @@ -76,12 +78,6 @@ class Contact < ActiveRecord::Base BIRTHDAY = 'birthday'.freeze PASSPORT = 'passport' - IDENT_TYPES = [ - ORG, # Company registry code (or similar) - PRIV, # National idendtification number - BIRTHDAY # Birthday date - ] - attr_accessor :deliver_emails attr_accessor :domain_transfer # hack but solves problem faster @@ -219,10 +215,6 @@ class Contact < ActiveRecord::Base STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{counter} orphaned contacts\n" unless Rails.env.test? end - def privs - where("ident_type = '#{PRIV}'") - end - def admin_statuses [ SERVER_UPDATE_PROHIBITED, @@ -299,28 +291,6 @@ class Contact < ActiveRecord::Base name || '[no name]' end - def val_ident_type - errors.add(:ident_type, :epp_ident_type_invalid, code: code) if !%w(org priv birthday).include?(ident_type) - end - - def val_ident_valid_format? - case ident_country_code - when 'EE'.freeze - err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym - case ident_type - when 'priv'.freeze - errors.add(:ident, err_msg) unless Isikukood.new(ident).valid? - when 'org'.freeze - # !%w(1 7 8 9).freeze.include?(ident.first) || - if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/) - errors.add(:ident, err_msg) - end - when BIRTHDAY - errors.add(:ident, err_msg) if id.blank? # only for create action right now. Later for all of them - end - end - end - def validate_html self.class.columns.each do |column| next unless column.type == :string @@ -334,7 +304,6 @@ class Contact < ActiveRecord::Base end end - def org? ident_type == ORG end @@ -344,10 +313,6 @@ class Contact < ActiveRecord::Base !org? end - def birthday? - ident_type == BIRTHDAY - end - def generate_auth_info return if @generate_auth_info_disabled return if auth_info.present? @@ -424,10 +389,6 @@ class Contact < ActiveRecord::Base errors.add(:country_code, :invalid) unless Country.new(country_code) end - def validate_ident_country_code - errors.add(:ident, :invalid_country_code) unless Country.new(ident_country_code) - end - def related_domain_descriptions ActiveSupport::Deprecation.warn('Use #domain_names_with_roles') @@ -572,7 +533,7 @@ class Contact < ActiveRecord::Base return if changes.slice(*(self.class.column_names - ["updated_at", "created_at", "statuses", "status_notes"])).empty? names = related_domain_descriptions.keys - UpdateWhoisRecordJob.enqueue(names, :domain) if names.present? + UpdateWhoisRecordJob.enqueue(names, 'domain') if names.present? end def children_log diff --git a/app/models/contact/ident.rb b/app/models/contact/ident.rb new file mode 100644 index 000000000..d531b833c --- /dev/null +++ b/app/models/contact/ident.rb @@ -0,0 +1,74 @@ +class Contact::Ident + include ActiveModel::Model + + attr_accessor :code + attr_accessor :type + attr_accessor :country_code + + validates :code, presence: true + validates :code, national_id: true, if: :national_id? + validates :code, reg_no: true, if: :reg_no? + validates :code, iso8601: { date_only: true }, if: :birthday? + + validates :type, presence: true, inclusion: { in: proc { types } } + validates :country_code, presence: true, iso31661_alpha2: true + validates_with MismatchValidator + + def self.epp_code_map + { + '2003' => [ + [:code, :blank], + [:type, :blank], + [:country_code, :blank] + ], + '2005' => [ + [:base, :mismatch], + [:code, :invalid_national_id], + [:code, :invalid_reg_no], + [:code, :invalid_iso8601_date], + [:country_code, :invalid_iso31661_alpha2] + ] + } + end + + def self.types + %w[org priv birthday] + end + + def marked_for_destruction? + false + end + + def birthday? + type == 'birthday' + end + + def national_id? + type == 'priv' + end + + def reg_no? + type == 'org' + end + + def country + Country.new(country_code) + end + + def ==(other_ident) + if other_ident.is_a?(self.class) + (code == other_ident.code) && + (type == other_ident.type) && + (country_code == other_ident.country_code) + else + false + end + end + + private + + # https://github.com/rails/rails/issues/1513 + def validation_context=(_value) + ; + end +end diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 53ebb2ee8..b280ceea6 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -109,7 +109,7 @@ class Epp::Contact < Contact end delegate :ident_attr_valid?, to: :class - def epp_code_map # rubocop:disable Metrics/MethodLength + def epp_code_map { '2003' => [ # Required parameter missing [:name, :blank], @@ -124,31 +124,19 @@ class Epp::Contact < Contact [:name, :invalid], [:phone, :invalid], [:email, :invalid], - [:ident, :invalid], - [:ident, :invalid_EE_identity_format], - [:ident, :invalid_EE_identity_format_update], - [:ident, :invalid_birthday_format], - [:ident, :invalid_country_code], [:country_code, :invalid], - [:ident_type, :missing], [:code, :invalid], [:code, :too_long_contact_code] ], '2302' => [ # Object exists [:code, :epp_id_taken] ], - '2304' => [ # Object status prohibits operation - [:ident_type, :epp_ident_type_invalid, { value: { obj: 'code', val: code}, interpolation: {code: code}}] - ], '2305' => [ # Association exists [:domains, :exist] - ], - '2306' => [ # Parameter policy error ] } end - # rubocop:disable Metrics/AbcSize def update_attributes(frame, current_user) return super if frame.blank? at = {}.with_indifferent_access @@ -158,9 +146,6 @@ class Epp::Contact < Contact at[:statuses] = statuses - statuses_attrs(frame.css('rem'), 'rem') + statuses_attrs(frame.css('add'), 'add') end - # legal_frame = frame.css('legalDocument').first - # at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame) - if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame)) frame.css("legalDocument").first.content = doc.path if doc && doc.persisted? self.legal_document_id = doc.id @@ -168,29 +153,28 @@ class Epp::Contact < Contact self.deliver_emails = true # turn on email delivery for epp + ident_frame = frame.css('ident').first - # allow to update ident code for legacy contacts - if frame.css('ident').first - self.ident_updated_at ||= Time.zone.now # not in use - ident_frame = frame.css('ident').first + # https://github.com/internetee/registry/issues/576 + if ident_frame + if identifier.valid? + submitted_ident = Ident.new(code: ident_frame.text, + type: ident_frame.attr('type'), + country_code: ident_frame.attr('cc')) - if ident_frame && ident_attr_valid?(ident_frame) - org_priv = %w(org priv).freeze - if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type')) - at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) - elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false) - at.merge!(ident: ident_frame.text) - at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? - elsif ident_type == "birthday" && ident_country_code.blank? - at.merge!(ident_country_code: ident_frame.attr('cc')) - elsif ident_type.blank? && ident_country_code.blank? - at.merge!(ident_type: ident_frame.attr('type')) - at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? - else - throw :epp_error, {code: '2306', msg: I18n.t(:ident_update_error)} - end + report_valid_ident_error if submitted_ident != identifier else - throw :epp_error, {code: '2306', msg: I18n.t(:ident_update_error)} + ident_update_attempt = ident_frame.text.present? && (ident_frame.text != ident) + report_ident_update_error if ident_update_attempt + + identifier = Ident.new(code: ident, + type: ident_frame.attr('type'), + country_code: ident_frame.attr('cc')) + + identifier.validate + + self.identifier = identifier + self.ident_updated_at ||= Time.zone.now end end @@ -199,7 +183,6 @@ class Epp::Contact < Contact super(at) end - # rubocop:enable Metrics/AbcSize def statuses_attrs(frame, action) status_list = status_list_from(frame) @@ -259,4 +242,13 @@ class Epp::Contact < Contact self.legal_document_id = doc.id end + private + + def report_valid_ident_error + throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.valid_ident') } + end + + def report_ident_update_error + throw :epp_error, { code: '2308', msg: I18n.t('epp.contacts.errors.ident_update') } + end end diff --git a/app/models/epp/response.rb b/app/models/epp/response.rb new file mode 100644 index 000000000..c9a5d8bb4 --- /dev/null +++ b/app/models/epp/response.rb @@ -0,0 +1,22 @@ +module EPP + class Response + attr_accessor :results + + def self.from_xml(xml) + xml_doc = Nokogiri::XML(xml) + response = new + + result_elements = xml_doc.css('result') + + result_elements.each do |result_element| + response.results << Result.new(result_element[:code].to_s, result_element.text.strip) + end + + response + end + + def initialize + @results = [] + end + end +end diff --git a/app/models/epp/response/result.rb b/app/models/epp/response/result.rb new file mode 100644 index 000000000..5c870c830 --- /dev/null +++ b/app/models/epp/response/result.rb @@ -0,0 +1,28 @@ +module EPP + class Response + class Result + CODE_TO_TYPE = { + '1000' => :success, + '1001' => :success_pending, + '1300' => :success_empty_queue, + '1301' => :success_dequeue, + '2001' => :syntax_error, + '2003' => :required_param_missing, + '2005' => :param_syntax_error, + '2308' => :data_management_policy_violation + } + + attr_accessor :code + attr_accessor :message + + def initialize(code, message) + @code = code + @message = message + end + + def self.codes + CODE_TO_TYPE + end + end + end +end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index b906beee3..3ad54279d 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -9,7 +9,6 @@ class Registrar < ActiveRecord::Base has_many :accounts has_many :nameservers, through: :domains has_many :whois_records - has_many :priv_contacts, -> { privs }, class_name: 'Contact' has_many :white_ips, dependent: :destroy delegate :balance, to: :cash_account, allow_nil: true diff --git a/app/validators/contact/ident/mismatch_validator.rb b/app/validators/contact/ident/mismatch_validator.rb new file mode 100644 index 000000000..d20bb82cf --- /dev/null +++ b/app/validators/contact/ident/mismatch_validator.rb @@ -0,0 +1,20 @@ +class Contact::Ident::MismatchValidator < ActiveModel::Validator + Mismatch = Struct.new(:type, :country) + + def self.mismatches + [ + Mismatch.new('birthday', Country.new('EE')), + ] + end + + def validate(record) + record.errors.add(:base, :mismatch, type: record.type, country: record.country) if mismatched?(record) + end + + private + + def mismatched?(record) + mismatch = Mismatch.new(record.type, record.country) + self.class.mismatches.include?(mismatch) + end +end diff --git a/app/validators/contact/ident/national_id_validator.rb b/app/validators/contact/ident/national_id_validator.rb new file mode 100644 index 000000000..2fcf019b1 --- /dev/null +++ b/app/validators/contact/ident/national_id_validator.rb @@ -0,0 +1,22 @@ +class Contact::Ident::NationalIdValidator < ActiveModel::EachValidator + def self.country_specific_validations + { + Country.new('EE') => proc { |code| Isikukood.new(code).valid? }, + } + end + + def validate_each(record, attribute, value) + validation = validation_for(record.country) + + return unless validation + + valid = validation.call(value) + record.errors.add(attribute, :invalid_national_id, country: record.country) unless valid + end + + private + + def validation_for(country) + self.class.country_specific_validations[country] + end +end diff --git a/app/validators/contact/ident/reg_no_validator.rb b/app/validators/contact/ident/reg_no_validator.rb new file mode 100644 index 000000000..611d13301 --- /dev/null +++ b/app/validators/contact/ident/reg_no_validator.rb @@ -0,0 +1,21 @@ +class Contact::Ident::RegNoValidator < ActiveModel::EachValidator + def self.country_specific_formats + { + Country.new('EE') => /\A[0-9]{8}\z/, + } + end + + def validate_each(record, attribute, value) + format = format_for(record.country) + + return unless format + + record.errors.add(attribute, :invalid_reg_no, country: record.country) unless value =~ format + end + + private + + def format_for(country) + self.class.country_specific_formats[country] + end +end diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index d9f60c13b..cc80ac744 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -19,7 +19,7 @@ .col-md-3 .form-group = label_tag t(:ident_type) - = select_tag '[q][ident_type_eq]', options_for_select(Contact::IDENT_TYPES, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + = select_tag '[q][ident_type_eq]', options_for_select(ident_types, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } .row .col-md-3 .form-group @@ -75,7 +75,7 @@ .row .col-md-12 .table-responsive - %table.table.table-hover.table-bordered.table-condensed + %table.table.table-hover.table-bordered.table-condensed.contacts %thead %tr %th{class: 'col-xs-2'} diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index fd4672350..5f5a667c0 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -21,7 +21,7 @@ .col-md-3 .form-group = label_tag t(:ident_type) - = select_tag '[q][ident_type_eq]', options_for_select(Contact::IDENT_TYPES, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + = select_tag '[q][ident_type_eq]', options_for_select(ident_types, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } .row .col-md-3 .form-group @@ -85,7 +85,7 @@ .row .col-md-12 .table-responsive - %table.table.table-hover.table-bordered.table-condensed + %table.table.table-hover.table-bordered.table-condensed.contacts %thead %tr %th{class: 'col-xs-2'} diff --git a/config/initializers/eis_custom_active_model.rb b/config/initializers/eis_custom_active_model.rb deleted file mode 100644 index ba5f29b06..000000000 --- a/config/initializers/eis_custom_active_model.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Log all active model user errors -# rubocop: disable Lint/AssignmentInCondition -# rubocop: disable Style/SignalException -module ActiveModel - class Errors - def add(attribute, message = :invalid, options = {}) - message = normalize_message(attribute, message, options) - if exception = options[:strict] - exception = ActiveModel::StrictValidationFailed if exception == true - raise exception, full_message(attribute, message) - end - - # CUSTOM logging - Rails.logger.info "USER MSG: ACTIVEMODEL: #{@base.try(:class)} [#{attribute}] #{message}" if message.present? - # END of CUSTOM logging - - self[attribute] << message - end - end -end diff --git a/config/initializers/eis_custom_active_record.rb b/config/initializers/eis_custom_active_record.rb deleted file mode 100644 index 60dcebeb9..000000000 --- a/config/initializers/eis_custom_active_record.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Log all user issues raised by active record -# rubocop: disable Metrics/LineLength -class ActiveRecord::Base - after_validation do |m| - Rails.logger.info "USER MSG: ACTIVERECORD: #{m.class} ##{m.id} #{m.errors.full_messages} #{m.errors['epp_errors']}" if m.errors.present? - true - end -end diff --git a/config/initializers/eis_custom_flash.rb b/config/initializers/eis_custom_flash.rb deleted file mode 100644 index 4e4d359b5..000000000 --- a/config/initializers/eis_custom_flash.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Log all flash messages -# rubocop: disable Metrics/CyclomaticComplexity -# rubocop: disable Metrics/LineLength -module ActionDispatch - class Flash - # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Style/MultilineOperationIndentation - def call(env) - @app.call(env) - ensure - session = Request::Session.find(env) || {} - flash_hash = env[KEY] - - if flash_hash && (flash_hash.present? || session.key?('flash')) - session["flash"] = flash_hash.to_session_value - - # EIS custom logging - Rails.logger.info "USER MSG: FLASH: #{session['flash']['flashes'].inspect}" if session['flash'] - # END OF EIS custom logging - - env[KEY] = flash_hash.dup - end - - if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) - session.key?('flash') && session['flash'].nil? - session.delete('flash') - end - end - end -end - diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml index 2061d2abd..0c3c1fe29 100644 --- a/config/locales/contacts.en.yml +++ b/config/locales/contacts.en.yml @@ -9,5 +9,20 @@ en: models: contact: attributes: + code: + blank: "Required parameter missing - code" + too_long_contact_code: "Contact code is too long, max 100 characters" + name: + blank: "Required parameter missing - name" + phone: + blank: "Required parameter missing - phone" + invalid: "Phone nr is invalid" + email: + blank: "Required parameter missing - email" + invalid: "Email is invalid" + domains: + exist: 'Object association prohibits operation' + statuses: + not_uniq: 'not uniq' country_code: invalid: Country code is not valid, should be in ISO_3166-1 alpha 2 format diff --git a/config/locales/en.yml b/config/locales/en.yml index ef8762917..0a4a83c98 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,33 +34,6 @@ en: activerecord: errors: models: - contact: - attributes: - code: - blank: "Required parameter missing - code" - too_long_contact_code: "Contact code is too long, max 100 characters" - name: - blank: "Required parameter missing - name" - phone: - blank: "Required parameter missing - phone" - invalid: "Phone nr is invalid" - email: - blank: "Required parameter missing - email" - invalid: "Email is invalid" - ident: - blank: "Required parameter missing - ident" - invalid_EE_identity_format: "Ident not in valid Estonian identity format." - invalid_EE_identity_format_update: "Ident not in valid Estonian identity format. Please create new contact" - invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD" - invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format" - ident_type: - ident_type_invalid: 'Ident type is invalid' - epp_ident_type_invalid: 'Object status prohibits operation: ident_type of contact %{code} is invalid' - domains: - exist: 'Object association prohibits operation' - statuses: - not_uniq: 'not uniq' - epp_domain: &epp_domain_ar_attributes attributes: base: @@ -262,6 +235,8 @@ en: unimplemented_command: 'Unimplemented command' domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar' required_ident_attribute_missing: "Required ident attribute missing: %{key}" + invalid_iso31661_alpha2: does not conform to ISO 3166-1 alpha-2 standard + invalid_iso8601_date: has invalid date format YYYY-MM-DD (ISO 8601) code: 'Code' action: 'Action' @@ -487,7 +462,6 @@ en: crt_revoked: 'CRT (revoked)' contact_org_error: 'Parameter value policy error. Org must be blank' contact_fax_error: 'Parameter value policy error. Fax must be blank' - ident_update_error: 'Parameter value policy error. Update of ident data not allowed [ident]' invoices: 'Invoices' no_such_user: 'No such user' phone_no: 'Phone number' diff --git a/config/locales/epp/contacts.en.yml b/config/locales/epp/contacts.en.yml index a669310ab..fe4ed7ccf 100644 --- a/config/locales/epp/contacts.en.yml +++ b/config/locales/epp/contacts.en.yml @@ -3,3 +3,11 @@ en: contacts: completed: Command completed successfully completed_without_address: Command completed successfully; Postal address data discarded + + errors: + valid_ident: >- + Ident update is not allowed. + Consider creating new contact object + ident_update: >- + Only ident type and country can be updated in case of invalid ident. + Please create new contact object to update ident code diff --git a/config/locales/idents.yml b/config/locales/idents.yml new file mode 100644 index 000000000..33b935833 --- /dev/null +++ b/config/locales/idents.yml @@ -0,0 +1,11 @@ +en: + activemodel: + errors: + models: + contact/ident: + attributes: + base: + mismatch: Ident type "%{type}" is invalid for %{country} + code: + invalid_national_id: does not conform to national identification number format of %{country} + invalid_reg_no: does not conform to registration number format of %{country} diff --git a/doc/epp/contact.md b/doc/epp/contact.md index 3ec314b9e..b1f00aedf 100644 --- a/doc/epp/contact.md +++ b/doc/epp/contact.md @@ -36,7 +36,7 @@ More info: https://en.wikipedia.org/wiki/Latin_script_in_Unicode 1 E-mail 1 1 Attribute: xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" - 1 Contact identificator + 1 Identifier Attribute: "type" "org" # Business registry code "priv" # National identification number @@ -73,7 +73,7 @@ More info: https://en.wikipedia.org/wiki/Latin_script_in_Unicode 1 Contact password. Attribute: roid="String" 0-1 0-1 Attribute: xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" - 0-1 Contact identificator + 0-1 Identifier Attribute: "type" "org" # Business registry code "priv" # National identification number diff --git a/doc/models_brief.svg b/doc/models_brief.svg index 76dd9a83f..22d63cfe7 100644 --- a/doc/models_brief.svg +++ b/doc/models_brief.svg @@ -1031,25 +1031,11 @@ -Registrar->Contact - - - -priv_contacts - - Registrar->Contact - -Registrar->Contact - - - -priv_contacts - Registrar->Domain diff --git a/doc/models_complete.svg b/doc/models_complete.svg index 58b86b986..255ddf0c9 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -1643,25 +1643,11 @@ -Registrar->Contact - - - -priv_contacts - - Registrar->Contact - -Registrar->Contact - - - -priv_contacts - Registrar->Domain diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 470949c14..65be88f7a 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -175,6 +175,8 @@ namespace :dev do end end + Setting.api_ip_whitelist_enabled = false + Setting.address_processing = false Setting.registrar_ip_whitelist_enabled = false ActiveRecord::Base.transaction do diff --git a/lib/validators/e164_validator.rb b/lib/validators/e164_validator.rb new file mode 100644 index 000000000..e5807e585 --- /dev/null +++ b/lib/validators/e164_validator.rb @@ -0,0 +1,12 @@ +class E164Validator < ActiveModel::EachValidator + def validate_each(record, attribute, _value) + length_validator = ActiveModel::Validations:: + LengthValidator.new(maximum: 17, attributes: attribute) + length_validator.validate(record) + + format_validator = ActiveModel::Validations:: + FormatValidator.new(with: /\+[0-9]{1,3}\.[0-9]{1,14}?/, + attributes: attribute) + format_validator.validate(record) + end +end diff --git a/lib/validators/iso31661_alpha2_validator.rb b/lib/validators/iso31661_alpha2_validator.rb new file mode 100644 index 000000000..6535e11d4 --- /dev/null +++ b/lib/validators/iso31661_alpha2_validator.rb @@ -0,0 +1,11 @@ +class Iso31661Alpha2Validator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + record.errors.add(attribute, :invalid_iso31661_alpha2) unless valid_country_code?(value) + end + + private + + def valid_country_code?(country_code) + Country.new(country_code) + end +end diff --git a/lib/validators/iso8601_validator.rb b/lib/validators/iso8601_validator.rb new file mode 100644 index 000000000..bbcf63798 --- /dev/null +++ b/lib/validators/iso8601_validator.rb @@ -0,0 +1,13 @@ +class Iso8601Validator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + if options[:date_only] + record.errors.add(attribute, :invalid_iso8601_date) unless value =~ date_format + end + end + + private + + def date_format + /\d{4}-\d{2}-\d{2}/ + end +end diff --git a/lib/validators/phone_validator.rb b/lib/validators/phone_validator.rb index d0bf94f1b..a2a91e9f7 100644 --- a/lib/validators/phone_validator.rb +++ b/lib/validators/phone_validator.rb @@ -2,11 +2,11 @@ class PhoneValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if record.errors[:phone].any? - splitted_phone = value.split('.') - country_code = splitted_phone.first - phone_number = splitted_phone.second + phone_parts = value.split('.') + country_code = phone_parts.first + subscriber_no = phone_parts.second - if zeros_only?(country_code) || zeros_only?(phone_number) + if zeros_only?(country_code) || zeros_only?(subscriber_no) record.errors.add(attribute, :invalid) end end diff --git a/spec/features/admin/contacts/list_spec.rb b/spec/features/admin/contacts/list_spec.rb new file mode 100644 index 000000000..80312fb17 --- /dev/null +++ b/spec/features/admin/contacts/list_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +RSpec.feature 'Contact list', settings: false do + background do + sign_in_to_admin_area + end + + it 'is visible' do + visit admin_contacts_path + expect(page).to have_css('.contacts') + end +end diff --git a/spec/features/registrar/contacts/list_spec.rb b/spec/features/registrar/contacts/list_spec.rb new file mode 100644 index 000000000..96f1f2c98 --- /dev/null +++ b/spec/features/registrar/contacts/list_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.feature 'Contact list', settings: false do + given!(:registrar) { create(:registrar) } + given!(:contact) { create(:contact, registrar: registrar) } + + background do + sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance, registrar: registrar)) + end + + it 'is visible' do + visit registrar_contacts_path + expect(page).to have_css('.contacts') + end +end diff --git a/spec/lib/validators/e164.rb b/spec/lib/validators/e164.rb new file mode 100644 index 000000000..bfb4914a3 --- /dev/null +++ b/spec/lib/validators/e164.rb @@ -0,0 +1,29 @@ +# https://en.wikipedia.org/wiki/E.164 + +RSpec.shared_examples 'e164' do + describe 'validation' do + it 'rejects invalid format' do + model.send("#{attribute}=", '+.1') + model.validate + expect(model.errors).to be_added(attribute, :invalid) + end + + it 'rejects longer than max length' do + model.send("#{attribute}=", '1' * 18) + model.validate + expect(model.errors).to be_added(attribute, :too_long, count: 17) + end + + it 'accepts valid format' do + model.send("#{attribute}=", '+123.4') + model.validate + expect(model.errors).to_not be_added(attribute, :invalid) + end + + it 'accepts max length' do + model.send("#{attribute}=", '1' * 17) + model.validate + expect(model.errors).to_not be_added(attribute, :too_long, count: 17) + end + end +end diff --git a/spec/lib/validators/iso31661_alpha2.rb b/spec/lib/validators/iso31661_alpha2.rb new file mode 100644 index 000000000..618a68cfb --- /dev/null +++ b/spec/lib/validators/iso31661_alpha2.rb @@ -0,0 +1,17 @@ +# https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + +RSpec.shared_examples 'iso31661_alpha2' do + describe 'validation' do + it 'rejects invalid' do + model.send("#{attribute}=", 'invalid') + model.validate + expect(model.errors).to be_added(attribute, :invalid_iso31661_alpha2) + end + + it 'accepts valid' do + model.send("#{attribute}=", 'US') + model.validate + expect(model.errors).to_not be_added(attribute, :invalid_iso31661_alpha2) + end + end +end diff --git a/spec/lib/validators/iso8601.rb b/spec/lib/validators/iso8601.rb new file mode 100644 index 000000000..78d8f2c4a --- /dev/null +++ b/spec/lib/validators/iso8601.rb @@ -0,0 +1,17 @@ +# https://en.wikipedia.org/wiki/ISO_8601 + +RSpec.shared_examples 'iso8601' do + describe 'validation' do + it 'rejects invalid' do + model.send("#{attribute}=", '2010-07-0') + model.validate + expect(model.errors).to be_added(attribute, :invalid_iso8601_date) + end + + it 'accepts valid' do + model.send("#{attribute}=", '2010-07-05') + model.validate + expect(model.errors).to_not be_added(attribute, :invalid_iso8601_date) + end + end +end diff --git a/spec/models/contact/contact_phone_spec.rb b/spec/models/contact/contact_phone_spec.rb new file mode 100644 index 000000000..cc1ecbec0 --- /dev/null +++ b/spec/models/contact/contact_phone_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' +require 'lib/validators/e164' + +RSpec.describe Contact do + let(:contact) { described_class.new } + + describe 'phone', db: false do + it_behaves_like 'e164' do + let(:model) { contact } + let(:attribute) { :phone } + end + end + + describe 'phone validation', db: false do + it 'rejects absent' do + contact.phone = nil + contact.validate + expect(contact.errors).to be_added(:phone, :blank) + end + + it 'rejects all zeros in country code' do + contact.phone = '+000.1' + contact.validate + expect(contact.errors).to be_added(:phone, :invalid) + end + + it 'rejects all zeros in subscriber number' do + contact.phone = '+123.0' + contact.validate + expect(contact.errors).to be_added(:phone, :invalid) + end + end +end diff --git a/spec/models/contact/ident_spec.rb b/spec/models/contact/ident_spec.rb new file mode 100644 index 000000000..d26f76d0f --- /dev/null +++ b/spec/models/contact/ident_spec.rb @@ -0,0 +1,227 @@ +require 'active_model' +require 'lib/validators/iso31661_alpha2' +require 'lib/validators/iso8601' + +RSpec.describe Contact::Ident, db: false do + let(:ident) { described_class.new } + + describe 'country code' do + it_behaves_like 'iso31661_alpha2' do + let(:model) { ident } + let(:attribute) { :country_code } + end + end + + describe 'code validation' do + it 'rejects absent' do + ident.code = nil + ident.validate + expect(ident.errors).to be_added(:code, :blank) + end + + context 'when type is :birthday' do + let(:ident) { described_class.new(type: 'birthday') } + + it_behaves_like 'iso8601' do + let(:model) { ident } + let(:attribute) { :code } + end + end + + context 'when type is not :birthday' do + let(:ident) { described_class.new(type: 'priv') } + + it 'accepts any' do + ident.code = '%123456789%' + ident.validate + expect(ident.errors).to_not include(:code) + end + end + + context 'when country code is EE' do + context 'when type is :priv' do + let(:ident) { described_class.new(country_code: 'EE', type: 'priv') } + + it 'rejects invalid' do + ident.code = 'invalid' + ident.validate + expect(ident.errors).to be_added(:code, :invalid_national_id, country: 'Estonia') + end + + it 'accepts valid' do + ident.code = '47101010033' + ident.validate + expect(ident.errors).to_not be_added(:code, :invalid_national_id, country: 'Estonia') + end + end + + context 'when ident type is :org' do + let(:ident) { described_class.new(country_code: 'EE', type: 'org') } + + it 'rejects invalid' do + ident.code = '1' * 7 + ident.validate + expect(ident.errors).to be_added(:code, :invalid_reg_no, country: 'Estonia') + end + + it 'accepts valid length' do + ident.code = '1' * 8 + ident.validate + expect(ident.errors).to_not be_added(:code, :invalid_reg_no, country: 'Estonia') + end + end + end + + context 'when ident country code is not EE' do + let(:ident) { described_class.new(country_code: 'US') } + + it 'accepts any' do + ident.code = 'test-123456789' + ident.validate + expect(ident.errors).to_not include(:code) + end + end + + it 'translates :invalid_national_id error message' do + expect(ident.errors.generate_message(:code, :invalid_national_id, country: 'Germany')) + .to eq('does not conform to national identification number format of Germany') + end + + it 'translates :invalid_reg_no error message' do + expect(ident.errors.generate_message(:code, :invalid_reg_no, country: 'Germany')) + .to eq('does not conform to registration number format of Germany') + end + end + + describe 'type validation' do + before do + allow(described_class).to receive(:types).and_return(%w(valid)) + end + + it 'rejects absent' do + ident.type = nil + ident.validate + expect(ident.errors).to be_added(:type, :blank) + end + + it 'rejects invalid' do + ident.type = 'invalid' + ident.validate + expect(ident.errors).to be_added(:type, :inclusion) + end + + it 'accepts valid' do + ident.type = 'valid' + ident.validate + expect(ident.errors).to_not be_added(:type, :inclusion) + end + end + + describe 'country code validation' do + it 'rejects absent' do + ident.country_code = nil + ident.validate + expect(ident.errors).to be_added(:country_code, :blank) + end + end + + describe 'mismatch validation' do + let(:ident) { described_class.new(type: 'test', country_code: 'DE') } + + before do + mismatches = [Contact::Ident::MismatchValidator::Mismatch.new('test', Country.new('DE'))] + allow(Contact::Ident::MismatchValidator).to receive(:mismatches).and_return(mismatches) + end + + it 'rejects mismatched' do + ident.validate + expect(ident.errors).to be_added(:base, :mismatch, type: 'test', country: 'Germany') + end + + it 'accepts matched' do + ident.validate + expect(ident.errors).to_not be_added(:base, :mismatch, type: 'another-test', country: 'Germany') + end + + it 'translates :mismatch error message' do + expect(ident.errors.generate_message(:base, :mismatch, type: 'test', country: 'Germany')) + .to eq('Ident type "test" is invalid for Germany') + end + end + + describe '::types' do + it 'returns types' do + types = %w[ + org + priv + birthday + ] + + expect(described_class.types).to eq(types) + end + end + + describe '#birthday?' do + context 'when type is birthday' do + subject(:ident) { described_class.new(type: 'birthday') } + it { is_expected.to be_birthday } + end + + context 'when type is not birthday' do + subject(:ident) { described_class.new(type: 'priv') } + it { is_expected.to_not be_birthday } + end + end + + describe '#national_id?' do + context 'when type is priv' do + subject(:ident) { described_class.new(type: 'priv') } + it { is_expected.to be_national_id } + end + + context 'when type is not' do + subject(:ident) { described_class.new(type: 'org') } + it { is_expected.to_not be_national_id } + end + end + + describe '#reg_no?' do + context 'when type is birthday' do + subject(:ident) { described_class.new(type: 'org') } + it { is_expected.to be_reg_no } + end + + context 'when type is not birthday' do + subject(:ident) { described_class.new(type: 'priv') } + it { is_expected.to_not be_reg_no } + end + end + + describe '#country' do + let(:ident) { described_class.new(country_code: 'US') } + + it 'returns country' do + expect(ident.country).to eq(Country.new('US')) + end + end + + describe '#==' do + let(:ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') } + + context 'when code, type and country code are the same' do + let(:another_ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') } + + it 'returns true' do + expect(ident).to eq(another_ident) + end + end + + context 'when code, type and country code are not the same' do + let(:another_ident) { described_class.new(code: 'another-test', type: 'test', country_code: 'US') } + + it 'returns false' do + expect(ident).to_not eq(another_ident) + end + end + end +end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index c7cd38719..bef5b87be 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -28,45 +28,6 @@ RSpec.describe Contact do @contact.updator.should == nil end - it 'should require country code when org' do - @contact.ident_type = 'org' - @contact.valid? - @contact.errors[:ident_country_code].should == ['is missing'] - end - - it 'should require country code when priv' do - @contact.ident_type = 'priv' - @contact.valid? - @contact.errors[:ident_country_code].should == ['is missing'] - end - - it 'should validate correct country code' do - @contact.ident = 1 - @contact.ident_type = 'org' - @contact.ident_country_code = 'EE' - @contact.valid? - - @contact.errors[:ident_country_code].should == [] - end - - it 'should require valid country code' do - @contact.ident = '123' - @contact.ident_type = 'org' - @contact.ident_country_code = 'INVALID' - @contact.valid? - - expect(@contact.errors).to have_key(:ident) - end - - it 'should convert to alpha2 country code' do - @contact.ident = 1 - @contact.ident_type = 'org' - @contact.ident_country_code = 'ee' - @contact.validate - - @contact.ident_country_code.should == 'EE' - end - it 'should not have any versions' do @contact.versions.should == [] end @@ -119,14 +80,6 @@ RSpec.describe Contact do @contact.domains_present?.should == false end - it 'org should be valid' do - contact = Fabricate.build(:contact, ident_type: 'org', ident: '1' * 8) - - contact.validate - - contact.errors.full_messages.should match_array([]) - end - it 'should not overwrite code' do old_code = @contact.code @contact.code = 'CID:REG1:should-not-overwrite-old-code-12345' @@ -217,31 +170,6 @@ RSpec.describe Contact do end end - context 'as birthday' do - before :example do - @contact.ident_type = 'birthday' - end - - it 'birthday should be valid' do - valid = ['2012-12-11', '1990-02-16'] - valid.each do |date| - @contact.ident = date - @contact.valid? - @contact.errors.full_messages.should match_array([]) - end - end - - it 'birthday should be invalid' do - invalid = ['123' '12/12/2012', 'aaaa', '12/12/12', '02-11-1999'] - invalid.each do |date| - @contact.ident = date - @contact.valid? - @contact.errors.full_messages.should == - ["Ident Ident not in valid birthady format, should be YYYY-MM-DD"] - end - end - end - context 'with callbacks' do before :example do # Ensure callbacks are not taken out from other specs @@ -445,7 +373,7 @@ RSpec.describe Contact do end end - describe 'country code validation' do + describe 'country code validation', db: false do let(:contact) { described_class.new(country_code: 'test') } it 'rejects invalid' do @@ -455,37 +383,25 @@ RSpec.describe Contact do end end - describe 'phone validation', db: false do + describe 'identifier validation', db: false do let(:contact) { described_class.new } - it 'rejects absent' do - contact.phone = nil + it 'rejects invalid' do + ident = Contact::Ident.new + ident.validate + contact.identifier = ident contact.validate - expect(contact.errors).to have_key(:phone) - end - it 'rejects invalid format' do - contact.phone = '123' - contact.validate - expect(contact.errors).to have_key(:phone) - end - - it 'rejects all zeros in country code' do - contact.phone = '+000.1' - contact.validate - expect(contact.errors).to have_key(:phone) - end - - it 'rejects all zeros in phone number' do - contact.phone = '+123.0' - contact.validate - expect(contact.errors).to have_key(:phone) + expect(contact.errors).to be_added(:identifier, :invalid) end it 'accepts valid' do - contact.phone = '+123.4' + ident = Contact::Ident.new(code: 'test', type: 'priv', country_code: 'US') + ident.validate + contact.identifier = ident contact.validate - expect(contact.errors).to_not have_key(:phone) + + expect(contact.errors).to_not be_added(:identifier, :invalid) end end @@ -595,4 +511,13 @@ RSpec.describe Contact do expect(domain_names).to eq({ 'test.com' => %i[admin_domain_contact].to_set }) end end + + it 'normalizes ident country code', db: false do + contact = described_class.new + + contact.ident_country_code = 'ee' + contact.validate + + expect(contact.ident_country_code).to eq('EE') + end end diff --git a/spec/models/epp/response/result_spec.rb b/spec/models/epp/response/result_spec.rb new file mode 100644 index 000000000..606a4c2de --- /dev/null +++ b/spec/models/epp/response/result_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +RSpec.describe EPP::Response::Result, db: false do + # https://tools.ietf.org/html/rfc5730#section-3 + describe '::codes' do + it 'returns codes' do + codes = { + '1000' => :success, + '1001' => :success_pending, + '1300' => :success_empty_queue, + '1301' => :success_dequeue, + '2001' => :syntax_error, + '2003' => :required_param_missing, + '2005' => :param_syntax_error, + '2308' => :data_management_policy_violation + } + + expect(described_class.codes).to eq(codes) + end + end +end diff --git a/spec/models/registrar_spec.rb b/spec/models/registrar_spec.rb index 1230899bc..45acfdab1 100644 --- a/spec/models/registrar_spec.rb +++ b/spec/models/registrar_spec.rb @@ -35,10 +35,6 @@ describe Registrar do @registrar.reference_no.should_not be_blank @registrar.reference_no.last(10).to_i.should_not == 0 end - - it 'should not have priv contacts' do - @registrar.priv_contacts.size.should == 0 - end end context 'with valid attributes' do @@ -120,9 +116,5 @@ describe Registrar do registrar.valid? registrar.errors.full_messages.should == ['Code is forbidden to use'] end - - it 'should not have priv contacts' do - @registrar.priv_contacts.size.should == 0 - end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index cd242967b..2fdd6a8e8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -10,6 +10,7 @@ require 'support/requests/epp_helpers' require 'support/features/session_helpers' require 'support/matchers/alias_attribute' require 'support/matchers/epp/code' +require 'support/matchers/epp/have_result' require 'support/capybara' require 'support/devise' @@ -28,7 +29,8 @@ RSpec.configure do |config| config.include AbstractController::Translation, type: :request config.include AbstractController::Translation, type: :feature config.include AbstractController::Translation, type: :mailer - config.include Requests::EPPHelpers, type: :request + config.include Requests::EPPHelpers, epp: true + config.include Matchers::EPP, epp: true config.define_derived_metadata(file_path: %r[/spec/features/]) do |metadata| metadata[:db] = true if metadata[:db].nil? diff --git a/spec/requests/epp/contact/create/ident_spec.rb b/spec/requests/epp/contact/create/ident_spec.rb new file mode 100644 index 000000000..e112e2618 --- /dev/null +++ b/spec/requests/epp/contact/create/ident_spec.rb @@ -0,0 +1,289 @@ +require 'rails_helper' + +RSpec.describe 'EPP contact:create' do + let(:request) { post '/epp/command/create', frame: request_xml } + + before do + Setting.address_processing = false + sign_in_to_epp_area + end + + context 'when all ident params are valid' do + let(:ident) { Contact.first.identifier } + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + test + + + + + XML + } + + it 'creates a contact' do + expect { request }.to change { Contact.count }.from(0).to(1) + end + + it 'saves ident type' do + request + expect(ident.type).to eq('priv') + end + + it 'saves ident country code' do + request + expect(ident.country_code).to eq('US') + end + + specify do + request + expect(epp_response).to have_result(:success) + end + end + + context 'when code is blank' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + + + + + + XML + } + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + expect(epp_response).to have_result(:required_param_missing, + 'Required parameter missing: extension > extdata > ident [ident]') + end + end + + context 'when code is not valid national id' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + invalid + + + + + XML + } + + before do + country_specific_validations = { + Country.new('DE') => proc { false }, + } + + allow(Contact::Ident::NationalIdValidator).to receive(:country_specific_validations) + .and_return(country_specific_validations) + end + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + + message = 'Ident code does not conform to national identification number format of Germany' + expect(epp_response).to have_result(:param_syntax_error, message) + end + end + + context 'when code is not valid registration number' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + invalid + + + + + XML + } + + before do + country_specific_formats = { + Country.new('DE') => /\Avalid\z/, + } + + allow(Contact::Ident::RegNoValidator).to receive(:country_specific_formats).and_return(country_specific_formats) + end + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + expect(epp_response).to have_result(:param_syntax_error, + 'Ident code does not conform to registration number format of Germany') + end + end + + context 'when country code is absent' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + test + + + + + XML + } + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + expect(epp_response).to have_result(:required_param_missing, + 'Required ident attribute missing: cc') + end + end + + context 'when country code is blank' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + test + + + + + XML + } + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + expect(epp_response).to have_result(:syntax_error) + end + end + + context 'when mismatches' do + let(:request_xml) { <<-XML + + + + + + + test + + +1.2 + test@test.com + + + + + test + + + + + XML + } + + before do + mismatches = [ + Contact::Ident::MismatchValidator::Mismatch.new('priv', Country.new('DE')) + ] + allow(Contact::Ident::MismatchValidator).to receive(:mismatches).and_return(mismatches) + end + + it 'does not create a contact' do + expect { request }.to_not change { Contact.count } + end + + specify do + request + expect(epp_response).to have_result(:param_syntax_error, + 'Ident type "priv" is invalid for Germany') + end + end +end diff --git a/spec/requests/epp/contact/update/ident_spec.rb b/spec/requests/epp/contact/update/ident_spec.rb new file mode 100644 index 000000000..c93ba6390 --- /dev/null +++ b/spec/requests/epp/contact/update/ident_spec.rb @@ -0,0 +1,196 @@ +require 'rails_helper' + +# https://github.com/internetee/registry/issues/576 + +RSpec.describe 'EPP contact:update' do + let(:ident) { contact.identifier } + let(:request) { post '/epp/command/update', frame: request_xml } + let(:request_xml) { <<-XML + + + + + + TEST + + + test + + + + + + + test + + + + + XML + } + + before do + sign_in_to_epp_area + end + + context 'when contact ident is valid' do + context 'when submitted ident matches current one' do + let!(:contact) { create(:contact, code: 'TEST', + ident: 'test', + ident_type: 'priv', + ident_country_code: 'US') } + + specify do + request + expect(epp_response).to have_result(:success) + end + end + + context 'when submitted ident does not match current one' do + let!(:contact) { create(:contact, code: 'TEST', + ident: 'another-test', + ident_type: 'priv', + ident_country_code: 'US') } + + it 'does not update code' do + expect do + request + contact.reload + end.to_not change { ident.code } + end + + it 'does not update type' do + expect do + request + contact.reload + end.to_not change { ident.type } + end + + it 'does not update country code' do + expect do + request + contact.reload + end.to_not change { ident.country_code } + end + + specify do + request + + expect(epp_response).to have_result(:data_management_policy_violation, + t('epp.contacts.errors.valid_ident')) + end + end + end + + context 'when contact ident is invalid' do + let(:contact) { build(:contact, code: 'TEST', ident: 'test', ident_type: nil, ident_country_code: nil) } + + before do + contact.save(validate: false) + end + + context 'when submitted ident is the same as current one' do + let(:request_xml) { <<-XML + + + + + + TEST + + + test + + + + + + + test + + + + + XML + } + + it 'does not update code' do + expect do + request + contact.reload + end.to_not change { ident.code } + end + + it 'updates type' do + request + contact.reload + expect(ident.type).to eq('priv') + end + + it 'updates country code' do + request + contact.reload + expect(ident.country_code).to eq('US') + end + + specify do + request + expect(epp_response).to have_result(:success) + end + end + + context 'when submitted ident is different from current one' do + let(:request_xml) { <<-XML + + + + + + TEST + + + test + + + + + + + another-test + + + + + XML + } + + it 'does not update code' do + expect do + request + contact.reload + end.to_not change { ident.code } + end + + it 'does not update type' do + expect do + request + contact.reload + end.to_not change { ident.type } + end + + it 'does not update country code' do + expect do + request + contact.reload + end.to_not change { ident.country_code } + end + + specify do + request + + expect(epp_response).to have_result(:data_management_policy_violation, + t('epp.contacts.errors.ident_update')) + end + end + end +end diff --git a/spec/support/matchers/epp/have_result.rb b/spec/support/matchers/epp/have_result.rb new file mode 100644 index 000000000..7850082dd --- /dev/null +++ b/spec/support/matchers/epp/have_result.rb @@ -0,0 +1,37 @@ +module Matchers + module EPP + class HaveResultMatcher + def initialize(expected) + @expected = expected + end + + def matches?(target) + @target = target + + if @expected.message.present? + @target.results.any? { |result| result.code == @expected.code && result.message == @expected.message } + else + @target.results.any? { |result| result.code == @expected.code } + end + end + + def failure_message + "expected #{@target.results} to have result #{@expected.inspect}" + end + + def failure_message_when_negated + "expected #{@target.results} not to have result #{@expected.inspect}" + end + + def description + "should have EPP code of #{@expected}" + end + end + + def have_result(type, message = nil) + code = ::EPP::Response::Result.codes.key(type) + result = ::EPP::Response::Result.new(code, message) + HaveResultMatcher.new(result) + end + end +end diff --git a/spec/support/requests/epp_helpers.rb b/spec/support/requests/epp_helpers.rb index beb8ca2c2..fb0175df1 100644 --- a/spec/support/requests/epp_helpers.rb +++ b/spec/support/requests/epp_helpers.rb @@ -7,5 +7,9 @@ module Requests def valid_legal_document Base64.encode64('a' * 5000) end + + def epp_response + EPP::Response.from_xml(response.body) + end end end diff --git a/spec/validators/contact/ident/mismatch_validator_spec.rb b/spec/validators/contact/ident/mismatch_validator_spec.rb new file mode 100644 index 000000000..dfb30fe09 --- /dev/null +++ b/spec/validators/contact/ident/mismatch_validator_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' + +RSpec.describe Contact::Ident::MismatchValidator do + describe '::mismatches' do + it 'returns mismatches' do + mismatches = [ + Contact::Ident::MismatchValidator::Mismatch.new('birthday', Country.new('EE')) + ] + + expect(described_class.mismatches).to eq(mismatches) + end + end +end From 9293d0996a1bd333e6b8dbef9b85648cbdba7c00 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 23 Oct 2017 12:13:36 +0300 Subject: [PATCH 04/16] use custom validator until validation errors are present in UI --- config/initializers/eis_custom_active_record.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 config/initializers/eis_custom_active_record.rb diff --git a/config/initializers/eis_custom_active_record.rb b/config/initializers/eis_custom_active_record.rb new file mode 100644 index 000000000..60dcebeb9 --- /dev/null +++ b/config/initializers/eis_custom_active_record.rb @@ -0,0 +1,8 @@ +# Log all user issues raised by active record +# rubocop: disable Metrics/LineLength +class ActiveRecord::Base + after_validation do |m| + Rails.logger.info "USER MSG: ACTIVERECORD: #{m.class} ##{m.id} #{m.errors.full_messages} #{m.errors['epp_errors']}" if m.errors.present? + true + end +end From ba8e75897962df4d935f4407e38a4aaf4e4c521c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 29 Oct 2017 11:47:16 +0200 Subject: [PATCH 05/16] Remove phantomjs gem. Motivation: - PhantomJS can be installed manually - gem has never been released (alpha version was used) --- Gemfile | 1 - Gemfile.lock | 2 -- 2 files changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index 2f7587fc9..3e912e67c 100644 --- a/Gemfile +++ b/Gemfile @@ -121,7 +121,6 @@ group :development, :test do gem 'rspec-rails', '~> 3.6' gem 'fabrication', '2.13.2' # Replacement for fixtures gem 'phantomjs-binaries' - gem 'phantomjs' gem 'poltergeist' gem 'launchy', '2.4.3' # for opening browser automatically diff --git a/Gemfile.lock b/Gemfile.lock index bd372118f..fd854f9b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -292,7 +292,6 @@ GEM ast (~> 2.2) pdfkit (0.6.2) pg (0.19.0) - phantomjs (1.9.8.0) phantomjs-binaries (2.1.1.1) sys-uname (= 0.9.0) poltergeist (1.14.0) @@ -534,7 +533,6 @@ DEPENDENCIES paper_trail! pdfkit (= 0.6.2) pg (= 0.19.0) - phantomjs phantomjs-binaries poltergeist pry (= 0.10.1) From e640a2c07ce6a641474f595203799afe4aed6d2e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 29 Oct 2017 11:48:15 +0200 Subject: [PATCH 06/16] Remove phantomjs-binaries gem --- Gemfile | 1 - Gemfile.lock | 6 ------ 2 files changed, 7 deletions(-) diff --git a/Gemfile b/Gemfile index 3e912e67c..80d4d9951 100644 --- a/Gemfile +++ b/Gemfile @@ -120,7 +120,6 @@ group :development, :test do gem 'capybara' gem 'rspec-rails', '~> 3.6' gem 'fabrication', '2.13.2' # Replacement for fixtures - gem 'phantomjs-binaries' gem 'poltergeist' gem 'launchy', '2.4.3' # for opening browser automatically diff --git a/Gemfile.lock b/Gemfile.lock index fd854f9b6..022ee8539 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -188,7 +188,6 @@ GEM factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - ffi (1.9.18) figaro (1.1.1) thor (~> 0.14) globalid (0.3.7) @@ -292,8 +291,6 @@ GEM ast (~> 2.2) pdfkit (0.6.2) pg (0.19.0) - phantomjs-binaries (2.1.1.1) - sys-uname (= 0.9.0) poltergeist (1.14.0) capybara (~> 2.1) cliver (~> 0.3.1) @@ -443,8 +440,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sys-uname (0.9.0) - ffi (>= 1.0.0) thor (0.19.4) thread_safe (0.3.6) tilt (1.4.1) @@ -533,7 +528,6 @@ DEPENDENCIES paper_trail! pdfkit (= 0.6.2) pg (= 0.19.0) - phantomjs-binaries poltergeist pry (= 0.10.1) puma From 925bec2b34c2c0b477278617d0459d81d20a58a9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 29 Oct 2017 11:48:40 +0200 Subject: [PATCH 07/16] Remove launchy gem --- Gemfile | 1 - Gemfile.lock | 3 --- 2 files changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index 80d4d9951..0a583a5f9 100644 --- a/Gemfile +++ b/Gemfile @@ -121,7 +121,6 @@ group :development, :test do gem 'rspec-rails', '~> 3.6' gem 'fabrication', '2.13.2' # Replacement for fixtures gem 'poltergeist' - gem 'launchy', '2.4.3' # for opening browser automatically # debug gem 'pry', '0.10.1' diff --git a/Gemfile.lock b/Gemfile.lock index 022ee8539..047a04c15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -250,8 +250,6 @@ GEM kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - launchy (2.4.3) - addressable (~> 2.3) libxml-ruby (3.0.0) liquid (3.0.6) loofah (2.0.3) @@ -519,7 +517,6 @@ DEPENDENCIES jquery-ui-rails (= 5.0.5) jquery-validation-rails (= 1.13.1) kaminari (= 0.16.3) - launchy (= 2.4.3) liquid (= 3.0.6) mina (= 0.3.1) money-rails From 648bd392d6cff3256ef76f78ffe5bb2c431a484a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 1 Nov 2017 09:49:09 +0200 Subject: [PATCH 08/16] Update Code Climate Rubocop version --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 03f849185..21ab3742c 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -27,6 +27,7 @@ engines: - HACK rubocop: enabled: true + channel: rubocop-0-51 reek: enabled: true checks: From 06049cd22fb7d1c240c731af7fbc649a11746eff Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 13 Nov 2017 17:14:26 +0200 Subject: [PATCH 09/16] while logging in with id/mid pick only users who have whitelisted ip --- .../registrar/sessions_controller.rb | 18 +++++++++++++++--- app/models/api_user.rb | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 4ba6501f1..80eefddb7 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -53,7 +53,7 @@ class Registrar end def id - @user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN']) + @user = ApiUser.find_by_idc_data_and_allowed(request.env['SSL_CLIENT_S_DN'],request.ip) if @user sign_in(@user, event: :authentication) @@ -87,7 +87,7 @@ class Registrar return end - @user = find_user_by_idc(response.user_id_code) + @user = find_user_by_idc_and_allowed(response.user_id_code) if @user.persisted? session[:user_id_code] = response.user_id_code @@ -112,7 +112,7 @@ class Registrar when 'OUTSTANDING_TRANSACTION' render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok when 'USER_AUTHENTICATED' - @user = find_user_by_idc(session[:user_id_code]) + @user = find_user_by_idc_and_allowed(session[:user_id_code]) sign_in @user flash[:notice] = t(:welcome) flash.keep(:notice) @@ -149,6 +149,18 @@ class Registrar ApiUser.find_by(identity_code: idc) || User.new end + def find_user_by_idc_and_allowed(idc) + return User.new unless idc + possible_users = ApiUser.where(identity_code: idc) || User.new + for i in 0..possible_users.count + if possible_users[i].registrar.white_ips.registrar_area.include_ip?(request.ip) + break + end + end + possible_users[i] + end + + def check_ip_restriction ip_restriction = Authorization::RestrictedIP.new(request.ip) allowed = ip_restriction.can_access_registrar_area_sign_in_page? diff --git a/app/models/api_user.rb b/app/models/api_user.rb index 5e20db24a..a6ec82b06 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -51,6 +51,21 @@ class ApiUser < User find_by(identity_code: identity_code) end + + def find_by_idc_data_and_allowed(idc_data,ip) + return false if idc_data.blank? + identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first + + return false if ip.blank? + possible_users = where(identity_code: identity_code) + for i in 0..possible_users.count + if possible_users[i].registrar.white_ips.registrar_area.include_ip?(ip) + break + end + end + possible_users[i] + end + end def registrar_typeahead From af3123028554f0dbc3f4426c72ad4c0a52acee0e Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 13 Nov 2017 17:46:31 +0200 Subject: [PATCH 10/16] fix rspec for mid without ip whitelist --- app/controllers/registrar/sessions_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 80eefddb7..fa8ab4a88 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -87,7 +87,11 @@ class Registrar return end - @user = find_user_by_idc_and_allowed(response.user_id_code) + 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 From 3f1c36bd9a7416b77d3b04a9547929a1e608d23a Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Mon, 13 Nov 2017 18:43:37 +0200 Subject: [PATCH 11/16] fix some of the style bugs --- app/controllers/registrar/sessions_controller.rb | 12 ++++++------ app/models/api_user.rb | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index fa8ab4a88..c39fa93d0 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -53,7 +53,7 @@ class Registrar end def id - @user = ApiUser.find_by_idc_data_and_allowed(request.env['SSL_CLIENT_S_DN'],request.ip) + @user = ApiUser.find_by_idc_data_and_allowed(request.env['SSL_CLIENT_S_DN'], request.ip) if @user sign_in(@user, event: :authentication) @@ -156,11 +156,11 @@ class Registrar def find_user_by_idc_and_allowed(idc) return User.new unless idc possible_users = ApiUser.where(identity_code: idc) || User.new - for i in 0..possible_users.count - if possible_users[i].registrar.white_ips.registrar_area.include_ip?(request.ip) - break - end - end + for i in 0..possible_users.count + if possible_users[i].registrar.white_ips.registrar_area.include_ip?(request.ip) + break + end + end possible_users[i] end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index a6ec82b06..4f230d3b4 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -52,16 +52,16 @@ class ApiUser < User find_by(identity_code: identity_code) end - def find_by_idc_data_and_allowed(idc_data,ip) + def find_by_idc_data_and_allowed(idc_data, ip) return false if idc_data.blank? identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first return false if ip.blank? possible_users = where(identity_code: identity_code) for i in 0..possible_users.count - if possible_users[i].registrar.white_ips.registrar_area.include_ip?(ip) - break - end + if possible_users[i].registrar.white_ips.registrar_area.include_ip?(ip) + break + end end possible_users[i] end From e62bb19a7edc91d38bfa1268942548aeb2c1ddbd Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 14 Nov 2017 12:32:33 +0200 Subject: [PATCH 12/16] fix indention --- app/controllers/registrar/sessions_controller.rb | 8 ++++---- app/models/api_user.rb | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index c39fa93d0..d56dc24de 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -156,12 +156,12 @@ class Registrar def find_user_by_idc_and_allowed(idc) return User.new unless idc possible_users = ApiUser.where(identity_code: idc) || User.new - for i in 0..possible_users.count - if possible_users[i].registrar.white_ips.registrar_area.include_ip?(request.ip) + for selected_user in 0..possible_users.count + if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(request.ip) break - end + end end - possible_users[i] + possible_users[selected_user] end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index 4f230d3b4..b70aeeb11 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -51,19 +51,19 @@ class ApiUser < User find_by(identity_code: identity_code) end - + def find_by_idc_data_and_allowed(idc_data, ip) return false if idc_data.blank? identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first return false if ip.blank? possible_users = where(identity_code: identity_code) - for i in 0..possible_users.count - if possible_users[i].registrar.white_ips.registrar_area.include_ip?(ip) - break - end + for selected_user in 0..possible_users.count + if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(ip) + break end - possible_users[i] + end + possible_users[selected_user] end end From abeeec3baf95ed5de690971372fb0475556b9c50 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 14 Nov 2017 12:51:44 +0200 Subject: [PATCH 13/16] prefer each over for --- app/controllers/registrar/sessions_controller.rb | 8 ++++---- app/models/api_user.rb | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index d56dc24de..811769400 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -156,15 +156,15 @@ class Registrar def find_user_by_idc_and_allowed(idc) return User.new unless idc possible_users = ApiUser.where(identity_code: idc) || User.new - for selected_user in 0..possible_users.count - if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(request.ip) - break + possible_users eacho do |selected_user| + if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip) + return selected_user end end - possible_users[selected_user] end + def check_ip_restriction ip_restriction = Authorization::RestrictedIP.new(request.ip) allowed = ip_restriction.can_access_registrar_area_sign_in_page? diff --git a/app/models/api_user.rb b/app/models/api_user.rb index b70aeeb11..d05f8eb46 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -58,12 +58,11 @@ class ApiUser < User return false if ip.blank? possible_users = where(identity_code: identity_code) - for selected_user in 0..possible_users.count - if possible_users[selected_user].registrar.white_ips.registrar_area.include_ip?(ip) - break + possible_users eacho do |selected_user| + if selected_user.registrar.white_ips.registrar_area.include_ip?(ip) + return selected_user end end - possible_users[selected_user] end end From f1739f2202d58655c683116fbc6a1780917aff11 Mon Sep 17 00:00:00 2001 From: Georg Kahest Date: Tue, 14 Nov 2017 12:58:22 +0200 Subject: [PATCH 14/16] fix typo --- app/controllers/registrar/sessions_controller.rb | 2 +- app/models/api_user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 811769400..1a8b195ee 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -156,7 +156,7 @@ class Registrar def find_user_by_idc_and_allowed(idc) return User.new unless idc possible_users = ApiUser.where(identity_code: idc) || User.new - possible_users eacho do |selected_user| + possible_users.each do |selected_user| if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip) return selected_user end diff --git a/app/models/api_user.rb b/app/models/api_user.rb index d05f8eb46..ce32c4045 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -58,7 +58,7 @@ class ApiUser < User return false if ip.blank? possible_users = where(identity_code: identity_code) - possible_users eacho do |selected_user| + possible_users.each do |selected_user| if selected_user.registrar.white_ips.registrar_area.include_ip?(ip) return selected_user end From 2da578a437e5d1d1a58afc44ee279b355528d002 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 16 Nov 2017 10:18:53 +0200 Subject: [PATCH 15/16] Migrate fabricators to factory bot factories (#626) * Remove factory_girl include from dev rake task No longer needed after 92b125b4a7fd1b4cc7535dd022d58b58a75ac2cf * Add missing factories * Use FactoryBot factories instead of fabricators * Remove all fabricators * Remove unused method * Remove fabrication gem * Rename FactoryGirl to FactoryBot https://robots.thoughtbot.com/factory_bot --- Gemfile | 3 +- Gemfile.lock | 10 +- app/models/contact.rb | 4 - lib/tasks/dev.rake | 3 +- spec/api/repp/contact_v1_spec.rb | 6 +- spec/fabricators/account_fabricator.rb | 6 - spec/fabricators/admin_user_fabricator.rb | 29 ---- spec/fabricators/api_user_fabricator.rb | 14 -- spec/fabricators/bank_statement_fabricator.rb | 6 - .../bank_transaction_fabricator.rb | 6 - spec/fabricators/blocked_domain_fabricator.rb | 3 - spec/fabricators/certificate_fabricator.rb | 36 ----- spec/fabricators/contact_fabricator.rb | 18 --- spec/fabricators/dnskey_fabricator.rb | 13 -- spec/fabricators/domain_contact_fabricator.rb | 12 -- spec/fabricators/domain_fabricator.rb | 16 -- .../fabricators/domain_transfer_fabricator.rb | 5 - spec/fabricators/epp_domain_fabricator.rb | 1 - spec/fabricators/epp_session_fabricator.rb | 4 - spec/fabricators/invoice_fabricator.rb | 13 -- spec/fabricators/invoice_item_fabricator.rb | 6 - spec/fabricators/keyrelay_fabricator.rb | 10 -- spec/fabricators/message_fabricator.rb | 3 - spec/fabricators/nameserver_fabricator.rb | 4 - spec/fabricators/registrant_fabricator.rb | 18 --- .../registrant_verification_fabricator.rb | 7 - spec/fabricators/registrar_fabricator.rb | 54 ------- .../fabricators/reserved_domain_fabricator.rb | 3 - spec/fabricators/zone_fabricator.rb | 16 -- spec/factories/account.rb | 2 +- spec/factories/account_activity.rb | 2 +- spec/factories/admin_domain_contact.rb | 2 +- spec/factories/admin_user.rb | 2 +- spec/factories/api_user.rb | 2 +- spec/factories/bank_statement.rb | 11 ++ spec/factories/bank_transaction.rb | 8 + spec/factories/billing/price.rb | 2 +- spec/factories/contact.rb | 2 +- spec/factories/dns/zone.rb | 2 +- spec/factories/dnskey.rb | 3 +- spec/factories/domain.rb | 6 +- spec/factories/domain_contact.rb | 2 +- spec/factories/domain_transfer.rb | 7 + spec/factories/epp_session.rb | 2 +- spec/factories/invoice.rb | 18 +++ spec/factories/invoice_item.rb | 8 + spec/factories/keyrelay.rb | 12 ++ spec/factories/message.rb | 5 + spec/factories/nameserver.rb | 2 +- spec/factories/registrant.rb | 2 +- spec/factories/registrant_user.rb | 2 +- spec/factories/registrant_verification.rb | 9 ++ spec/factories/registrar.rb | 2 +- spec/factories/reserved_domain.rb | 5 + spec/factories/tech_domain_contact.rb | 2 +- spec/factories/white_ip.rb | 2 +- spec/factory_lint_spec.rb | 6 +- .../registrar/sign_in/mobile_id_spec.rb | 2 +- spec/models/admin_user_spec.rb | 2 +- spec/models/api_user_spec.rb | 4 +- spec/models/bank_statement_spec.rb | 60 ++----- spec/models/bank_transaction_spec.rb | 14 +- spec/models/concerns/domain/expirable_spec.rb | 8 +- .../concerns/domain/force_delete_spec.rb | 8 +- spec/models/contact_spec.rb | 54 +++---- spec/models/dnskey_spec.rb | 20 ++- spec/models/domain_contact_spec.rb | 24 +-- spec/models/domain_cron_spec.rb | 8 +- spec/models/domain_spec.rb | 149 +++++++++--------- spec/models/domain_transfer_spec.rb | 6 +- spec/models/epp_contact_spec.rb | 4 +- spec/models/epp_session.rb | 2 +- spec/models/invoice_spec.rb | 12 +- spec/models/keyrelay_spec.rb | 10 +- spec/models/legal_document_spec.rb | 14 +- spec/models/message_spec.rb | 4 +- spec/models/nameserver_spec.rb | 32 ++-- spec/models/registrant_verification_spec.rb | 6 +- spec/models/registrar_spec.rb | 28 ++-- spec/models/whois_record_spec.rb | 12 +- spec/rails_helper.rb | 2 +- spec/requests/epp/contact/info_spec.rb | 2 +- spec/requests/epp/contact/update_spec.rb | 2 +- spec/support/factory_bot.rb | 3 + spec/support/factory_girl.rb | 3 - spec/support/features/session_helpers.rb | 4 +- spec/support/requests/session_helpers.rb | 6 +- spec/support/settings.rb | 2 +- 88 files changed, 356 insertions(+), 610 deletions(-) delete mode 100644 spec/fabricators/account_fabricator.rb delete mode 100644 spec/fabricators/admin_user_fabricator.rb delete mode 100644 spec/fabricators/api_user_fabricator.rb delete mode 100644 spec/fabricators/bank_statement_fabricator.rb delete mode 100644 spec/fabricators/bank_transaction_fabricator.rb delete mode 100644 spec/fabricators/blocked_domain_fabricator.rb delete mode 100644 spec/fabricators/certificate_fabricator.rb delete mode 100644 spec/fabricators/contact_fabricator.rb delete mode 100644 spec/fabricators/dnskey_fabricator.rb delete mode 100644 spec/fabricators/domain_contact_fabricator.rb delete mode 100644 spec/fabricators/domain_fabricator.rb delete mode 100644 spec/fabricators/domain_transfer_fabricator.rb delete mode 100644 spec/fabricators/epp_domain_fabricator.rb delete mode 100644 spec/fabricators/epp_session_fabricator.rb delete mode 100644 spec/fabricators/invoice_fabricator.rb delete mode 100644 spec/fabricators/invoice_item_fabricator.rb delete mode 100644 spec/fabricators/keyrelay_fabricator.rb delete mode 100644 spec/fabricators/message_fabricator.rb delete mode 100644 spec/fabricators/nameserver_fabricator.rb delete mode 100644 spec/fabricators/registrant_fabricator.rb delete mode 100644 spec/fabricators/registrant_verification_fabricator.rb delete mode 100644 spec/fabricators/registrar_fabricator.rb delete mode 100644 spec/fabricators/reserved_domain_fabricator.rb delete mode 100644 spec/fabricators/zone_fabricator.rb create mode 100644 spec/factories/bank_statement.rb create mode 100644 spec/factories/bank_transaction.rb create mode 100644 spec/factories/domain_transfer.rb create mode 100644 spec/factories/invoice.rb create mode 100644 spec/factories/invoice_item.rb create mode 100644 spec/factories/keyrelay.rb create mode 100644 spec/factories/message.rb create mode 100644 spec/factories/registrant_verification.rb create mode 100644 spec/factories/reserved_domain.rb create mode 100644 spec/support/factory_bot.rb delete mode 100644 spec/support/factory_girl.rb diff --git a/Gemfile b/Gemfile index c5aa5dc82..fe8498495 100644 --- a/Gemfile +++ b/Gemfile @@ -117,10 +117,9 @@ group :development do end group :development, :test do - gem 'factory_girl_rails' + gem 'factory_bot_rails' gem 'capybara' gem 'rspec-rails', '~> 3.6' - gem 'fabrication', '2.13.2' # Replacement for fixtures gem 'poltergeist' # debug diff --git a/Gemfile.lock b/Gemfile.lock index 523ca1585..a41ece538 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -185,11 +185,10 @@ GEM equalizer (0.0.11) erubis (2.7.0) execjs (2.7.0) - fabrication (2.13.2) - factory_girl (4.8.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) - factory_girl_rails (4.8.0) - factory_girl (~> 4.8.0) + factory_bot_rails (4.8.2) + factory_bot (~> 4.8.2) railties (>= 3.0.0) figaro (1.1.1) thor (~> 0.14) @@ -506,8 +505,7 @@ DEPENDENCIES digidoc_client! epp (= 1.5.0)! epp-xml (= 1.1.0)! - fabrication (= 2.13.2) - factory_girl_rails + factory_bot_rails figaro (= 1.1.1) grape (= 0.12.0) haml-rails (= 0.9.0) diff --git a/app/models/contact.rb b/app/models/contact.rb index f04a16032..61a82ae0a 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -319,10 +319,6 @@ class Contact < ActiveRecord::Base self.auth_info = SecureRandom.hex(11) end - def disable_generate_auth_info! # needed for testing - @generate_auth_info_disabled = true - end - # def auth_info=(pw) # self[:auth_info] = pw if new_record? # end diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 9b8301b89..c624b3c95 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -5,8 +5,7 @@ namespace :dev do task :prime, [:random] => :environment do |t, args| abort 'Production environment is not supported' if Rails.env.production? - require 'factory_girl' - include FactoryGirl::Syntax::Methods + include FactoryBot::Syntax::Methods PaperTrail.enabled = false Domain.paper_trail_on! diff --git a/spec/api/repp/contact_v1_spec.rb b/spec/api/repp/contact_v1_spec.rb index 455b7bd91..716eb40cc 100644 --- a/spec/api/repp/contact_v1_spec.rb +++ b/spec/api/repp/contact_v1_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' RSpec.describe Repp::ContactV1, db: true do - let(:user) { FactoryGirl.create(:api_user, registrar: registrar) } - let(:registrar) { FactoryGirl.create(:registrar) } + let(:user) { create(:api_user, registrar: registrar) } + let(:registrar) { create(:registrar) } describe '/contacts' do let(:returned_attributes) { HashWithIndifferentAccess.new(JSON.parse(response.body)['contacts'].first).keys } @@ -13,7 +13,7 @@ RSpec.describe Repp::ContactV1, db: true do allow(endpoint).to receive(:current_user).and_return(user) end - registrar.contacts << FactoryGirl.create(:contact) + registrar.contacts << create(:contact) end it 'responds with success' do diff --git a/spec/fabricators/account_fabricator.rb b/spec/fabricators/account_fabricator.rb deleted file mode 100644 index 683d98739..000000000 --- a/spec/fabricators/account_fabricator.rb +++ /dev/null @@ -1,6 +0,0 @@ -Fabricator(:account) do - account_type { Account::CASH } - balance 0.0 - currency 'EUR' - registrar -end diff --git a/spec/fabricators/admin_user_fabricator.rb b/spec/fabricators/admin_user_fabricator.rb deleted file mode 100644 index a73596810..000000000 --- a/spec/fabricators/admin_user_fabricator.rb +++ /dev/null @@ -1,29 +0,0 @@ -# currently identity code generation not implemented, -# thus default user is FI for a while -Fabricator(:admin_user) do - username 'gitlab' - password 'ghyt9e4fu' - password_confirmation 'ghyt9e4fu' - email { sequence(:email) { |i| "info#{i}@example.com" } } - country_code 'FI' - roles ['admin'] -end - -Fabricator(:ee_user, from: :admin_user) do - identity_code "45002036517" - country_code 'EE' - username 'user1' - password 'testtest' - password_confirmation 'testtest' - roles ['admin'] -end - -# Valid identity codes -# 48805195231 -# 45002036517 -# 47601126511 -# 48802292754 -# 45912080223 -# 34406056538 -# 39503140321 -# 39507241618 diff --git a/spec/fabricators/api_user_fabricator.rb b/spec/fabricators/api_user_fabricator.rb deleted file mode 100644 index 43fc9b553..000000000 --- a/spec/fabricators/api_user_fabricator.rb +++ /dev/null @@ -1,14 +0,0 @@ -# default fabricator should be reusable -Fabricator(:api_user) do - username { sequence(:username) { |i| "username#{i}" } } - password 'ghyt9e4fu' - identity_code '14212128025' - registrar - active true - roles ['super'] -end - -# use dedicated fabricator for fixed one -Fabricator(:gitlab_api_user, from: :api_user) do - username 'gitlab' -end diff --git a/spec/fabricators/bank_statement_fabricator.rb b/spec/fabricators/bank_statement_fabricator.rb deleted file mode 100644 index 4219ab869..000000000 --- a/spec/fabricators/bank_statement_fabricator.rb +++ /dev/null @@ -1,6 +0,0 @@ -Fabricator(:bank_statement) do - bank_code { '767' } - iban { 'EE557700771000598731' } - queried_at { Time.zone.now } - bank_transactions(count: 2) -end diff --git a/spec/fabricators/bank_transaction_fabricator.rb b/spec/fabricators/bank_transaction_fabricator.rb deleted file mode 100644 index e284bbd83..000000000 --- a/spec/fabricators/bank_transaction_fabricator.rb +++ /dev/null @@ -1,6 +0,0 @@ -Fabricator(:bank_transaction) do - currency { 'EUR' } - sum { 100.0 } - description { 'Invoice no. 1' } - reference_no { 'RF2405752128' } -end diff --git a/spec/fabricators/blocked_domain_fabricator.rb b/spec/fabricators/blocked_domain_fabricator.rb deleted file mode 100644 index 363cc0526..000000000 --- a/spec/fabricators/blocked_domain_fabricator.rb +++ /dev/null @@ -1,3 +0,0 @@ -Fabricator(:blocked_domain) do - names ['ftp.ee', 'cache.ee'] -end diff --git a/spec/fabricators/certificate_fabricator.rb b/spec/fabricators/certificate_fabricator.rb deleted file mode 100644 index 804543c39..000000000 --- a/spec/fabricators/certificate_fabricator.rb +++ /dev/null @@ -1,36 +0,0 @@ -# default fabricator should be reusable -Fabricator(:certificate) do - api_user - common_name 'cn' - md5 'md5hash' - interface 'api' - csr "-----BEGIN CERTIFICATE REQUEST-----\n" \ - "MIIE+DCCAuACAQAwgZ0xCzAJBgNVBAYTAkVFMREwDwYDVQQIDAhIYXJqdW1hYTEQ\n" \ - "MA4GA1UEBwwHVGFsbGlubjEbMBkGA1UECgwSRWVzdGkgSW50ZXJuZXRpIFNBMRIw\n" \ - "EAYDVQQLDAlSRUdJU1RSQVIxEjAQBgNVBAMMCXdlYmNsaWVudDEkMCIGCSqGSIb3\n" \ - "DQEJARYVd2ViY2xpZW50QGludGVybmV0LmVlMIICIjANBgkqhkiG9w0BAQEFAAOC\n" \ - "Ag8AMIICCgKCAgEAuXronFj8CxPWGkyUhXf+/WirkFGb8a/My2+7GvQWYE10Nq4C\n" \ - "u9wDgjU3AuLw8qzwEeE3Z5uxHXWfwnshXOF6aJNCQWUsrs0odCxw69iIwCNGKhyF\n" \ - "jljtx8uSH8RRSRc8BFIUkvUpmp8m7kZTlB4FDey+XaGy4p/rImiAiwfFMIJMjdE9\n" \ - "9gk0EGDbomgP6KC3Ss/iQfuOFCQWSqjFuvp3mygr193YplaPgeLM1ERIW1LVFGDK\n" \ - "jy6keZ3E/Vb4O4qUPDRgTMr2KWM3Auzh2hXCymHNWn3yRn5Q4KSjJbG/P7Kz5nfZ\n" \ - "kY3eVRBIBll+1Q0VV7g+1B48zzjZX2qiY3iL77MV1oL17KeOO3PAxsEtptdqNgUa\n" \ - "Fpp73dwPST1ZKvq8FSgDKcdTCziSeViGhXjJRpEMr8FoeKNO7nvd1maKN9HAOy75\n" \ - "eSxatj6LoQ+JFN7Ci3IbwKFI7BnIHbEr9eP7O7Qbhljz2GE9+GWUqr3zwUEgpFSI\n" \ - "crAnRHQI2ALakEMsryF416zg5yr/bJp8/IzgZLaKpBVLOL88sI6r+JRdM6QXvKYx\n" \ - "XhamV6bH6CrR8ZYN4okaZH6sAcy8eyBnEmc05h/KsDzTNadwadeZe73F+PltoEXH\n" \ - "XgtpTpQ8XarN1uLq99WD6gWilAx3LF/xetCO86+w/MkYBmfOrXge+WLUUW8CAwEA\n" \ - "AaAVMBMGCSqGSIb3DQEJBzEGDAR0ZXN0MA0GCSqGSIb3DQEBCwUAA4ICAQAkTlU3\n" \ - "RcI6UMRA7As2FJSph3QurPebQFoZhnhMD+hb6+hXip8MY77YxLwo/ihB9wghaZKL\n" \ - "uV0BxjdZgjDt9GhA8dtPgaCp5LvB6kQYvcEzRvitN2CpJhtz39rlF3gxuy+RtpNf\n" \ - "5KbC691FivoXur1qx9I7mc4snB3DTzLiJPIZ6nQzPYcSVpPCbns30N/i/sOdHO0o\n" \ - "9hP5wlhCdYrOxad993m+InpMDyDWhB1+TA9ZO7gYpg8S4kBX3Cz9OXe80Pe56ZdK\n" \ - "pcgjTXnUDjNSRRGamJib2lyZ/axMbb/etwyy3X+jBDuOQropkmgrPEFJHpgNlFah\n" \ - "BuW7KEASqbw5YxpTSc0nDk5uxBw3voL8fk9M1sX64tbzGAEBRZnrWGeb1mOLM/YI\n" \ - "K6ocAYSBhNmWUzpHTwL7qSeP9ztQUGzoGHyRjBdan+1U2G75Kpj+TjEm/X8wmtnq\n" \ - "3/qVhUYNEavcZbgR1gSE45+mS8NsD7Oq0Xdc0UKsVDbUcCGIkGG9+ERAbRznfi3W\n" \ - "qhChtUxySX8T3SmX5mviwlJ5OwQVjdUF1/2voPK0oFK7zV+wZqcuORzDKdqB8XV7\n" \ - "MDcQjza4EOB78OmcHDgQ7nMXuY7/UL4F+bRZosxPy43X2JId5d+/GpgV8sP9dzK8\n" \ - "UGJDNEZ2YsBbPuKZS+2eNZ8g3sjjFBeadvrQ1w==\n" \ - "-----END CERTIFICATE REQUEST-----" -end diff --git a/spec/fabricators/contact_fabricator.rb b/spec/fabricators/contact_fabricator.rb deleted file mode 100644 index 8f68c518d..000000000 --- a/spec/fabricators/contact_fabricator.rb +++ /dev/null @@ -1,18 +0,0 @@ -Fabricator(:contact) do - registrar { Fabricate(:registrar) } - code { sequence(:code) { |i| "1234#{i}#{rand(1000)}" } } - auth_info 'password' - name 'test name' - phone '+372.12345678' - email { sequence(:email) { |i| "test#{i}@test.com" } } - street 'Short street 11' - city 'Tallinn' - zip '11111' - country_code 'EE' - ident '37605030299' - ident_type 'priv' - ident_country_code 'EE' - # rubocop: disable Style/SymbolProc - after_validation { |c| c.disable_generate_auth_info! } - # rubocop: enamble Style/SymbolProc -end diff --git a/spec/fabricators/dnskey_fabricator.rb b/spec/fabricators/dnskey_fabricator.rb deleted file mode 100644 index cf35cd932..000000000 --- a/spec/fabricators/dnskey_fabricator.rb +++ /dev/null @@ -1,13 +0,0 @@ -Fabricator(:dnskey) do - alg 8 - flags 257 - protocol 3 - public_key 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\ - 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\ - 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\ - 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\ - 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\ - 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' - ds_digest_type 2 - domain -end diff --git a/spec/fabricators/domain_contact_fabricator.rb b/spec/fabricators/domain_contact_fabricator.rb deleted file mode 100644 index 9f693ef51..000000000 --- a/spec/fabricators/domain_contact_fabricator.rb +++ /dev/null @@ -1,12 +0,0 @@ -Fabricator(:domain_contact) do - contact { Fabricate(:contact) } - type 'TechDomainContact' -end - -Fabricator(:tech_domain_contact, from: :domain_contact) do - type 'TechDomainContact' -end - -Fabricator(:admin_domain_contact, from: :domain_contact) do - type 'AdminDomainContact' -end diff --git a/spec/fabricators/domain_fabricator.rb b/spec/fabricators/domain_fabricator.rb deleted file mode 100644 index e1ee9b989..000000000 --- a/spec/fabricators/domain_fabricator.rb +++ /dev/null @@ -1,16 +0,0 @@ -Fabricator(:domain) do - name { sequence(:name) { |i| "domain#{i}.ee" } } - valid_to Date.new(2014, 8, 7) - period 1 - period_unit 'y' - registrant { Fabricate(:registrant) } - nameservers(count: 3) - admin_domain_contacts(count: 1) { Fabricate(:admin_domain_contact) } - tech_domain_contacts(count: 1) { Fabricate(:tech_domain_contact) } - registrar { Fabricate(:registrar) } - auth_info '98oiewslkfkd' -end - -Fabricator(:domain_with_dnskeys, from: :domain) do - after_create { |domain| Fabricate(:dnskey, domain: domain) } -end diff --git a/spec/fabricators/domain_transfer_fabricator.rb b/spec/fabricators/domain_transfer_fabricator.rb deleted file mode 100644 index f16e1932e..000000000 --- a/spec/fabricators/domain_transfer_fabricator.rb +++ /dev/null @@ -1,5 +0,0 @@ -Fabricator(:domain_transfer) do - domain - transfer_from { Fabricate(:registrar) } - transfer_to { Fabricate(:registrar) } -end diff --git a/spec/fabricators/epp_domain_fabricator.rb b/spec/fabricators/epp_domain_fabricator.rb deleted file mode 100644 index 35deda396..000000000 --- a/spec/fabricators/epp_domain_fabricator.rb +++ /dev/null @@ -1 +0,0 @@ -Fabricator(:epp_domain, from: :domain, class_name: 'Epp::Domain') diff --git a/spec/fabricators/epp_session_fabricator.rb b/spec/fabricators/epp_session_fabricator.rb deleted file mode 100644 index 24145c78f..000000000 --- a/spec/fabricators/epp_session_fabricator.rb +++ /dev/null @@ -1,4 +0,0 @@ -Fabricator(:epp_session) do - session_id 'test' - data { { api_user_id: 1 } } -end diff --git a/spec/fabricators/invoice_fabricator.rb b/spec/fabricators/invoice_fabricator.rb deleted file mode 100644 index 31d951cf1..000000000 --- a/spec/fabricators/invoice_fabricator.rb +++ /dev/null @@ -1,13 +0,0 @@ -Fabricator(:invoice) do - buyer_name 'Registrar 1' - currency { 'EUR' } - due_date { Time.zone.now.to_date + 1.day } - invoice_type 'DEB' - seller_iban { '123' } - seller_name { 'EIS' } - seller_city { 'Tallinn' } - seller_street { 'Paldiski mnt. 123' } - invoice_items(count: 2) - vat_prc 0.2 - buyer { Fabricate(:registrar) } -end diff --git a/spec/fabricators/invoice_item_fabricator.rb b/spec/fabricators/invoice_item_fabricator.rb deleted file mode 100644 index 24d01676e..000000000 --- a/spec/fabricators/invoice_item_fabricator.rb +++ /dev/null @@ -1,6 +0,0 @@ -Fabricator(:invoice_item) do - description { 'add money' } - unit 1 - amount 1 - price 150 -end diff --git a/spec/fabricators/keyrelay_fabricator.rb b/spec/fabricators/keyrelay_fabricator.rb deleted file mode 100644 index 436518ef8..000000000 --- a/spec/fabricators/keyrelay_fabricator.rb +++ /dev/null @@ -1,10 +0,0 @@ -Fabricator(:keyrelay) do - pa_date { Time.zone.now } - expiry_relative 'P1W' - key_data_public_key 'abc' - key_data_flags 0 - key_data_protocol 3 - key_data_alg 3 - auth_info_pw 'abc' - domain -end diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb deleted file mode 100644 index 6204c4fd3..000000000 --- a/spec/fabricators/message_fabricator.rb +++ /dev/null @@ -1,3 +0,0 @@ -Fabricator(:message) do - body 'fabricator body' -end diff --git a/spec/fabricators/nameserver_fabricator.rb b/spec/fabricators/nameserver_fabricator.rb deleted file mode 100644 index f73668b25..000000000 --- a/spec/fabricators/nameserver_fabricator.rb +++ /dev/null @@ -1,4 +0,0 @@ -Fabricator(:nameserver) do - hostname { sequence(:hostname) { |i| "ns.test#{i}.ee" } } - ipv4 '192.168.1.1' -end diff --git a/spec/fabricators/registrant_fabricator.rb b/spec/fabricators/registrant_fabricator.rb deleted file mode 100644 index 42cff7cdf..000000000 --- a/spec/fabricators/registrant_fabricator.rb +++ /dev/null @@ -1,18 +0,0 @@ -Fabricator(:registrant) do - registrar { Fabricate(:registrar) } - code { sequence(:code) { |i| "REGISTRANT#{i}#{rand(1000)}" } } - auth_info 'password' - name 'test name' - phone '+372.12345678' - email { sequence(:email) { |i| "test#{i}@test.com" } } - street 'Short street 11' - city 'Tallinn' - zip '11111' - country_code 'EE' - ident '37605030299' - ident_type 'priv' - ident_country_code 'EE' - # rubocop: disable Style/SymbolProc - after_validation { |c| c.disable_generate_auth_info! } - # rubocop: enamble Style/SymbolProc -end diff --git a/spec/fabricators/registrant_verification_fabricator.rb b/spec/fabricators/registrant_verification_fabricator.rb deleted file mode 100644 index c0b5fd65f..000000000 --- a/spec/fabricators/registrant_verification_fabricator.rb +++ /dev/null @@ -1,7 +0,0 @@ -Fabricator(:registrant_verification) do - domain_name { sequence(:name) { |i| "domain#{i}.ee" } } - domain(fabricate: :domain) - verification_token '123' - action 'confirmed' - action_type 'registrant_change' -end diff --git a/spec/fabricators/registrar_fabricator.rb b/spec/fabricators/registrar_fabricator.rb deleted file mode 100644 index 37236cb87..000000000 --- a/spec/fabricators/registrar_fabricator.rb +++ /dev/null @@ -1,54 +0,0 @@ -Fabricator(:registrar) do - name { sequence(:name) { |i| "Registrar #{i}" } } - reg_no { sequence(:reg_no) { |i| "123#{i}" } } - street 'Street 999' - city 'Town' - state 'County' - zip 'Postal' - email 'info@registrar1.ee' - country_code 'EE' - code { sequence(:code) { |i| "REGISTRAR#{i}" } } - reference_no { sequence(:reference_no) { |i| "RF#{i}" } } -end - -Fabricator(:registrar_with_no_account_activities, from: :registrar) do - accounts(count: 1) { Fabricate(:account, account_activities: []) } -end - -Fabricator(:registrar1, from: :registrar) do - name 'registrar1' - reg_no '111' - street 'Street 111' - city 'Town' - state 'County' - zip 'Postal' - email 'info@registrar1.ee' - code { sequence(:code) { |i| "FIRST#{i}" } } -end - -Fabricator(:registrar2, from: :registrar) do - name 'registrar2' - reg_no '222' - street 'Street 222' - city 'Town' - state 'County' - zip 'Postal' - email 'info@registrar2.ee' - code { sequence(:code) { |i| "SECOND#{i}" } } -end - -Fabricator(:eis, from: :registrar) do - name 'EIS' - reg_no '90010019' - phone '+372 727 1000' - country_code 'EE' - vat_no 'EE101286464' - email 'info@internet.ee' - state 'Harjumaa' - city 'Tallinn' - street 'Paldiski mnt 80' - zip '10617' - website 'www.internet.ee' - code { sequence(:code) { |i| "EIS#{i}" } } - accounts(count: 1) { Fabricate(:account, account_activities: []) } -end diff --git a/spec/fabricators/reserved_domain_fabricator.rb b/spec/fabricators/reserved_domain_fabricator.rb deleted file mode 100644 index 3bbdadbe1..000000000 --- a/spec/fabricators/reserved_domain_fabricator.rb +++ /dev/null @@ -1,3 +0,0 @@ -Fabricator(:reserved_domain) do - name { sequence(:name) { |i| "domain#{i}.ee" } } -end diff --git a/spec/fabricators/zone_fabricator.rb b/spec/fabricators/zone_fabricator.rb deleted file mode 100644 index e7bf81c42..000000000 --- a/spec/fabricators/zone_fabricator.rb +++ /dev/null @@ -1,16 +0,0 @@ -Fabricator(:zone, from: 'DNS::Zone') do - origin 'ee' - ttl 43200 - refresh 3600 - expire 1209600 - minimum_ttl 3600 - email 'hostmaster.eestiinternet.ee' - master_nameserver 'ns.tld.ee' - ns_records "ee. IN NS ns.ut.ee.\nee. IN NS ns.tld.ee.\nee. IN NS sunic.sunet.se.\n" \ - "ee. IN NS ee.aso.ee.\nee. IN NS b.tld.ee.\nee. IN NS ns.eenet.ee.\nee. IN NS e.tld.ee." - a_records "ns.ut.ee. IN A 193.40.5.99\nns.tld.ee. IN A 195.43.87.10\nee.aso.ee. IN A 213.184.51.122\n" \ - "b.tld.ee. IN A 194.146.106.110\nns.eenet.ee. IN A 193.40.56.245\ne.tld.ee. IN A 204.61.216.36" - a4_records "ee.aso.ee. IN AAAA 2a02:88:0:21::2\nb.tld.ee. IN AAAA 2001:67c:1010:28::53\n" \ - "ns.eenet.ee. IN AAAA 2001:bb8::1\ne.tld.ee. IN AAAA 2001:678:94:53::53" - after_build { |x| x.retry = 900 } -end diff --git a/spec/factories/account.rb b/spec/factories/account.rb index 65f40a433..4407b1f86 100644 --- a/spec/factories/account.rb +++ b/spec/factories/account.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :account do account_type Account::CASH balance 1 diff --git a/spec/factories/account_activity.rb b/spec/factories/account_activity.rb index 3735349b9..b5dd348f2 100644 --- a/spec/factories/account_activity.rb +++ b/spec/factories/account_activity.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :account_activity do sum 1.0 account diff --git a/spec/factories/admin_domain_contact.rb b/spec/factories/admin_domain_contact.rb index 786825214..bdfb193e3 100644 --- a/spec/factories/admin_domain_contact.rb +++ b/spec/factories/admin_domain_contact.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :admin_domain_contact, parent: :domain_contact, class: AdminDomainContact do end diff --git a/spec/factories/admin_user.rb b/spec/factories/admin_user.rb index 0714d9f1f..8f948062d 100644 --- a/spec/factories/admin_user.rb +++ b/spec/factories/admin_user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :admin_user do username 'test' sequence(:email) { |n| "test#{n}@test.com" } diff --git a/spec/factories/api_user.rb b/spec/factories/api_user.rb index a38fb8bf9..a3f9623b6 100644 --- a/spec/factories/api_user.rb +++ b/spec/factories/api_user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :api_user do sequence(:username) { |n| "test#{n}" } password 'a' * ApiUser.min_password_length diff --git a/spec/factories/bank_statement.rb b/spec/factories/bank_statement.rb new file mode 100644 index 000000000..fa4865496 --- /dev/null +++ b/spec/factories/bank_statement.rb @@ -0,0 +1,11 @@ +FactoryBot.define do + factory :bank_statement do + bank_code { '767' } + iban { 'EE557700771000598731' } + queried_at { Time.zone.now } + + after :build do |bank_statement| + bank_statement.bank_transactions << FactoryBot.create_pair(:bank_transaction) + end + end +end diff --git a/spec/factories/bank_transaction.rb b/spec/factories/bank_transaction.rb new file mode 100644 index 000000000..ebe471984 --- /dev/null +++ b/spec/factories/bank_transaction.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :bank_transaction do + currency { 'EUR' } + sum { 100.0 } + description { 'Invoice no. 1' } + reference_no { 'RF2405752128' } + end +end diff --git a/spec/factories/billing/price.rb b/spec/factories/billing/price.rb index b7d49653d..4d44cf6a1 100644 --- a/spec/factories/billing/price.rb +++ b/spec/factories/billing/price.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :price, class: Billing::Price do price Money.from_amount(1) valid_from Time.zone.parse('05.07.2010') diff --git a/spec/factories/contact.rb b/spec/factories/contact.rb index e47b67012..7e7a9a6a2 100644 --- a/spec/factories/contact.rb +++ b/spec/factories/contact.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :contact do name 'test' sequence(:code) { |n| "test#{n}" } diff --git a/spec/factories/dns/zone.rb b/spec/factories/dns/zone.rb index c1180bb50..e88a3f2fe 100644 --- a/spec/factories/dns/zone.rb +++ b/spec/factories/dns/zone.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :zone, class: DNS::Zone do sequence(:origin) { |n| "test#{n}" } ttl 1 diff --git a/spec/factories/dnskey.rb b/spec/factories/dnskey.rb index ed90b7549..4dbf0a788 100644 --- a/spec/factories/dnskey.rb +++ b/spec/factories/dnskey.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :dnskey do alg Dnskey::ALGORITHMS.first flags Dnskey::FLAGS.first @@ -10,5 +10,6 @@ FactoryGirl.define do 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\ 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\ 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=' + domain end end diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb index 4c1b4b1cc..191a8055c 100644 --- a/spec/factories/domain.rb +++ b/spec/factories/domain.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :domain do sequence(:name) { |n| "test#{n}.com" } period 1 @@ -7,8 +7,8 @@ FactoryGirl.define do registrant after :build do |domain| - domain.admin_domain_contacts << FactoryGirl.build(:admin_domain_contact) - domain.tech_domain_contacts << FactoryGirl.build(:tech_domain_contact) + domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact) + domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact) end factory :domain_without_force_delete do diff --git a/spec/factories/domain_contact.rb b/spec/factories/domain_contact.rb index ae05fd293..caf964ed3 100644 --- a/spec/factories/domain_contact.rb +++ b/spec/factories/domain_contact.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :domain_contact do contact end diff --git a/spec/factories/domain_transfer.rb b/spec/factories/domain_transfer.rb new file mode 100644 index 000000000..4ecbfd084 --- /dev/null +++ b/spec/factories/domain_transfer.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :domain_transfer do + domain + transfer_from { FactoryBot.create(:registrar) } + transfer_to { FactoryBot.create(:registrar) } + end +end diff --git a/spec/factories/epp_session.rb b/spec/factories/epp_session.rb index 61fa06151..96dd78da3 100644 --- a/spec/factories/epp_session.rb +++ b/spec/factories/epp_session.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :epp_session do end diff --git a/spec/factories/invoice.rb b/spec/factories/invoice.rb new file mode 100644 index 000000000..7eeed32b9 --- /dev/null +++ b/spec/factories/invoice.rb @@ -0,0 +1,18 @@ +FactoryBot.define do + factory :invoice do + buyer_name 'Registrar 1' + currency { 'EUR' } + due_date { Time.zone.now.to_date + 1.day } + invoice_type 'DEB' + seller_iban { '123' } + seller_name { 'EIS' } + seller_city { 'Tallinn' } + seller_street { 'Paldiski mnt. 123' } + vat_prc 0.2 + buyer { FactoryBot.create(:registrar) } + + after :build do |invoice| + invoice.invoice_items << FactoryBot.create_pair(:invoice_item) + end + end +end diff --git a/spec/factories/invoice_item.rb b/spec/factories/invoice_item.rb new file mode 100644 index 000000000..3dee95319 --- /dev/null +++ b/spec/factories/invoice_item.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :invoice_item do + description { 'add money' } + unit 1 + amount 1 + price 150 + end +end diff --git a/spec/factories/keyrelay.rb b/spec/factories/keyrelay.rb new file mode 100644 index 000000000..4587af999 --- /dev/null +++ b/spec/factories/keyrelay.rb @@ -0,0 +1,12 @@ +FactoryBot.define do + factory :keyrelay do + pa_date { Time.zone.now } + expiry_relative 'P1W' + key_data_public_key 'abc' + key_data_flags 0 + key_data_protocol 3 + key_data_alg 3 + auth_info_pw 'abc' + domain + end +end diff --git a/spec/factories/message.rb b/spec/factories/message.rb new file mode 100644 index 000000000..6ae235aaf --- /dev/null +++ b/spec/factories/message.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :message do + body 'fabricator body' + end +end diff --git a/spec/factories/nameserver.rb b/spec/factories/nameserver.rb index ebe7a7909..edae45597 100644 --- a/spec/factories/nameserver.rb +++ b/spec/factories/nameserver.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :nameserver do sequence(:hostname) { |n| "ns.test#{n}.ee" } ipv4 '192.168.1.1' diff --git a/spec/factories/registrant.rb b/spec/factories/registrant.rb index d84d1688e..f21fbe7c4 100644 --- a/spec/factories/registrant.rb +++ b/spec/factories/registrant.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :registrant, parent: :contact, class: Registrant do name 'test' diff --git a/spec/factories/registrant_user.rb b/spec/factories/registrant_user.rb index 38f883067..29d0a2479 100644 --- a/spec/factories/registrant_user.rb +++ b/spec/factories/registrant_user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :registrant_user do end diff --git a/spec/factories/registrant_verification.rb b/spec/factories/registrant_verification.rb new file mode 100644 index 000000000..5ecc81fa5 --- /dev/null +++ b/spec/factories/registrant_verification.rb @@ -0,0 +1,9 @@ +FactoryBot.define do + factory :registrant_verification do + sequence(:domain_name) { |i| "domain#{i}.ee" } + domain + verification_token '123' + action 'confirmed' + action_type 'registrant_change' + end +end diff --git a/spec/factories/registrar.rb b/spec/factories/registrar.rb index 426561dda..df7d73690 100644 --- a/spec/factories/registrar.rb +++ b/spec/factories/registrar.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :registrar do sequence(:name) { |n| "test#{n}" } sequence(:code) { |n| "test#{n}" } diff --git a/spec/factories/reserved_domain.rb b/spec/factories/reserved_domain.rb new file mode 100644 index 000000000..54d3c61df --- /dev/null +++ b/spec/factories/reserved_domain.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :reserved_domain do + sequence(:name) { |i| "domain#{i}.ee" } + end +end diff --git a/spec/factories/tech_domain_contact.rb b/spec/factories/tech_domain_contact.rb index e407474a3..b3b3f0564 100644 --- a/spec/factories/tech_domain_contact.rb +++ b/spec/factories/tech_domain_contact.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :tech_domain_contact, parent: :domain_contact, class: TechDomainContact do end diff --git a/spec/factories/white_ip.rb b/spec/factories/white_ip.rb index eb4033fc9..f2b46711c 100644 --- a/spec/factories/white_ip.rb +++ b/spec/factories/white_ip.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :white_ip do ipv4 '127.0.0.1' end diff --git a/spec/factory_lint_spec.rb b/spec/factory_lint_spec.rb index 619779827..8d6386f2f 100644 --- a/spec/factory_lint_spec.rb +++ b/spec/factory_lint_spec.rb @@ -1,15 +1,15 @@ require_relative 'rails_helper' -RSpec.describe 'FactoryGirl', db: true do +RSpec.describe 'FactoryBot', db: true do before :example do allow(Contact).to receive(:address_processing?).and_return(false) end it 'lints factories' do - factories_to_lint = FactoryGirl.factories.reject do |factory| + factories_to_lint = FactoryBot.factories.reject do |factory| %i(reserved_domain).include?(factory.name) || factory.name.to_s =~ /^domain/ # Ignore the ones with domain_name validator end - FactoryGirl.lint factories_to_lint + FactoryBot.lint factories_to_lint end end diff --git a/spec/features/registrar/sign_in/mobile_id_spec.rb b/spec/features/registrar/sign_in/mobile_id_spec.rb index 9c1b42ee5..5373be4ec 100644 --- a/spec/features/registrar/sign_in/mobile_id_spec.rb +++ b/spec/features/registrar/sign_in/mobile_id_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.feature 'Mobile ID login', db: true do - given!(:api_user) { Fabricate(:api_user, identity_code: 1234) } + given!(:api_user) { create(:api_user, identity_code: 1234) } background do Setting.registrar_ip_whitelist_enabled = false diff --git a/spec/models/admin_user_spec.rb b/spec/models/admin_user_spec.rb index 84a653614..f25ea77bd 100644 --- a/spec/models/admin_user_spec.rb +++ b/spec/models/admin_user_spec.rb @@ -13,7 +13,7 @@ RSpec.describe AdminUser do context 'with valid attributes' do before do - @admin_user = Fabricate(:admin_user) + @admin_user = create(:admin_user) end it 'should require password confirmation when changing password' do diff --git a/spec/models/api_user_spec.rb b/spec/models/api_user_spec.rb index 12213c819..89feeac6d 100644 --- a/spec/models/api_user_spec.rb +++ b/spec/models/api_user_spec.rb @@ -28,7 +28,7 @@ RSpec.describe ApiUser do context 'with valid attributes' do before do - @api_user = Fabricate(:api_user) + @api_user = create(:api_user) end it 'should be valid' do @@ -37,7 +37,7 @@ RSpec.describe ApiUser do end it 'should be valid twice' do - @api_user = Fabricate(:api_user) + @api_user = create(:api_user) @api_user.valid? @api_user.errors.full_messages.should match_array([]) end diff --git a/spec/models/bank_statement_spec.rb b/spec/models/bank_statement_spec.rb index d115f6f04..8b10307fc 100644 --- a/spec/models/bank_statement_spec.rb +++ b/spec/models/bank_statement_spec.rb @@ -20,9 +20,8 @@ describe BankStatement do end context 'with valid attributes' do - before :all do - @bank_statement = Fabricate(:bank_statement) - Fabricate(:eis) + before do + @bank_statement = create(:bank_statement) end it 'should be valid' do @@ -31,67 +30,32 @@ describe BankStatement do end it 'should be valid twice' do - @bank_statement = Fabricate(:bank_statement) + @bank_statement = create(:bank_statement) @bank_statement.valid? @bank_statement.errors.full_messages.should match_array([]) end - it 'should bind transactions with invoices' do - # sometimes it works, sometimes not - # r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') - # invoice = r.issue_prepayment_invoice(200, 'add some money') - - # bs = Fabricate(:bank_statement, bank_transactions: [ - # Fabricate(:bank_transaction, { - # sum: 240.0, # with vat - # reference_no: 'RF7086666663', - # description: "Invoice no. #{invoice.number}" - # }), - # Fabricate(:bank_transaction, { - # sum: 240.0, - # reference_no: 'RF7086666663', - # description: "Invoice no. #{invoice.number}" - # }) - # ]) - - # bs.bank_transactions.count.should == 2 - - # AccountActivity.count.should == 0 - # bs.bind_invoices - - # AccountActivity.count.should == 1 - - # a = AccountActivity.last - # a.description.should == "Invoice no. #{invoice.number}" - # a.sum.should == BigDecimal.new('200.0') - # a.activity_type = AccountActivity::ADD_CREDIT - - # r.reload - # r.cash_account.reload - # r.cash_account.balance.should == 200.0 - - # bs.bank_transactions.unbinded.count.should == 1 - # bs.partially_binded?.should == true - end - it 'should not bind transactions with invalid match data' do - r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') + r = create(:registrar, reference_no: 'RF7086666663') + + create(:account, registrar: r, account_type: 'cash', balance: 0) + r.issue_prepayment_invoice(200, 'add some money') - bs = Fabricate(:bank_statement, bank_transactions: [ - Fabricate(:bank_transaction, { + bs = create(:bank_statement, bank_transactions: [ + create(:bank_transaction, { sum: 240.0, # with vat reference_no: 'RF7086666662', description: 'Invoice no. 1' }), - Fabricate(:bank_transaction, { + create(:bank_transaction, { sum: 240.0, reference_no: 'RF7086666663', description: 'Invoice no. 4948934' }) ]) - bs.bank_transactions.count.should == 2 + bs.bank_transactions.count.should == 4 AccountActivity.count.should == 0 bs.bind_invoices @@ -100,7 +64,7 @@ describe BankStatement do r.cash_account.balance.should == 0.0 - bs.bank_transactions.unbinded.count.should == 2 + bs.bank_transactions.unbinded.count.should == 4 bs.not_binded?.should == true end diff --git a/spec/models/bank_transaction_spec.rb b/spec/models/bank_transaction_spec.rb index 627427d57..9a559bbd6 100644 --- a/spec/models/bank_transaction_spec.rb +++ b/spec/models/bank_transaction_spec.rb @@ -19,8 +19,8 @@ describe BankTransaction do context 'with valid attributes' do before :all do - @bank_transaction = Fabricate(:bank_transaction) - Fabricate(:eis) + @bank_transaction = create(:bank_transaction) + create(:registrar) end it 'should be valid' do @@ -29,27 +29,27 @@ describe BankTransaction do end it 'should be valid twice' do - @bank_transaction = Fabricate(:bank_statement) + @bank_transaction = create(:bank_statement) @bank_transaction.valid? @bank_transaction.errors.full_messages.should match_array([]) end it 'should not bind transaction with mismatching sums' do - r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') + r = create(:registrar, reference_no: 'RF7086666663') invoice = r.issue_prepayment_invoice(200, 'add some money') - bt = Fabricate(:bank_transaction, { sum: 10 }) + bt = create(:bank_transaction, { sum: 10 }) bt.bind_invoice(invoice.number) bt.errors.full_messages.should match_array(["Invoice and transaction sums do not match"]) end it 'should not bind transaction with cancelled invoice' do - r = Fabricate(:registrar_with_no_account_activities, reference_no: 'RF7086666663') + r = create(:registrar, reference_no: 'RF7086666663') invoice = r.issue_prepayment_invoice(200, 'add some money') invoice.cancel - bt = Fabricate(:bank_transaction, { sum: 240 }) + bt = create(:bank_transaction, { sum: 240 }) bt.bind_invoice(invoice.number) bt.errors.full_messages.should match_array(["Cannot bind cancelled invoice"]) diff --git a/spec/models/concerns/domain/expirable_spec.rb b/spec/models/concerns/domain/expirable_spec.rb index 17c366819..242d9818a 100644 --- a/spec/models/concerns/domain/expirable_spec.rb +++ b/spec/models/concerns/domain/expirable_spec.rb @@ -7,11 +7,11 @@ RSpec.describe Domain, db: false do before :example do travel_to Time.zone.parse('05.07.2010 00:00') - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') - Fabricate.create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59')) - Fabricate.create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00')) - Fabricate.create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01')) + create(:domain, id: 1, expire_time: Time.zone.parse('04.07.2010 23:59')) + create(:domain, id: 2, expire_time: Time.zone.parse('05.07.2010 00:00')) + create(:domain, id: 3, expire_time: Time.zone.parse('05.07.2010 00:01')) end it 'returns expired domains' do diff --git a/spec/models/concerns/domain/force_delete_spec.rb b/spec/models/concerns/domain/force_delete_spec.rb index b454fb034..cc022a6d7 100644 --- a/spec/models/concerns/domain/force_delete_spec.rb +++ b/spec/models/concerns/domain/force_delete_spec.rb @@ -4,11 +4,15 @@ RSpec.describe Domain do it { is_expected.to alias_attribute(:force_delete_time, :force_delete_at) } before :example do - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end it 'should set force delete time' do - domain = Fabricate(:domain) + domain = build(:domain) + domain.nameservers.build(attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) + domain.save! + domain.statuses = ['ok'] domain.schedule_force_delete diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index bef5b87be..80dfb47ad 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe Contact do before :example do - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'about class' do @@ -63,7 +63,7 @@ RSpec.describe Contact do context 'with valid attributes' do before :example do - @contact = Fabricate(:contact) + @contact = create(:contact, auth_info: 'password') end it 'should have one version' do @@ -102,7 +102,7 @@ RSpec.describe Contact do end it 'should remove ok status when other non linked status present' do - contact = Fabricate(:contact) + contact = create(:contact) contact.statuses = [Contact::SERVER_UPDATE_PROHIBITED] contact.statuses.should == [Contact::SERVER_UPDATE_PROHIBITED] # temp test contact.save @@ -110,9 +110,9 @@ RSpec.describe Contact do end it 'should have code' do - registrar = Fabricate.create(:registrar, code: 'registrarcode') + registrar = create(:registrar, code: 'registrarcode') - contact = Fabricate.build(:contact, registrar: registrar, code: 'contactcode') + contact = build(:contact, registrar: registrar, code: 'contactcode') contact.generate_code contact.save! @@ -120,7 +120,7 @@ RSpec.describe Contact do end it 'should save status notes' do - contact = Fabricate(:contact) + contact = create(:contact) contact.statuses = ['serverDeleteProhibited', 'serverUpdateProhibited'] contact.status_notes_array = [nil, 'update manually turned off'] contact.status_notes['serverDeleteProhibited'].should == nil @@ -134,7 +134,7 @@ RSpec.describe Contact do it 'should have not update ident updated at when initializing old contact' do # creating a legacy contact - contact = Fabricate(:contact) + contact = create(:contact) contact.update_column(:ident_updated_at, nil) Contact.find(contact.id).ident_updated_at.should == nil @@ -142,7 +142,7 @@ RSpec.describe Contact do context 'as birthday' do before do - @domain = Fabricate(:domain) + @domain = create(:domain) end it 'should have related domain descriptions hash' do @@ -178,13 +178,13 @@ RSpec.describe Contact do context 'after create' do it 'should not allow to use same code' do - registrar = Fabricate.create(:registrar, code: 'FIXED') + registrar = create(:registrar, code: 'FIXED') - Fabricate.create(:contact, + create(:contact, registrar: registrar, code: 'FIXED:new-code', auth_info: 'qwe321') - @contact = Fabricate.build(:contact, + @contact = build(:contact, registrar: registrar, code: 'FIXED:new-code', auth_info: 'qwe321') @@ -195,33 +195,33 @@ RSpec.describe Contact do end it 'should generate a new password' do - @contact = Fabricate.build(:contact, code: '123asd', auth_info: nil) + @contact = build(:contact, code: '123asd', auth_info: nil) @contact.auth_info.should == nil @contact.save.should == true @contact.auth_info.should_not be_nil end it 'should allow supported code format' do - @contact = Fabricate.build(:contact, code: 'CID:REG1:12345', registrar: Fabricate(:registrar, code: 'FIXED')) + @contact = build(:contact, code: 'CID:REG1:12345', registrar: create(:registrar, code: 'FIXED')) @contact.valid? @contact.errors.full_messages.should == [] end it 'should not allow unsupported characters in code' do - @contact = Fabricate.build(:contact, code: 'unsupported!ÄÖÜ~?', registrar: Fabricate(:registrar, code: 'FIXED')) + @contact = build(:contact, code: 'unsupported!ÄÖÜ~?', registrar: create(:registrar, code: 'FIXED')) @contact.valid? @contact.errors.full_messages.should == ['Code is invalid'] end it 'should generate code if empty code is given' do - @contact = Fabricate.build(:contact, code: '') + @contact = build(:contact, code: '') @contact.generate_code @contact.save! @contact.code.should_not == '' end it 'should not ignore empty spaces as code and generate new one' do - @contact = Fabricate.build(:contact, code: ' ', registrar: Fabricate(:registrar, code: 'FIXED')) + @contact = build(:contact, code: ' ', registrar: create(:registrar, code: 'FIXED')) @contact.generate_code @contact.valid?.should == true @contact.code.should =~ /FIXED:..../ @@ -230,8 +230,8 @@ RSpec.describe Contact do context 'after update' do before :example do - @contact = Fabricate.build(:contact, - registrar: Fabricate(:registrar, code: 'FIXED'), + @contact = build(:contact, + registrar: create(:registrar, code: 'FIXED'), code: '123asd', auth_info: 'qwe321') @contact.generate_code @@ -256,9 +256,9 @@ end describe Contact, '.destroy_orphans' do before do - Fabricate(:zone, origin: 'ee') - @contact_1 = Fabricate(:contact, code: 'asd12') - @contact_2 = Fabricate(:contact, code: 'asd13') + create(:zone, origin: 'ee') + @contact_1 = create(:contact, code: 'asd12') + @contact_2 = create(:contact, code: 'asd13') end it 'destroys orphans' do @@ -268,13 +268,13 @@ describe Contact, '.destroy_orphans' do end it 'should find one orphan' do - Fabricate(:domain, registrant: Registrant.find(@contact_1.id)) + create(:domain, registrant: Registrant.find(@contact_1.id)) Contact.find_orphans.count.should == 1 Contact.find_orphans.last.should == @contact_2 end it 'should find no orphans' do - Fabricate(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2]) + create(:domain, registrant: Registrant.find(@contact_1.id), admin_contacts: [@contact_2]) cc = Contact.count Contact.find_orphans.count.should == 0 Contact.destroy_orphans @@ -424,13 +424,13 @@ RSpec.describe Contact do subject(:reg_no) { contact.reg_no } context 'when contact is legal entity' do - let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') } + let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') } specify { expect(reg_no).to eq('1234') } end context 'when contact is private entity' do - let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') } + let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') } specify { expect(reg_no).to be_nil } end @@ -438,13 +438,13 @@ RSpec.describe Contact do describe '#id_code' do context 'when contact is private entity' do - let(:contact) { FactoryGirl.build_stubbed(:contact_private_entity, ident: '1234') } + let(:contact) { build_stubbed(:contact_private_entity, ident: '1234') } specify { expect(contact.id_code).to eq('1234') } end context 'when contact is legal entity' do - let(:contact) { FactoryGirl.build_stubbed(:contact_legal_entity, ident: '1234') } + let(:contact) { build_stubbed(:contact_legal_entity, ident: '1234') } specify { expect(contact.id_code).to be_nil } end diff --git a/spec/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb index 9987de090..5c0f7859f 100644 --- a/spec/models/dnskey_spec.rb +++ b/spec/models/dnskey_spec.rb @@ -21,7 +21,7 @@ describe Dnskey do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'with invalid attribute' do @@ -42,7 +42,17 @@ describe Dnskey do context 'with valid attributes' do before :example do - @dnskey = Fabricate(:dnskey) + @dnskey = create(:dnskey, + alg: 8, + flags: 257, + protocol: 3, + public_key: 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\ + 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\ + 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\ + 'DDFi6oOZ0xE/0CuveB64I3ree7nCrwLwNs56kXC4LYoX3XdkOMKiJLL/ '\ + 'MAhcxXa60CdZLoRtTEW3z8/oBq4hEAYMCNclpbd6y/exScwBxFTdUfFk '\ + 'KsdNcmvai1lyk9vna0WQrtpYpHKMXvY9LFHaJxCOLR4umfeQ42RuTd82 lqfU6ClMeXs=', + ds_digest_type: 2) end it 'should be valid' do @@ -51,7 +61,7 @@ describe Dnskey do end it 'should be valid twice' do - @dnskey = Fabricate(:dnskey) + @dnskey = create(:dnskey) @dnskey.valid? @dnskey.errors.full_messages.should match_array([]) end @@ -66,7 +76,7 @@ describe Dnskey do # end it 'generates correct DS digest and DS key tag for ria.ee' do - d = Fabricate(:domain, name: 'ria.ee', dnskeys: [@dnskey]) + d = create(:domain, name: 'ria.ee', dnskeys: [@dnskey]) dk = d.dnskeys.last dk.generate_digest @@ -75,7 +85,7 @@ describe Dnskey do end it 'generates correct DS digest and DS key tag for emta.ee' do - d = Fabricate(:domain, name: 'emta.ee', dnskeys: [@dnskey]) + d = create(:domain, name: 'emta.ee', dnskeys: [@dnskey]) dk = d.dnskeys.last diff --git a/spec/models/domain_contact_spec.rb b/spec/models/domain_contact_spec.rb index 783d7e69b..fc7ec010e 100644 --- a/spec/models/domain_contact_spec.rb +++ b/spec/models/domain_contact_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' describe DomainContact do before :example do - @api_user = Fabricate(:domain_contact) + @api_user = create(:domain_contact) end context 'with invalid attribute' do @@ -32,7 +32,7 @@ describe DomainContact do context 'with valid attributes' do before :example do - @domain_contact = Fabricate(:domain_contact) + @domain_contact = create(:domain_contact, type: 'TechDomainContact') end it 'should be valid' do @@ -41,7 +41,7 @@ describe DomainContact do end it 'should be valid twice' do - @domain_contact = Fabricate(:domain_contact) + @domain_contact = create(:domain_contact) @domain_contact.valid? @domain_contact.errors.full_messages.should match_array([]) end @@ -51,11 +51,11 @@ describe DomainContact do end it 'should have one version' do - @domain_contact = Fabricate.create(:domain_contact) + @domain_contact = create(:domain_contact) with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.contact = Fabricate.create(:contact) + @domain_contact.contact = create(:contact) @domain_contact.save! @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 @@ -65,7 +65,7 @@ describe DomainContact do context 'with valid attributes with tech domain contact' do before :example do - @domain_contact = Fabricate(:tech_domain_contact) + @domain_contact = create(:tech_domain_contact) end it 'should be valid' do @@ -74,7 +74,7 @@ describe DomainContact do end it 'should be valid twice' do - @domain_contact = Fabricate(:tech_domain_contact) + @domain_contact = create(:tech_domain_contact) @domain_contact.valid? @domain_contact.errors.full_messages.should match_array([]) end @@ -84,11 +84,11 @@ describe DomainContact do end it 'should have one version' do - @domain_contact = Fabricate.create(:domain_contact) + @domain_contact = create(:domain_contact) with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.contact = Fabricate.create(:contact) + @domain_contact.contact = create(:contact) @domain_contact.save! @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 @@ -98,7 +98,7 @@ describe DomainContact do context 'with valid attributes with admin domain contact' do before :example do - @domain_contact = Fabricate(:admin_domain_contact) + @domain_contact = create(:admin_domain_contact) end it 'should be valid' do @@ -107,7 +107,7 @@ describe DomainContact do end it 'should be valid twice' do - @domain_contact = Fabricate(:admin_domain_contact) + @domain_contact = create(:admin_domain_contact) @domain_contact.valid? @domain_contact.errors.full_messages.should match_array([]) end @@ -119,7 +119,7 @@ describe DomainContact do it 'should have one version' do with_versioning do @domain_contact.versions.reload.should == [] - @domain_contact.contact = Fabricate.create(:contact) + @domain_contact.contact = create(:contact) @domain_contact.save @domain_contact.errors.full_messages.should match_array([]) @domain_contact.versions.size.should == 1 diff --git a/spec/models/domain_cron_spec.rb b/spec/models/domain_cron_spec.rb index 9b5e68f54..7fe2246a0 100644 --- a/spec/models/domain_cron_spec.rb +++ b/spec/models/domain_cron_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' RSpec.describe DomainCron do it 'should expire domains' do - Fabricate(:zone, origin: 'ee') - @domain = Fabricate(:domain) + create(:zone, origin: 'ee') + @domain = create(:domain) Setting.expire_warning_period = 1 Setting.redemption_grace_period = 1 @@ -25,8 +25,8 @@ RSpec.describe DomainCron do end it 'should start redemption grace period' do - Fabricate(:zone, origin: 'ee') - @domain = Fabricate(:domain) + create(:zone, origin: 'ee') + @domain = create(:domain) old_valid_to = Time.zone.now - 10.days @domain.valid_to = old_valid_to diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 9cb27a751..fe9dae9a6 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -21,11 +21,11 @@ RSpec.describe Domain do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') - Fabricate(:zone, origin: 'pri.ee') - Fabricate(:zone, origin: 'med.ee') - Fabricate(:zone, origin: 'fie.ee') - Fabricate(:zone, origin: 'com.ee') + create(:zone, origin: 'ee') + create(:zone, origin: 'pri.ee') + create(:zone, origin: 'med.ee') + create(:zone, origin: 'fie.ee') + create(:zone, origin: 'com.ee') end context 'with invalid attribute' do @@ -64,7 +64,7 @@ RSpec.describe Domain do context 'with valid attributes' do before :example do - @domain = Fabricate(:domain) + @domain = create(:domain) end it 'should be valid' do @@ -73,14 +73,14 @@ RSpec.describe Domain do end it 'should be valid twice' do - @domain = Fabricate(:domain) + @domain = create(:domain) @domain.valid? @domain.errors.full_messages.should match_array([]) end it 'should validate uniqueness of tech contacts' do - same_contact = Fabricate(:contact, code: 'same_contact') - domain = Fabricate(:domain) + same_contact = create(:contact, code: 'same_contact') + domain = create(:domain) domain.tech_contacts << same_contact domain.tech_contacts << same_contact domain.valid? @@ -88,8 +88,8 @@ RSpec.describe Domain do end it 'should validate uniqueness of tech contacts' do - same_contact = Fabricate(:contact, code: 'same_contact') - domain = Fabricate(:domain) + same_contact = create(:contact, code: 'same_contact') + domain = create(:domain) domain.admin_contacts << same_contact domain.admin_contacts << same_contact domain.valid? @@ -113,7 +113,7 @@ RSpec.describe Domain do end it 'should not find any domains with wrong pendings' do - domain = Fabricate(:domain) + domain = create(:domain) domain.registrant_verification_asked!('frame-str', '1') domain.registrant_verification_asked_at = 30.days.ago domain.save @@ -122,7 +122,7 @@ RSpec.describe Domain do end it 'should clean domain pendings' do - domain = Fabricate(:domain) + domain = create(:domain) domain.registrant_verification_asked!('frame-str', '1') domain.registrant_verification_asked_at = 30.days.ago domain.pending_delete! @@ -165,7 +165,7 @@ RSpec.describe Domain do end it 'should start redemption grace period' do - domain = Fabricate(:domain) + domain = create(:domain) DomainCron.start_redemption_grace_period domain.reload @@ -253,6 +253,9 @@ RSpec.describe Domain do end it 'should set pending delete' do + @domain.nameservers.build(attributes_for(:nameserver)) + @domain.nameservers.build(attributes_for(:nameserver)) + @domain.statuses = DomainStatus::OK # restore @domain.save @domain.pending_delete?.should == false @@ -281,7 +284,7 @@ RSpec.describe Domain do end it 'should add poll message to registrar' do - domain = Fabricate(:domain, name: 'testpollmessage123.ee') + domain = create(:domain, name: 'testpollmessage123.ee') domain.poll_message!(:poll_pending_update_confirmed_by_registrant) domain.registrar.messages.first.body.should == 'Registrant confirmed domain update: testpollmessage123.ee' end @@ -341,13 +344,13 @@ RSpec.describe Domain do it 'should return api_creator when created by api user' do with_versioning do - @user = Fabricate(:admin_user) - @api_user = Fabricate(:api_user) + @user = create(:admin_user) + @api_user = create(:api_user) @user.id.should == 1 @api_user.id.should == 2 ::PaperTrail.whodunnit = '2-ApiUser: testuser' - @domain = Fabricate(:domain) + @domain = create(:domain) @domain.creator_str.should == '2-ApiUser: testuser' @domain.creator.should == @api_user @@ -357,13 +360,13 @@ RSpec.describe Domain do it 'should return api_creator when created by api user' do with_versioning do - @user = Fabricate(:admin_user, id: 1000) - @api_user = Fabricate(:api_user, id: 2000) + @user = create(:admin_user, id: 1000) + @api_user = create(:api_user, id: 2000) @user.id.should == 1000 @api_user.id.should == 2000 ::PaperTrail.whodunnit = '1000-AdminUser: testuser' - @domain = Fabricate(:domain) + @domain = create(:domain) @domain.creator_str.should == '1000-AdminUser: testuser' @domain.creator.should == @user @@ -374,7 +377,7 @@ RSpec.describe Domain do end it 'validates domain name' do - d = Fabricate(:domain) + d = create(:domain) expect(d.name).to_not be_nil invalid = [ @@ -384,7 +387,7 @@ RSpec.describe Domain do ] invalid.each do |x| - expect(Fabricate.build(:domain, name: x).valid?).to be false + expect(build(:domain, name: x).valid?).to be false end valid = [ @@ -393,28 +396,28 @@ RSpec.describe Domain do ] valid.each do |x| - expect(Fabricate.build(:domain, name: x).valid?).to be true + expect(build(:domain, name: x).valid?).to be true end invalid_punycode = ['xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-4we.pri.ee'] invalid_punycode.each do |x| - expect(Fabricate.build(:domain, name: x).valid?).to be false + expect(build(:domain, name: x).valid?).to be false end valid_punycode = ['xn--ge-uia.pri.ee', 'xn--geaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-9te.pri.ee'] valid_punycode.each do |x| - expect(Fabricate.build(:domain, name: x).valid?).to be true + expect(build(:domain, name: x).valid?).to be true end end it 'should not create zone origin domain' do - d = Fabricate.build(:domain, name: 'ee') + d = build(:domain, name: 'ee') d.save.should == false expect(d.errors.full_messages).to include('Data management policy violation: Domain name is blocked [name]') - d = Fabricate.build(:domain, name: 'bla') + d = build(:domain, name: 'bla') d.save.should == false expect(d.errors.full_messages).to include('Domain name Domain name is invalid') end @@ -427,13 +430,13 @@ RSpec.describe Domain do end it 'should be valid when name length is exatly 63 in characters' do - d = Fabricate(:domain, name: "#{'a' * 63}.ee") + d = create(:domain, name: "#{'a' * 63}.ee") d.valid? d.errors.full_messages.should == [] end it 'should not be valid when name length is longer than 63 characters' do - d = Fabricate.build(:domain, name: "#{'a' * 64}.ee") + d = build(:domain, name: "#{'a' * 64}.ee") d.valid? d.errors.full_messages.should match_array([ "Domain name Domain name is invalid", @@ -442,7 +445,7 @@ RSpec.describe Domain do end it 'should not be valid when name length is longer than 63 characters' do - d = Fabricate.build(:domain, + d = build(:domain, name: "xn--4caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.ee") d.valid? d.errors.full_messages.should match_array([ @@ -452,7 +455,7 @@ RSpec.describe Domain do end it 'should be valid when name length is 63 characters' do - d = Fabricate.build(:domain, + d = build(:domain, name: "õäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžõäöüšžab123.pri.ee") d.valid? d.errors.full_messages.should match_array([ @@ -460,7 +463,7 @@ RSpec.describe Domain do end it 'should not be valid when name length is longer than 63 punycode characters' do - d = Fabricate.build(:domain, name: "#{'ä' * 63}.ee") + d = build(:domain, name: "#{'ä' * 63}.ee") d.valid? d.errors.full_messages.should == [ "Puny label Domain name is too long (maximum is 63 characters)" @@ -468,7 +471,7 @@ RSpec.describe Domain do end it 'should not be valid when name length is longer than 63 punycode characters' do - d = Fabricate.build(:domain, name: "#{'ä' * 64}.ee") + d = build(:domain, name: "#{'ä' * 64}.ee") d.valid? d.errors.full_messages.should match_array([ "Domain name Domain name is invalid", @@ -477,7 +480,7 @@ RSpec.describe Domain do end it 'should not be valid when name length is longer than 63 punycode characters' do - d = Fabricate.build(:domain, name: "#{'ä' * 63}.pri.ee") + d = build(:domain, name: "#{'ä' * 63}.pri.ee") d.valid? d.errors.full_messages.should match_array([ "Puny label Domain name is too long (maximum is 63 characters)" @@ -485,63 +488,69 @@ RSpec.describe Domain do end it 'should be valid when punycode name length is not longer than 63' do - d = Fabricate.build(:domain, name: "#{'ä' * 53}.pri.ee") + d = build(:domain, name: "#{'ä' * 53}.pri.ee") d.valid? d.errors.full_messages.should == [] end it 'should be valid when punycode name length is not longer than 63' do - d = Fabricate.build(:domain, name: "#{'ä' * 57}.ee") + d = build(:domain, name: "#{'ä' * 57}.ee") d.valid? d.errors.full_messages.should == [] end it 'should not be valid when name length is one pynicode' do - d = Fabricate.build(:domain, name: "xn--4ca.ee") + d = build(:domain, name: "xn--4ca.ee") d.valid? d.errors.full_messages.should == ["Domain name Domain name is invalid"] end it 'should not be valid with at character' do - d = Fabricate.build(:domain, name: 'dass@sf.ee') + d = build(:domain, name: 'dass@sf.ee') d.valid? d.errors.full_messages.should == ["Domain name Domain name is invalid"] end it 'should not be valid with invalid characters' do - d = Fabricate.build(:domain, name: '@ba)s(?ä_:-df.ee') + d = build(:domain, name: '@ba)s(?ä_:-df.ee') d.valid? d.errors.full_messages.should == ["Domain name Domain name is invalid"] end it 'should be valid when name length is two pynicodes' do - d = Fabricate.build(:domain, name: "xn--4caa.ee") + d = build(:domain, name: "xn--4caa.ee") d.valid? d.errors.full_messages.should == [] end it 'should be valid when name length is two pynicodes' do - d = Fabricate.build(:domain, name: "xn--4ca0b.ee") + d = build(:domain, name: "xn--4ca0b.ee") d.valid? d.errors.full_messages.should == [] end it 'does not create a reserved domain' do - Fabricate.create(:reserved_domain, name: 'test.ee') + create(:reserved_domain, name: 'test.ee') - domain = Fabricate.build(:domain, name: 'test.ee') + domain = build(:domain, name: 'test.ee') domain.validate expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains') end it 'generates auth info' do - d = Fabricate(:domain) + d = create(:domain) expect(d.auth_info).to_not be_empty end it 'manages statuses automatically' do - d = Fabricate(:domain) + d = build(:domain) + + d.nameservers.build(attributes_for(:nameserver)) + d.nameservers.build(attributes_for(:nameserver)) + + d.save! + expect(d.statuses.count).to eq(1) expect(d.statuses.first).to eq(DomainStatus::OK) @@ -562,28 +571,16 @@ RSpec.describe Domain do end with_versioning do - context 'when not saved' do - it 'does not create domain version' do - Fabricate.build(:domain) - expect(DomainVersion.count).to eq(0) - end - - it 'does not create child versions' do - Fabricate.build(:domain) - expect(ContactVersion.count).to eq(0) - expect(NameserverVersion.count).to eq(0) - end - end - context 'when saved' do before(:each) do - Fabricate(:domain) + domain = create(:domain) + domain.nameservers << create(:nameserver) end it 'creates domain version' do expect(DomainVersion.count).to eq(1) expect(ContactVersion.count).to eq(3) - expect(NameserverVersion.count).to eq(3) + expect(NameserverVersion.count).to eq(2) end end end @@ -672,7 +669,7 @@ RSpec.describe Domain do it 'rejects less than min' do Setting.ns_min_count = 2 - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) domain.validate expect(domain.errors).to have_key(:nameservers) end @@ -680,15 +677,15 @@ RSpec.describe Domain do it 'rejects more than max' do Setting.ns_min_count = 1 Setting.ns_max_count = 1 - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) domain.validate expect(domain.errors).to have_key(:nameservers) end it 'accepts min' do Setting.ns_min_count = 1 - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) domain.validate expect(domain.errors).to_not have_key(:nameservers) end @@ -696,8 +693,8 @@ RSpec.describe Domain do it 'accepts max' do Setting.ns_min_count = 1 Setting.ns_max_count = 2 - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) domain.validate expect(domain.errors).to_not have_key(:nameservers) end @@ -709,7 +706,7 @@ RSpec.describe Domain do it 'rejects less than min' do Setting.ns_min_count = 2 - domain.nameservers.build(FactoryGirl.attributes_for(:nameserver)) + domain.nameservers.build(attributes_for(:nameserver)) domain.validate expect(domain.errors).to have_key(:nameservers) end @@ -867,11 +864,11 @@ RSpec.describe Domain do before :example do travel_to Time.zone.parse('05.07.2010 00:00') - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') - Fabricate.create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59')) - Fabricate.create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00')) - Fabricate.create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01')) + create(:domain, id: 1, outzone_time: Time.zone.parse('04.07.2010 23:59')) + create(:domain, id: 2, outzone_time: Time.zone.parse('05.07.2010 00:00')) + create(:domain, id: 3, outzone_time: Time.zone.parse('05.07.2010 00:01')) end it 'returns domains with outzone time in the past' do @@ -883,11 +880,11 @@ RSpec.describe Domain do before :example do travel_to Time.zone.parse('05.07.2010 00:00') - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') - Fabricate.create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59')) - Fabricate.create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00')) - Fabricate.create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01')) + create(:domain, id: 1, delete_time: Time.zone.parse('04.07.2010 23:59')) + create(:domain, id: 2, delete_time: Time.zone.parse('05.07.2010 00:00')) + create(:domain, id: 3, delete_time: Time.zone.parse('05.07.2010 00:01')) end it 'returns domains with delete time in the past' do diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb index d1ff29eee..5f8bf54a0 100644 --- a/spec/models/domain_transfer_spec.rb +++ b/spec/models/domain_transfer_spec.rb @@ -21,7 +21,7 @@ describe DomainTransfer do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'with invalid attribute' do @@ -42,7 +42,7 @@ describe DomainTransfer do context 'with valid attributes' do before :example do - @domain_transfer = Fabricate(:domain_transfer) + @domain_transfer = create(:domain_transfer) end it 'should be valid' do @@ -51,7 +51,7 @@ describe DomainTransfer do end it 'should be valid twice' do - @domain_transfer = Fabricate(:domain_transfer) + @domain_transfer = create(:domain_transfer) @domain_transfer.valid? @domain_transfer.errors.full_messages.should match_array([]) end diff --git a/spec/models/epp_contact_spec.rb b/spec/models/epp_contact_spec.rb index 5f5d2eafa..401a63cc6 100644 --- a/spec/models/epp_contact_spec.rb +++ b/spec/models/epp_contact_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' describe Epp::Contact, '.check_availability' do before do - Fabricate(:contact, code: 'asd12') - Fabricate(:contact, code: 'asd13') + create(:contact, code: 'asd12') + create(:contact, code: 'asd13') end it 'should return array if argument is string' do diff --git a/spec/models/epp_session.rb b/spec/models/epp_session.rb index 6261e2599..484cd1345 100644 --- a/spec/models/epp_session.rb +++ b/spec/models/epp_session.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe EppSession do - let(:epp_session) { Fabricate(:epp_session) } + let(:epp_session) { create(:epp_session) } it 'has marshalled data' do expect(epp_session.read_attribute(:data)).to_not be_blank diff --git a/spec/models/invoice_spec.rb b/spec/models/invoice_spec.rb index 33bf4fa6e..49d15310f 100644 --- a/spec/models/invoice_spec.rb +++ b/spec/models/invoice_spec.rb @@ -27,7 +27,7 @@ describe Invoice do context 'with valid attributes' do before :all do - @invoice = Fabricate(:invoice) + @invoice = create(:invoice) end it 'should be valid' do @@ -36,24 +36,24 @@ describe Invoice do end it 'should be valid twice' do - @invoice = Fabricate(:invoice) + @invoice = create(:invoice) @invoice.valid? @invoice.errors.full_messages.should match_array([]) end it 'should be valid twice' do - @invoice = Fabricate(:invoice) + @invoice = create(:invoice) @invoice.valid? @invoice.errors.full_messages.should match_array([]) end it 'should return correct addresses' do - @invoice = Fabricate(:invoice) + @invoice = create(:invoice) @invoice.seller_address.should == 'Paldiski mnt. 123, Tallinn' end it 'should calculate sums correctly' do - @invoice = Fabricate(:invoice) + @invoice = create(:invoice) @invoice.vat_prc.should == BigDecimal.new('0.2') @invoice.sum_without_vat.should == BigDecimal.new('300.0') @invoice.vat.should == BigDecimal.new('60.0') @@ -67,7 +67,7 @@ describe Invoice do end it 'should cancel overdue invoices' do - Fabricate(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 30.days) + create(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 30.days) Invoice.cancel_overdue_invoices Invoice.where(cancelled_at: nil).count.should == 1 end diff --git a/spec/models/keyrelay_spec.rb b/spec/models/keyrelay_spec.rb index 319faf87c..5c335941b 100644 --- a/spec/models/keyrelay_spec.rb +++ b/spec/models/keyrelay_spec.rb @@ -21,7 +21,7 @@ describe Keyrelay do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'with invalid attribute' do @@ -49,7 +49,7 @@ describe Keyrelay do context 'with valid attributes' do before :example do - @keyrelay = Fabricate(:keyrelay) + @keyrelay = create(:keyrelay) end it 'should be valid' do @@ -58,7 +58,7 @@ describe Keyrelay do end it 'should be valid twice' do - @keyrelay = Fabricate(:keyrelay) + @keyrelay = create(:keyrelay) @keyrelay.valid? @keyrelay.errors.full_messages.should match_array([]) end @@ -79,12 +79,12 @@ describe Keyrelay do end it 'is in expired status' do - kr = Fabricate(:keyrelay, pa_date: Time.zone.now - 2.weeks) + kr = create(:keyrelay, pa_date: Time.zone.now - 2.weeks) expect(kr.status).to eq('expired') end it 'does not accept invalid relative expiry' do - kr = Fabricate.build(:keyrelay, expiry_relative: 'adf') + kr = build(:keyrelay, expiry_relative: 'adf') expect(kr.save).to eq(false) expect(kr.errors[:expiry_relative].first).to eq('Expiry relative must be compatible to ISO 8601') end diff --git a/spec/models/legal_document_spec.rb b/spec/models/legal_document_spec.rb index e87a3b77a..03c83bc89 100644 --- a/spec/models/legal_document_spec.rb +++ b/spec/models/legal_document_spec.rb @@ -3,16 +3,16 @@ require 'rails_helper' describe LegalDocument do context 'tasks' do it 'make files uniq' do - Fabricate(:zone, origin: 'ee') - Fabricate(:zone, origin: 'pri.ee') - Fabricate(:zone, origin: 'med.ee') - Fabricate(:zone, origin: 'fie.ee') - Fabricate(:zone, origin: 'com.ee') + create(:zone, origin: 'ee') + create(:zone, origin: 'pri.ee') + create(:zone, origin: 'med.ee') + create(:zone, origin: 'fie.ee') + create(:zone, origin: 'com.ee') LegalDocument.explicitly_write_file = true PaperTrail.enabled = true - domain = Fabricate(:domain) - domain2 = Fabricate(:domain) + domain = create(:domain) + domain2 = create(:domain) legals = [] legals << original = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes)) legals << copy = domain.legal_documents.create!(body: Base64.encode64('S' * 4.kilobytes)) diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index ddbea285b..a71988701 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -20,7 +20,7 @@ describe Message do context 'with valid attributes' do before :all do - @mssage = Fabricate(:message) + @mssage = create(:message) end it 'should be valid' do @@ -29,7 +29,7 @@ describe Message do end it 'should be valid twice' do - @mssage = Fabricate(:message) + @mssage = create(:message) @mssage.valid? @mssage.errors.full_messages.should match_array([]) end diff --git a/spec/models/nameserver_spec.rb b/spec/models/nameserver_spec.rb index 494d5696b..b7cd7a6be 100644 --- a/spec/models/nameserver_spec.rb +++ b/spec/models/nameserver_spec.rb @@ -21,7 +21,7 @@ describe Nameserver do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'with invalid attribute' do @@ -36,7 +36,7 @@ describe Nameserver do context 'with valid attributes' do before :example do - @nameserver = Fabricate(:nameserver) + @nameserver = create(:nameserver) end it 'should be valid' do @@ -45,7 +45,7 @@ describe Nameserver do end it 'should be valid twice' do - @nameserver = Fabricate(:nameserver) + @nameserver = create(:nameserver) @nameserver.valid? @nameserver.errors.full_messages.should match_array([]) end @@ -62,23 +62,23 @@ describe Nameserver do context 'with many nameservers' do before :example do - @api_user = Fabricate(:api_user) - @domain_1 = Fabricate(:domain, nameservers: [ - Fabricate(:nameserver, hostname: 'ns1.ns.ee'), - Fabricate(:nameserver, hostname: 'ns2.ns.ee'), - Fabricate(:nameserver, hostname: 'ns2.test.ee') + @api_user = create(:api_user) + @domain_1 = create(:domain, nameservers: [ + create(:nameserver, hostname: 'ns1.ns.ee'), + create(:nameserver, hostname: 'ns2.ns.ee'), + create(:nameserver, hostname: 'ns2.test.ee') ], registrar: @api_user.registrar) - @domain_2 = Fabricate(:domain, nameservers: [ - Fabricate(:nameserver, hostname: 'ns1.ns.ee'), - Fabricate(:nameserver, hostname: 'ns2.ns.ee'), - Fabricate(:nameserver, hostname: 'ns3.test.ee') + @domain_2 = create(:domain, nameservers: [ + create(:nameserver, hostname: 'ns1.ns.ee'), + create(:nameserver, hostname: 'ns2.ns.ee'), + create(:nameserver, hostname: 'ns3.test.ee') ], registrar: @api_user.registrar) - @domain_3 = Fabricate(:domain, nameservers: [ - Fabricate(:nameserver, hostname: 'ns1.ns.ee'), - Fabricate(:nameserver, hostname: 'ns2.ns.ee'), - Fabricate(:nameserver, hostname: 'ns3.test.ee') + @domain_3 = create(:domain, nameservers: [ + create(:nameserver, hostname: 'ns1.ns.ee'), + create(:nameserver, hostname: 'ns2.ns.ee'), + create(:nameserver, hostname: 'ns3.test.ee') ]) end diff --git a/spec/models/registrant_verification_spec.rb b/spec/models/registrant_verification_spec.rb index 13036ef21..6438fda84 100644 --- a/spec/models/registrant_verification_spec.rb +++ b/spec/models/registrant_verification_spec.rb @@ -21,7 +21,7 @@ describe RegistrantVerification do Setting.client_side_status_editing_enabled = true - Fabricate(:zone, origin: 'ee') + create(:zone, origin: 'ee') end context 'with invalid attribute' do before :example do @@ -42,7 +42,7 @@ describe RegistrantVerification do context 'with valid attributes' do before :example do - @registrant_verification = Fabricate(:registrant_verification) + @registrant_verification = create(:registrant_verification) end it 'should be valid' do @@ -51,7 +51,7 @@ describe RegistrantVerification do end it 'should be valid twice' do - @registrant_verification = Fabricate(:registrant_verification) + @registrant_verification = create(:registrant_verification) @registrant_verification.valid? @registrant_verification.errors.full_messages.should match_array([]) end diff --git a/spec/models/registrar_spec.rb b/spec/models/registrar_spec.rb index 45acfdab1..4a8110d45 100644 --- a/spec/models/registrar_spec.rb +++ b/spec/models/registrar_spec.rb @@ -8,7 +8,7 @@ describe Registrar do it 'is not valid' do @registrar.valid? - @registrar.errors.full_messages.should match_array([ + @registrar.errors.full_messages.should include(*[ 'Contact e-mail is missing', 'Country code is missing', 'Name is missing', @@ -39,7 +39,7 @@ describe Registrar do context 'with valid attributes' do before :all do - @registrar = Fabricate(:registrar) + @registrar = create(:registrar) end it 'should be valid' do @@ -48,13 +48,13 @@ describe Registrar do end it 'should be valid twice' do - @registrar = Fabricate(:registrar) + @registrar = create(:registrar) @registrar.valid? @registrar.errors.full_messages.should match_array([]) end it 'should remove blank from code' do - registrar = Fabricate.build(:registrar, code: 'with blank') + registrar = build(:registrar, code: 'with blank') registrar.valid? registrar.errors.full_messages.should match_array([ ]) @@ -62,7 +62,7 @@ describe Registrar do end it 'should remove colon from code' do - registrar = Fabricate.build(:registrar, code: 'with colon:and:blank') + registrar = build(:registrar, code: 'with colon:and:blank') registrar.valid? registrar.errors.full_messages.should match_array([ ]) @@ -70,7 +70,7 @@ describe Registrar do end it 'should allow dot in code' do - registrar = Fabricate.build(:registrar, code: 'with.dot') + registrar = build(:registrar, code: 'with.dot') registrar.valid? registrar.errors.full_messages.should match_array([ ]) @@ -88,21 +88,19 @@ describe Registrar do end it 'should return full address' do - @registrar.address.should == 'Street 999, Town, County, Postal' - end - - it 'should have code' do - @registrar.code.should =~ /REGISTRAR/ + registrar = described_class.new(street: 'Street 999', city: 'Town', state: 'County', zip: 'Postal') + registrar.address.should == 'Street 999, Town, County, Postal' end it 'should not be able to change code' do - @registrar.code = 'not-updated' - @registrar.code.should =~ /REGISTRAR/ + registrar = create(:registrar, code: 'TEST') + registrar.code = 'new-code' + expect(registrar.code).to eq('TEST') end it 'should be able to issue a prepayment invoice' do Setting.days_to_keep_invoices_active = 30 - Fabricate(:registrar, name: 'EIS', reg_no: '90010019') + create(:registrar, name: 'EIS', reg_no: '90010019') @registrar.issue_prepayment_invoice(200, 'add some money') @registrar.invoices.count.should == 1 i = @registrar.invoices.first @@ -112,7 +110,7 @@ describe Registrar do end it 'should not allaw to use CID as code for leagcy reasons' do - registrar = Fabricate.build(:registrar, code: 'CID') + registrar = build(:registrar, code: 'CID') registrar.valid? registrar.errors.full_messages.should == ['Code is forbidden to use'] end diff --git a/spec/models/whois_record_spec.rb b/spec/models/whois_record_spec.rb index 0f404a4de..c1fba57f9 100644 --- a/spec/models/whois_record_spec.rb +++ b/spec/models/whois_record_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' RSpec.describe WhoisRecord do describe '::generate_json', db: false do - let(:registrant) { FactoryGirl.build_stubbed(:registrant) } - let(:domain) { FactoryGirl.build_stubbed(:domain, registrant: registrant) } + let(:registrant) { build_stubbed(:registrant) } + let(:domain) { build_stubbed(:domain, registrant: registrant) } let(:whois_record) { described_class.new } subject(:generated_json) { whois_record.generate_json } @@ -24,7 +24,7 @@ RSpec.describe WhoisRecord do end context 'when registrant is legal entity' do - let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) } + let(:registrant) { build_stubbed(:registrant_legal_entity) } it 'is present' do expect(reg_no).to eq('test reg no') @@ -32,7 +32,7 @@ RSpec.describe WhoisRecord do end context 'when registrant is private entity' do - let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) } + let(:registrant) { build_stubbed(:registrant_private_entity) } it 'is absent' do expect(reg_no).to be_nil @@ -48,7 +48,7 @@ RSpec.describe WhoisRecord do end context 'when registrant is legal entity' do - let(:registrant) { FactoryGirl.build_stubbed(:registrant_legal_entity) } + let(:registrant) { build_stubbed(:registrant_legal_entity) } it 'is present' do expect(country_code).to eq('test country code') @@ -56,7 +56,7 @@ RSpec.describe WhoisRecord do end context 'when registrant is private entity' do - let(:registrant) { FactoryGirl.build_stubbed(:registrant_private_entity) } + let(:registrant) { build_stubbed(:registrant_private_entity) } it 'is absent' do expect(country_code).to be_nil diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2fdd6a8e8..f4dcd9cb3 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -14,7 +14,7 @@ require 'support/matchers/epp/have_result' require 'support/capybara' require 'support/devise' -require 'support/factory_girl' +require 'support/factory_bot' require 'support/database_cleaner' require 'support/paper_trail' require 'support/settings' diff --git a/spec/requests/epp/contact/info_spec.rb b/spec/requests/epp/contact/info_spec.rb index d37ac8e5f..d97a0373e 100644 --- a/spec/requests/epp/contact/info_spec.rb +++ b/spec/requests/epp/contact/info_spec.rb @@ -20,7 +20,7 @@ RSpec.describe 'EPP contact:update' do before do sign_in_to_epp_area - FactoryGirl.create(:contact, code: 'TEST') + create(:contact, code: 'TEST') end context 'when address processing is enabled' do diff --git a/spec/requests/epp/contact/update_spec.rb b/spec/requests/epp/contact/update_spec.rb index cd596dd85..a8be4c85d 100644 --- a/spec/requests/epp/contact/update_spec.rb +++ b/spec/requests/epp/contact/update_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'EPP contact:update' do before do sign_in_to_epp_area - FactoryGirl.create(:contact, code: 'TEST') + create(:contact, code: 'TEST') end context 'when address processing is enabled' do diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 000000000..c7890e49c --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include FactoryBot::Syntax::Methods +end diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb deleted file mode 100644 index eec437fb3..000000000 --- a/spec/support/factory_girl.rb +++ /dev/null @@ -1,3 +0,0 @@ -RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods -end diff --git a/spec/support/features/session_helpers.rb b/spec/support/features/session_helpers.rb index a3ea7c2ae..e274d0e48 100644 --- a/spec/support/features/session_helpers.rb +++ b/spec/support/features/session_helpers.rb @@ -1,6 +1,6 @@ module Features module SessionHelpers - def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) + def sign_in_to_admin_area(user: create(:admin_user)) visit admin_login_url fill_in 'admin_user[username]', with: user.username @@ -9,7 +9,7 @@ module Features click_button 'Log in' end - def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) + def sign_in_to_registrar_area(user: create(:api_user)) visit registrar_login_url fill_in 'depp_user_tag', with: user.username diff --git a/spec/support/requests/session_helpers.rb b/spec/support/requests/session_helpers.rb index c58741946..0345959e2 100644 --- a/spec/support/requests/session_helpers.rb +++ b/spec/support/requests/session_helpers.rb @@ -1,6 +1,6 @@ module Requests module SessionHelpers - def sign_in_to_epp_area(user: FactoryGirl.create(:api_user_epp)) + def sign_in_to_epp_area(user: create(:api_user_epp)) login_xml = " @@ -29,11 +29,11 @@ module Requests post '/epp/session/login', frame: login_xml end - def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) + def sign_in_to_admin_area(user: create(:admin_user)) post admin_sessions_path, admin_user: { username: user.username, password: user.password } end - def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) + def sign_in_to_registrar_area(user: create(:api_user)) post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } } end end diff --git a/spec/support/settings.rb b/spec/support/settings.rb index bf7fbc5d5..e39fea035 100644 --- a/spec/support/settings.rb +++ b/spec/support/settings.rb @@ -1,7 +1,7 @@ RSpec.configure do |config| config.before :example do |example| if example.metadata[:db] && (example.metadata[:settings] != false) - Fabricate(:zone, origin: 'com') + create(:zone, origin: 'com') Setting.ds_algorithm = 2 Setting.ds_data_allowed = true From 3abc3f89b3cb380376157d49b0fc7cb906e02ed1 Mon Sep 17 00:00:00 2001 From: Georg Date: Tue, 21 Nov 2017 14:51:16 +0200 Subject: [PATCH 16/16] remove unneeded fields from registrant portal (#649) #648 --- app/views/registrant/registrars/show.haml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/views/registrant/registrars/show.haml b/app/views/registrant/registrars/show.haml index ed5c72b29..e0da73ee3 100644 --- a/app/views/registrant/registrars/show.haml +++ b/app/views/registrant/registrars/show.haml @@ -22,9 +22,6 @@ %dt= t(:vat_no) %dd= @registrar.vat_no - %dt= t(:reference_no) - %dd= @registrar.reference_no - %dt= t(:id) %dd= @registrar.code @@ -45,9 +42,3 @@ %dt= t(:contact_email) %dd= @registrar.email - - %dt= t(:billing_address) - %dd= @registrar.billing_address - - %dt= t(:billing_email) - %dd= @registrar.billing_email