From 0ad0437decc64853c8b5fe0e5b5ffe0050b9d5a5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 10:37:21 +0200 Subject: [PATCH 001/167] Convert HAML to ERB --- app/views/admin/domains/index.haml | 81 --------------- app/views/admin/domains/index.html.erb | 130 +++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 81 deletions(-) delete mode 100644 app/views/admin/domains/index.haml create mode 100644 app/views/admin/domains/index.html.erb diff --git a/app/views/admin/domains/index.haml b/app/views/admin/domains/index.haml deleted file mode 100644 index fdc6f64b2..000000000 --- a/app/views/admin/domains/index.haml +++ /dev/null @@ -1,81 +0,0 @@ -= render 'shared/title', name: t(:domains) - -.row - .col-md-12 - = search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| - .row - .col-md-3 - .form-group - = f.label :name - = f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) - .col-md-3 - .form-group - = f.label t(:registrant_ident) - = f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) - .col-md-3 - .form-group - = f.label t(:contact_ident) - = f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) - .col-md-3 - .form-group - = f.label t(:nameserver_hostname) - = f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) - .row - .col-md-6 - .form-group - = f.label t(:registrar_name) - = f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) - .col-md-3 - .form-group - = f.label t(:valid_to_from) - = f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) - .col-md-3 - .form-group - = f.label t(:valid_to_until) - = f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) - .row - .col-md-6 - .form-group - = label_tag t(:status) - = select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } - .col-md-3 - .form-group - = label_tag t(:results_per_page) - = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) - .col-md-3{style: 'padding-top: 25px;'} - %button.btn.btn-primary -   - %span.glyphicon.glyphicon-search -   - = link_to(t('.reset_btn'), admin_domains_path, class: 'btn btn-default') -%hr -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-2'} - = sort_link(@q, 'name') - %th{class: 'col-xs-2'} - = sort_link(@q, 'registrant_name', t('.registrant')) - %th{class: 'col-xs-2'} - = sort_link(@q, 'valid_to', t(:valid_to)) - %th{class: 'col-xs-2'} - = sort_link(@q, 'registrar_name', t(:registrar_name)) - %tbody - - @domains.each do |x| - %tr - %td= link_to(x, admin_domain_path(x)) - %td - - if x.registrant - = link_to(x.registrant, [:admin, x.registrant]) - - %td= l(x.valid_to, format: :short) - %td= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar -.row - .col-md-6 - = paginate @domains - .col-md-6.text-right - .pagination - = t(:result_count, count: @domains.total_count) diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb new file mode 100644 index 000000000..ed117c2c3 --- /dev/null +++ b/app/views/admin/domains/index.html.erb @@ -0,0 +1,130 @@ +<%= render 'shared/title', name: t(:domains) %> +
+
+ <%= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %> +
+
+
+ <%= f.label :name %> + <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> +
+
+
+
+ <%= f.label t(:registrant_ident) %> + <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> +
+
+
+
+ <%= f.label t(:contact_ident) %> + <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %> +
+
+
+
+ <%= f.label t(:nameserver_hostname) %> + <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> +
+
+
+
+
+
+ <%= f.label t(:registrar_name) %> + <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) %> +
+
+
+
+ <%= f.label t(:valid_to_from) %> + <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> +
+
+
+
+ <%= f.label t(:valid_to_until) %> + <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> +
+
+
+
+
+
+ <%= label_tag t(:status) %> + <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> +
+
+
+
+ <%= label_tag t(:results_per_page) %> + <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> +
+
+
+ + <%= link_to(t('.reset_btn'), admin_domains_path, class: 'btn btn-default') %> +
+
+ <% end %> +
+
+
+
+
+
+ + + + + + + + + + + <% @domains.each do |x| %> + + + + + + + <% end %> + +
+ <%= sort_link(@q, 'name') %> + + <%= sort_link(@q, 'registrant_name', t('.registrant')) %> + + <%= sort_link(@q, 'valid_to', t(:valid_to)) %> + + <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> +
+ <%= link_to(x, admin_domain_path(x)) %> + + <% if x.registrant %> + <%= link_to(x.registrant, [:admin, x.registrant]) %> + <% end %> + + <%= l(x.valid_to, format: :short) %> + + <%= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar %> +
+
+
+
+
+
+ <%= paginate @domains %> +
+
+ +
+
From 5f26c868ed02e4edbf6249b8b758eb471e00041a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 10:40:53 +0200 Subject: [PATCH 002/167] Remove unused CSS --- app/views/admin/domains/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index ed117c2c3..2fb2293c5 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -1,7 +1,7 @@ <%= render 'shared/title', name: t(:domains) %>
- <%= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| %> + <%= search_form_for [:admin, @q], html: { autocomplete: 'off' } do |f| %>
From fe6302609aa1e4bf934a69a99851e7cc0fc1888e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 10:43:21 +0200 Subject: [PATCH 003/167] Use standard header --- app/views/admin/domains/index.html.erb | 5 ++++- config/locales/admin/domains.en.yml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index 2fb2293c5..d90d2af1f 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -1,4 +1,7 @@ -<%= render 'shared/title', name: t(:domains) %> + +
<%= search_form_for [:admin, @q], html: { autocomplete: 'off' } do |f| %> diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index 26b85c9bb..58d2bdc55 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -2,6 +2,7 @@ en: admin: domains: index: + header: Domains reset_btn: Reset registrant: Registrant From ae61f1acdda6b3fc234c23946b8c22d210416018 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 10:48:47 +0200 Subject: [PATCH 004/167] Remove inline CSS --- app/views/admin/domains/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index d90d2af1f..4480b9cd9 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -4,7 +4,7 @@
- <%= search_form_for [:admin, @q], html: { autocomplete: 'off' } do |f| %> + <%= search_form_for [:admin, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
@@ -64,7 +64,7 @@ <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
-
+
+ <%= link_to(t('.reset_btn'), admin_domains_path, class: 'btn btn-default') %> +
+
+<% end %> diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index 4480b9cd9..39199872e 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -4,76 +4,7 @@
- <%= search_form_for [:admin, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %> -
-
-
- <%= f.label :name %> - <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> -
-
-
-
- <%= f.label t(:registrant_ident) %> - <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> -
-
-
-
- <%= f.label t(:contact_ident) %> - <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %> -
-
-
-
- <%= f.label t(:nameserver_hostname) %> - <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> -
-
-
-
-
-
- <%= f.label t(:registrar_name) %> - <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) %> -
-
-
-
- <%= f.label t(:valid_to_from) %> - <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> -
-
-
-
- <%= f.label t(:valid_to_until) %> - <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> -
-
-
-
-
-
- <%= label_tag t(:status) %> - <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> -
-
-
-
- <%= label_tag t(:results_per_page) %> - <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> -
-
-
- - <%= link_to(t('.reset_btn'), admin_domains_path, class: 'btn btn-default') %> -
-
- <% end %> + <%= render 'search_form' %>

diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index 58d2bdc55..be26a5542 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -3,9 +3,11 @@ en: domains: index: header: Domains - reset_btn: Reset registrant: Registrant + search_form: + reset_btn: Reset + edit: add_new_status_btn: Add new status back_btn: Back to domain From fa30e6f23c547abf5020623d1dbbc72dd93ebb26 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:08:07 +0200 Subject: [PATCH 006/167] Extract partial --- app/views/admin/domains/_domain.html.erb | 16 ++++++++++++++++ app/views/admin/domains/index.html.erb | 19 +------------------ 2 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 app/views/admin/domains/_domain.html.erb diff --git a/app/views/admin/domains/_domain.html.erb b/app/views/admin/domains/_domain.html.erb new file mode 100644 index 000000000..f0358784e --- /dev/null +++ b/app/views/admin/domains/_domain.html.erb @@ -0,0 +1,16 @@ + + + <%= link_to(domain, admin_domain_path(domain)) %> + + + <% if domain.registrant %> + <%= link_to(domain.registrant, [:admin, domain.registrant]) %> + <% end %> + + + <%= l(domain.valid_to, format: :short) %> + + + <%= link_to(domain.registrar, admin_registrar_path(domain.registrar)) if domain.registrar %> + + diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index 39199872e..17b47b4d0 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -29,24 +29,7 @@ - <% @domains.each do |x| %> - - - <%= link_to(x, admin_domain_path(x)) %> - - - <% if x.registrant %> - <%= link_to(x.registrant, [:admin, x.registrant]) %> - <% end %> - - - <%= l(x.valid_to, format: :short) %> - - - <%= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar %> - - - <% end %> + <%= render @domains %>
From b7380f52f31d4b4b54f3ab5ce2c832ff971cef68 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:10:35 +0200 Subject: [PATCH 007/167] Remove unneeded if statements Domain registrar and registrant are always present --- app/views/admin/domains/_domain.html.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/admin/domains/_domain.html.erb b/app/views/admin/domains/_domain.html.erb index f0358784e..6c9b714b9 100644 --- a/app/views/admin/domains/_domain.html.erb +++ b/app/views/admin/domains/_domain.html.erb @@ -3,14 +3,12 @@ <%= link_to(domain, admin_domain_path(domain)) %> - <% if domain.registrant %> - <%= link_to(domain.registrant, [:admin, domain.registrant]) %> - <% end %> + <%= link_to(domain.registrant, [:admin, domain.registrant]) %> <%= l(domain.valid_to, format: :short) %> - <%= link_to(domain.registrar, admin_registrar_path(domain.registrar)) if domain.registrar %> + <%= link_to(domain.registrar, admin_registrar_path(domain.registrar)) %> From 06ca8fdb14a7f8e3bf8fadd00956e75623a92777 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:11:21 +0200 Subject: [PATCH 008/167] Use default time format --- app/views/admin/domains/_domain.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/domains/_domain.html.erb b/app/views/admin/domains/_domain.html.erb index 6c9b714b9..8e1bbaf03 100644 --- a/app/views/admin/domains/_domain.html.erb +++ b/app/views/admin/domains/_domain.html.erb @@ -6,7 +6,7 @@ <%= link_to(domain.registrant, [:admin, domain.registrant]) %> - <%= l(domain.valid_to, format: :short) %> + <%= l domain.expire_time %> <%= link_to(domain.registrar, admin_registrar_path(domain.registrar)) %> From 9cd3c3be593b1a92faad69c349d45050e4f79176 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:20:41 +0200 Subject: [PATCH 009/167] Improve readability --- app/views/admin/domains/_domain.html.erb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/views/admin/domains/_domain.html.erb b/app/views/admin/domains/_domain.html.erb index 8e1bbaf03..6431833e6 100644 --- a/app/views/admin/domains/_domain.html.erb +++ b/app/views/admin/domains/_domain.html.erb @@ -1,14 +1,6 @@ - - <%= link_to(domain, admin_domain_path(domain)) %> - - - <%= link_to(domain.registrant, [:admin, domain.registrant]) %> - - - <%= l domain.expire_time %> - - - <%= link_to(domain.registrar, admin_registrar_path(domain.registrar)) %> - + <%= link_to domain, admin_domain_path(domain) %> + <%= link_to domain.registrant, admin_registrant_path(domain.registrant) %> + <%= l domain.expire_time %> + <%= link_to domain.registrar, admin_registrar_path(domain.registrar) %> From 7d52fccc042cf5bb2b50a8dc7d41fdff625f21b8 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:24:23 +0200 Subject: [PATCH 010/167] Improve readability --- app/views/admin/domains/index.html.erb | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/app/views/admin/domains/index.html.erb b/app/views/admin/domains/index.html.erb index 17b47b4d0..89e1c41be 100644 --- a/app/views/admin/domains/index.html.erb +++ b/app/views/admin/domains/index.html.erb @@ -7,27 +7,20 @@ <%= render 'search_form' %>
-
+
- - - - - - + + + + + + + <%= render @domains %> @@ -35,10 +28,12 @@ +
<%= paginate @domains %>
+
- + - + From 2ce2f3b491a3ea18ce4d55b3a6b6fa7bb529db08 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 15 Jan 2018 11:43:35 +0200 Subject: [PATCH 012/167] Fix invalid HTML --- app/views/admin/domains/_search_form.html.erb | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/admin/domains/_search_form.html.erb b/app/views/admin/domains/_search_form.html.erb index e1a91af57..bc317ea0b 100644 --- a/app/views/admin/domains/_search_form.html.erb +++ b/app/views/admin/domains/_search_form.html.erb @@ -2,25 +2,25 @@
- <%= f.label :name %> + <%= f.label :name, for: nil %> <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
- <%= f.label t(:registrant_ident) %> + <%= f.label :registrant_ident, for: nil %> <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
- <%= f.label t(:contact_ident) %> + <%= f.label :contact_ident, for: nil %> <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
- <%= f.label t(:nameserver_hostname) %> + <%= f.label :nameserver_hostname, for: nil %> <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %>
@@ -28,19 +28,19 @@
- <%= f.label t(:registrar_name) %> - <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) %> + <%= f.label :registrar_name, for: nil %> + <%= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize' %>
- <%= f.label t(:valid_to_from) %> + <%= f.label :valid_to_from, for: nil %> <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
- <%= f.label t(:valid_to_until) %> + <%= f.label :valid_to_until, for: nil %> <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
@@ -48,13 +48,13 @@
- <%= label_tag t(:status) %> - <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> + <%= label_tag :status, nil, for: nil %> + <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, class: 'form-control js-combobox' } %>
- <%= label_tag t(:results_per_page) %> + <%= label_tag :results_per_page, nil, for: nil %> <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
@@ -64,7 +64,7 @@   - <%= link_to(t('.reset_btn'), admin_domains_path, class: 'btn btn-default') %> + <%= link_to t('.reset_btn'), admin_domains_path, class: 'btn btn-default' %>
<% end %> From 1c8d3badce04b8a9bdb8df64f256d4bdc631c0da Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:21:20 +0200 Subject: [PATCH 013/167] Remove commented code --- app/views/registrar/domains/index.haml | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 3bcda214f..32291e67d 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -1,9 +1,6 @@ - content_for :actions do = link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary') = link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default') - -# turned off requested by client - -# = link_to(t(:keyrelay), registrar_keyrelay_path, class: 'btn btn-default') - -# = link_to(t(:nameservers), registrar_nameservers_path, class: 'btn btn-default') = render 'shared/title', name: t(:domains) .row From ac349a8e12f926e539a3a3dd6e383cee98dc2f63 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:26:59 +0200 Subject: [PATCH 014/167] Remove inline JS --- app/views/registrar/domains/index.haml | 8 +------- config/locales/registrar/domains.en.yml | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 32291e67d..56d188919 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -47,8 +47,7 @@   %span.glyphicon.glyphicon-search   - %button.btn.btn-default.js-reset-form - = t(:clear_fields) + = link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' .row .col-md-2 = button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', @@ -89,8 +88,3 @@ .col-md-6.text-right .pagination = t(:result_count, count: @domains.total_count) - -:coffee - $(".js-reset-form").on "click", (e) -> - e.preventDefault(); - window.location = "#{registrar_domains_path}" diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 61d5001ad..7cd8b3555 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -3,6 +3,7 @@ en: domains: index: registrant: Registrant + reset_btn: Reset download_btn: Download csv: domain_name: Domain From 7d1f59f03fef51dd95adab0d1e1f491a083f6e1c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:27:55 +0200 Subject: [PATCH 015/167] Remove unused CSS --- app/views/registrar/domains/index.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 56d188919..2036c88fe 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -5,7 +5,7 @@ .row .col-md-12 - = search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| + = search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', autocomplete: 'off' } do |f| .row .col-md-3 .form-group From 81814b464005d80b33e8bba9dc461d9bb7358074 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:30:21 +0200 Subject: [PATCH 016/167] Include forms css in registrar area --- app/assets/stylesheets/registrar-manifest.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/registrar-manifest.sass b/app/assets/stylesheets/registrar-manifest.sass index 8de8ff95a..731b6c630 100644 --- a/app/assets/stylesheets/registrar-manifest.sass +++ b/app/assets/stylesheets/registrar-manifest.sass @@ -5,6 +5,7 @@ //= require 'select2-bootstrap' @import shared/fonts @import shared/general +@import forms @import nprogress @import nprogress-bootstrap @import typeaheadjs From b2b7405ec0c634ed0bc47310be8d98b42e566055 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:30:41 +0200 Subject: [PATCH 017/167] Remove inline CSS --- app/views/registrar/domains/index.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index 2036c88fe..c5c1ab26b 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -5,7 +5,7 @@ .row .col-md-12 - = search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', autocomplete: 'off' } do |f| + = search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| .row .col-md-3 .form-group @@ -42,7 +42,7 @@ .form-group = label_tag t(:results_per_page) = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) - .col-md-3{style: 'padding-top: 25px;'} + .col-md-3.actions %button.btn.btn-primary.search   %span.glyphicon.glyphicon-search From b71b0238e603acb4d82d733decff74ca7e46c272 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:35:26 +0200 Subject: [PATCH 018/167] Improve readability --- app/views/registrar/domains/index.haml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index c5c1ab26b..c34f5d19f 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -68,19 +68,19 @@ = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'}= t('actions') %tbody - - @domains.each do |x| + - @domains.each do |domain| %tr - %td= link_to(truncate(x.name), info_registrar_domains_path(domain_name: x.name)) + %td= link_to(truncate(domain.name), info_registrar_domains_path(domain_name: domain.name)) %td - - if x.registrant - = link_to(x.registrant, registrar_contact_path(id: x.registrant.code)) - %td= l(x.valid_to, format: :date_long) + - if domain.registrant + = link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) + %td= l(domain.valid_to, format: :date_long) %td - = link_to(t(:edit), edit_registrar_domains_path(domain_name: x.name), + = link_to(t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs') - = link_to(t(:renew), renew_registrar_domains_path(domain_name: x.name), + = link_to(t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') - = link_to(t(:delete), delete_registrar_domains_path(domain_name: x.name), + = link_to(t(:delete), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') .row .col-md-6 From 58efa020a5ec2a1c02d6a22563e30a85d824ceac Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:36:40 +0200 Subject: [PATCH 019/167] Remove unneeded if statement Domain registrant is always present --- app/views/registrar/domains/index.haml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml index c34f5d19f..a63808848 100644 --- a/app/views/registrar/domains/index.haml +++ b/app/views/registrar/domains/index.haml @@ -71,9 +71,7 @@ - @domains.each do |domain| %tr %td= link_to(truncate(domain.name), info_registrar_domains_path(domain_name: domain.name)) - %td - - if domain.registrant - = link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) + %td= link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) %td= l(domain.valid_to, format: :date_long) %td = link_to(t(:edit), edit_registrar_domains_path(domain_name: domain.name), From c571251e7669f68503efe16c0b1e3520a18dbaf0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:40:21 +0200 Subject: [PATCH 020/167] Convert HAML to ERB --- app/views/registrar/domains/index.haml | 88 -------------- app/views/registrar/domains/index.html.erb | 134 +++++++++++++++++++++ 2 files changed, 134 insertions(+), 88 deletions(-) delete mode 100644 app/views/registrar/domains/index.haml create mode 100644 app/views/registrar/domains/index.html.erb diff --git a/app/views/registrar/domains/index.haml b/app/views/registrar/domains/index.haml deleted file mode 100644 index a63808848..000000000 --- a/app/views/registrar/domains/index.haml +++ /dev/null @@ -1,88 +0,0 @@ -- content_for :actions do - = link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary') - = link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default') -= render 'shared/title', name: t(:domains) - -.row - .col-md-12 - = search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| - .row - .col-md-3 - .form-group - = f.label :name - = f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) - .col-md-3 - .form-group - = f.label t(:registrant_ident) - = f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) - .col-md-3 - .form-group - = f.label t(:contact_ident) - = f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) - .col-md-3 - .form-group - = f.label t(:nameserver_hostname) - = f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) - .row - .col-md-6 - .form-group - = label_tag t(:status) - = select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } - .col-md-3 - .form-group - = f.label t(:valid_to_from) - = f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) - .col-md-3 - .form-group - = f.label t(:valid_to_until) - = f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) - .row - .col-md-6 - .col-md-3 - .form-group - = label_tag t(:results_per_page) - = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) - .col-md-3.actions - %button.btn.btn-primary.search -   - %span.glyphicon.glyphicon-search -   - = link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' - .row - .col-md-2 - = button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', - formaction: registrar_domains_path(format: 'csv') -%hr - -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-2'} - = sort_link(@q, 'name') - %th{class: 'col-xs-2'} - = sort_link(@q, 'registrant_name', t('.registrant')) - %th{class: 'col-xs-2'} - = sort_link(@q, 'valid_to', t(:valid_to)) - %th{class: 'col-xs-2'}= t('actions') - %tbody - - @domains.each do |domain| - %tr - %td= link_to(truncate(domain.name), info_registrar_domains_path(domain_name: domain.name)) - %td= link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) - %td= l(domain.valid_to, format: :date_long) - %td - = link_to(t(:edit), edit_registrar_domains_path(domain_name: domain.name), - class: 'btn btn-primary btn-xs') - = link_to(t(:renew), renew_registrar_domains_path(domain_name: domain.name), - class: 'btn btn-default btn-xs') - = link_to(t(:delete), delete_registrar_domains_path(domain_name: domain.name), - class: 'btn btn-default btn-xs') -.row - .col-md-6 - = paginate @domains - .col-md-6.text-right - .pagination - = t(:result_count, count: @domains.total_count) diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb new file mode 100644 index 000000000..83c0d5259 --- /dev/null +++ b/app/views/registrar/domains/index.html.erb @@ -0,0 +1,134 @@ +<% content_for :actions do %> + <%= link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary') %> + <%= link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default') %> +<% end %> +<%= render 'shared/title', name: t(:domains) %> +
+
+ <%= search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %> +
+
+
+ <%= f.label :name %> + <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> +
+
+
+
+ <%= f.label t(:registrant_ident) %> + <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> +
+
+
+
+ <%= f.label t(:contact_ident) %> + <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %> +
+
+
+
+ <%= f.label t(:nameserver_hostname) %> + <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> +
+
+
+
+
+
+ <%= label_tag t(:status) %> + <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> +
+
+
+
+ <%= f.label t(:valid_to_from) %> + <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> +
+
+
+
+ <%= f.label t(:valid_to_until) %> + <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> +
+
+
+
+
+
+
+ <%= label_tag t(:results_per_page) %> + <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> +
+
+
+ + <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %> +
+
+
+
+ <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', formaction: registrar_domains_path(format: 'csv') %> +
+
+ <% end %> +
+
+
+
+
+
+
- <%= sort_link(@q, 'name') %> - - <%= sort_link(@q, 'registrant_name', t('.registrant')) %> - - <%= sort_link(@q, 'valid_to', t(:valid_to)) %> - - <%= sort_link(@q, 'registrar_name', t(:registrar_name)) %> -
<%= sort_link(@q, 'name') %><%= sort_link(@q, 'registrant_name', t('.registrant')) %><%= sort_link(@q, 'valid_to', t(:valid_to)) %><%= sort_link(@q, 'registrar_name', t(:registrar_name)) %>
<%= sort_link(@q, 'name') %><%= sort_link(@q, 'registrant_name', t('.registrant')) %><%= sort_link(@q, 'registrant_name', Registrant.model_name.human) %> <%= sort_link(@q, 'valid_to', t(:valid_to)) %><%= sort_link(@q, 'registrar_name', t(:registrar_name)) %><%= sort_link(@q, 'registrar_name', Registrar.model_name.human) %>
+ + + + + + + + + + <% @domains.each do |domain| %> + + + + + + + <% end %> + +
+ <%= sort_link(@q, 'name') %> + + <%= sort_link(@q, 'registrant_name', t('.registrant')) %> + + <%= sort_link(@q, 'valid_to', t(:valid_to)) %> + + <%= t('actions') %> +
+ <%= link_to(truncate(domain.name), info_registrar_domains_path(domain_name: domain.name)) %> + + <%= link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) %> + + <%= l(domain.valid_to, format: :date_long) %> + + <%= link_to(t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs') %> + <%= link_to(t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') %> + <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') %> +
+
+
+
+
+
+ <%= paginate @domains %> +
+
+ +
+
From b692e7623ae5b4965c6a9e0b79637d642c945d06 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:42:26 +0200 Subject: [PATCH 021/167] Extract partial --- app/views/registrar/domains/_domain.html.erb | 10 ++++++++++ app/views/registrar/domains/index.html.erb | 19 +------------------ 2 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 app/views/registrar/domains/_domain.html.erb diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb new file mode 100644 index 000000000..0cb020acb --- /dev/null +++ b/app/views/registrar/domains/_domain.html.erb @@ -0,0 +1,10 @@ + + <%= link_to truncate(domain.name), info_registrar_domains_path(domain_name: domain.name) %> + <%= link_to domain.registrant, registrar_contact_path(id: domain.registrant.code) %> + <%= l(domain.valid_to, format: :date_long) %> + + <%= link_to t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs' %> + <%= link_to t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + <%= link_to t(:delete), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + + diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index 83c0d5259..af220799b 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -99,24 +99,7 @@ - <% @domains.each do |domain| %> - - - <%= link_to(truncate(domain.name), info_registrar_domains_path(domain_name: domain.name)) %> - - - <%= link_to(domain.registrant, registrar_contact_path(id: domain.registrant.code)) %> - - - <%= l(domain.valid_to, format: :date_long) %> - - - <%= link_to(t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs') %> - <%= link_to(t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') %> - <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs') %> - - - <% end %> + <%= render @domains %>
From a24350626e061fd223dcd7717ac671535acb4a7b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:44:46 +0200 Subject: [PATCH 022/167] Extract partial --- .../registrar/domains/_search_form.html.erb | 79 +++++++++++++++++++ app/views/registrar/domains/index.html.erb | 71 +---------------- config/locales/registrar/domains.en.yml | 6 +- 3 files changed, 84 insertions(+), 72 deletions(-) create mode 100644 app/views/registrar/domains/_search_form.html.erb diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb new file mode 100644 index 000000000..0e31bab91 --- /dev/null +++ b/app/views/registrar/domains/_search_form.html.erb @@ -0,0 +1,79 @@ +<%= search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %> +
+
+
+ <%= f.label :name %> + <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> +
+
+ +
+
+ <%= f.label t(:registrant_ident) %> + <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> +
+
+ +
+
+ <%= f.label t(:contact_ident) %> + <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %> +
+
+ +
+
+ <%= f.label t(:nameserver_hostname) %> + <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> +
+
+
+ +
+
+
+ <%= label_tag t(:status) %> + <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> +
+
+ +
+
+ <%= f.label t(:valid_to_from) %> + <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> +
+
+ +
+
+ <%= f.label t(:valid_to_until) %> + <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> +
+
+
+ +
+
+
+
+ <%= label_tag t(:results_per_page) %> + <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> +
+
+ +
+ + <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %> +
+
+ +
+
+ <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', formaction: registrar_domains_path(format: 'csv') %> +
+
+<% end %> diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index af220799b..04ee4fb13 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -5,76 +5,7 @@ <%= render 'shared/title', name: t(:domains) %>
- <%= search_form_for [:registrar, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %> -
-
-
- <%= f.label :name %> - <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> -
-
-
-
- <%= f.label t(:registrant_ident) %> - <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %> -
-
-
-
- <%= f.label t(:contact_ident) %> - <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %> -
-
-
-
- <%= f.label t(:nameserver_hostname) %> - <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> -
-
-
-
-
-
- <%= label_tag t(:status) %> - <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> -
-
-
-
- <%= f.label t(:valid_to_from) %> - <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> -
-
-
-
- <%= f.label t(:valid_to_until) %> - <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> -
-
-
-
-
-
-
- <%= label_tag t(:results_per_page) %> - <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> -
-
-
- - <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %> -
-
-
-
- <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', formaction: registrar_domains_path(format: 'csv') %> -
-
- <% end %> + <%= render 'search_form' %>

diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 7cd8b3555..cc26f9bb8 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -3,14 +3,16 @@ en: domains: index: registrant: Registrant - reset_btn: Reset - download_btn: Download csv: domain_name: Domain registrant_name: Registrant name registrant_code: Registrant code expire_time: Date of expiry + search_form: + download_btn: Download + reset_btn: Reset + form: save_btn: Save dnskeys: From 76208a4eeacf0535cf571405e77449dd1610f9d9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:51:09 +0200 Subject: [PATCH 023/167] Use standard header --- app/views/registrar/domains/index.html.erb | 18 +++++++++++++----- config/locales/registrar/domains.en.yml | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index 04ee4fb13..067191e60 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -1,8 +1,16 @@ -<% content_for :actions do %> - <%= link_to(t(:new), new_registrar_domain_path, class: 'btn btn-primary') %> - <%= link_to(t(:transfer), transfer_registrar_domains_path, class: 'btn btn-default') %> -<% end %> -<%= render 'shared/title', name: t(:domains) %> + +
<%= render 'search_form' %> diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index cc26f9bb8..b36369137 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -2,6 +2,7 @@ en: registrar: domains: index: + header: Domains registrant: Registrant csv: domain_name: Domain From ef0126367c3707137a709a9d45ae2d8099c6527a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 09:53:23 +0200 Subject: [PATCH 024/167] Reformat code --- app/views/registrar/domains/index.html.erb | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index 067191e60..c48a355b2 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -16,27 +16,28 @@ <%= render 'search_form' %>
-
+
- - - - - - + + + + + + + <%= render @domains %> @@ -44,13 +45,15 @@ +
<%= paginate @domains %>
+
From 80331072d687d540f788aec832845c1e3cbc3b54 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 16 Jan 2018 10:04:08 +0200 Subject: [PATCH 025/167] Remove unused code --- app/views/registrar/shared/_nav.haml | 13 ------------- config/locales/en.yml | 1 - 2 files changed, 14 deletions(-) delete mode 100644 app/views/registrar/shared/_nav.haml diff --git a/app/views/registrar/shared/_nav.haml b/app/views/registrar/shared/_nav.haml deleted file mode 100644 index d85a17de3..000000000 --- a/app/views/registrar/shared/_nav.haml +++ /dev/null @@ -1,13 +0,0 @@ -- content_for :tabs do - .container.subnav - %ul.nav.nav-tabs.navbar-right - %li{role: :presentation, class: active == :domains ? 'active' : ''} - = link_to t(:all), registrar_domains_path - %li{role: :presentation, class: active == :new ? 'active' : ''} - = link_to t(:new), new_registrar_domain_path - %li{role: :presentation, class: active == :check ? 'active' : ''} - = link_to t(:check), check_registrar_domains_path - %li{role: :presentation, class: active == :transfer ? 'active' : ''} - = link_to t(:transfer), transfer_registrar_domains_path - %li{role: :presentation, class: active == :keyrelay ? 'active' : ''} - = link_to t(:keyrelay), registrar_keyrelay_path diff --git a/config/locales/en.yml b/config/locales/en.yml index 0a4a83c98..10c7db27a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -505,7 +505,6 @@ en: log_in: 'Log in' domains: 'Domains' register: 'Register' - check: 'Check' contacts: 'Contacts' domain_info: 'Domain info' domain_details: 'Domain details' From c5892a5f9c2749491b90c34a0cda152c5282c012 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 17:53:11 +0200 Subject: [PATCH 026/167] Remove duplicated translation --- config/locales/en.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 10c7db27a..12f1f113a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -501,7 +501,6 @@ en: username: 'Username' password: 'Password' - authinfo_pw: 'AuthInfo pw' log_in: 'Log in' domains: 'Domains' register: 'Register' From f2a20cd84a44a690702fa5e8e923cb5be6ab6633 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 18:09:39 +0200 Subject: [PATCH 027/167] Use default datetime format --- app/views/registrar/domains/_domain.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb index 0cb020acb..c2d6b9e0e 100644 --- a/app/views/registrar/domains/_domain.html.erb +++ b/app/views/registrar/domains/_domain.html.erb @@ -1,7 +1,7 @@ - + - + diff --git a/config/locales/en.yml b/config/locales/en.yml index 12f1f113a..75b08aefb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -833,7 +833,6 @@ en: deleted: 'Deleted' cant_match_version: 'Impossible match version with request' user_not_authenticated: "user not authenticated" - actions: Actions number: currency: diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index b36369137..7f9bc100c 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -3,7 +3,8 @@ en: domains: index: header: Domains - registrant: Registrant + new_btn: New domain + transfer_btn: Transfer csv: domain_name: Domain registrant_name: Registrant name From a43559b9787dac7dbde5a3effc324b8c7b6d1d91 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 18:14:26 +0200 Subject: [PATCH 029/167] Improve translation --- app/views/registrar/domains/_domain.html.erb | 6 +++--- config/locales/registrar/domains.en.yml | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb index c2d6b9e0e..72313fd02 100644 --- a/app/views/registrar/domains/_domain.html.erb +++ b/app/views/registrar/domains/_domain.html.erb @@ -3,8 +3,8 @@ diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 7f9bc100c..a420994dd 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -15,6 +15,11 @@ en: download_btn: Download reset_btn: Reset + domain: + edit_btn: Edit + renew_btn: Renew + delete_btn: Delete + form: save_btn: Save dnskeys: From 3204532dbe84c14d14889bbb9eec69bbeead4ad5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 18:22:12 +0200 Subject: [PATCH 030/167] Fix invalid HTML --- .../registrar/domains/_search_form.html.erb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb index 9ff34032a..7f15fafb6 100644 --- a/app/views/registrar/domains/_search_form.html.erb +++ b/app/views/registrar/domains/_search_form.html.erb @@ -2,28 +2,28 @@
- <%= f.label :name %> + <%= f.label :name, for: nil %> <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
- <%= f.label :registrant_ident %> + <%= f.label :registrant_ident, for: nil %> <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
- <%= f.label :contact_ident %> + <%= f.label :contact_ident, for: nil %> <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
- <%= f.label :nameserver_hostname %> + <%= f.label :nameserver_hostname, for: nil %> <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %>
@@ -32,21 +32,21 @@
- <%= label_tag :status %> - <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %> + <%= label_tag :status, nil, for: nil %> + <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, class: 'form-control js-combobox' } %>
- <%= f.label :valid_to_from %> + <%= f.label :valid_to_from, for: nil %> <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
- <%= f.label :valid_to_until %> + <%= f.label :valid_to_until, for: nil %> <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
@@ -56,7 +56,7 @@
- <%= label_tag :results_per_page %> + <%= label_tag :results_per_page, nil, for: nil %> <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
From 53949316868d63cdb1c43db01067b8fa87d4ef48 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 18:31:08 +0200 Subject: [PATCH 031/167] Restore translation --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 75b08aefb..12f1f113a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -833,6 +833,7 @@ en: deleted: 'Deleted' cant_match_version: 'Impossible match version with request' user_not_authenticated: "user not authenticated" + actions: Actions number: currency: From ddef2d2d900e8ce90fdfc87ee78b44312634f3e1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 19:11:59 +0200 Subject: [PATCH 032/167] Convert HAML to ERB --- .../admin/domains/partials/_general.haml | 32 ---------------- .../admin/domains/partials/_general.html.erb | 37 +++++++++++++++++++ .../registrant/domains/partials/_general.haml | 32 ---------------- .../domains/partials/_general.html.erb | 37 +++++++++++++++++++ .../registrar/domains/partials/_general.haml | 27 -------------- .../domains/partials/_general.html.erb | 35 ++++++++++++++++++ 6 files changed, 109 insertions(+), 91 deletions(-) delete mode 100644 app/views/admin/domains/partials/_general.haml create mode 100644 app/views/admin/domains/partials/_general.html.erb delete mode 100644 app/views/registrant/domains/partials/_general.haml create mode 100644 app/views/registrant/domains/partials/_general.html.erb delete mode 100644 app/views/registrar/domains/partials/_general.haml create mode 100644 app/views/registrar/domains/partials/_general.html.erb diff --git a/app/views/admin/domains/partials/_general.haml b/app/views/admin/domains/partials/_general.haml deleted file mode 100644 index d64654a8f..000000000 --- a/app/views/admin/domains/partials/_general.haml +++ /dev/null @@ -1,32 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:name) - %dd= @domain.name - - %dt= t(:registered_at) - %dd= l(@domain.registered_at) - - %dt= t(:registrar_name) - %dd= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) - - %dt= t(:authinfo_pw) - %dd - = text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' - - %dt= t(:valid_from) - %dd= l(@domain.valid_from) - - %dt= t(:valid_to) - %dd= l(@domain.valid_to) - - %dt= t('.outzone_time') - %dd= l(@domain.outzone_at) - - %dt= t('.delete_time') - %dd= l(@domain.delete_at) - - %dt= t('.force_delete_time') - %dd= l(@domain.force_delete_at) diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb new file mode 100644 index 000000000..ff4ea6bbd --- /dev/null +++ b/app/views/admin/domains/partials/_general.html.erb @@ -0,0 +1,37 @@ +
+
+

+ <%= t(:general) %> +

+
+
+
+
<%= t(:name) %>
+
<%= @domain.name %>
+ +
<%= t(:registered_at) %>
+
<%= l(@domain.registered_at) %>
+ +
<%= t(:registrar_name) %>
+
<%= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) %>
+ +
<%= t(:authinfo_pw) %>
+
<%= text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' %>
+ +
<%= t(:valid_from) %>
+
<%= l(@domain.valid_from) %>
+ +
<%= t(:valid_to) %>
+
<%= l(@domain.valid_to) %>
+ +
<%= t('.outzone_time') %>
+
<%= l(@domain.outzone_at) %>
+ +
<%= t('.delete_time') %>
+
<%= l(@domain.delete_at) %>
+ +
<%= t('.force_delete_time') %>
+
<%= l(@domain.force_delete_at) %>
+
+
+
diff --git a/app/views/registrant/domains/partials/_general.haml b/app/views/registrant/domains/partials/_general.haml deleted file mode 100644 index 7fb355c1f..000000000 --- a/app/views/registrant/domains/partials/_general.haml +++ /dev/null @@ -1,32 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:name) - %dd= @domain.name - - %dt= t(:registered_at) - %dd= l(@domain.registered_at) - - %dt= t(:registrar_name) - %dd= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) - - %dt= t(:authinfo_pw) - %dd - = text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' - - %dt= t(:valid_from) - %dd= l(@domain.valid_from) - - %dt= t(:valid_to) - %dd= l(@domain.valid_to) - - %dt= t(:outzone_at) - %dd= l(@domain.outzone_at) - - %dt= t(:delete_at) - %dd= l(@domain.delete_at) - - %dt= t(:force_delete_at) - %dd= l(@domain.force_delete_at) diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb new file mode 100644 index 000000000..57dea3e30 --- /dev/null +++ b/app/views/registrant/domains/partials/_general.html.erb @@ -0,0 +1,37 @@ +
+
+

+ <%= t(:general) %> +

+
+
+
+
<%= t(:name) %>
+
<%= @domain.name %>
+ +
<%= t(:registered_at) %>
+
<%= l(@domain.registered_at) %>
+ +
<%= t(:registrar_name) %>
+
<%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %>
+ +
<%= t(:authinfo_pw) %>
+
<%= text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' %>
+ +
<%= t(:valid_from) %>
+
<%= l(@domain.valid_from) %>
+ +
<%= t(:valid_to) %>
+
<%= l(@domain.valid_to) %>
+ +
<%= t(:outzone_at) %>
+
<%= l(@domain.outzone_at) %>
+ +
<%= t(:delete_at) %>
+
<%= l(@domain.delete_at) %>
+ +
<%= t(:force_delete_at) %>
+
<%= l(@domain.force_delete_at) %>
+
+
+
diff --git a/app/views/registrar/domains/partials/_general.haml b/app/views/registrar/domains/partials/_general.haml deleted file mode 100644 index db06b3376..000000000 --- a/app/views/registrar/domains/partials/_general.haml +++ /dev/null @@ -1,27 +0,0 @@ -.panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:authinfo_pw) - %dd= @data.css('pw').text.present? ? @data.css('pw').text : t('hidden') - - - if @data.css('pw').text.blank? - %dt= t(:registrar_name) - %dd= @data.css('clID').text - - - registrant = Contact.find_by_code(@data.css('registrant').text) - %dt= t('.registrant') - %dd= "#{registrant.name} (#{@data.css('registrant').text})" - - %dt= t('.registered') - %dd= @data.css('crDate').text - - %dt= t(:valid_to) - %dd= @data.css('exDate').text - - %dt= t('.created') - %dd= @data.css('crDate').text - - %dt= t('.updated') - %dd= @data.css('upDate').text diff --git a/app/views/registrar/domains/partials/_general.html.erb b/app/views/registrar/domains/partials/_general.html.erb new file mode 100644 index 000000000..7d878bba9 --- /dev/null +++ b/app/views/registrar/domains/partials/_general.html.erb @@ -0,0 +1,35 @@ +
+
+

+ <%= t(:general) %> +

+
+ +
+
+
<%= t(:authinfo_pw) %>
+
<%= @data.css('pw').text.present? ? @data.css('pw').text : t('hidden') %>
+ + <% if @data.css('pw').text.blank? %> +
<%= t(:registrar_name) %>
+
<%= @data.css('clID').text %>
+ <% end %> + + <% registrant = Contact.find_by_code(@data.css('registrant').text) %> +
<%= t('.registrant') %>
+
<%= "#{registrant.name} (#{@data.css('registrant').text})" %>
+ +
<%= t('.registered') %>
+
<%= @data.css('crDate').text %>
+ +
<%= t(:valid_to) %>
+
<%= @data.css('exDate').text %>
+ +
<%= t('.created') %>
+
<%= @data.css('crDate').text %>
+ +
<%= t('.updated') %>
+
<%= @data.css('upDate').text %>
+
+
+
From 592fae71ea6b4bce48755d8da3d3264221ab8127 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 19:22:35 +0200 Subject: [PATCH 033/167] Standardize domain auth info attribute presentation --- app/views/admin/domains/partials/_general.html.erb | 7 +++++-- .../registrant/domains/partials/_general.html.erb | 7 +++++-- app/views/registrar/domains/partials/_general.html.erb | 10 ++++++++-- config/locales/en.yml | 1 - 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb index ff4ea6bbd..64dbd7336 100644 --- a/app/views/admin/domains/partials/_general.html.erb +++ b/app/views/admin/domains/partials/_general.html.erb @@ -15,8 +15,11 @@
<%= t(:registrar_name) %>
<%= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) %>
-
<%= t(:authinfo_pw) %>
-
<%= text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' %>
+
<%= Domain.human_attribute_name :auth_info %>
+
+ <%= tag :input, type: 'text', value: @domain.auth_info, readonly: true, + class: 'form-control input-sm' %> +
<%= t(:valid_from) %>
<%= l(@domain.valid_from) %>
diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb index 57dea3e30..3d3fd6ee1 100644 --- a/app/views/registrant/domains/partials/_general.html.erb +++ b/app/views/registrant/domains/partials/_general.html.erb @@ -15,8 +15,11 @@
<%= t(:registrar_name) %>
<%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %>
-
<%= t(:authinfo_pw) %>
-
<%= text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' %>
+
<%= Domain.human_attribute_name :auth_info %>
+
+ <%= tag :input, type: 'text', value: @domain.auth_info, readonly: true, + class: 'form-control input-sm' %> +
<%= t(:valid_from) %>
<%= l(@domain.valid_from) %>
diff --git a/app/views/registrar/domains/partials/_general.html.erb b/app/views/registrar/domains/partials/_general.html.erb index 7d878bba9..45cae00e6 100644 --- a/app/views/registrar/domains/partials/_general.html.erb +++ b/app/views/registrar/domains/partials/_general.html.erb @@ -7,8 +7,14 @@
-
<%= t(:authinfo_pw) %>
-
<%= @data.css('pw').text.present? ? @data.css('pw').text : t('hidden') %>
+
<%= Domain.human_attribute_name :auth_info %>
+
+ <% if @data.css('pw').text.present? %> + <%= tag(:input, type: 'text', value: @data.css('pw').text, readonly: true, + class: 'form-control input-sm') %> + <% end %> +
+ <% if @data.css('pw').text.blank? %>
<%= t(:registrar_name) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 12f1f113a..5a3564411 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -804,7 +804,6 @@ en: manage: Manage pending_epp: Pending epp id: ID - hidden: '[hidden]' created_at_from: 'Created at from' created_at_until: 'Created at until' is_registrant: 'Is registrant' From 6c0f086fcfc7f048f5ab1526f2161bdcd889b8ee Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 18 Jan 2018 09:40:31 +0200 Subject: [PATCH 034/167] Reformat code --- app/views/admin/domains/partials/_general.html.erb | 1 + app/views/registrant/domains/partials/_general.html.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb index 64dbd7336..ca33c476c 100644 --- a/app/views/admin/domains/partials/_general.html.erb +++ b/app/views/admin/domains/partials/_general.html.erb @@ -4,6 +4,7 @@ <%= t(:general) %>
+
<%= t(:name) %>
diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb index 3d3fd6ee1..486bee8be 100644 --- a/app/views/registrant/domains/partials/_general.html.erb +++ b/app/views/registrant/domains/partials/_general.html.erb @@ -4,6 +4,7 @@ <%= t(:general) %>
+
<%= t(:name) %>
From c41d329f79bb41b369c88c8dcd997660e45f3c31 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 18 Jan 2018 15:07:14 +0200 Subject: [PATCH 035/167] Add auth info to CSV domain list in registrar area #660 --- app/presenters/domain_presenter.rb | 2 +- .../registrar/domain_list_csv_presenter.rb | 8 +++++--- config/locales/registrar/domains.en.yml | 1 + spec/presenters/domain_presenter_spec.rb | 1 + .../domain_list_csv_presenter_spec.rb | 18 ++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb index e81aede33..6729fae0f 100644 --- a/app/presenters/domain_presenter.rb +++ b/app/presenters/domain_presenter.rb @@ -1,5 +1,5 @@ class DomainPresenter - delegate :name, :registrant_name, :registrant_id, :registrant_code, to: :domain + delegate :name, :auth_info, :registrant_name, :registrant_id, :registrant_code, to: :domain def initialize(domain:, view:) @domain = domain diff --git a/app/presenters/registrar/domain_list_csv_presenter.rb b/app/presenters/registrar/domain_list_csv_presenter.rb index d6f0c46bd..392109502 100644 --- a/app/presenters/registrar/domain_list_csv_presenter.rb +++ b/app/presenters/registrar/domain_list_csv_presenter.rb @@ -19,6 +19,7 @@ class Registrar::DomainListCSVPresenter def header columns = %w( domain_name + auth_info registrant_name registrant_code expire_time @@ -32,9 +33,10 @@ class Registrar::DomainListCSVPresenter def domain_to_row(domain:) row = [] row[0] = domain.name - row[1] = domain.registrant_name - row[2] = domain.registrant_code - row[3] = domain.expire_date + row[1] = domain.auth_info + row[2] = domain.registrant_name + row[3] = domain.registrant_code + row[4] = domain.expire_date row CSV::Row.new([], row) diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index a420994dd..2b34ddd9f 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -7,6 +7,7 @@ en: transfer_btn: Transfer csv: domain_name: Domain + auth_info: Auth info registrant_name: Registrant name registrant_code: Registrant code expire_time: Date of expiry diff --git a/spec/presenters/domain_presenter_spec.rb b/spec/presenters/domain_presenter_spec.rb index 717850d17..1ae58c5c0 100644 --- a/spec/presenters/domain_presenter_spec.rb +++ b/spec/presenters/domain_presenter_spec.rb @@ -151,6 +151,7 @@ RSpec.describe DomainPresenter do domain_delegatable_attributes = %i( name + auth_info registrant_name registrant_id registrant_code diff --git a/spec/presenters/registrar/domain_list_csv_presenter_spec.rb b/spec/presenters/registrar/domain_list_csv_presenter_spec.rb index df4eec1fe..8fa1f256d 100644 --- a/spec/presenters/registrar/domain_list_csv_presenter_spec.rb +++ b/spec/presenters/registrar/domain_list_csv_presenter_spec.rb @@ -10,9 +10,10 @@ RSpec.describe Registrar::DomainListCSVPresenter do it 'is present' do columns = [] columns[0] = 'Domain' - columns[1] = 'Registrant name' - columns[2] = 'Registrant code' - columns[3] = 'Date of expiry' + columns[1] = 'Auth info' + columns[2] = 'Registrant name' + columns[3] = 'Registrant code' + columns[4] = 'Date of expiry' columns expect(header).to eq(columns) @@ -27,19 +28,24 @@ RSpec.describe Registrar::DomainListCSVPresenter do expect(row[0]).to eq('test name') end + it 'has domain auth info' do + expect(domain).to receive(:auth_info).and_return('test auth info') + expect(row[1]).to eq('test auth info') + end + it 'has registrant name' do expect(domain).to receive(:registrant_name).and_return('test registrant name') - expect(row[1]).to eq('test registrant name') + expect(row[2]).to eq('test registrant name') end it 'has registrant code' do expect(domain).to receive(:registrant_code).and_return('test registrant code') - expect(row[2]).to eq('test registrant code') + expect(row[3]).to eq('test registrant code') end it 'has expire date' do expect(domain).to receive(:expire_date).and_return('expire date') - expect(row[3]).to eq('expire date') + expect(row[4]).to eq('expire date') end end end From a4ec28344a1bbca967c10f3242e7c4ec72796ed3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 09:34:31 +0200 Subject: [PATCH 036/167] Reformat code --- app/views/registrar/domains/_domain.html.erb | 9 ++++--- .../registrar/domains/_search_form.html.erb | 24 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/views/registrar/domains/_domain.html.erb b/app/views/registrar/domains/_domain.html.erb index 72313fd02..74f29dc15 100644 --- a/app/views/registrar/domains/_domain.html.erb +++ b/app/views/registrar/domains/_domain.html.erb @@ -3,8 +3,11 @@
diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb index 7f15fafb6..c399b54b9 100644 --- a/app/views/registrar/domains/_search_form.html.erb +++ b/app/views/registrar/domains/_search_form.html.erb @@ -3,7 +3,8 @@
<%= f.label :name, for: nil %> - <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %> + <%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', + placeholder: t(:name) %>
@@ -24,7 +25,8 @@
<%= f.label :nameserver_hostname, for: nil %> - <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %> + <%= f.search_field :nameservers_hostname_eq, class: 'form-control', + placeholder: t(:nameserver_hostname) %>
@@ -33,21 +35,27 @@
<%= label_tag :status, nil, for: nil %> - <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, class: 'form-control js-combobox' } %> + <%= select_tag :statuses_contains, + options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), + { multiple: true, class: 'form-control js-combobox' } %>
<%= f.label :valid_to_from, for: nil %> - <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %> + <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], + class: 'form-control js-datepicker', + placeholder: t(:valid_to_from) %>
<%= f.label :valid_to_until, for: nil %> - <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %> + <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], + class: 'form-control js-datepicker', + placeholder: t(:valid_to_until) %>
@@ -57,7 +65,8 @@
<%= label_tag :results_per_page, nil, for: nil %> - <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %> + <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', + placeholder: t(:results_per_page) %>
@@ -73,7 +82,8 @@
- <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', formaction: registrar_domains_path(format: 'csv') %> + <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', + formaction: registrar_domains_path(format: 'csv') %>
<% end %> From 8ffda2f61019213185034a6237f01805f7470365 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 09:48:40 +0200 Subject: [PATCH 037/167] Improve UI --- config/locales/registrar/domains.en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 2b34ddd9f..059c5ebc5 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -13,7 +13,7 @@ en: expire_time: Date of expiry search_form: - download_btn: Download + download_btn: Download as CSV reset_btn: Reset domain: From 0b3b61bf2483b992261d38449b51e2df449d2d8f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 09:49:27 +0200 Subject: [PATCH 038/167] Improve UI --- app/assets/stylesheets/forms.scss | 4 --- .../registrar/domains/_search_form.html.erb | 31 +++++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/forms.scss b/app/assets/stylesheets/forms.scss index 7962ffcae..c59a5e951 100644 --- a/app/assets/stylesheets/forms.scss +++ b/app/assets/stylesheets/forms.scss @@ -5,7 +5,3 @@ input[type=number]::-webkit-inner-spin-button { input[type=number] { -moz-appearance: textfield; } - -.search-form .actions { - padding-top: 25px; -} diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb index c399b54b9..b494e0d8d 100644 --- a/app/views/registrar/domains/_search_form.html.erb +++ b/app/views/registrar/domains/_search_form.html.erb @@ -61,29 +61,28 @@
-
-
-
- <%= label_tag :results_per_page, nil, for: nil %> - <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', - placeholder: t(:results_per_page) %> -
-
- -
- - <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %> +
+ <%= label_tag :results_per_page, nil, for: nil %>
+
+ <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', + placeholder: t(:results_per_page) %> +
+
+ +
+ <%= button_tag t('.download_btn'), class: 'btn btn-primary export-domains-csv-btn', formaction: registrar_domains_path(format: 'csv') %> + <%= link_to t('.reset_btn'), registrar_domains_path, class: 'btn btn-default' %>
<% end %> From 472d37f30f5934ddd4f10dff65f82a0c216bb67b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 10:10:57 +0200 Subject: [PATCH 039/167] Convert HAML to ERB --- .../registrar/domains/transfer_index.haml | 27 ------------ .../registrar/domains/transfer_index.html.erb | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 27 deletions(-) delete mode 100644 app/views/registrar/domains/transfer_index.haml create mode 100644 app/views/registrar/domains/transfer_index.html.erb diff --git a/app/views/registrar/domains/transfer_index.haml b/app/views/registrar/domains/transfer_index.haml deleted file mode 100644 index 502a3aab8..000000000 --- a/app/views/registrar/domains/transfer_index.haml +++ /dev/null @@ -1,27 +0,0 @@ -= render 'shared/title', name: t(:transfer_domain) - -.row - .col-md-8 - = form_tag transfer_registrar_domains_path, class: 'form-horizontal', method: :post, multipart: true, autocomplete: 'off' do - .form-group - .col-md-3.control-label - = label_tag :domain_name, t(:name), class: 'required' - .col-md-7 - = text_field_tag :domain_name, params[:domain_name], class: 'form-control', - placeholder: t(:domain_name), autocomplete: 'off', autofocus: true, required: true - .form-group - .col-md-3.control-label - = label_tag :password, t(:password), class: 'required' - .col-md-7 - = text_field_tag :password, params[:password], - class: 'form-control', autocomplete: 'off', required: true - .form-group - .col-md-3.control-label - = label_tag 'legal_document', t(:legal_document) - .col-md-7 - = file_field_tag 'legal_document' - .form-group - .col-md-10.text-right - %button.btn.btn-warning{ name: 'request' }= t(:transfer) - /%button.btn.btn-warning{ name: 'approve' }= t(:approve) - /%button.btn.btn-warning{ name: 'reject' }= t(:reject) diff --git a/app/views/registrar/domains/transfer_index.html.erb b/app/views/registrar/domains/transfer_index.html.erb new file mode 100644 index 000000000..e5a82f873 --- /dev/null +++ b/app/views/registrar/domains/transfer_index.html.erb @@ -0,0 +1,42 @@ +<%= render 'shared/title', name: t(:transfer_domain) %> + +
+
+ <%= form_tag transfer_registrar_domains_path, class: 'form-horizontal', method: :post, multipart: true, autocomplete: 'off' do %> +
+
+ <%= label_tag :domain_name, t(:name), class: 'required' %> +
+
+ <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', autofocus: true, required: true %> +
+
+ +
+
+ <%= label_tag :password, t(:password), class: 'required' %> +
+
+ <%= text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off', required: true %> +
+
+ +
+
+ <%= label_tag 'legal_document', t(:legal_document) %> +
+
+ <%= file_field_tag 'legal_document' %> +
+
+ +
+
+ +
+
+ <% end %> +
+
From b06e9152f660da813fb7a0b5bca034d7961ec4b2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 10:13:11 +0200 Subject: [PATCH 040/167] Use standard header --- app/views/registrar/domains/transfer_index.html.erb | 6 +++++- config/locales/registrar/domains.en.yml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/registrar/domains/transfer_index.html.erb b/app/views/registrar/domains/transfer_index.html.erb index e5a82f873..d4d7f29e3 100644 --- a/app/views/registrar/domains/transfer_index.html.erb +++ b/app/views/registrar/domains/transfer_index.html.erb @@ -1,4 +1,8 @@ -<%= render 'shared/title', name: t(:transfer_domain) %> +
diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 059c5ebc5..c08504ba7 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -12,6 +12,9 @@ en: registrant_code: Registrant code expire_time: Date of expiry + transfer_index: + header: Domain transfer + search_form: download_btn: Download as CSV reset_btn: Reset From 0fa0c698773151bd420c481012472ab7d5b06de4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 12:12:07 +0200 Subject: [PATCH 041/167] Convert specs to tests --- .../registrar/domains/csv_export_spec.rb | 14 ----- .../domain_list_csv_presenter_spec.rb | 51 ------------------- .../registrar/domains_controller_spec.rb | 24 --------- test/fixtures/contacts.yml | 5 +- test/fixtures/domains.yml | 18 ++++--- test/integration/registrar/domains_test.rb | 20 ++++++++ 6 files changed, 36 insertions(+), 96 deletions(-) delete mode 100644 spec/features/registrar/domains/csv_export_spec.rb delete mode 100644 spec/presenters/registrar/domain_list_csv_presenter_spec.rb delete mode 100644 spec/requests/registrar/domains_controller_spec.rb create mode 100644 test/integration/registrar/domains_test.rb diff --git a/spec/features/registrar/domains/csv_export_spec.rb b/spec/features/registrar/domains/csv_export_spec.rb deleted file mode 100644 index 71258db78..000000000 --- a/spec/features/registrar/domains/csv_export_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -RSpec.feature 'CSV Export' do - background do - Setting.api_ip_whitelist_enabled = false - Setting.registrar_ip_whitelist_enabled = false - sign_in_to_registrar_area(user: create(:api_user_with_unlimited_balance)) - end - - scenario 'exports csv' do - visit registrar_domains_url - click_link_or_button 'Download' - end -end diff --git a/spec/presenters/registrar/domain_list_csv_presenter_spec.rb b/spec/presenters/registrar/domain_list_csv_presenter_spec.rb deleted file mode 100644 index 8fa1f256d..000000000 --- a/spec/presenters/registrar/domain_list_csv_presenter_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'rails_helper' - -RSpec.describe Registrar::DomainListCSVPresenter do - let(:domain) { instance_spy(DomainPresenter) } - let(:csv) { CSV.parse(described_class.new(domains: [domain], view: view).to_s, converters: :all) } - - describe 'header' do - subject(:header) { csv.first } - - it 'is present' do - columns = [] - columns[0] = 'Domain' - columns[1] = 'Auth info' - columns[2] = 'Registrant name' - columns[3] = 'Registrant code' - columns[4] = 'Date of expiry' - columns - - expect(header).to eq(columns) - end - end - - describe 'row' do - subject(:row) { csv.second } - - it 'has domain name' do - expect(domain).to receive(:name).and_return('test name') - expect(row[0]).to eq('test name') - end - - it 'has domain auth info' do - expect(domain).to receive(:auth_info).and_return('test auth info') - expect(row[1]).to eq('test auth info') - end - - it 'has registrant name' do - expect(domain).to receive(:registrant_name).and_return('test registrant name') - expect(row[2]).to eq('test registrant name') - end - - it 'has registrant code' do - expect(domain).to receive(:registrant_code).and_return('test registrant code') - expect(row[3]).to eq('test registrant code') - end - - it 'has expire date' do - expect(domain).to receive(:expire_date).and_return('expire date') - expect(row[4]).to eq('expire date') - end - end -end diff --git a/spec/requests/registrar/domains_controller_spec.rb b/spec/requests/registrar/domains_controller_spec.rb deleted file mode 100644 index eadb060c0..000000000 --- a/spec/requests/registrar/domains_controller_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe Registrar::DomainsController, db: true do - describe '#index' do - before do - sign_in_to_registrar_area - end - - it 'responds with success' do - csv_presenter = instance_double(Registrar::DomainListCSVPresenter, to_s: 'csv') - expect(Registrar::DomainListCSVPresenter).to receive(:new).and_return(csv_presenter) - - get registrar_domains_url(format: 'csv') - - expect(response.body).to eq('csv') - end - - it 'returns csv' do - get registrar_domains_url(format: 'csv') - - expect(response).to have_http_status(:success) - end - end -end diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 0300ef2b6..be4981b88 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -4,6 +4,7 @@ john: ident_type: priv ident_country_code: US registrar: acme + code: john-001 jane: name: Jane @@ -11,10 +12,12 @@ jane: ident_type: priv ident_country_code: US registrar: acme + code: jane-001 acme_ltd: - name: Acme Ltd. + name: Acme Ltd ident: 1234 ident_type: org registrar: acme ident_country_code: US + code: acme-ltd-001 diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 46a1e44e0..e734b71b4 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -1,14 +1,20 @@ -one: - name: one.test +shop: + name: shop.test registrar: valid registrant: john + auth_info: 65078d5 + valid_to: 2010-07-05 -two: - name: two.test +airport: + name: airport.test registrar: valid registrant: john + auth_info: 55438j5 + valid_to: 2010-07-05 -three: - name: three.test +library: + name: library.test registrar: valid registrant: acme_ltd + auth_info: 45118f5 + valid_to: 2010-07-05 diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb new file mode 100644 index 000000000..0db99fe74 --- /dev/null +++ b/test/integration/registrar/domains_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' + +class DomainsTest < ActionDispatch::IntegrationTest + def setup + login_as users(:api) + end + + def test_downloads_domain_list_as_csv + expected_csv = <<-CSV.strip_heredoc + Domain,Auth info,Registrant name,Registrant code,Date of expiry + library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05 + shop.test,65078d5,John,john-001,2010-07-05 + airport.test,55438j5,John,john-001,2010-07-05 + CSV + + visit registrar_domains_url + click_button 'Download as CSV' + assert_equal expected_csv, page.body + end +end From e20a4499c55d3b1fc48a64c667a2c5e3ff57c803 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 13:31:22 +0200 Subject: [PATCH 042/167] Include Warden.test_reset! in test teardown https://github.com/hassox/warden/blob/86aeb9a94528a90bfadafeb5b2c87ea526a00666/lib/warden/test/helpers.rb#L8 --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 98d6dcf8e..433f7cf47 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -19,6 +19,7 @@ class ActionDispatch::IntegrationTest include AbstractController::Translation def teardown + Warden.test_reset! Capybara.reset_sessions! Capybara.use_default_driver end From cf9e53972983a9a54a9f63cdb599fc958bbff592 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 13:33:31 +0200 Subject: [PATCH 043/167] Fix test class name clash --- test/integration/registrant/domains_test.rb | 2 +- test/integration/registrar/domains_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/registrant/domains_test.rb b/test/integration/registrant/domains_test.rb index 6a1a76e39..bddd92caa 100644 --- a/test/integration/registrant/domains_test.rb +++ b/test/integration/registrant/domains_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class DomainsTest < ActionDispatch::IntegrationTest +class RegistrantDomainsTest < ActionDispatch::IntegrationTest def setup login_as users(:registrant) diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index 0db99fe74..a8a84acc6 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class DomainsTest < ActionDispatch::IntegrationTest +class RegistrarDomainsTest < ActionDispatch::IntegrationTest def setup login_as users(:api) end From 842f7ff4aa7690fa10568cffa414c78d0d23e9b0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 13:33:56 +0200 Subject: [PATCH 044/167] Fix test --- test/integration/registrant/domains_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/integration/registrant/domains_test.rb b/test/integration/registrant/domains_test.rb index bddd92caa..9b1151b84 100644 --- a/test/integration/registrant/domains_test.rb +++ b/test/integration/registrant/domains_test.rb @@ -10,16 +10,16 @@ class RegistrantDomainsTest < ActionDispatch::IntegrationTest def test_shows_domains_where_current_user_is_registrant visit registrant_domains_url - assert_text 'one.test' + assert_text 'shop.test' end def test_shows_domains_where_current_user_is_contact_person visit registrant_domains_url - assert_text 'two.test' + assert_text 'airport.test' end def test_shows_domains_where_current_user_has_associated_organizations visit registrant_domains_url - assert_text 'three.test' + assert_text 'library.test' end end From 48313e379c66a179ff96e56910808cbee1d11de7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 13:44:50 +0200 Subject: [PATCH 045/167] Remove explicit form method --- app/views/registrar/domains/transfer_index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/domains/transfer_index.html.erb b/app/views/registrar/domains/transfer_index.html.erb index d4d7f29e3..bd43f055f 100644 --- a/app/views/registrar/domains/transfer_index.html.erb +++ b/app/views/registrar/domains/transfer_index.html.erb @@ -6,7 +6,7 @@
- <%= form_tag transfer_registrar_domains_path, class: 'form-horizontal', method: :post, multipart: true, autocomplete: 'off' do %> + <%= form_tag transfer_registrar_domains_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %>
<%= label_tag :domain_name, t(:name), class: 'required' %> From 4499830bfd50d0a4ac683b274c99a34b7fc0bedf Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 14:56:23 +0200 Subject: [PATCH 046/167] Convert HAML to ERB --- app/views/registrar/domains/transfer.haml | 16 ------------- app/views/registrar/domains/transfer.html.erb | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 app/views/registrar/domains/transfer.haml create mode 100644 app/views/registrar/domains/transfer.html.erb diff --git a/app/views/registrar/domains/transfer.haml b/app/views/registrar/domains/transfer.haml deleted file mode 100644 index b5a8f438f..000000000 --- a/app/views/registrar/domains/transfer.haml +++ /dev/null @@ -1,16 +0,0 @@ -= render 'shared/title', name: t(:transfer_domain) - -.row - .col-md-12 - .panel.panel-default - .panel-heading - %h3.panel-title= t(:result) - .panel-body - %dl.dl-horizontal - %dt= t(:domain_name) - %dd= @data.css('name').text - - - @data.css('trnData').children.each do |x| - - next if x.blank? - %dt= t(x.name) - %dd= x.text diff --git a/app/views/registrar/domains/transfer.html.erb b/app/views/registrar/domains/transfer.html.erb new file mode 100644 index 000000000..773760243 --- /dev/null +++ b/app/views/registrar/domains/transfer.html.erb @@ -0,0 +1,24 @@ +<%= render 'shared/title', name: t(:transfer_domain) %> +
+
+
+
+

+ <%= t(:result) %> +

+
+
+
+
<%= t(:domain_name) %>
+
<%= @data.css('name').text %>
+ + <% @data.css('trnData').children.each do |x| %> + <% next if x.blank? %> +
<%= t(x.name) %>
+
<%= x.text %>
+ <% end %> +
+
+
+
+
From 2b1e81a33808f12360950c08cb6f4d0e8a4fa013 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 14:56:52 +0200 Subject: [PATCH 047/167] Use standard header --- app/views/registrar/domains/transfer.html.erb | 7 ++++++- config/locales/en.yml | 2 -- config/locales/registrar/domains.en.yml | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/registrar/domains/transfer.html.erb b/app/views/registrar/domains/transfer.html.erb index 773760243..676385966 100644 --- a/app/views/registrar/domains/transfer.html.erb +++ b/app/views/registrar/domains/transfer.html.erb @@ -1,4 +1,9 @@ -<%= render 'shared/title', name: t(:transfer_domain) %> + +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 5a3564411..cc253e7db 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -332,7 +332,6 @@ en: approve: 'Approve' domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar' other_registrar_has_already_requested_to_transfer_this_domain: 'Other registrar has already requested to transfer this domain.' - transfer_domain: 'Transfer domain' failed_to_request_domain_transfer: 'Failed to request domain transfer' #not used atm domain_transfer: 'Domain transfer' request_domain_transfer: 'Request domain transfer' @@ -548,7 +547,6 @@ en: cur_exp_date: 'curExpDate' transfer: 'Transfer' query: 'Query' - transfer_domain: 'Transfer domain' reject: 'Reject' approve: 'Approve' contact_info: 'Contact info' diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index c08504ba7..16c4f5d58 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -15,6 +15,9 @@ en: transfer_index: header: Domain transfer + transfer: + header: Domain transfer + search_form: download_btn: Download as CSV reset_btn: Reset From 4322830314444712f92b9c047a629de7f1b3faef Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 15:05:22 +0200 Subject: [PATCH 048/167] Remove unused translations --- config/locales/en.yml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index cc253e7db..ea89e324a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -97,11 +97,6 @@ en: domain: <<: *epp_domain_ar_attributes - domain_transfer: - attributes: - base: - transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar' - nameserver: attributes: hostname: @@ -326,26 +321,9 @@ en: starting_balance: 'Starting balance' destroyed: 'Destroyed' - domain_transfer_requested: 'Domain transfer requested!' - domain_transfer_approved: 'Domain transfer approved!' - failed_to_approve_domain_transfer: 'Failed to approve domain transfer' approve: 'Approve' domain_already_belongs_to_the_querying_registrar: 'Domain already belongs to the querying registrar' - other_registrar_has_already_requested_to_transfer_this_domain: 'Other registrar has already requested to transfer this domain.' - failed_to_request_domain_transfer: 'Failed to request domain transfer' #not used atm - domain_transfer: 'Domain transfer' - request_domain_transfer: 'Request domain transfer' - domain_valid_to: 'Domain valid to' - accept_time: 'Accept time' - transfer_from: 'Transfer from' - transferred_at: 'Transferred at' - domain_transfers_list: 'Domain transfers list' - domain_transfers: 'Domain transfers' - password_invalid: 'Password invalid!' - domain_was_not_found: 'Domain was not found!' - domain_list: 'Domain list' - create_new_domain: 'Create new domain' welcome: 'Welcome!' edit_statuses: 'Edit statuses' contact_list: 'Contact list' @@ -420,7 +398,6 @@ en: tech_contacts_min_count: 'Tech contacts minimum count' tech_contacts_max_count: 'Tech contacts maximum count' action_failed_due_to_server_error: 'Action failed due to server error' - pending_transfer_was_not_found: 'Pending transfer was not found' transfer_can_be_rejected_only_by_current_registrar: 'Transfer can be rejected only by current registrar' request_command: 'Request command' request_object: 'Request object' From e11fe9522727128f9e7080f7f4c235bacafa55fe Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 16:36:05 +0200 Subject: [PATCH 049/167] Simplify fixture --- test/fixtures/users.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 856788de9..93e792e77 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,15 +1,12 @@ -DEFAULTS: &DEFAULTS - username: test - api: - <<: *DEFAULTS + username: test type: ApiUser registrar: valid roles: - super admin: - <<: *DEFAULTS + username: test type: AdminUser country_code: US roles: From 66afb4c56b043b0f1093ef69ef1fa8eeb9718dc1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 16:36:38 +0200 Subject: [PATCH 050/167] Add domain transfer test --- test/integration/registrar/domains_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index a8a84acc6..97c1780e9 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -17,4 +17,16 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest click_button 'Download as CSV' assert_equal expected_csv, page.body end + + def test_transfers_domain + travel_to Time.zone.parse('2010-07-05 10:30:00') + + visit registrar_domains_url + click_link 'Transfer' + fill_in 'Name', with: 'shop.test' + fill_in 'Password', with: '65078d5' + click_button 'Transfer' + + assert_text 'Transfer requested at: 2010-07-05 10:30:00' + end end From 2065daf0242f63ef8230a05eab5b0ffc0b9b9948 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 19 Jan 2018 17:10:30 +0200 Subject: [PATCH 051/167] Add EPP session fixture --- test/fixtures/epp_sessions.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 test/fixtures/epp_sessions.yml diff --git a/test/fixtures/epp_sessions.yml b/test/fixtures/epp_sessions.yml new file mode 100644 index 000000000..8f114b2de --- /dev/null +++ b/test/fixtures/epp_sessions.yml @@ -0,0 +1,3 @@ +shop: + registrar: valid + data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api)})) %> From 43cf1d483cb9e94fba2aa1f37528d5d2d595dbac Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 19:29:14 +0200 Subject: [PATCH 052/167] Add "domain_transfers" DB table foreign keys #660 --- ...72042_add_domain_transfers_domain_id_fk.rb | 5 ++++ ...dd_domain_transfers_transfer_from_id_fk.rb | 5 ++++ ..._add_domain_transfers_transfer_to_id_fk.rb | 5 ++++ db/structure.sql | 30 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 db/migrate/20180120172042_add_domain_transfers_domain_id_fk.rb create mode 100644 db/migrate/20180120172649_add_domain_transfers_transfer_from_id_fk.rb create mode 100644 db/migrate/20180120172657_add_domain_transfers_transfer_to_id_fk.rb diff --git a/db/migrate/20180120172042_add_domain_transfers_domain_id_fk.rb b/db/migrate/20180120172042_add_domain_transfers_domain_id_fk.rb new file mode 100644 index 000000000..3b4a050ca --- /dev/null +++ b/db/migrate/20180120172042_add_domain_transfers_domain_id_fk.rb @@ -0,0 +1,5 @@ +class AddDomainTransfersDomainIdFk < ActiveRecord::Migration + def change + add_foreign_key :domain_transfers, :domains + end +end diff --git a/db/migrate/20180120172649_add_domain_transfers_transfer_from_id_fk.rb b/db/migrate/20180120172649_add_domain_transfers_transfer_from_id_fk.rb new file mode 100644 index 000000000..9e4e6a31f --- /dev/null +++ b/db/migrate/20180120172649_add_domain_transfers_transfer_from_id_fk.rb @@ -0,0 +1,5 @@ +class AddDomainTransfersTransferFromIdFk < ActiveRecord::Migration + def change + add_foreign_key :domain_transfers, :registrars, column: :transfer_from_id + end +end diff --git a/db/migrate/20180120172657_add_domain_transfers_transfer_to_id_fk.rb b/db/migrate/20180120172657_add_domain_transfers_transfer_to_id_fk.rb new file mode 100644 index 000000000..6b0dd0865 --- /dev/null +++ b/db/migrate/20180120172657_add_domain_transfers_transfer_to_id_fk.rb @@ -0,0 +1,5 @@ +class AddDomainTransfersTransferToIdFk < ActiveRecord::Migration + def change + add_foreign_key :domain_transfers, :registrars, column: :transfer_to_id + end +end diff --git a/db/structure.sql b/db/structure.sql index d2000ab98..50ec2d2ca 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4505,6 +4505,14 @@ ALTER TABLE ONLY domains ADD CONSTRAINT domains_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES registrars(id); +-- +-- Name: fk_rails_59c422f73d; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domain_transfers + ADD CONSTRAINT fk_rails_59c422f73d FOREIGN KEY (transfer_from_id) REFERENCES registrars(id); + + -- -- Name: fk_rails_78c376257f; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -4513,6 +4521,14 @@ ALTER TABLE ONLY prices ADD CONSTRAINT fk_rails_78c376257f FOREIGN KEY (zone_id) REFERENCES zones(id); +-- +-- Name: fk_rails_833ed7f3c0; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domain_transfers + ADD CONSTRAINT fk_rails_833ed7f3c0 FOREIGN KEY (transfer_to_id) REFERENCES registrars(id); + + -- -- Name: fk_rails_86cd2b09f5; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -4521,6 +4537,14 @@ ALTER TABLE ONLY account_activities ADD CONSTRAINT fk_rails_86cd2b09f5 FOREIGN KEY (account_id) REFERENCES accounts(id); +-- +-- Name: fk_rails_87b8e40c63; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domain_transfers + ADD CONSTRAINT fk_rails_87b8e40c63 FOREIGN KEY (domain_id) REFERENCES domains(id); + + -- -- Name: fk_rails_b80dbb973d; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5081,3 +5105,9 @@ INSERT INTO schema_migrations (version) VALUES ('20180112084221'); INSERT INTO schema_migrations (version) VALUES ('20180112084442'); +INSERT INTO schema_migrations (version) VALUES ('20180120172042'); + +INSERT INTO schema_migrations (version) VALUES ('20180120172649'); + +INSERT INTO schema_migrations (version) VALUES ('20180120172657'); + From a337604dc08c12f941b6892d48e710456ff2d9b5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 20:36:57 +0200 Subject: [PATCH 053/167] Remove DomainTransferVersion #660 --- app/models/domain_transfer.rb | 1 - app/models/version/domain_transfer_version.rb | 5 -- ...0180120182712_drop_log_domain_transfers.rb | 5 ++ ...441_remove_domain_transfers_paper_trail.rb | 6 ++ db/structure.sql | 75 ++----------------- doc/models_brief.svg | 18 ----- doc/models_complete.svg | 29 ------- spec/models/domain_transfer_spec.rb | 14 ---- 8 files changed, 16 insertions(+), 137 deletions(-) delete mode 100644 app/models/version/domain_transfer_version.rb create mode 100644 db/migrate/20180120182712_drop_log_domain_transfers.rb create mode 100644 db/migrate/20180120183441_remove_domain_transfers_paper_trail.rb diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index adcd10e50..8f2fbcdf5 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -1,5 +1,4 @@ class DomainTransfer < ActiveRecord::Base - include Versions # version/domain_transfer_version.rb belongs_to :domain belongs_to :transfer_from, class_name: 'Registrar' diff --git a/app/models/version/domain_transfer_version.rb b/app/models/version/domain_transfer_version.rb deleted file mode 100644 index 7005337ba..000000000 --- a/app/models/version/domain_transfer_version.rb +++ /dev/null @@ -1,5 +0,0 @@ -class DomainTransferVersion < PaperTrail::Version - include VersionSession - self.table_name = :log_domain_transfers - self.sequence_name = :log_domain_transfers_id_seq -end diff --git a/db/migrate/20180120182712_drop_log_domain_transfers.rb b/db/migrate/20180120182712_drop_log_domain_transfers.rb new file mode 100644 index 000000000..1b77aa1bf --- /dev/null +++ b/db/migrate/20180120182712_drop_log_domain_transfers.rb @@ -0,0 +1,5 @@ +class DropLogDomainTransfers < ActiveRecord::Migration + def change + drop_table :log_domain_transfers + end +end diff --git a/db/migrate/20180120183441_remove_domain_transfers_paper_trail.rb b/db/migrate/20180120183441_remove_domain_transfers_paper_trail.rb new file mode 100644 index 000000000..b77b6fffb --- /dev/null +++ b/db/migrate/20180120183441_remove_domain_transfers_paper_trail.rb @@ -0,0 +1,6 @@ +class RemoveDomainTransfersPaperTrail < ActiveRecord::Migration + def change + remove_column :domain_transfers, :creator_str, :string + remove_column :domain_transfers, :updator_str, :string + end +end diff --git a/db/structure.sql b/db/structure.sql index 50ec2d2ca..d49004ee5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -962,9 +962,7 @@ CREATE TABLE domain_transfers ( transfer_to_id integer, created_at timestamp without time zone, updated_at timestamp without time zone, - wait_until timestamp without time zone, - creator_str character varying, - updator_str character varying + wait_until timestamp without time zone ); @@ -1722,44 +1720,6 @@ CREATE SEQUENCE log_domain_statuses_id_seq ALTER SEQUENCE log_domain_statuses_id_seq OWNED BY log_domain_statuses.id; --- --- Name: log_domain_transfers; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE log_domain_transfers ( - id integer NOT NULL, - item_type character varying NOT NULL, - item_id integer NOT NULL, - event character varying NOT NULL, - whodunnit character varying, - object json, - object_changes json, - created_at timestamp without time zone, - session character varying, - children json, - uuid character varying -); - - --- --- Name: log_domain_transfers_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE log_domain_transfers_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_domain_transfers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE log_domain_transfers_id_seq OWNED BY log_domain_transfers.id; - - -- -- Name: log_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -3029,13 +2989,6 @@ ALTER TABLE ONLY log_domain_contacts ALTER COLUMN id SET DEFAULT nextval('log_do ALTER TABLE ONLY log_domain_statuses ALTER COLUMN id SET DEFAULT nextval('log_domain_statuses_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY log_domain_transfers ALTER COLUMN id SET DEFAULT nextval('log_domain_transfers_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3506,14 +3459,6 @@ ALTER TABLE ONLY log_domain_statuses ADD CONSTRAINT log_domain_statuses_pkey PRIMARY KEY (id); --- --- Name: log_domain_transfers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY log_domain_transfers - ADD CONSTRAINT log_domain_transfers_pkey PRIMARY KEY (id); - - -- -- Name: log_domains_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -4171,20 +4116,6 @@ CREATE INDEX index_log_domain_statuses_on_item_type_and_item_id ON log_domain_st CREATE INDEX index_log_domain_statuses_on_whodunnit ON log_domain_statuses USING btree (whodunnit); --- --- Name: index_log_domain_transfers_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_domain_transfers_on_item_type_and_item_id ON log_domain_transfers USING btree (item_type, item_id); - - --- --- Name: index_log_domain_transfers_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_domain_transfers_on_whodunnit ON log_domain_transfers USING btree (whodunnit); - - -- -- Name: index_log_domains_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -5111,3 +5042,7 @@ INSERT INTO schema_migrations (version) VALUES ('20180120172649'); INSERT INTO schema_migrations (version) VALUES ('20180120172657'); +INSERT INTO schema_migrations (version) VALUES ('20180120182712'); + +INSERT INTO schema_migrations (version) VALUES ('20180120183441'); + diff --git a/doc/models_brief.svg b/doc/models_brief.svg index 22d63cfe7..fa3f478c7 100644 --- a/doc/models_brief.svg +++ b/doc/models_brief.svg @@ -249,17 +249,6 @@ - -DomainTransferVersion - -DomainTransferVersion - - -DomainTransferVersion->VersionAssociation - - - - BankTransactionVersion @@ -1142,13 +1131,6 @@ versions - -DomainTransfer->DomainTransferVersion - - - -versions - ContactStatus->ContactStatusVersion diff --git a/doc/models_complete.svg b/doc/models_complete.svg index b6216a3b0..9391a7f6d 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -490,28 +490,6 @@ - -DomainTransferVersion - -DomainTransferVersion - -id :integer -item_type :string -item_id :integer -event :string -whodunnit :string -object :json -object_changes :json -created_at :datetime -session :string -children :json - - -DomainTransferVersion->VersionAssociation - - - - BankTransactionVersion @@ -1848,13 +1826,6 @@ versions - -DomainTransfer->DomainTransferVersion - - - -versions - ContactStatus->ContactStatusVersion diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb index 5f8bf54a0..b68838f3c 100644 --- a/spec/models/domain_transfer_spec.rb +++ b/spec/models/domain_transfer_spec.rb @@ -34,10 +34,6 @@ describe DomainTransfer do @domain_transfer.errors.full_messages.should match_array([ ]) end - - it 'should not have any versions' do - @domain_transfer.versions.should == [] - end end context 'with valid attributes' do @@ -55,15 +51,5 @@ describe DomainTransfer do @domain_transfer.valid? @domain_transfer.errors.full_messages.should match_array([]) end - - it 'should have one version' do - with_versioning do - @domain_transfer.versions.should == [] - @domain_transfer.wait_until = 1.day.since - @domain_transfer.save - @domain_transfer.errors.full_messages.should match_array([]) - @domain_transfer.versions.size.should == 1 - end - end end end From 5bcd8462467d3107541dd32c58a5d1c8ad347678 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 20:40:25 +0200 Subject: [PATCH 054/167] Remove unused method --- .reek | 1 - app/models/domain_transfer.rb | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/.reek b/.reek index 933847410..70ddddd1c 100644 --- a/.reek +++ b/.reek @@ -784,7 +784,6 @@ TooManyStatements: - 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 diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 8f2fbcdf5..63c1d505b 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -38,18 +38,6 @@ class DomainTransfer < ActiveRecord::Base status == PENDING end - def approve_as_client - transaction do - self.status = DomainTransfer::CLIENT_APPROVED - self.transferred_at = Time.zone.now - save - - domain.generate_auth_info - domain.registrar = transfer_to - domain.save(validate: false) - end - end - def notify_losing_registrar(contacts, registrant) transfer_from.messages.create!( body: I18n.t('domain_transfer_was_approved', contacts: contacts, registrant: registrant), From 8678d7186652794e6b301936b1d31e5f4483de58 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 20:41:58 +0200 Subject: [PATCH 055/167] Remove unused constants --- app/models/domain_transfer.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 63c1d505b..55cab821c 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -6,10 +6,8 @@ class DomainTransfer < ActiveRecord::Base PENDING = 'pending' CLIENT_APPROVED = 'clientApproved' - CLIENT_CANCELLED = 'clientCancelled' CLIENT_REJECTED = 'clientRejected' SERVER_APPROVED = 'serverApproved' - SERVER_CANCELLED = 'serverCancelled' before_create :set_wait_until def set_wait_until From ce58feba6e52c67e5361fb055314f4c0e16118da Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 20:43:29 +0200 Subject: [PATCH 056/167] Remove useless spec --- spec/models/domain_transfer_spec.rb | 55 ----------------------------- 1 file changed, 55 deletions(-) delete mode 100644 spec/models/domain_transfer_spec.rb diff --git a/spec/models/domain_transfer_spec.rb b/spec/models/domain_transfer_spec.rb deleted file mode 100644 index b68838f3c..000000000 --- a/spec/models/domain_transfer_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'rails_helper' - -describe DomainTransfer do - before :example do - Setting.ds_algorithm = 2 - Setting.ds_data_allowed = true - Setting.ds_data_with_key_allowed = true - Setting.key_data_allowed = true - - Setting.dnskeys_min_count = 0 - Setting.dnskeys_max_count = 9 - Setting.ns_min_count = 2 - Setting.ns_max_count = 11 - - Setting.transfer_wait_time = 0 - - Setting.admin_contacts_min_count = 1 - Setting.admin_contacts_max_count = 10 - Setting.tech_contacts_min_count = 0 - Setting.tech_contacts_max_count = 10 - - Setting.client_side_status_editing_enabled = true - - create(:zone, origin: 'ee') - end - - context 'with invalid attribute' do - before :example do - @domain_transfer = DomainTransfer.new - end - - it 'should not be valid' do - @domain_transfer.valid? - @domain_transfer.errors.full_messages.should match_array([ - ]) - end - end - - context 'with valid attributes' do - before :example do - @domain_transfer = create(:domain_transfer) - end - - it 'should be valid' do - @domain_transfer.valid? - @domain_transfer.errors.full_messages.should match_array([]) - end - - it 'should be valid twice' do - @domain_transfer = create(:domain_transfer) - @domain_transfer.valid? - @domain_transfer.errors.full_messages.should match_array([]) - end - end -end From 013122335d22d8483c13e5b17fe8681b4ef018fc Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 22:22:30 +0200 Subject: [PATCH 057/167] Update fixtures --- .../admin/registrars/update_test.rb | 2 +- test/fixtures/contacts.yml | 6 +++--- test/fixtures/domains.yml | 6 +++--- test/fixtures/epp_sessions.yml | 2 +- test/fixtures/registrars.yml | 20 ++++--------------- test/fixtures/users.yml | 3 ++- .../admin/registrars/edit_registrar_test.rb | 2 +- .../admin/registrars/show_registrar_test.rb | 2 +- test/models/registrar_test.rb | 2 +- 9 files changed, 17 insertions(+), 28 deletions(-) diff --git a/test/controllers/admin/registrars/update_test.rb b/test/controllers/admin/registrars/update_test.rb index ae695f3c3..2c996ef44 100644 --- a/test/controllers/admin/registrars/update_test.rb +++ b/test/controllers/admin/registrars/update_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class RegistrarsControllerTest < ActionDispatch::IntegrationTest def setup login_as users(:admin) - @registrar = registrars(:valid) + @registrar = registrars(:bestnames) end def test_updates_website diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index be4981b88..a6262f9c4 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -3,7 +3,7 @@ john: ident: 1234 ident_type: priv ident_country_code: US - registrar: acme + registrar: bestnames code: john-001 jane: @@ -11,13 +11,13 @@ jane: ident: 1234 ident_type: priv ident_country_code: US - registrar: acme + registrar: bestnames code: jane-001 acme_ltd: name: Acme Ltd ident: 1234 ident_type: org - registrar: acme + registrar: bestnames ident_country_code: US code: acme-ltd-001 diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index e734b71b4..2ad5be054 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -1,20 +1,20 @@ shop: name: shop.test - registrar: valid + registrar: bestnames registrant: john auth_info: 65078d5 valid_to: 2010-07-05 airport: name: airport.test - registrar: valid + registrar: bestnames registrant: john auth_info: 55438j5 valid_to: 2010-07-05 library: name: library.test - registrar: valid + registrar: bestnames registrant: acme_ltd auth_info: 45118f5 valid_to: 2010-07-05 diff --git a/test/fixtures/epp_sessions.yml b/test/fixtures/epp_sessions.yml index 8f114b2de..8a2104f8c 100644 --- a/test/fixtures/epp_sessions.yml +++ b/test/fixtures/epp_sessions.yml @@ -1,3 +1,3 @@ shop: - registrar: valid + registrar: bestnames data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api)})) %> diff --git a/test/fixtures/registrars.yml b/test/fixtures/registrars.yml index 52b2bbc00..ccd8e983d 100644 --- a/test/fixtures/registrars.yml +++ b/test/fixtures/registrars.yml @@ -1,21 +1,9 @@ -DEFAULTS: &DEFAULTS - name: Acme Ltd +bestnames: + name: Best Names Ltd reg_no: 1234 + code: bestnames country_code: US - email: acme@example.com - code: 1234 + email: info@bestnames.test accounting_customer_code: ACCOUNT001 language: en - -valid: - <<: *DEFAULTS - -complete: - <<: *DEFAULTS - name: 2 - reg_no: 2 - code: 2 - website: example.com - email: info@example.com billing_email: billing@example.com - vat_no: US12345 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 93e792e77..e07415d6f 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,7 +1,8 @@ api: username: test + password: test type: ApiUser - registrar: valid + registrar: bestnames roles: - super diff --git a/test/integration/admin/registrars/edit_registrar_test.rb b/test/integration/admin/registrars/edit_registrar_test.rb index b21488306..ada794032 100644 --- a/test/integration/admin/registrars/edit_registrar_test.rb +++ b/test/integration/admin/registrars/edit_registrar_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class EditRegistrarTest < ActionDispatch::IntegrationTest def setup login_as users(:admin) - @registrar = registrars(:valid) + @registrar = registrars(:bestnames) end def test_updates_registrar diff --git a/test/integration/admin/registrars/show_registrar_test.rb b/test/integration/admin/registrars/show_registrar_test.rb index b56c3a74f..6b8dc5d33 100644 --- a/test/integration/admin/registrars/show_registrar_test.rb +++ b/test/integration/admin/registrars/show_registrar_test.rb @@ -5,7 +5,7 @@ class ShowRegistrarTest < ActionDispatch::IntegrationTest def setup login_as users(:admin) - @registrar = registrars(:complete) + @registrar = registrars(:bestnames) visit admin_registrar_path(@registrar) end diff --git a/test/models/registrar_test.rb b/test/models/registrar_test.rb index 6c92bbff9..58a06b0ae 100644 --- a/test/models/registrar_test.rb +++ b/test/models/registrar_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RegistrarTest < ActiveSupport::TestCase def setup - @registrar = registrars(:valid) + @registrar = registrars(:bestnames) end def test_valid From e36e31f6d94901b789ad5b8432366f161a63cedd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 22:30:33 +0200 Subject: [PATCH 058/167] Update fixtures --- test/fixtures/registrars.yml | 15 ++++++++++++--- .../admin/registrars/show_registrar_test.rb | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/fixtures/registrars.yml b/test/fixtures/registrars.yml index ccd8e983d..0026f323b 100644 --- a/test/fixtures/registrars.yml +++ b/test/fixtures/registrars.yml @@ -1,9 +1,18 @@ bestnames: - name: Best Names Ltd + name: Best Names reg_no: 1234 code: bestnames - country_code: US email: info@bestnames.test - accounting_customer_code: ACCOUNT001 + country_code: US + accounting_customer_code: bestnames language: en billing_email: billing@example.com + +goodnames: + name: Good Names + reg_no: 12345 + code: goodnames + email: info@goodnames.test + country_code: US + accounting_customer_code: goodnames + language: en diff --git a/test/integration/admin/registrars/show_registrar_test.rb b/test/integration/admin/registrars/show_registrar_test.rb index 6b8dc5d33..cb310317c 100644 --- a/test/integration/admin/registrars/show_registrar_test.rb +++ b/test/integration/admin/registrars/show_registrar_test.rb @@ -10,7 +10,7 @@ class ShowRegistrarTest < ActionDispatch::IntegrationTest end def test_accounting_customer_code - assert_text 'ACCOUNT001' + assert_text 'bestnames' end def test_language From 624cc70bef03776c3c3d5cc325ea8ae63e5cc61c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 22:38:14 +0200 Subject: [PATCH 059/167] Add Domain#transfer --- app/models/domain.rb | 11 +++++++++++ test/models/domain_test.rb | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/models/domain_test.rb diff --git a/app/models/domain.rb b/app/models/domain.rb index 6d16d617f..3abcb026a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -672,6 +672,11 @@ class Domain < ActiveRecord::Base pending_json['new_registrant_id'] end + def transfer(new_registrar) + self.registrar = new_registrar + regenerate_auth_info + end + def self.to_csv CSV.generate do |csv| csv << column_names @@ -705,5 +710,11 @@ class Domain < ActiveRecord::Base def self.uses_zone?(zone) exists?(["name ILIKE ?", "%.#{zone.origin}"]) end + + private + + def regenerate_auth_info + generate_auth_info! + end end # rubocop: enable Metrics/ClassLength diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb new file mode 100644 index 000000000..090fc17a5 --- /dev/null +++ b/test/models/domain_test.rb @@ -0,0 +1,16 @@ +require 'test_helper' + +class DomainTest < ActiveSupport::TestCase + def setup + @domain = domains(:shop) + end + + def test_transfers_domain + old_auth_info = @domain.auth_info + new_registrar = registrars(:goodnames) + @domain.transfer(new_registrar) + + assert_equal new_registrar, @domain.registrar + refute_same @domain.auth_info, old_auth_info + end +end From 218517816296037e843df692c6c9d4cbd581325c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 20 Jan 2018 22:39:01 +0200 Subject: [PATCH 060/167] Add domains transfer API #660 --- app/api/repp/api.rb | 1 + app/api/repp/domain_transfers_v1.rb | 18 ++++++++++++++++++ test/api/domain_transfers_test.rb | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 app/api/repp/domain_transfers_v1.rb create mode 100644 test/api/domain_transfers_test.rb diff --git a/app/api/repp/api.rb b/app/api/repp/api.rb index 394edfdad..aec46c68b 100644 --- a/app/api/repp/api.rb +++ b/app/api/repp/api.rb @@ -57,5 +57,6 @@ module Repp mount Repp::DomainV1 mount Repp::ContactV1 mount Repp::AccountV1 + mount Repp::DomainTransfersV1 end end diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb new file mode 100644 index 000000000..7668c8bdf --- /dev/null +++ b/app/api/repp/domain_transfers_v1.rb @@ -0,0 +1,18 @@ +module Repp + class DomainTransfersV1 < Grape::API + version 'v1', using: :path + + resource :domain_transfers do + post '/' do + params['domainTransfers'].each do |domain_transfer| + domain_name = domain_transfer['domainName'] + auth_info = domain_transfer['authInfo'] + new_registrar = current_user.registrar + + domain = Domain.find_by(name: domain_name) + domain.transfer(registrar: new_registrar, auth_info: auth_info) + end + end + end + end +end diff --git a/test/api/domain_transfers_test.rb b/test/api/domain_transfers_test.rb new file mode 100644 index 000000000..c04e19b8b --- /dev/null +++ b/test/api/domain_transfers_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest + def test_post_to_domain_transfers + request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, authInfo: domains(:shop).auth_info }] } + post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response :created + + assert_difference -> { domains(:shop).domain_transfers.count } do + post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } + end + end + + private + + def http_auth_key + ActionController::HttpAuthentication::Basic.encode_credentials(users(:api).username, users(:api).password) + end +end From 571601619248e7b630392f342a37948ff24247e0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 18:22:16 +0200 Subject: [PATCH 061/167] Update fixtures #660 --- test/fixtures/dns/zones.yml | 2 ++ test/fixtures/domain_contacts.yml | 16 +++++++++++++--- test/fixtures/domains.yml | 9 +++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/dns/zones.yml diff --git a/test/fixtures/dns/zones.yml b/test/fixtures/dns/zones.yml new file mode 100644 index 000000000..40a8a289e --- /dev/null +++ b/test/fixtures/dns/zones.yml @@ -0,0 +1,2 @@ +test: + origin: test diff --git a/test/fixtures/domain_contacts.yml b/test/fixtures/domain_contacts.yml index 3e1d01d62..538e3b235 100644 --- a/test/fixtures/domain_contacts.yml +++ b/test/fixtures/domain_contacts.yml @@ -1,4 +1,14 @@ -two_jane: - domain: two - contact: jane +shop_john: + domain: shop + contact: john + type: AdminDomainContact + +airport_john: + domain: airport + contact: john + type: AdminDomainContact + +library_john: + domain: library + contact: john type: AdminDomainContact diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 2ad5be054..6b170b53b 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -1,20 +1,29 @@ shop: name: shop.test + name_dirty: shop.test registrar: bestnames registrant: john auth_info: 65078d5 valid_to: 2010-07-05 + period: 1 + period_unit: m airport: name: airport.test + name_dirty: airport.test registrar: bestnames registrant: john auth_info: 55438j5 valid_to: 2010-07-05 + period: 1 + period_unit: m library: name: library.test + name_dirty: library.test registrar: bestnames registrant: acme_ltd auth_info: 45118f5 valid_to: 2010-07-05 + period: 1 + period_unit: m From 340e61804be4a7dbb00622ade932880268aab5f2 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 18:29:42 +0200 Subject: [PATCH 062/167] Extract domain transferable module #660 --- app/models/concerns/domain/transferable.rb | 18 +++++++++++++++ app/models/domain.rb | 27 +--------------------- app/models/epp/domain.rb | 2 +- spec/models/domain_spec.rb | 5 ---- test/models/domain_test.rb | 20 ++++++++++++++++ 5 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 app/models/concerns/domain/transferable.rb diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb new file mode 100644 index 000000000..84c855a55 --- /dev/null +++ b/app/models/concerns/domain/transferable.rb @@ -0,0 +1,18 @@ +module Concerns::Domain::Transferable + extend ActiveSupport::Concern + + included do + after_initialize :generate_auth_info, if: :new_record? + end + + def transfer(new_registrar) + self.registrar = new_registrar + generate_auth_info + end + + private + + def generate_auth_info + self.auth_info = SecureRandom.hex + end +end diff --git a/app/models/domain.rb b/app/models/domain.rb index 3abcb026a..31ef08cca 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -6,6 +6,7 @@ class Domain < ActiveRecord::Base include Concerns::Domain::Activatable include Concerns::Domain::ForceDelete include Concerns::Domain::Deletable + include Concerns::Domain::Transferable has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } @@ -79,9 +80,7 @@ class Domain < ActiveRecord::Base self.status_notes = {} if status_notes.nil? end - before_create :generate_auth_info before_create -> { self.reserved = in_reserved_list?; nil } - before_save :manage_automatic_statuses before_save :touch_always_version def touch_always_version @@ -497,19 +496,6 @@ class Domain < ActiveRecord::Base Registrant.find_by(id: pending_json['new_registrant_id']) end - def generate_auth_info - return if auth_info.present? - generate_auth_info! - end - - # rubocop:disable Lint/Loop - def generate_auth_info! - begin - self.auth_info = SecureRandom.hex - end while self.class.exists?(auth_info: auth_info) - end - # rubocop:enable Lint/Loop - def set_graceful_expired self.outzone_at = expire_time + self.class.expire_warning_period self.delete_at = outzone_at + self.class.redemption_grace_period @@ -672,11 +658,6 @@ class Domain < ActiveRecord::Base pending_json['new_registrant_id'] end - def transfer(new_registrar) - self.registrar = new_registrar - regenerate_auth_info - end - def self.to_csv CSV.generate do |csv| csv << column_names @@ -710,11 +691,5 @@ class Domain < ActiveRecord::Base def self.uses_zone?(zone) exists?(["name ILIKE ?", "%.#{zone.origin}"]) end - - private - - def regenerate_auth_info - generate_auth_info! - end end # rubocop: enable Metrics/ClassLength diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 997c77fc5..20e30fdde 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -722,7 +722,7 @@ class Epp::Domain < Domain if dt.approved? transfer_contacts(current_user.registrar_id) dt.notify_losing_registrar(old_contact_codes, old_registrant_code) - generate_auth_info! + generate_auth_info self.registrar = current_user.registrar end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index fe9dae9a6..0ccc9f4fa 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -538,11 +538,6 @@ RSpec.describe Domain do expect(domain.errors[:base]).to include('Required parameter missing; reserved>pw element required for reserved domains') end - it 'generates auth info' do - d = create(:domain) - expect(d.auth_info).to_not be_empty - end - it 'manages statuses automatically' do d = build(:domain) diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index 090fc17a5..5a244138b 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -5,6 +5,26 @@ class DomainTest < ActiveSupport::TestCase @domain = domains(:shop) end + def test_validates + assert @domain.valid? + end + + def test_generates_random_auth_info_if_new + domain = Domain.new + another_domain = Domain.new + + refute_empty domain.auth_info + refute_empty another_domain.auth_info + refute_equal domain.auth_info, another_domain.auth_info + end + + def test_does_not_regenerate_auth_info_if_persisted + original_auth_info = @domain.auth_info + @domain.save! + @domain.reload + assert_equal original_auth_info, @domain.auth_info + end + def test_transfers_domain old_auth_info = @domain.auth_info new_registrar = registrars(:goodnames) From 4b836f1476dc8c3dacdce1f2e6718b6458472d1b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 19:31:16 +0200 Subject: [PATCH 063/167] Rename domain "auth_info" to "transfer_code" #660 --- app/api/repp/domain_transfers_v1.rb | 4 ++-- app/api/repp/domain_v1.rb | 2 +- app/models/ability.rb | 10 +++++----- app/models/concerns/domain/transferable.rb | 8 ++++---- app/models/epp/domain.rb | 10 +++++----- app/presenters/domain_presenter.rb | 2 +- .../registrar/domain_list_csv_presenter.rb | 4 ++-- .../admin/domains/partials/_general.html.erb | 4 ++-- app/views/epp/domains/info.xml.builder | 2 +- .../domains/partials/_general.html.erb | 4 ++-- .../domains/partials/_general.html.erb | 2 +- config/locales/en.yml | 2 +- config/locales/registrar/domains.en.yml | 2 +- ...ename_domains_auth_info_to_transfer_code.rb | 5 +++++ db/structure.sql | 4 +++- doc/models_complete.svg | 2 +- doc/repp/v1/domain.md | 2 +- lib/tasks/import.rake | 2 +- spec/presenters/domain_presenter_spec.rb | 2 +- test/api/domain_transfers_test.rb | 2 +- test/fixtures/domains.yml | 6 +++--- test/integration/registrar/domains_test.rb | 2 +- test/models/domain_test.rb | 18 +++++++++--------- 23 files changed, 54 insertions(+), 47 deletions(-) create mode 100644 db/migrate/20180121165304_rename_domains_auth_info_to_transfer_code.rb diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index 7668c8bdf..3c3104a8f 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -6,11 +6,11 @@ module Repp post '/' do params['domainTransfers'].each do |domain_transfer| domain_name = domain_transfer['domainName'] - auth_info = domain_transfer['authInfo'] + transfer_code = domain_transfer['transferCode'] new_registrar = current_user.registrar domain = Domain.find_by(name: domain_name) - domain.transfer(registrar: new_registrar, auth_info: auth_info) + domain.transfer(registrar: new_registrar, transfer_code: transfer_code) end end end diff --git a/app/api/repp/domain_v1.rb b/app/api/repp/domain_v1.rb index cd0f01bdf..5e6c286ca 100644 --- a/app/api/repp/domain_v1.rb +++ b/app/api/repp/domain_v1.rb @@ -32,7 +32,7 @@ module Repp domain = ident =~ /\A[0-9]+\z/ ? Domain.find_by(id: ident) : Domain.find_by_idn(ident) error! I18n.t('errors.messages.epp_domain_not_found'), 404 unless domain - error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.auth_info.eql? request.headers['Auth-Code'] + error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.transfer_code.eql? request.headers['Auth-Code'] contact_repp_json = proc{|contact| contact.as_json.slice("code", "name", "ident", "ident_type", "ident_country_code", "phone", "email", "street", "city", "zip","country_code", "statuses") diff --git a/app/models/ability.rb b/app/models/ability.rb index 2b25dc753..3883bbabf 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -54,14 +54,14 @@ class Ability # can(:create, :epp_request) # Epp::Domain - can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.auth_info == pw } + can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || pw.blank? ? true : d.transfer_code == pw } can(:check, Epp::Domain) can(:create, Epp::Domain) can(:renew, Epp::Domain) { |d| d.registrar_id == @user.registrar_id } - can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw } - can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw } - can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw } - can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw } + can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } + can(:transfer, Epp::Domain) { |d, pw| d.transfer_code == pw } + can(:view_password, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } + can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } # Epp::Contact can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw } diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 84c855a55..a0cc10faf 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -2,17 +2,17 @@ module Concerns::Domain::Transferable extend ActiveSupport::Concern included do - after_initialize :generate_auth_info, if: :new_record? + after_initialize :generate_transfer_code, if: :new_record? end def transfer(new_registrar) self.registrar = new_registrar - generate_auth_info + generate_transfer_code end private - def generate_auth_info - self.auth_info = SecureRandom.hex + def generate_transfer_code + self.transfer_code = SecureRandom.hex end end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 20e30fdde..3c0c423dc 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -100,7 +100,7 @@ class Epp::Domain < Domain [:puny_label, :too_long, { obj: 'name', val: name_puny }] ], '2201' => [ # Authorisation error - [:auth_info, :wrong_pw] + [:transfer_code, :wrong_pw] ], '2202' => [ [:base, :invalid_auth_information_reserved] @@ -182,7 +182,7 @@ class Epp::Domain < Domain # at[:domain_statuses_attributes] = domain_statuses_attrs(frame, action) pw = frame.css('authInfo > pw').text - at[:auth_info] = pw if pw.present? + at[:transfer_code] = pw if pw.present? if new_record? dnskey_frame = frame.css('extension create') @@ -722,7 +722,7 @@ class Epp::Domain < Domain if dt.approved? transfer_contacts(current_user.registrar_id) dt.notify_losing_registrar(old_contact_codes, old_registrant_code) - generate_auth_info + generate_transfer_code self.registrar = current_user.registrar end @@ -751,7 +751,7 @@ class Epp::Domain < Domain ) transfer_contacts(pt.transfer_to_id) - generate_auth_info + generate_transfer_code self.registrar = pt.transfer_to attach_legal_document(self.class.parse_legal_document_from_frame(frame)) @@ -872,7 +872,7 @@ class Epp::Domain < Domain # For domain transfer def authenticate(pw) - errors.add(:auth_info, :wrong_pw) if pw != auth_info + errors.add(:transfer_code, :wrong_pw) if pw != transfer_code errors.empty? end diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb index 6729fae0f..11a066b7a 100644 --- a/app/presenters/domain_presenter.rb +++ b/app/presenters/domain_presenter.rb @@ -1,5 +1,5 @@ class DomainPresenter - delegate :name, :auth_info, :registrant_name, :registrant_id, :registrant_code, to: :domain + delegate :name, :transfer_code, :registrant_name, :registrant_id, :registrant_code, to: :domain def initialize(domain:, view:) @domain = domain diff --git a/app/presenters/registrar/domain_list_csv_presenter.rb b/app/presenters/registrar/domain_list_csv_presenter.rb index 392109502..5b47cfdcf 100644 --- a/app/presenters/registrar/domain_list_csv_presenter.rb +++ b/app/presenters/registrar/domain_list_csv_presenter.rb @@ -19,7 +19,7 @@ class Registrar::DomainListCSVPresenter def header columns = %w( domain_name - auth_info + transfer_code registrant_name registrant_code expire_time @@ -33,7 +33,7 @@ class Registrar::DomainListCSVPresenter def domain_to_row(domain:) row = [] row[0] = domain.name - row[1] = domain.auth_info + row[1] = domain.transfer_code row[2] = domain.registrant_name row[3] = domain.registrant_code row[4] = domain.expire_date diff --git a/app/views/admin/domains/partials/_general.html.erb b/app/views/admin/domains/partials/_general.html.erb index ca33c476c..eeeef6eb5 100644 --- a/app/views/admin/domains/partials/_general.html.erb +++ b/app/views/admin/domains/partials/_general.html.erb @@ -16,9 +16,9 @@
<%= t(:registrar_name) %>
<%= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) %>
-
<%= Domain.human_attribute_name :auth_info %>
+
<%= Domain.human_attribute_name :transfer_code %>
- <%= tag :input, type: 'text', value: @domain.auth_info, readonly: true, + <%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true, class: 'form-control input-sm' %>
diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index ef283ab07..8bf169acd 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -55,7 +55,7 @@ xml.epp_head do if can? :view_password, @domain, @password xml.tag!('domain:authInfo') do - xml.tag!('domain:pw', @domain.auth_info) + xml.tag!('domain:pw', @domain.transfer_code) end end end diff --git a/app/views/registrant/domains/partials/_general.html.erb b/app/views/registrant/domains/partials/_general.html.erb index 486bee8be..72ae8aad7 100644 --- a/app/views/registrant/domains/partials/_general.html.erb +++ b/app/views/registrant/domains/partials/_general.html.erb @@ -16,9 +16,9 @@
<%= t(:registrar_name) %>
<%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %>
-
<%= Domain.human_attribute_name :auth_info %>
+
<%= Domain.human_attribute_name :transfer_code %>
- <%= tag :input, type: 'text', value: @domain.auth_info, readonly: true, + <%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true, class: 'form-control input-sm' %>
diff --git a/app/views/registrar/domains/partials/_general.html.erb b/app/views/registrar/domains/partials/_general.html.erb index 45cae00e6..3fb3a5df8 100644 --- a/app/views/registrar/domains/partials/_general.html.erb +++ b/app/views/registrar/domains/partials/_general.html.erb @@ -7,7 +7,7 @@
-
<%= Domain.human_attribute_name :auth_info %>
+
<%= Domain.human_attribute_name :transfer_code %>
<% if @data.css('pw').text.present? %> <%= tag(:input, type: 'text', value: @data.css('pw').text, readonly: true, diff --git a/config/locales/en.yml b/config/locales/en.yml index ea89e324a..e4389eed4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,7 +79,7 @@ en: period: not_a_number: 'Period is not a number' not_an_integer: 'Period must be an integer' - auth_info: + transfer_code: wrong_pw: 'Authorization error' domain_statuses: invalid: 'Statuses are invalid' diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 16c4f5d58..e56f38ebb 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -7,7 +7,7 @@ en: transfer_btn: Transfer csv: domain_name: Domain - auth_info: Auth info + transfer_code: Transfer code registrant_name: Registrant name registrant_code: Registrant code expire_time: Date of expiry diff --git a/db/migrate/20180121165304_rename_domains_auth_info_to_transfer_code.rb b/db/migrate/20180121165304_rename_domains_auth_info_to_transfer_code.rb new file mode 100644 index 000000000..3f543bb2c --- /dev/null +++ b/db/migrate/20180121165304_rename_domains_auth_info_to_transfer_code.rb @@ -0,0 +1,5 @@ +class RenameDomainsAuthInfoToTransferCode < ActiveRecord::Migration + def change + rename_column :domains, :auth_info, :transfer_code + end +end diff --git a/db/structure.sql b/db/structure.sql index d49004ee5..3f3c2b7f2 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -998,7 +998,7 @@ CREATE TABLE domains ( valid_from timestamp without time zone, valid_to timestamp without time zone, registrant_id integer NOT NULL, - auth_info character varying, + transfer_code character varying, created_at timestamp without time zone, updated_at timestamp without time zone, name_dirty character varying, @@ -5046,3 +5046,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180120182712'); INSERT INTO schema_migrations (version) VALUES ('20180120183441'); +INSERT INTO schema_migrations (version) VALUES ('20180121165304'); + diff --git a/doc/models_complete.svg b/doc/models_complete.svg index 9391a7f6d..0d8af5f9d 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -921,7 +921,7 @@ valid_from :datetime valid_to :datetime registrant_id :integer -auth_info :string +transfer_code :string created_at :datetime updated_at :datetime name_dirty :string diff --git a/doc/repp/v1/domain.md b/doc/repp/v1/domain.md index 319713660..adb9c4c8e 100644 --- a/doc/repp/v1/domain.md +++ b/doc/repp/v1/domain.md @@ -39,7 +39,7 @@ Content-Type: application/json "valid_from": "2015-09-09T09:11:14.861Z", "valid_to": "2016-09-09T09:11:14.861Z", "registrant_id": 1, - "auth_info": "98oiewslkfkd", + "transfer_code": "98oiewslkfkd", "created_at": "2015-09-09T09:11:14.861Z", "updated_at": "2015-09-09T09:11:14.860Z", "name_dirty": "domain0.ee", diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 042515f33..c3b67ba88 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -340,7 +340,7 @@ namespace :import do registered_at valid_from valid_to - auth_info + transfer_code created_at updated_at name_dirty diff --git a/spec/presenters/domain_presenter_spec.rb b/spec/presenters/domain_presenter_spec.rb index 1ae58c5c0..65f5efc93 100644 --- a/spec/presenters/domain_presenter_spec.rb +++ b/spec/presenters/domain_presenter_spec.rb @@ -151,7 +151,7 @@ RSpec.describe DomainPresenter do domain_delegatable_attributes = %i( name - auth_info + transfer_code registrant_name registrant_id registrant_code diff --git a/test/api/domain_transfers_test.rb b/test/api/domain_transfers_test.rb index c04e19b8b..40667dbaf 100644 --- a/test/api/domain_transfers_test.rb +++ b/test/api/domain_transfers_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest def test_post_to_domain_transfers - request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, authInfo: domains(:shop).auth_info }] } + request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, transferCode: domains(:shop).transfer_code }] } post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } assert_response :created diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 6b170b53b..7c7b429cf 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -3,7 +3,7 @@ shop: name_dirty: shop.test registrar: bestnames registrant: john - auth_info: 65078d5 + transfer_code: 65078d5 valid_to: 2010-07-05 period: 1 period_unit: m @@ -13,7 +13,7 @@ airport: name_dirty: airport.test registrar: bestnames registrant: john - auth_info: 55438j5 + transfer_code: 55438j5 valid_to: 2010-07-05 period: 1 period_unit: m @@ -23,7 +23,7 @@ library: name_dirty: library.test registrar: bestnames registrant: acme_ltd - auth_info: 45118f5 + transfer_code: 45118f5 valid_to: 2010-07-05 period: 1 period_unit: m diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index 97c1780e9..e0fdca33e 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -7,7 +7,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest def test_downloads_domain_list_as_csv expected_csv = <<-CSV.strip_heredoc - Domain,Auth info,Registrant name,Registrant code,Date of expiry + Domain,Transfer code,Registrant name,Registrant code,Date of expiry library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05 shop.test,65078d5,John,john-001,2010-07-05 airport.test,55438j5,John,john-001,2010-07-05 diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index 5a244138b..c01980601 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -9,28 +9,28 @@ class DomainTest < ActiveSupport::TestCase assert @domain.valid? end - def test_generates_random_auth_info_if_new + def test_generates_random_transfer_code_if_new domain = Domain.new another_domain = Domain.new - refute_empty domain.auth_info - refute_empty another_domain.auth_info - refute_equal domain.auth_info, another_domain.auth_info + refute_empty domain.transfer_code + refute_empty another_domain.transfer_code + refute_equal domain.transfer_code, another_domain.transfer_code end - def test_does_not_regenerate_auth_info_if_persisted - original_auth_info = @domain.auth_info + def test_does_not_regenerate_transfer_code_if_persisted + original_transfer_code = @domain.transfer_code @domain.save! @domain.reload - assert_equal original_auth_info, @domain.auth_info + assert_equal original_transfer_code, @domain.transfer_code end def test_transfers_domain - old_auth_info = @domain.auth_info + old_transfer_code = @domain.transfer_code new_registrar = registrars(:goodnames) @domain.transfer(new_registrar) assert_equal new_registrar, @domain.registrar - refute_same @domain.auth_info, old_auth_info + refute_same @domain.transfer_code, old_transfer_code end end From 222cf02d3cf482b221180e3801002cac5c2f8664 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 19:35:18 +0200 Subject: [PATCH 064/167] Remove unused translations --- config/locales/en.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index e4389eed4..438f4a616 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -328,7 +328,6 @@ en: edit_statuses: 'Edit statuses' contact_list: 'Contact list' create_new_contact: 'Create new contact' - domain_pw: 'Domain password' history: 'History' new_registrar: 'New registrar' @@ -476,7 +475,6 @@ en: blank: "Password can't be blank" username: 'Username' - password: 'Password' log_in: 'Log in' domains: 'Domains' register: 'Register' @@ -789,9 +787,6 @@ en: contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal' interfaces: 'Interfaces' - list_format_is_in_yaml: 'List format is in YAML' - if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.' - each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.' next: 'Next' previous: 'Previous' personal_domain_verification_url: 'Personal domain verification url' From a235db5e83f4134168be1b28ca779467b557202e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 20:45:32 +0200 Subject: [PATCH 065/167] Remove unused factory --- spec/factories/domain_transfer.rb | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 spec/factories/domain_transfer.rb diff --git a/spec/factories/domain_transfer.rb b/spec/factories/domain_transfer.rb deleted file mode 100644 index 4ecbfd084..000000000 --- a/spec/factories/domain_transfer.rb +++ /dev/null @@ -1,7 +0,0 @@ -FactoryBot.define do - factory :domain_transfer do - domain - transfer_from { FactoryBot.create(:registrar) } - transfer_to { FactoryBot.create(:registrar) } - end -end From 46c82b3d99fb3ef3fc0bfc3646975870430a83b1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 23:27:41 +0200 Subject: [PATCH 066/167] Update fixtures --- test/api/domain_transfers_test.rb | 2 +- test/fixtures/epp_sessions.yml | 10 ++++++++-- test/fixtures/users.yml | 14 +++++++++++--- test/integration/registrar/domains_test.rb | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/test/api/domain_transfers_test.rb b/test/api/domain_transfers_test.rb index 40667dbaf..6cd868314 100644 --- a/test/api/domain_transfers_test.rb +++ b/test/api/domain_transfers_test.rb @@ -14,6 +14,6 @@ class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest private def http_auth_key - ActionController::HttpAuthentication::Basic.encode_credentials(users(:api).username, users(:api).password) + ActionController::HttpAuthentication::Basic.encode_credentials(users(:api_bestnames).username, users(:api_bestnames).password) end end diff --git a/test/fixtures/epp_sessions.yml b/test/fixtures/epp_sessions.yml index 8a2104f8c..8cdaedb8c 100644 --- a/test/fixtures/epp_sessions.yml +++ b/test/fixtures/epp_sessions.yml @@ -1,3 +1,9 @@ -shop: +api_bestnames: + session_id: 1 registrar: bestnames - data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api)})) %> + data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api_bestnames)})) %> + +api_goodnames: + session_id: 2 + registrar: goodnames + data: <%= Base64.encode64(Marshal.dump({api_user_id: ActiveRecord::Fixtures.identify(:api_goodnames)})) %> diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index e07415d6f..e8e17b569 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,11 +1,19 @@ -api: - username: test - password: test +api_bestnames: + username: test_bestnames + password: testtest type: ApiUser registrar: bestnames roles: - super +api_goodnames: + username: test_goodnames + password: testtest + type: ApiUser + registrar: goodnames + roles: + - super + admin: username: test type: AdminUser diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index e0fdca33e..8c68387cb 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RegistrarDomainsTest < ActionDispatch::IntegrationTest def setup - login_as users(:api) + login_as users(:api_bestnames) end def test_downloads_domain_list_as_csv From 524854451a5dde06dcce19242af223ce052320a0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 21 Jan 2018 23:29:21 +0200 Subject: [PATCH 067/167] Add EPP domain:transfer test #660 --- test/integration/epp/domain_transfer_test.rb | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/integration/epp/domain_transfer_test.rb diff --git a/test/integration/epp/domain_transfer_test.rb b/test/integration/epp/domain_transfer_test.rb new file mode 100644 index 000000000..2bf733bd1 --- /dev/null +++ b/test/integration/epp/domain_transfer_test.rb @@ -0,0 +1,26 @@ +require 'test_helper' + +class Epp::DomainTransferTest < ActionDispatch::IntegrationTest + def test_transfers_domain + request_xml = <<-XML + + + + + + shop.test + + 65078d5 + + + + + + XML + + session_id = epp_sessions(:api_goodnames).session_id + post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + assert_response :ok + assert_equal registrars(:goodnames), domains(:shop).registrar + end +end From be057656e869d85e2a0da7f6e33b8e390cbcc11b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 13:03:34 +0200 Subject: [PATCH 068/167] Always require domain#transfer_code #660 --- app/models/domain.rb | 1 + ...180122105335_change_domains_transfer_code_to_not_null.rb | 5 +++++ db/structure.sql | 4 +++- test/models/domain_test.rb | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180122105335_change_domains_transfer_code_to_not_null.rb diff --git a/app/models/domain.rb b/app/models/domain.rb index 31ef08cca..3a120d214 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -104,6 +104,7 @@ class Domain < ActiveRecord::Base validates :name_dirty, domain_name: true, uniqueness: true validates :puny_label, length: { maximum: 63 } validates :period, presence: true, numericality: { only_integer: true } + validates :transfer_code, presence: true validate :validate_reservation def validate_reservation diff --git a/db/migrate/20180122105335_change_domains_transfer_code_to_not_null.rb b/db/migrate/20180122105335_change_domains_transfer_code_to_not_null.rb new file mode 100644 index 000000000..e4ee8fbc9 --- /dev/null +++ b/db/migrate/20180122105335_change_domains_transfer_code_to_not_null.rb @@ -0,0 +1,5 @@ +class ChangeDomainsTransferCodeToNotNull < ActiveRecord::Migration + def change + change_column_null :domains, :transfer_code, false + end +end diff --git a/db/structure.sql b/db/structure.sql index 3f3c2b7f2..8e7d649bf 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -998,7 +998,7 @@ CREATE TABLE domains ( valid_from timestamp without time zone, valid_to timestamp without time zone, registrant_id integer NOT NULL, - transfer_code character varying, + transfer_code character varying NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, name_dirty character varying, @@ -5048,3 +5048,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180120183441'); INSERT INTO schema_migrations (version) VALUES ('20180121165304'); +INSERT INTO schema_migrations (version) VALUES ('20180122105335'); + diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index c01980601..3d60ed515 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -9,6 +9,12 @@ class DomainTest < ActiveSupport::TestCase assert @domain.valid? end + def test_rejects_absent_transfer_code + @domain.transfer_code = nil + @domain.validate + assert @domain.invalid? + end + def test_generates_random_transfer_code_if_new domain = Domain.new another_domain = Domain.new From ed3ec0a82e153205da4725b65b05d45569b93bb8 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 15:02:47 +0200 Subject: [PATCH 069/167] Remove unused method #660 --- app/controllers/application_controller.rb | 7 ------- doc/controllers_complete.svg | 1 - 2 files changed, 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ff1e8eb26..87dabad01 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,13 +65,6 @@ class ApplicationController < ActionController::Base user_log_str(current_user) end - def depp_current_user - @depp_current_user ||= Depp::User.new( - tag: current_user.username, - password: current_user.password - ) - end - def user_log_str(user) user.nil? ? 'public' : user.id_role_username end diff --git a/doc/controllers_complete.svg b/doc/controllers_complete.svg index 1c9bc94ec..61ca0ec5f 100644 --- a/doc/controllers_complete.svg +++ b/doc/controllers_complete.svg @@ -441,7 +441,6 @@ after_sign_out_path_for api_user_log_str current_root_url -depp_current_user registrant_request? registrar_request? user_for_paper_trail From d64686777cb11b41ad94895f6198877a6945d677 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 16:21:54 +0200 Subject: [PATCH 070/167] Convert HAML to ERB --- app/views/registrar/domains/info.haml | 30 ------------- app/views/registrar/domains/info.html.erb | 53 +++++++++++++++++++++++ 2 files changed, 53 insertions(+), 30 deletions(-) delete mode 100644 app/views/registrar/domains/info.haml create mode 100644 app/views/registrar/domains/info.html.erb diff --git a/app/views/registrar/domains/info.haml b/app/views/registrar/domains/info.haml deleted file mode 100644 index e794382ed..000000000 --- a/app/views/registrar/domains/info.haml +++ /dev/null @@ -1,30 +0,0 @@ -- content_for :actions do - - if @data.css('pw').text.present? - = link_to(t(:edit), edit_registrar_domains_path(domain_name: params[:domain_name]), - class: 'btn btn-default') - = link_to(t(:renew), renew_registrar_domains_path(domain_name: params[:domain_name]), - class: 'btn btn-default') - = link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), - class: 'btn btn-default') - - else - = link_to(t(:transfer), transfer_registrar_domains_path(domain_name: params[:domain_name]), - class: 'btn btn-default') -= render 'shared/title', name: truncate(@data.css('name').text) - -.row - .col-sm-12 - - if @data.css('result').first['code'] == '1000' - .row - .col-md-12= render 'registrar/domains/partials/general' - .row - .col-md-12= render 'registrar/domains/partials/contacts' - .row - .col-md-12= render 'registrar/domains/partials/statuses' - .row - .col-md-12= render 'registrar/domains/partials/nameservers' - .row - .col-md-12= render 'registrar/domains/partials/dnskeys' - - else - .row - .col-sm-6 - %h1= t(:not_found) diff --git a/app/views/registrar/domains/info.html.erb b/app/views/registrar/domains/info.html.erb new file mode 100644 index 000000000..b251989f5 --- /dev/null +++ b/app/views/registrar/domains/info.html.erb @@ -0,0 +1,53 @@ +<% content_for :actions do %> + <% if @data.css('pw').text.present? %> + <%= link_to(t(:edit), edit_registrar_domains_path(domain_name: params[:domain_name]), + class: 'btn btn-default') %> + <%= link_to(t(:renew), renew_registrar_domains_path(domain_name: params[:domain_name]), + class: 'btn btn-default') %> + <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), + class: 'btn btn-default') %> + <% else %> + <%= link_to(t(:transfer), transfer_registrar_domains_path(domain_name: params[:domain_name]), + class: 'btn btn-default') %> + <% end %> +<% end %> +<%= render 'shared/title', name: truncate(@data.css('name').text) %> +
+
+ <% if @data.css('result').first['code'] == '1000' %> +
+
+ <%= render 'registrar/domains/partials/general' %> +
+
+
+
+ <%= render 'registrar/domains/partials/contacts' %> +
+
+
+
+ <%= render 'registrar/domains/partials/statuses' %> +
+
+
+
+ <%= render 'registrar/domains/partials/nameservers' %> +
+
+
+
+ <%= render 'registrar/domains/partials/dnskeys' %> +
+
+ <% else %> +
+
+

+ <%= t(:not_found) %> +

+
+
+ <% end %> +
+
From b11b6f7d8b117a20ce9446241b85ae152e893915 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 16:29:37 +0200 Subject: [PATCH 071/167] Extract domain transfers controller #660 --- .../registrar/domain_transfers_controller.rb | 15 +++++++++++++++ app/controllers/registrar/domains_controller.rb | 10 ---------- .../create.html.erb} | 0 .../new.html.erb} | 2 +- app/views/registrar/domains/index.html.erb | 2 +- app/views/registrar/domains/info.html.erb | 2 +- config/locales/registrar/domain_transfers.en.yml | 8 ++++++++ config/locales/registrar/domains.en.yml | 6 ------ config/routes.rb | 2 +- test/integration/registrar/domains_test.rb | 6 ++++++ 10 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 app/controllers/registrar/domain_transfers_controller.rb rename app/views/registrar/{domains/transfer.html.erb => domain_transfers/create.html.erb} (100%) rename app/views/registrar/{domains/transfer_index.html.erb => domain_transfers/new.html.erb} (96%) create mode 100644 config/locales/registrar/domain_transfers.en.yml diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb new file mode 100644 index 000000000..89c942845 --- /dev/null +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -0,0 +1,15 @@ +class Registrar + class DomainTransfersController < DeppController + before_action do + authorize! :transfer, Depp::Domain + end + + def new + end + + def create + domain = Depp::Domain.new(current_user: depp_current_user) + @data = domain.transfer(params) + end + end +end diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index 76467ce79..78a5b24b6 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -146,16 +146,6 @@ class Registrar end end - def transfer - authorize! :transfer, Depp::Domain - if request.post? && params[:domain_name] - @data = @domain.transfer(params) - render 'transfer_index' and return unless response_ok? - else - render 'transfer_index' - end - end - def search_contacts authorize! :create, Depp::Domain diff --git a/app/views/registrar/domains/transfer.html.erb b/app/views/registrar/domain_transfers/create.html.erb similarity index 100% rename from app/views/registrar/domains/transfer.html.erb rename to app/views/registrar/domain_transfers/create.html.erb diff --git a/app/views/registrar/domains/transfer_index.html.erb b/app/views/registrar/domain_transfers/new.html.erb similarity index 96% rename from app/views/registrar/domains/transfer_index.html.erb rename to app/views/registrar/domain_transfers/new.html.erb index bd43f055f..dd847e6c2 100644 --- a/app/views/registrar/domains/transfer_index.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -6,7 +6,7 @@
- <%= form_tag transfer_registrar_domains_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %> + <%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %>
<%= label_tag :domain_name, t(:name), class: 'required' %> diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index a8680b7cf..a62619ca4 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -6,7 +6,7 @@
<%= link_to t('.new_btn'), new_registrar_domain_path, class: 'btn btn-primary' %> - <%= link_to t('.transfer_btn'), transfer_registrar_domains_path, class: 'btn btn-default' %> + <%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path, class: 'btn btn-default' %>
diff --git a/app/views/registrar/domains/info.html.erb b/app/views/registrar/domains/info.html.erb index b251989f5..ee7329cea 100644 --- a/app/views/registrar/domains/info.html.erb +++ b/app/views/registrar/domains/info.html.erb @@ -7,7 +7,7 @@ <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), class: 'btn btn-default') %> <% else %> - <%= link_to(t(:transfer), transfer_registrar_domains_path(domain_name: params[:domain_name]), + <%= link_to(t(:transfer), new_registrar_domain_transfer_path(domain_name: params[:domain_name]), class: 'btn btn-default') %> <% end %> <% end %> diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml new file mode 100644 index 000000000..1e507c27b --- /dev/null +++ b/config/locales/registrar/domain_transfers.en.yml @@ -0,0 +1,8 @@ +en: + registrar: + domain_transfers: + new: + header: Domain transfer + + create: + header: Domain transfer diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index e56f38ebb..1e6f58326 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -12,12 +12,6 @@ en: registrant_code: Registrant code expire_time: Date of expiry - transfer_index: - header: Domain transfer - - transfer: - header: Domain transfer - search_form: download_btn: Download as CSV reset_btn: Reset diff --git a/config/routes.rb b/config/routes.rb index 242028cbb..c49399573 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,7 +54,6 @@ Rails.application.routes.draw do post 'update', as: 'update' post 'destroy', as: 'destroy' get 'renew' - match 'transfer', via: [:post, :get] get 'edit' get 'info' get 'check' @@ -62,6 +61,7 @@ Rails.application.routes.draw do get 'search_contacts' end end + resources :domain_transfers, only: %i[new create] resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do member do diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index 8c68387cb..d81321233 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -29,4 +29,10 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest assert_text 'Transfer requested at: 2010-07-05 10:30:00' end + + def test_prefills_domain_transfer_form + visit info_registrar_domains_url(domain_name: 'airport.test') + click_link 'Transfer' + assert_field 'domain_name', with: 'airport.test' + end end From 09b013f73f09280ff040a9c46ba75a48b4970e97 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 16:31:30 +0200 Subject: [PATCH 072/167] Rename "Domain password" to "Domain transfer code" in EPP spec Original change in 4b836f1476dc8c3dacdce1f2e6718b6458472d1b #660 --- doc/epp/domain.md | 4 ++-- doc/epp/keyrelay.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/epp/domain.md b/doc/epp/domain.md index cd9de65b8..856588e88 100644 --- a/doc/epp/domain.md +++ b/doc/epp/domain.md @@ -115,7 +115,7 @@ Domain name mapping protocol short version: 1 Domain name. Can contain unicode characters. Attribute: hosts="all / del / sub / none" 0-1 Required if registrar is not the owner of the domain. - 1 Domain password. Attribute: roid="String" + 1 Domain transfer code. Attribute: roid="String" 0-1 Client transaction id [EXAMPLE REQUEST AND RESPONSE](/doc/epp-examples.md#epp-domain-with-valid-domain-returns-domain-info) @@ -148,7 +148,7 @@ Domain name mapping protocol short version: 1 Attribute: xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd" 1 Domain name. Can contain unicode characters. 1 - 1 Domain password. Attribute: roid="String" + 1 Domain transfer code. Attribute: roid="String" 0-1 0-1 Attribute: xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" 0-1 Base64 encoded document. diff --git a/doc/epp/keyrelay.md b/doc/epp/keyrelay.md index 804fed6db..cda7dfa56 100644 --- a/doc/epp/keyrelay.md +++ b/doc/epp/keyrelay.md @@ -14,7 +14,7 @@ NB! Keyrelay not implemented. 1 Allowed values: 3, 5, 6, 7, 8, 10, 13, 14 1 Public key 1 - 1 Domain password. Attribute: roid="String" + 1 Domain transfer code. Attribute: roid="String" 1 0-1 Relative expiry duration (ISO8601). Required if ext:absolute is not specified From 76e0b3b80e51b3b730a44791a12b19e1c462a170 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 16:36:34 +0200 Subject: [PATCH 073/167] Extract translation #660 --- app/views/registrar/domain_transfers/new.html.erb | 2 +- app/views/registrar/domains/info.html.erb | 4 ++-- config/locales/en.yml | 1 - config/locales/registrar/domain_transfers.en.yml | 1 + config/locales/registrar/domains.en.yml | 3 +++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index dd847e6c2..3e277aa39 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -37,7 +37,7 @@
diff --git a/app/views/registrar/domains/info.html.erb b/app/views/registrar/domains/info.html.erb index ee7329cea..1fcfc23c3 100644 --- a/app/views/registrar/domains/info.html.erb +++ b/app/views/registrar/domains/info.html.erb @@ -7,8 +7,8 @@ <%= link_to(t(:delete), delete_registrar_domains_path(domain_name: params[:domain_name]), class: 'btn btn-default') %> <% else %> - <%= link_to(t(:transfer), new_registrar_domain_transfer_path(domain_name: params[:domain_name]), - class: 'btn btn-default') %> + <%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path(domain_name: params[:domain_name]), + class: 'btn btn-default' %> <% end %> <% end %> <%= render 'shared/title', name: truncate(@data.css('name').text) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 438f4a616..c82a10d24 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -520,7 +520,6 @@ en: new: New renew_domain: 'Renew domain' cur_exp_date: 'curExpDate' - transfer: 'Transfer' query: 'Query' reject: 'Reject' approve: 'Approve' diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml index 1e507c27b..bf1a4a8c9 100644 --- a/config/locales/registrar/domain_transfers.en.yml +++ b/config/locales/registrar/domain_transfers.en.yml @@ -3,6 +3,7 @@ en: domain_transfers: new: header: Domain transfer + transfer_btn: Transfer create: header: Domain transfer diff --git a/config/locales/registrar/domains.en.yml b/config/locales/registrar/domains.en.yml index 1e6f58326..6ff110694 100644 --- a/config/locales/registrar/domains.en.yml +++ b/config/locales/registrar/domains.en.yml @@ -12,6 +12,9 @@ en: registrant_code: Registrant code expire_time: Date of expiry + info: + transfer_btn: Transfer + search_form: download_btn: Download as CSV reset_btn: Reset From a4c11996f2d010f34c246d3d5d19af3713dd7ffb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 16:38:47 +0200 Subject: [PATCH 074/167] Extract partial #660 --- .../registrar/domain_transfers/_form.html.erb | 38 +++++++++++++++++++ .../registrar/domain_transfers/new.html.erb | 37 +----------------- .../locales/registrar/domain_transfers.en.yml | 4 +- 3 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 app/views/registrar/domain_transfers/_form.html.erb diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/_form.html.erb new file mode 100644 index 000000000..1377ec427 --- /dev/null +++ b/app/views/registrar/domain_transfers/_form.html.erb @@ -0,0 +1,38 @@ +<%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %> +
+
+ <%= label_tag :domain_name, t(:name), class: 'required' %> +
+
+ <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), + autocomplete: 'off', autofocus: true, required: true %> +
+
+ +
+
+ <%= label_tag :password, t(:password), class: 'required' %> +
+
+ <%= text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off', + required: true %> +
+
+ +
+
+ <%= label_tag 'legal_document', t(:legal_document) %> +
+
+ <%= file_field_tag 'legal_document' %> +
+
+ +
+
+ +
+
+<% end %> diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index 3e277aa39..cc1cfb4a8 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -6,41 +6,6 @@
- <%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %> -
-
- <%= label_tag :domain_name, t(:name), class: 'required' %> -
-
- <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', autofocus: true, required: true %> -
-
- -
-
- <%= label_tag :password, t(:password), class: 'required' %> -
-
- <%= text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off', required: true %> -
-
- -
-
- <%= label_tag 'legal_document', t(:legal_document) %> -
-
- <%= file_field_tag 'legal_document' %> -
-
- -
-
- -
-
- <% end %> + <%= render 'form' %>
diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml index bf1a4a8c9..8c37aa686 100644 --- a/config/locales/registrar/domain_transfers.en.yml +++ b/config/locales/registrar/domain_transfers.en.yml @@ -3,7 +3,9 @@ en: domain_transfers: new: header: Domain transfer - transfer_btn: Transfer create: header: Domain transfer + + form: + transfer_btn: Transfer From 07900ed807a8cc1c02947696ab51345a9ffb4322 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:12:35 +0200 Subject: [PATCH 075/167] Rename "Domain password" to "Domain transfer code" Original change in 4b836f1476dc8c3dacdce1f2e6718b6458472d1b #660 --- app/models/depp/domain.rb | 2 +- app/views/registrar/domain_transfers/_form.html.erb | 4 ++-- test/integration/registrar/domains_test.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index 1351b2672..0032fd958 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -118,7 +118,7 @@ module Depp current_user.request(epp_xml.transfer({ name: { value: params[:domain_name] }, - authInfo: { pw: { value: params[:password] } } + authInfo: { pw: { value: params[:transfer_code] } } }, op, Domain.construct_custom_params_hash(params))) end diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/_form.html.erb index 1377ec427..f9ca8ce89 100644 --- a/app/views/registrar/domain_transfers/_form.html.erb +++ b/app/views/registrar/domain_transfers/_form.html.erb @@ -11,10 +11,10 @@
- <%= label_tag :password, t(:password), class: 'required' %> + <%= label_tag :transfer_code, nil, class: 'required' %>
- <%= text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off', + <%= text_field_tag :transfer_code, params[:transfer_code], class: 'form-control', autocomplete: 'off', required: true %>
diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index d81321233..415d92e90 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -24,7 +24,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest visit registrar_domains_url click_link 'Transfer' fill_in 'Name', with: 'shop.test' - fill_in 'Password', with: '65078d5' + fill_in 'Transfer code', with: '65078d5' click_button 'Transfer' assert_text 'Transfer requested at: 2010-07-05 10:30:00' From aeae0ac8d5fa10429bd8bd69a58ca699a514b825 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:13:23 +0200 Subject: [PATCH 076/167] Graceful domain transfer #660 --- app/controllers/registrar/domain_transfers_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 89c942845..06e91b93a 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -10,6 +10,7 @@ class Registrar def create domain = Depp::Domain.new(current_user: depp_current_user) @data = domain.transfer(params) + render :new unless response_ok? end end end From 9fa3948c01fb4484160709895136eea55723b6c7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:13:38 +0200 Subject: [PATCH 077/167] Add admin domain details test #660 --- test/integration/admin/domains_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/integration/admin/domains_test.rb diff --git a/test/integration/admin/domains_test.rb b/test/integration/admin/domains_test.rb new file mode 100644 index 000000000..1dfb0dfd1 --- /dev/null +++ b/test/integration/admin/domains_test.rb @@ -0,0 +1,13 @@ +require 'test_helper' + +class AdminDomainsTestTest < ActionDispatch::IntegrationTest + def setup + login_as users(:admin) + end + + def test_shows_details + domain = domains(:shop) + visit admin_domain_path(domain) + assert_field nil, with: domain.transfer_code + end +end From c34753f3e34fbe7cc4ff31bf7460286bafec7403 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:14:02 +0200 Subject: [PATCH 078/167] Update .reek #660 --- .reek | 1 - 1 file changed, 1 deletion(-) diff --git a/.reek b/.reek index 70ddddd1c..949072761 100644 --- a/.reek +++ b/.reek @@ -209,7 +209,6 @@ DuplicateMethodCall: - 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 From bcad54aa8425107c0a14697098cb3706fbd8f9c9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:20:32 +0200 Subject: [PATCH 079/167] Clean up HTML #660 --- app/views/registrar/domain_transfers/create.html.erb | 4 +--- app/views/registrar/domain_transfers/new.html.erb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/registrar/domain_transfers/create.html.erb b/app/views/registrar/domain_transfers/create.html.erb index 676385966..bf258e476 100644 --- a/app/views/registrar/domain_transfers/create.html.erb +++ b/app/views/registrar/domain_transfers/create.html.erb @@ -1,7 +1,5 @@
diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index cc1cfb4a8..d72a85ed4 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -1,7 +1,5 @@
From 928f2401eb671fc71152f50a188a3693cd157904 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:21:07 +0200 Subject: [PATCH 080/167] Improve UI #660 --- app/views/registrar/domain_transfers/_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/_form.html.erb index f9ca8ce89..d4720f569 100644 --- a/app/views/registrar/domain_transfers/_form.html.erb +++ b/app/views/registrar/domain_transfers/_form.html.erb @@ -1,11 +1,11 @@ <%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %>
- <%= label_tag :domain_name, t(:name), class: 'required' %> + <%= label_tag :domain_name, nil, class: 'required' %>
- <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), - autocomplete: 'off', autofocus: true, required: true %> + <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', autocomplete: 'off', + autofocus: true, required: true %>
From e1b6af03db986244ba67ae31cdf03e6e488480b3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 22 Jan 2018 18:23:11 +0200 Subject: [PATCH 081/167] Remove autocomplete=off #660 --- app/views/registrar/domain_transfers/_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/_form.html.erb index d4720f569..beba0c12c 100644 --- a/app/views/registrar/domain_transfers/_form.html.erb +++ b/app/views/registrar/domain_transfers/_form.html.erb @@ -4,8 +4,8 @@ <%= label_tag :domain_name, nil, class: 'required' %>
- <%= text_field_tag :domain_name, params[:domain_name], class: 'form-control', autocomplete: 'off', - autofocus: true, required: true %> + <%= text_field_tag :domain_name, params[:domain_name], autofocus: true, required: true, + class: 'form-control' %>
From 40d64fb65b31cd1d38217c0cccec9b37200bc650 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 14:47:21 +0200 Subject: [PATCH 082/167] Add `contacts.copy_from_id` foreign key #660 --- .../20180123124342_add_contacts_copy_from_id_fk.rb | 5 +++++ db/structure.sql | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb diff --git a/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb b/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb new file mode 100644 index 000000000..b1f694bf1 --- /dev/null +++ b/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb @@ -0,0 +1,5 @@ +class AddContactsCopyFromIdFk < ActiveRecord::Migration + def change + add_foreign_key :contacts, :contacts, column: :copy_from_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 8e7d649bf..85377cf65 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4484,6 +4484,14 @@ ALTER TABLE ONLY account_activities ADD CONSTRAINT fk_rails_b80dbb973d FOREIGN KEY (bank_transaction_id) REFERENCES bank_transactions(id); +-- +-- Name: fk_rails_c107909cf3; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY contacts + ADD CONSTRAINT fk_rails_c107909cf3 FOREIGN KEY (copy_from_id) REFERENCES contacts(id); + + -- -- Name: fk_rails_c9f635c0b3; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5050,3 +5058,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180121165304'); INSERT INTO schema_migrations (version) VALUES ('20180122105335'); +INSERT INTO schema_migrations (version) VALUES ('20180123124342'); + From d801e1829944d190fb7bd8c7ca359e4dcbd2c9e0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 16:19:28 +0200 Subject: [PATCH 083/167] Remove unused attribute #660 --- .reek | 1 - app/models/contact.rb | 1 - app/models/epp/domain.rb | 1 - 3 files changed, 3 deletions(-) diff --git a/.reek b/.reek index 949072761..66578b0aa 100644 --- a/.reek +++ b/.reek @@ -1091,7 +1091,6 @@ Attribute: - BankStatement#th6_file - Versions#version_loader - Contact#deliver_emails - - Contact#domain_transfer - Contact#domains_present - Contact#legal_document_id - Counter#value diff --git a/app/models/contact.rb b/app/models/contact.rb index 61a82ae0a..59ead2d77 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -79,7 +79,6 @@ class Contact < ActiveRecord::Base PASSPORT = 'passport' attr_accessor :deliver_emails - attr_accessor :domain_transfer # hack but solves problem faster # # STATUSES diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 3c0c423dc..97eac4e02 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -655,7 +655,6 @@ class Epp::Domain < Domain oc.registrar_id = registrar_id oc.copy_from_id = c.id oc.generate_code - oc.domain_transfer = true oc.remove_address unless Contact.address_processing? oc.save!(validate: false) oc From b620793e974bf509ae922b2682d9cf3804385969 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 16:21:31 +0200 Subject: [PATCH 084/167] Describe intention clearer #660 --- app/models/concerns/domain/transferable.rb | 4 +++- app/models/epp/domain.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index a0cc10faf..939244e75 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -7,7 +7,7 @@ module Concerns::Domain::Transferable def transfer(new_registrar) self.registrar = new_registrar - generate_transfer_code + regenerate_transfer_code end private @@ -15,4 +15,6 @@ module Concerns::Domain::Transferable def generate_transfer_code self.transfer_code = SecureRandom.hex end + + alias_method :regenerate_transfer_code, :generate_transfer_code end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 97eac4e02..f8a6024ea 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -721,7 +721,7 @@ class Epp::Domain < Domain if dt.approved? transfer_contacts(current_user.registrar_id) dt.notify_losing_registrar(old_contact_codes, old_registrant_code) - generate_transfer_code + regenerate_transfer_code self.registrar = current_user.registrar end @@ -750,7 +750,7 @@ class Epp::Domain < Domain ) transfer_contacts(pt.transfer_to_id) - generate_transfer_code + regenerate_transfer_code self.registrar = pt.transfer_to attach_legal_document(self.class.parse_legal_document_from_frame(frame)) From a9f522642cc3a800f29ba3df3cfd47810bdcbb56 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 16:27:31 +0200 Subject: [PATCH 085/167] Fix domain transfer #660 --- app/controllers/registrar/domain_transfers_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 06e91b93a..43d40e70e 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -8,6 +8,7 @@ class Registrar end def create + params[:request] = true # EPP domain:transfer "op" attribute domain = Depp::Domain.new(current_user: depp_current_user) @data = domain.transfer(params) render :new unless response_ok? From c586932418b7546c6ec360ebee13a3b834901c05 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 16:32:03 +0200 Subject: [PATCH 086/167] Add domain transfer batch form #660 --- .../domain_transfers/form/_batch.html.erb | 18 +++++++++++++++++ .../{_form.html.erb => form/_single.html.erb} | 7 +++---- .../registrar/domain_transfers/new.html.erb | 20 ++++++++++++++++++- .../locales/registrar/domain_transfers.en.yml | 8 +++++++- 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 app/views/registrar/domain_transfers/form/_batch.html.erb rename app/views/registrar/domain_transfers/{_form.html.erb => form/_single.html.erb} (79%) diff --git a/app/views/registrar/domain_transfers/form/_batch.html.erb b/app/views/registrar/domain_transfers/form/_batch.html.erb new file mode 100644 index 000000000..d6953dd05 --- /dev/null +++ b/app/views/registrar/domain_transfers/form/_batch.html.erb @@ -0,0 +1,18 @@ +<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %> +
+
+ <%= label_tag 'file' %> +
+
+ <%= file_field_tag 'file' %> +
+
+ +
+
+ +
+
+<% end %> diff --git a/app/views/registrar/domain_transfers/_form.html.erb b/app/views/registrar/domain_transfers/form/_single.html.erb similarity index 79% rename from app/views/registrar/domain_transfers/_form.html.erb rename to app/views/registrar/domain_transfers/form/_single.html.erb index beba0c12c..8a9488580 100644 --- a/app/views/registrar/domain_transfers/_form.html.erb +++ b/app/views/registrar/domain_transfers/form/_single.html.erb @@ -1,4 +1,4 @@ -<%= form_tag registrar_domain_transfers_path, class: 'form-horizontal', multipart: true, autocomplete: 'off' do %> +<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
<%= label_tag :domain_name, nil, class: 'required' %> @@ -14,8 +14,7 @@ <%= label_tag :transfer_code, nil, class: 'required' %>
- <%= text_field_tag :transfer_code, params[:transfer_code], class: 'form-control', autocomplete: 'off', - required: true %> + <%= text_field_tag :transfer_code, params[:transfer_code], class: 'form-control', required: true %>
@@ -30,7 +29,7 @@
-
diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index d72a85ed4..28e196a83 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -4,6 +4,24 @@
- <%= render 'form' %> + + +
+
+ <%= render 'registrar/domain_transfers/form/single' %> +
+ +
+ <%= render 'registrar/domain_transfers/form/batch' %> +
+
diff --git a/config/locales/registrar/domain_transfers.en.yml b/config/locales/registrar/domain_transfers.en.yml index 8c37aa686..bf93e562f 100644 --- a/config/locales/registrar/domain_transfers.en.yml +++ b/config/locales/registrar/domain_transfers.en.yml @@ -3,9 +3,15 @@ en: domain_transfers: new: header: Domain transfer + single: One by one + batch: Batch create: header: Domain transfer form: - transfer_btn: Transfer + single: + transfer_btn: Transfer + + batch: + transfer_btn: Transfer From a5db4e3bfb03f15848ccd55a133826e3a313520e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 16:41:10 +0200 Subject: [PATCH 087/167] Pull up methods #660 --- .reek | 7 ---- app/models/concerns/domain/transferable.rb | 48 ++++++++++++++++++++++ app/models/epp/domain.rb | 40 ------------------ test/models/domain_test.rb | 16 ++++++++ 4 files changed, 64 insertions(+), 47 deletions(-) diff --git a/.reek b/.reek index 66578b0aa..4d3bfd449 100644 --- a/.reek +++ b/.reek @@ -103,13 +103,11 @@ UncommunicativeVariableName: - 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 @@ -317,7 +315,6 @@ DuplicateMethodCall: - 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 @@ -795,7 +792,6 @@ TooManyStatements: - 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 @@ -811,7 +807,6 @@ TooManyStatements: - Epp::Domain#reject_transfer - Epp::Domain#renew - Epp::Domain#transfer - - Epp::Domain#transfer_domain_contacts - Epp::Domain#update - Epp::Domain#validate_contacts - Invoice#cancel @@ -881,7 +876,6 @@ UtilityFunction: - 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 @@ -956,7 +950,6 @@ FeatureEnvy: - 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 diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 939244e75..954370e76 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -6,8 +6,18 @@ module Concerns::Domain::Transferable end def transfer(new_registrar) + old_registrar = registrar + self.registrar = new_registrar regenerate_transfer_code + + domain_transfers.create!( + transfer_requested_at: Time.zone.now, + transfer_from: old_registrar, + transfer_to: new_registrar + ) + + transfer_contacts(new_registrar.id) end private @@ -16,5 +26,43 @@ module Concerns::Domain::Transferable self.transfer_code = SecureRandom.hex end + def transfer_contacts(registrar_id) + transfer_registrant(registrar_id) + transfer_domain_contacts(registrar_id) + end + + def transfer_registrant(registrar_id) + return if registrant.registrar_id == registrar_id + self.registrant_id = copy_and_transfer_contact(registrant_id, registrar_id).id + end + + def transfer_domain_contacts(registrar_id) + copied_ids = [] + contacts.each do |c| + next if copied_ids.include?(c.id) || c.registrar_id == registrar_id + + if registrant_id_was == c.id # registrant was copied previously, do not copy it again + oc = OpenStruct.new(id: registrant_id) + else + oc = copy_and_transfer_contact(c.id, registrar_id) + end + + domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround + copied_ids << c.id + end + end + + def copy_and_transfer_contact(contact_id, registrar_id) + c = Contact.find(contact_id) # n+1 workaround + oc = c.deep_clone + oc.code = nil + oc.registrar_id = registrar_id + oc.copy_from_id = c.id + oc.generate_code + oc.remove_address unless Contact.address_processing? + oc.save!(validate: false) + oc + end + alias_method :regenerate_transfer_code, :generate_transfer_code end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index f8a6024ea..8791a6126 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -641,46 +641,6 @@ class Epp::Domain < Domain end end - # TODO: Eager load problems here. Investigate how it's possible not to query contact again - # Check if versioning works with update_column - def transfer_contacts(registrar_id) - transfer_registrant(registrar_id) - transfer_domain_contacts(registrar_id) - end - - def copy_and_transfer_contact(contact_id, registrar_id) - c = Contact.find(contact_id) # n+1 workaround - oc = c.deep_clone - oc.code = nil - oc.registrar_id = registrar_id - oc.copy_from_id = c.id - oc.generate_code - oc.remove_address unless Contact.address_processing? - oc.save!(validate: false) - oc - end - - def transfer_registrant(registrar_id) - return if registrant.registrar_id == registrar_id - self.registrant_id = copy_and_transfer_contact(registrant_id, registrar_id).id - end - - def transfer_domain_contacts(registrar_id) - copied_ids = [] - contacts.each do |c| - next if copied_ids.include?(c.id) || c.registrar_id == registrar_id - - if registrant_id_was == c.id # registrant was copied previously, do not copy it again - oc = OpenStruct.new(id: registrant_id) - else - oc = copy_and_transfer_contact(c.id, registrar_id) - end - - domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround - copied_ids << c.id - end - end - # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index 3d60ed515..3cbfe880d 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -39,4 +39,20 @@ class DomainTest < ActiveSupport::TestCase assert_equal new_registrar, @domain.registrar refute_same @domain.transfer_code, old_transfer_code end + + def test_transfer_creates_domain_transfer_object + new_registrar = registrars(:goodnames) + + assert_difference 'DomainTransfer.count' do + @domain.transfer(new_registrar) + end + end + + def test_transfer_copies_contacts + new_registrar = registrars(:goodnames) + + assert_difference 'Contact.count', 2 do + @domain.transfer(new_registrar) + end + end end From 44332ffb1f477550528fe02af1e071257aa2fe83 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 17:49:03 +0200 Subject: [PATCH 088/167] Rename `contacts.copy_from_id` to `original_id` Add association #660 --- app/models/concerns/domain/transferable.rb | 2 +- app/models/contact.rb | 1 + ...123154407_rename_contacts_copy_from_id_to_original_id.rb | 5 +++++ db/structure.sql | 6 ++++-- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180123154407_rename_contacts_copy_from_id_to_original_id.rb diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 954370e76..c7b36c4bd 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -57,7 +57,7 @@ module Concerns::Domain::Transferable oc = c.deep_clone oc.code = nil oc.registrar_id = registrar_id - oc.copy_from_id = c.id + oc.original = c oc.generate_code oc.remove_address unless Contact.address_processing? oc.save!(validate: false) diff --git a/app/models/contact.rb b/app/models/contact.rb index 59ead2d77..7edef09ea 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -3,6 +3,7 @@ class Contact < ActiveRecord::Base include EppErrors include UserEvents + belongs_to :original, class_name: self.name belongs_to :registrar, required: true has_many :domain_contacts has_many :domains, through: :domain_contacts diff --git a/db/migrate/20180123154407_rename_contacts_copy_from_id_to_original_id.rb b/db/migrate/20180123154407_rename_contacts_copy_from_id_to_original_id.rb new file mode 100644 index 000000000..347137507 --- /dev/null +++ b/db/migrate/20180123154407_rename_contacts_copy_from_id_to_original_id.rb @@ -0,0 +1,5 @@ +class RenameContactsCopyFromIdToOriginalId < ActiveRecord::Migration + def change + rename_column :contacts, :copy_from_id, :original_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 85377cf65..1ba85fc02 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -668,7 +668,7 @@ CREATE TABLE contacts ( statuses character varying[] DEFAULT '{}'::character varying[], status_notes hstore, legacy_history_id integer, - copy_from_id integer, + original_id integer, ident_updated_at timestamp without time zone, upid integer, up_date timestamp without time zone @@ -4489,7 +4489,7 @@ ALTER TABLE ONLY account_activities -- ALTER TABLE ONLY contacts - ADD CONSTRAINT fk_rails_c107909cf3 FOREIGN KEY (copy_from_id) REFERENCES contacts(id); + ADD CONSTRAINT fk_rails_c107909cf3 FOREIGN KEY (original_id) REFERENCES contacts(id); -- @@ -5060,3 +5060,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180122105335'); INSERT INTO schema_migrations (version) VALUES ('20180123124342'); +INSERT INTO schema_migrations (version) VALUES ('20180123154407'); + From f5d0520ab24413508142c1c10c5e9524337ef9cf Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:19:09 +0200 Subject: [PATCH 089/167] Remove empty file --- app/assets/stylesheets/admin-manifest.sass | 1 - app/assets/stylesheets/registrant-manifest.sass | 1 - app/assets/stylesheets/registrar-manifest.sass | 1 - app/assets/stylesheets/shared/general-manifest.sass | 0 4 files changed, 3 deletions(-) delete mode 100644 app/assets/stylesheets/shared/general-manifest.sass diff --git a/app/assets/stylesheets/admin-manifest.sass b/app/assets/stylesheets/admin-manifest.sass index 4dabdad0c..8a577df91 100644 --- a/app/assets/stylesheets/admin-manifest.sass +++ b/app/assets/stylesheets/admin-manifest.sass @@ -1,4 +1,3 @@ -//= require 'shared/general-manifest' //= require 'admin/admin-bootstrap' //= require 'jquery-ui/datepicker' //= require 'select2' diff --git a/app/assets/stylesheets/registrant-manifest.sass b/app/assets/stylesheets/registrant-manifest.sass index 75eafe582..384b4ba9a 100644 --- a/app/assets/stylesheets/registrant-manifest.sass +++ b/app/assets/stylesheets/registrant-manifest.sass @@ -1,4 +1,3 @@ -//= require 'shared/general-manifest' //= require 'registrant/registrant-bootstrap' //= require 'jquery-ui/datepicker' //= require 'select2' diff --git a/app/assets/stylesheets/registrar-manifest.sass b/app/assets/stylesheets/registrar-manifest.sass index 731b6c630..e0837f78d 100644 --- a/app/assets/stylesheets/registrar-manifest.sass +++ b/app/assets/stylesheets/registrar-manifest.sass @@ -1,4 +1,3 @@ -//= require 'shared/general-manifest' //= require 'registrar/registrar-bootstrap' //= require 'jquery-ui/datepicker' //= require 'select2' diff --git a/app/assets/stylesheets/shared/general-manifest.sass b/app/assets/stylesheets/shared/general-manifest.sass deleted file mode 100644 index e69de29bb..000000000 From 4bfe01129fb2d0f9eba23404c3e44474b64e78e0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:21:15 +0200 Subject: [PATCH 090/167] Improve tabs CSS --- app/assets/stylesheets/shared/general-bootstrap.sass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/shared/general-bootstrap.sass b/app/assets/stylesheets/shared/general-bootstrap.sass index 29a605cb7..8f382b017 100644 --- a/app/assets/stylesheets/shared/general-bootstrap.sass +++ b/app/assets/stylesheets/shared/general-bootstrap.sass @@ -65,3 +65,6 @@ .required:after content: "*" margin: 0 0 0 1px + +.tab-content + padding-top: 15px From 0608c3f5e5d83bd70b4d2818dab7dfe5bf739765 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:21:53 +0200 Subject: [PATCH 091/167] Update fixtures --- test/fixtures/contacts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index a6262f9c4..578ba5920 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -1,5 +1,7 @@ john: name: John + email: john@inbox.test + phone: '+555.555' ident: 1234 ident_type: priv ident_country_code: US @@ -8,6 +10,8 @@ john: jane: name: Jane + email: jane@mail.test + phone: '+555.555' ident: 1234 ident_type: priv ident_country_code: US @@ -16,6 +20,8 @@ jane: acme_ltd: name: Acme Ltd + email: acme@outlook.test + phone: '+555.555' ident: 1234 ident_type: org registrar: bestnames From cbccb6b49780ce5b4be00ee2fae87c5d4aa82dd4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:25:03 +0200 Subject: [PATCH 092/167] Remove deep_cloneable gem --- Gemfile | 3 --- Gemfile.lock | 3 --- 2 files changed, 6 deletions(-) diff --git a/Gemfile b/Gemfile index fe8498495..89c718f5a 100644 --- a/Gemfile +++ b/Gemfile @@ -76,9 +76,6 @@ gem 'whenever', '0.9.4', require: false # country listing gem 'countries', :require => 'countries/global' -# cloning activerecord objects -gem 'deep_cloneable', '2.1.1' - # id + mid login # gem 'digidoc_client', '0.3.0' gem 'digidoc_client', diff --git a/Gemfile.lock b/Gemfile.lock index d4f0cf9fd..a83ebf0bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -167,8 +167,6 @@ GEM daemons multi_json (~> 1.0) database_cleaner (1.6.1) - deep_cloneable (2.1.1) - activerecord (>= 3.1.0, < 5.0.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) devise (3.5.4) @@ -500,7 +498,6 @@ DEPENDENCIES daemons-rails (= 1.2.1) data_migrate! database_cleaner - deep_cloneable (= 2.1.1) devise (= 3.5.4) digidoc_client! epp (= 1.5.0)! From 51243c59833d1838402fe70d877a03b4c9ddc285 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:41:49 +0200 Subject: [PATCH 093/167] Extract contact Transferable concern #660 --- app/models/concerns/contact/transferable.rb | 13 ++++++ app/models/concerns/domain/transferable.rb | 32 +++++---------- app/models/contact.rb | 1 + app/models/epp/domain.rb | 4 +- test/models/contact_test.rb | 44 +++++++++++++++++++++ test/models/domain_test.rb | 10 ++++- 6 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 app/models/concerns/contact/transferable.rb create mode 100644 test/models/contact_test.rb diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb new file mode 100644 index 000000000..3805287ac --- /dev/null +++ b/app/models/concerns/contact/transferable.rb @@ -0,0 +1,13 @@ +module Concerns::Contact::Transferable + extend ActiveSupport::Concern + + def transfer(new_registrar) + new_contact = self.dup + new_contact.registrar = new_registrar + new_contact.generate_code + new_contact.original = self + new_contact.remove_address unless self.class.address_processing? + new_contact.save! + new_contact + end +end diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index c7b36c4bd..161f513a2 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -17,7 +17,7 @@ module Concerns::Domain::Transferable transfer_to: new_registrar ) - transfer_contacts(new_registrar.id) + transfer_contacts(new_registrar) end private @@ -26,25 +26,25 @@ module Concerns::Domain::Transferable self.transfer_code = SecureRandom.hex end - def transfer_contacts(registrar_id) - transfer_registrant(registrar_id) - transfer_domain_contacts(registrar_id) + def transfer_contacts(new_registrar) + transfer_registrant(new_registrar) + transfer_domain_contacts(new_registrar) end - def transfer_registrant(registrar_id) - return if registrant.registrar_id == registrar_id - self.registrant_id = copy_and_transfer_contact(registrant_id, registrar_id).id + def transfer_registrant(new_registrar) + return if registrant.registrar == new_registrar + self.registrant = registrant.transfer(new_registrar) end - def transfer_domain_contacts(registrar_id) + def transfer_domain_contacts(new_registrar) copied_ids = [] contacts.each do |c| - next if copied_ids.include?(c.id) || c.registrar_id == registrar_id + next if copied_ids.include?(c.id) || c.registrar == new_registrar if registrant_id_was == c.id # registrant was copied previously, do not copy it again oc = OpenStruct.new(id: registrant_id) else - oc = copy_and_transfer_contact(c.id, registrar_id) + oc = c.transfer(new_registrar) end domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround @@ -52,17 +52,5 @@ module Concerns::Domain::Transferable end end - def copy_and_transfer_contact(contact_id, registrar_id) - c = Contact.find(contact_id) # n+1 workaround - oc = c.deep_clone - oc.code = nil - oc.registrar_id = registrar_id - oc.original = c - oc.generate_code - oc.remove_address unless Contact.address_processing? - oc.save!(validate: false) - oc - end - alias_method :regenerate_transfer_code, :generate_transfer_code end diff --git a/app/models/contact.rb b/app/models/contact.rb index 7edef09ea..85687cb6f 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -2,6 +2,7 @@ class Contact < ActiveRecord::Base include Versions # version/contact_version.rb include EppErrors include UserEvents + include Concerns::Contact::Transferable belongs_to :original, class_name: self.name belongs_to :registrar, required: true diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 8791a6126..4b944c9d3 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -679,7 +679,7 @@ class Epp::Domain < Domain end if dt.approved? - transfer_contacts(current_user.registrar_id) + transfer_contacts(current_user.registrar) dt.notify_losing_registrar(old_contact_codes, old_registrant_code) regenerate_transfer_code self.registrar = current_user.registrar @@ -709,7 +709,7 @@ class Epp::Domain < Domain transferred_at: Time.zone.now ) - transfer_contacts(pt.transfer_to_id) + transfer_contacts(pt.transfer_to) regenerate_transfer_code self.registrar = pt.transfer_to diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb new file mode 100644 index 000000000..017a50c0b --- /dev/null +++ b/test/models/contact_test.rb @@ -0,0 +1,44 @@ +require 'test_helper' + +class ContactTest < ActiveSupport::TestCase + def setup + @contact = contacts(:john) + @new_registrar = registrars(:goodnames) + end + + def test_validates + assert @contact.valid? + end + + def test_transfer_keeps_original_contact_untouched + original_hash = @contact.to_json + new_contact = @contact.transfer(@new_registrar) + refute_equal original_hash, new_contact.to_json + end + + def test_transfer_creates_new_contact + assert_difference 'Contact.count' do + @contact.transfer(@new_registrar) + end + end + + def test_transfer_changes_registrar + new_contact = @contact.transfer(@new_registrar) + assert_equal @new_registrar, new_contact.registrar + end + + def test_transfer_links_to_original + new_contact = @contact.transfer(@new_registrar) + assert_equal @contact, new_contact.original + end + + def test_transfer_regenerates_new_code + new_contact = @contact.transfer(@new_registrar) + refute_equal @contact.code, new_contact.code + end + + def test_transfer_regenerates_auth_info + new_contact = @contact.transfer(@new_registrar) + refute_equal @contact.auth_info, new_contact.auth_info + end +end diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index 3cbfe880d..f3baa2e4a 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -31,7 +31,7 @@ class DomainTest < ActiveSupport::TestCase assert_equal original_transfer_code, @domain.transfer_code end - def test_transfers_domain + def test_changes_registrar old_transfer_code = @domain.transfer_code new_registrar = registrars(:goodnames) @domain.transfer(new_registrar) @@ -40,6 +40,14 @@ class DomainTest < ActiveSupport::TestCase refute_same @domain.transfer_code, old_transfer_code end + def test_regenerates_transfer_code + old_transfer_code = @domain.transfer_code + new_registrar = registrars(:goodnames) + @domain.transfer(new_registrar) + + refute_same @domain.transfer_code, old_transfer_code + end + def test_transfer_creates_domain_transfer_object new_registrar = registrars(:goodnames) From 2db906c5820cf3ca3da77cbc54db472ed3f8c3d6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:42:05 +0200 Subject: [PATCH 094/167] Fix tests #660 --- app/api/repp/domain_transfers_v1.rb | 2 +- test/integration/registrar/domains_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index 3c3104a8f..a5b9fdb19 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -10,7 +10,7 @@ module Repp new_registrar = current_user.registrar domain = Domain.find_by(name: domain_name) - domain.transfer(registrar: new_registrar, transfer_code: transfer_code) + domain.transfer(registrar: new_registrar) end end end diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index 415d92e90..c683cce86 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -23,7 +23,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest visit registrar_domains_url click_link 'Transfer' - fill_in 'Name', with: 'shop.test' + fill_in 'Domain name', with: 'shop.test' fill_in 'Transfer code', with: '65078d5' click_button 'Transfer' From fed011953588b26dd5836f68a09acfde7fe180be Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:43:18 +0200 Subject: [PATCH 095/167] Reformat code #660 --- app/models/concerns/domain/transferable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 161f513a2..3608a81aa 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -26,6 +26,8 @@ module Concerns::Domain::Transferable self.transfer_code = SecureRandom.hex end + alias_method :regenerate_transfer_code, :generate_transfer_code + def transfer_contacts(new_registrar) transfer_registrant(new_registrar) transfer_domain_contacts(new_registrar) @@ -51,6 +53,4 @@ module Concerns::Domain::Transferable copied_ids << c.id end end - - alias_method :regenerate_transfer_code, :generate_transfer_code end From 404932316d308053eb5e6bbd384ed37b5ecfe8e3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 18:47:00 +0200 Subject: [PATCH 096/167] Improve readability --- app/models/concerns/domain/transferable.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 3608a81aa..08d04d6e0 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -40,17 +40,17 @@ module Concerns::Domain::Transferable def transfer_domain_contacts(new_registrar) copied_ids = [] - contacts.each do |c| - next if copied_ids.include?(c.id) || c.registrar == new_registrar + contacts.each do |contact| + next if copied_ids.include?(contact.id) || contact.registrar == new_registrar - if registrant_id_was == c.id # registrant was copied previously, do not copy it again + if registrant_id_was == contact.id # registrant was copied previously, do not copy it again oc = OpenStruct.new(id: registrant_id) else - oc = c.transfer(new_registrar) + oc = contact.transfer(new_registrar) end - domain_contacts.where(contact_id: c.id).update_all({ contact_id: oc.id }) # n+1 workaround - copied_ids << c.id + domain_contacts.where(contact_id: contact.id).update_all({ contact_id: oc.id }) # n+1 workaround + copied_ids << contact.id end end end From d99a63d476d88965d7c472cbdd36741769d899ed Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:00:46 +0200 Subject: [PATCH 097/167] Rename `DomainTransfer#transfer_from` to `old_registrar` --- app/models/concerns/domain/transferable.rb | 2 +- app/models/domain_transfer.rb | 4 ++-- app/models/epp/domain.rb | 6 +++--- app/models/registrar.rb | 2 +- app/views/epp/domains/partials/_transfer.xml.builder | 2 +- ...domain_transfers_transfer_from_id_to_old_registrar_id.rb | 5 +++++ db/structure.sql | 6 ++++-- doc/models_complete.svg | 2 +- 8 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20180123165604_rename_domain_transfers_transfer_from_id_to_old_registrar_id.rb diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 08d04d6e0..1fe34f296 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -13,7 +13,7 @@ module Concerns::Domain::Transferable domain_transfers.create!( transfer_requested_at: Time.zone.now, - transfer_from: old_registrar, + old_registrar: old_registrar, transfer_to: new_registrar ) diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 55cab821c..4887b5597 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -1,7 +1,7 @@ class DomainTransfer < ActiveRecord::Base belongs_to :domain - belongs_to :transfer_from, class_name: 'Registrar' + belongs_to :old_registrar, class_name: 'Registrar' belongs_to :transfer_to, class_name: 'Registrar' PENDING = 'pending' @@ -37,7 +37,7 @@ class DomainTransfer < ActiveRecord::Base end def notify_losing_registrar(contacts, registrant) - transfer_from.messages.create!( + old_registrar.messages.create!( body: I18n.t('domain_transfer_was_approved', contacts: contacts, registrant: registrant), attached_obj_id: id, attached_obj_type: self.class.to_s diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 4b944c9d3..abe1bf768 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -667,7 +667,7 @@ class Epp::Domain < Domain dt = domain_transfers.create!( transfer_requested_at: Time.zone.now, transfer_to: current_user.registrar, - transfer_from: registrar + old_registrar: registrar ) if dt.pending? @@ -696,7 +696,7 @@ class Epp::Domain < Domain def approve_transfer(frame, current_user) pt = pending_transfer - if current_user.registrar != pt.transfer_from + if current_user.registrar != pt.old_registrar throw :epp_error, { msg: I18n.t('transfer_can_be_approved_only_by_current_registrar'), code: '2304' @@ -722,7 +722,7 @@ class Epp::Domain < Domain def reject_transfer(frame, current_user) pt = pending_transfer - if current_user.registrar != pt.transfer_from + if current_user.registrar != pt.old_registrar throw :epp_error, { msg: I18n.t('transfer_can_be_rejected_only_by_current_registrar'), code: '2304' diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 418277b8a..b6f07efc8 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -141,7 +141,7 @@ class Registrar < ActiveRecord::Base at = DomainTransfer.arel_table DomainTransfer.where( at[:transfer_to_id].eq(id).or( - at[:transfer_from_id].eq(id) + at[:old_registrar_id].eq(id) ) ) end diff --git a/app/views/epp/domains/partials/_transfer.xml.builder b/app/views/epp/domains/partials/_transfer.xml.builder index 13daf8014..f29ffb1b6 100644 --- a/app/views/epp/domains/partials/_transfer.xml.builder +++ b/app/views/epp/domains/partials/_transfer.xml.builder @@ -3,7 +3,7 @@ builder.tag!('domain:trnData', 'xmlns:domain' => 'https://epp.tld.ee/schema/doma builder.tag!('domain:trStatus', dt.status) builder.tag!('domain:reID', dt.transfer_to.code) builder.tag!('domain:reDate', dt.transfer_requested_at.try(:iso8601)) - builder.tag!('domain:acID', dt.transfer_from.code) + builder.tag!('domain:acID', dt.old_registrar.code) builder.tag!('domain:acDate', dt.transferred_at.try(:iso8601) || dt.wait_until.try(:iso8601)) builder.tag!('domain:exDate', dt.domain_valid_to.try(:iso8601)) end diff --git a/db/migrate/20180123165604_rename_domain_transfers_transfer_from_id_to_old_registrar_id.rb b/db/migrate/20180123165604_rename_domain_transfers_transfer_from_id_to_old_registrar_id.rb new file mode 100644 index 000000000..0eae471e4 --- /dev/null +++ b/db/migrate/20180123165604_rename_domain_transfers_transfer_from_id_to_old_registrar_id.rb @@ -0,0 +1,5 @@ +class RenameDomainTransfersTransferFromIdToOldRegistrarId < ActiveRecord::Migration + def change + rename_column :domain_transfers, :transfer_from_id, :old_registrar_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 1ba85fc02..af7d0fc18 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -958,7 +958,7 @@ CREATE TABLE domain_transfers ( status character varying, transfer_requested_at timestamp without time zone, transferred_at timestamp without time zone, - transfer_from_id integer, + old_registrar_id integer, transfer_to_id integer, created_at timestamp without time zone, updated_at timestamp without time zone, @@ -4441,7 +4441,7 @@ ALTER TABLE ONLY domains -- ALTER TABLE ONLY domain_transfers - ADD CONSTRAINT fk_rails_59c422f73d FOREIGN KEY (transfer_from_id) REFERENCES registrars(id); + ADD CONSTRAINT fk_rails_59c422f73d FOREIGN KEY (old_registrar_id) REFERENCES registrars(id); -- @@ -5062,3 +5062,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180123124342'); INSERT INTO schema_migrations (version) VALUES ('20180123154407'); +INSERT INTO schema_migrations (version) VALUES ('20180123165604'); + diff --git a/doc/models_complete.svg b/doc/models_complete.svg index 0d8af5f9d..5fcb222a4 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -1281,7 +1281,7 @@ status :string transfer_requested_at :datetime transferred_at :datetime -transfer_from_id :integer +old_registrar_id :integer transfer_to_id :integer created_at :datetime updated_at :datetime From 189129ec4865cfe80946cd5dfa42aa6eb3392b42 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:07:17 +0200 Subject: [PATCH 098/167] Rename `DomainTransfer#transfer_to` to `new_registrar` --- app/models/concerns/domain/transferable.rb | 2 +- app/models/domain_transfer.rb | 2 +- app/models/epp/domain.rb | 8 ++++---- app/models/registrar.rb | 2 +- app/views/epp/domains/partials/_transfer.xml.builder | 2 +- ...domain_transfers_transfer_to_id_to_new_registrar_id.rb | 5 +++++ db/structure.sql | 6 ++++-- doc/models_complete.svg | 2 +- 8 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20180123170112_rename_domain_transfers_transfer_to_id_to_new_registrar_id.rb diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 1fe34f296..8d612f42f 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -14,7 +14,7 @@ module Concerns::Domain::Transferable domain_transfers.create!( transfer_requested_at: Time.zone.now, old_registrar: old_registrar, - transfer_to: new_registrar + new_registrar: new_registrar ) transfer_contacts(new_registrar) diff --git a/app/models/domain_transfer.rb b/app/models/domain_transfer.rb index 4887b5597..6dd539bb8 100644 --- a/app/models/domain_transfer.rb +++ b/app/models/domain_transfer.rb @@ -2,7 +2,7 @@ class DomainTransfer < ActiveRecord::Base belongs_to :domain belongs_to :old_registrar, class_name: 'Registrar' - belongs_to :transfer_to, class_name: 'Registrar' + belongs_to :new_registrar, class_name: 'Registrar' PENDING = 'pending' CLIENT_APPROVED = 'clientApproved' diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index abe1bf768..969d9a9bc 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -666,8 +666,8 @@ class Epp::Domain < Domain transaction do dt = domain_transfers.create!( transfer_requested_at: Time.zone.now, - transfer_to: current_user.registrar, - old_registrar: registrar + old_registrar: registrar, + new_registrar: current_user.registrar ) if dt.pending? @@ -709,9 +709,9 @@ class Epp::Domain < Domain transferred_at: Time.zone.now ) - transfer_contacts(pt.transfer_to) + transfer_contacts(pt.new_registrar) regenerate_transfer_code - self.registrar = pt.transfer_to + self.registrar = pt.new_registrar attach_legal_document(self.class.parse_legal_document_from_frame(frame)) save!(validate: false) diff --git a/app/models/registrar.rb b/app/models/registrar.rb index b6f07efc8..7646b2ceb 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -140,7 +140,7 @@ class Registrar < ActiveRecord::Base def domain_transfers at = DomainTransfer.arel_table DomainTransfer.where( - at[:transfer_to_id].eq(id).or( + at[:new_registrar_id].eq(id).or( at[:old_registrar_id].eq(id) ) ) diff --git a/app/views/epp/domains/partials/_transfer.xml.builder b/app/views/epp/domains/partials/_transfer.xml.builder index f29ffb1b6..151af28b3 100644 --- a/app/views/epp/domains/partials/_transfer.xml.builder +++ b/app/views/epp/domains/partials/_transfer.xml.builder @@ -1,7 +1,7 @@ builder.tag!('domain:trnData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do builder.tag!('domain:name', dt.domain_name) builder.tag!('domain:trStatus', dt.status) - builder.tag!('domain:reID', dt.transfer_to.code) + builder.tag!('domain:reID', dt.new_registrar.code) builder.tag!('domain:reDate', dt.transfer_requested_at.try(:iso8601)) builder.tag!('domain:acID', dt.old_registrar.code) builder.tag!('domain:acDate', dt.transferred_at.try(:iso8601) || dt.wait_until.try(:iso8601)) diff --git a/db/migrate/20180123170112_rename_domain_transfers_transfer_to_id_to_new_registrar_id.rb b/db/migrate/20180123170112_rename_domain_transfers_transfer_to_id_to_new_registrar_id.rb new file mode 100644 index 000000000..b00d78c5e --- /dev/null +++ b/db/migrate/20180123170112_rename_domain_transfers_transfer_to_id_to_new_registrar_id.rb @@ -0,0 +1,5 @@ +class RenameDomainTransfersTransferToIdToNewRegistrarId < ActiveRecord::Migration + def change + rename_column :domain_transfers, :transfer_to_id, :new_registrar_id + end +end diff --git a/db/structure.sql b/db/structure.sql index af7d0fc18..8317f545d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -959,7 +959,7 @@ CREATE TABLE domain_transfers ( transfer_requested_at timestamp without time zone, transferred_at timestamp without time zone, old_registrar_id integer, - transfer_to_id integer, + new_registrar_id integer, created_at timestamp without time zone, updated_at timestamp without time zone, wait_until timestamp without time zone @@ -4457,7 +4457,7 @@ ALTER TABLE ONLY prices -- ALTER TABLE ONLY domain_transfers - ADD CONSTRAINT fk_rails_833ed7f3c0 FOREIGN KEY (transfer_to_id) REFERENCES registrars(id); + ADD CONSTRAINT fk_rails_833ed7f3c0 FOREIGN KEY (new_registrar_id) REFERENCES registrars(id); -- @@ -5064,3 +5064,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180123154407'); INSERT INTO schema_migrations (version) VALUES ('20180123165604'); +INSERT INTO schema_migrations (version) VALUES ('20180123170112'); + diff --git a/doc/models_complete.svg b/doc/models_complete.svg index 5fcb222a4..148b12942 100644 --- a/doc/models_complete.svg +++ b/doc/models_complete.svg @@ -1282,7 +1282,7 @@ transfer_requested_at :datetime transferred_at :datetime old_registrar_id :integer -transfer_to_id :integer +new_registrar_id :integer created_at :datetime updated_at :datetime wait_until :datetime From c4b8a5b71ba3716ab5fab0d1cb4bf2a8fcafc7bb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:33:33 +0200 Subject: [PATCH 099/167] Do not use turbolinks gem in registrar area --- app/assets/javascripts/datepicker.js | 5 ----- app/assets/javascripts/registrar-manifest.coffee | 1 - app/assets/javascripts/registrar/application.coffee | 2 +- app/assets/javascripts/shared/general.coffee | 3 +-- app/views/layouts/registrar/base.haml | 4 ++-- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/datepicker.js b/app/assets/javascripts/datepicker.js index 188dac211..2210612eb 100644 --- a/app/assets/javascripts/datepicker.js +++ b/app/assets/javascripts/datepicker.js @@ -12,10 +12,5 @@ dateFields.datepicker(); } - // For turbolinks - document.addEventListener('page:change', function() { - attachDatePicker(); - }); - attachDatePicker(); })(); diff --git a/app/assets/javascripts/registrar-manifest.coffee b/app/assets/javascripts/registrar-manifest.coffee index c5d8918b6..656b5cb18 100644 --- a/app/assets/javascripts/registrar-manifest.coffee +++ b/app/assets/javascripts/registrar-manifest.coffee @@ -1,6 +1,5 @@ #= require jquery #= require jquery_ujs -#= require turbolinks #= require bootstrap-sprockets #= require typeahead.bundle.min #= require jquery.nested_attributes diff --git a/app/assets/javascripts/registrar/application.coffee b/app/assets/javascripts/registrar/application.coffee index f1b92f0f1..51ab8e60a 100644 --- a/app/assets/javascripts/registrar/application.coffee +++ b/app/assets/javascripts/registrar/application.coffee @@ -1,4 +1,4 @@ -$(document).on 'page:change', -> +$ -> $('.js-contact-form').on 'restoreDefault', (e) -> form = $(e.target) form.find('.js-ident-tip').hide() diff --git a/app/assets/javascripts/shared/general.coffee b/app/assets/javascripts/shared/general.coffee index 05d5ce8ed..64488b5cd 100644 --- a/app/assets/javascripts/shared/general.coffee +++ b/app/assets/javascripts/shared/general.coffee @@ -1,5 +1,4 @@ #= require nprogress -#= require nprogress-turbolinks NProgress.configure showSpinner: false @@ -16,7 +15,7 @@ NProgress.configure $('#flash').find('div').html(msg) $('#flash').show() -$(document).on 'page:change', -> +$ -> today = new Date() tomorrow = new Date(today) tomorrow.setDate(today.getDate() + 1) diff --git a/app/views/layouts/registrar/base.haml b/app/views/layouts/registrar/base.haml index e0bdd5f24..c3e30d90f 100644 --- a/app/views/layouts/registrar/base.haml +++ b/app/views/layouts/registrar/base.haml @@ -9,8 +9,8 @@ - else %title= t(:registrar_head_title) = csrf_meta_tags - = stylesheet_link_tag 'registrar-manifest', media: 'all', 'data-turbolinks-track' => true - = javascript_include_tag 'registrar-manifest', 'data-turbolinks-track' => true + = stylesheet_link_tag 'registrar-manifest', media: 'all' + = javascript_include_tag 'registrar-manifest' = favicon_link_tag 'favicon.ico' %body %nav.navbar.navbar-default.navbar-fixed-top From f8e3b6ab2018c638a826d702f03aa028572bd4ed Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:33:58 +0200 Subject: [PATCH 100/167] Remove turbolinks gem --- Gemfile | 1 - Gemfile.lock | 3 --- 2 files changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index 89c718f5a..de7fa8eb0 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,6 @@ gem 'sass-rails', '5.0.6' # sass style gem 'coffee-rails', '4.1.0' # coffeescript support gem 'jquery-rails', '4.0.4' # jquery -gem 'turbolinks', '2.5.3' # faster page load gem 'selectize-rails', '0.12.1' # include selectize.js for select gem 'jquery-validation-rails', '1.13.1' # validate on client side diff --git a/Gemfile.lock b/Gemfile.lock index a83ebf0bf..f61982c46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -441,8 +441,6 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (1.4.1) - turbolinks (2.5.3) - coffee-rails tzinfo (1.2.3) thread_safe (~> 0.1) unf (0.1.4) @@ -545,7 +543,6 @@ DEPENDENCIES simpleidn (= 0.0.7) spring spring-commands-rspec - turbolinks (= 2.5.3) uuidtools (= 2.1.5) validates_email_format_of (= 1.6.3) webmock From be38162be122b6ddaf43ebf46aba1284eeb2eb77 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:36:12 +0200 Subject: [PATCH 101/167] Do not use nprogress --- app/assets/javascripts/shared/general.coffee | 5 ----- app/assets/stylesheets/registrant-manifest.sass | 2 -- app/assets/stylesheets/registrar-manifest.sass | 2 -- 3 files changed, 9 deletions(-) diff --git a/app/assets/javascripts/shared/general.coffee b/app/assets/javascripts/shared/general.coffee index 64488b5cd..8cfbf41b5 100644 --- a/app/assets/javascripts/shared/general.coffee +++ b/app/assets/javascripts/shared/general.coffee @@ -1,8 +1,3 @@ -#= require nprogress - -NProgress.configure - showSpinner: false - @flash_notice = (msg) -> $('#flash').find('div').removeClass('bg-danger') $('#flash').find('div').addClass('bg-success') diff --git a/app/assets/stylesheets/registrant-manifest.sass b/app/assets/stylesheets/registrant-manifest.sass index 384b4ba9a..6d0a281fe 100644 --- a/app/assets/stylesheets/registrant-manifest.sass +++ b/app/assets/stylesheets/registrant-manifest.sass @@ -5,8 +5,6 @@ @import shared/fonts @import shared/general @import forms -@import nprogress -@import nprogress-bootstrap @import typeaheadjs @import selectize @import selectize.bootstrap3 diff --git a/app/assets/stylesheets/registrar-manifest.sass b/app/assets/stylesheets/registrar-manifest.sass index e0837f78d..a5e9c3593 100644 --- a/app/assets/stylesheets/registrar-manifest.sass +++ b/app/assets/stylesheets/registrar-manifest.sass @@ -5,8 +5,6 @@ @import shared/fonts @import shared/general @import forms -@import nprogress -@import nprogress-bootstrap @import typeaheadjs @import selectize @import selectize.bootstrap3 From 720012b3dfd008f3666f0adf2f580eee6dd1d45f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:36:19 +0200 Subject: [PATCH 102/167] Remove nprogress gem --- Gemfile | 1 - Gemfile.lock | 2 -- 2 files changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index de7fa8eb0..a7d2e52ac 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'jquery-validation-rails', '1.13.1' # validate on client side gem 'kaminari', '0.16.3' # pagination gem 'coderay', '1.1.0' # xml console visualize gem 'html5_validators', '1.2.2' # model requements now automatically on html form -gem 'nprogress-rails', '0.1.6.7' # visual loader gem 'select2-rails', '3.5.9.3' # for autocomplete gem 'liquid', '3.0.6' # for email templates diff --git a/Gemfile.lock b/Gemfile.lock index f61982c46..e0ca04840 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -281,7 +281,6 @@ GEM nokogiri (1.8.1) mini_portile2 (~> 2.3.0) nori (2.6.0) - nprogress-rails (0.1.6.7) open4 (1.3.4) orm_adapter (0.5.0) parallel (1.12.0) @@ -518,7 +517,6 @@ DEPENDENCIES mina (= 0.3.1) money-rails nokogiri - nprogress-rails (= 0.1.6.7) paper_trail! pdfkit (= 0.6.2) pg (= 0.19.0) From f0a90c4bc27364ce8feda4fe56ee9a77026ca3cb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:54:28 +0200 Subject: [PATCH 103/167] Convert HAML to ERB --- app/views/layouts/registrar/base.haml | 44 ---------------- app/views/layouts/registrar/base.html.erb | 64 +++++++++++++++++++++++ 2 files changed, 64 insertions(+), 44 deletions(-) delete mode 100644 app/views/layouts/registrar/base.haml create mode 100644 app/views/layouts/registrar/base.html.erb diff --git a/app/views/layouts/registrar/base.haml b/app/views/layouts/registrar/base.haml deleted file mode 100644 index c3e30d90f..000000000 --- a/app/views/layouts/registrar/base.haml +++ /dev/null @@ -1,44 +0,0 @@ -!!! 5 -%html{lang: I18n.locale.to_s} - %head - %meta{charset: "utf-8"}/ - %meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/ - %meta{content: "width=device-width, initial-scale=1", name: "viewport"}/ - - if content_for? :head_title - = yield :head_title - - else - %title= t(:registrar_head_title) - = csrf_meta_tags - = stylesheet_link_tag 'registrar-manifest', media: 'all' - = javascript_include_tag 'registrar-manifest' - = favicon_link_tag 'favicon.ico' - %body - %nav.navbar.navbar-default.navbar-fixed-top - .container - .navbar-header - %button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"} - %span.sr-only Toggle navigation - %span.icon-bar - %span.icon-bar - %span.icon-bar - = link_to registrar_root_path, class: 'navbar-brand' do - = t(:registrar_head_title) - - if unstable_env.present? - .text-center - %small{style: 'color: #0074B3;'}= unstable_env - = render 'navbar' - - .container - = render 'shared/flash' - - if depp_controller? - = render 'registrar/shared/epp_results' - = yield - - %footer.footer - .container - .row - .col-md-6 - = image_tag 'eis-logo-et.png' - .col-md-6.text-right - Version - = CURRENT_COMMIT_HASH diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb new file mode 100644 index 000000000..fcbaaa21e --- /dev/null +++ b/app/views/layouts/registrar/base.html.erb @@ -0,0 +1,64 @@ + + + + + + + <% if content_for? :head_title %> + <%= yield :head_title %> + <% else %> + + <%= t(:registrar_head_title) %> + + <% end %> + <%= csrf_meta_tags %> + <%= stylesheet_link_tag 'registrar-manifest', media: 'all' %> + <%= javascript_include_tag 'registrar-manifest' %> + <%= favicon_link_tag 'favicon.ico' %> + + + +
+ <%= render 'shared/flash' %> + <% if depp_controller? %> + <%= render 'registrar/shared/epp_results' %> + <% end %> + <%= yield %> +
+
+
+
+
+ <%= image_tag 'eis-logo-et.png' %> +
+
+ Version + <%= CURRENT_COMMIT_HASH %> +
+
+
+
+ + From e7b377e651690c990aa8e3512cd243a4bde74cee Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 19:56:52 +0200 Subject: [PATCH 104/167] Remove unneeded meta tag --- app/views/layouts/registrar/base.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb index fcbaaa21e..c27b22430 100644 --- a/app/views/layouts/registrar/base.html.erb +++ b/app/views/layouts/registrar/base.html.erb @@ -2,7 +2,6 @@ - <% if content_for? :head_title %> <%= yield :head_title %> From e21de1c42deaf56f54300fd4733944500c2b8d8e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 23 Jan 2018 20:03:43 +0200 Subject: [PATCH 105/167] Load JS in async mode before closing --- app/views/layouts/registrar/base.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/registrar/base.html.erb b/app/views/layouts/registrar/base.html.erb index c27b22430..6116c7a26 100644 --- a/app/views/layouts/registrar/base.html.erb +++ b/app/views/layouts/registrar/base.html.erb @@ -12,7 +12,6 @@ <% end %> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'registrar-manifest', media: 'all' %> - <%= javascript_include_tag 'registrar-manifest' %> <%= favicon_link_tag 'favicon.ico' %> @@ -59,5 +58,6 @@
+<%= javascript_include_tag 'registrar-manifest', async: true %> From 05bdb11ee3c04cc65f717f288fb2217c1538a187 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 24 Jan 2018 09:13:56 +0200 Subject: [PATCH 106/167] Remove unused method --- .reek | 3 --- app/models/depp/user.rb | 33 --------------------------------- 2 files changed, 36 deletions(-) diff --git a/.reek b/.reek index 4d3bfd449..3bdfebb81 100644 --- a/.reek +++ b/.reek @@ -281,7 +281,6 @@ DuplicateMethodCall: - 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 @@ -760,7 +759,6 @@ TooManyStatements: - 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 @@ -938,7 +936,6 @@ FeatureEnvy: - Depp::Domain#renew - Depp::Domain#transfer - Depp::Keyrelay#keyrelay - - Depp::User#repp_request - DomainMailModel#format - Epp::Contact#attach_legal_document - Epp::Contact#attrs_from diff --git a/app/models/depp/user.rb b/app/models/depp/user.rb index 51ce3f682..b40d910e4 100644 --- a/app/models/depp/user.rb +++ b/app/models/depp/user.rb @@ -36,39 +36,6 @@ module Depp Nokogiri::XML(e.response_xml.to_s).remove_namespaces! end - # rubocop:disable Metrics/AbcSize - def repp_request(path, params = {}) - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - - repp_url = Rails.env.test? ? 'http://localhost:8989/repp/v1/' : ENV['repp_url'] - uri = URI.parse("#{repp_url}#{path}") - uri.query = URI.encode_www_form(params) - - req = Net::HTTP::Get.new(uri) - req.basic_auth tag, password - - res = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(req) - end - - ret = OpenStruct.new(code: res.code) - ret.parsed_body = JSON.parse(res.body) if res.body.present? - - if ret.parsed_body && ret.parsed_body['error'] - ret.message = ret.parsed_body['error'] - else - ret.message = res.message - end - - ret - end - # rubocop:enable Metrics/AbcSize - private # rubocop:disable Metrics/AbcSize From 0751a69d8375cf4dca6809d8d50e42e4383753c7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 24 Jan 2018 13:38:51 +0200 Subject: [PATCH 107/167] Implement domain transfer API #660 --- app/api/repp/domain_transfers_v1.rb | 39 +++++++++++++++++++--- app/models/concerns/domain/transferable.rb | 15 +++++---- test/api/domain_transfers_test.rb | 32 ++++++++++++++---- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index a5b9fdb19..1fcb9f2dc 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -4,13 +4,44 @@ module Repp resource :domain_transfers do post '/' do - params['domainTransfers'].each do |domain_transfer| + params do + requires :data, type: Hash do + requires :domainTransfers, type: Array do + requires :domainName, type: String, allow_blank: false + requires :transferCode, type: String, allow_blank: false + end + end + end + + new_registrar = current_user.registrar + request_domain_transfers = params['data']['domainTransfers'] + response_domain_transfers = [] + errors = [] + + request_domain_transfers.each do |domain_transfer| domain_name = domain_transfer['domainName'] transfer_code = domain_transfer['transferCode'] - new_registrar = current_user.registrar - domain = Domain.find_by(name: domain_name) - domain.transfer(registrar: new_registrar) + + if domain + if domain.transfer_code == transfer_code + domain.transfer(new_registrar) + else + errors << { title: "#{domain_name} transfer code is wrong" } + end + + else + errors << { title: "#{domain_name} does not exist" } + end + + response_domain_transfers << { domainName: domain_name } + end + + if errors.none? + status 204 + else + status 400 + { errors: errors } end end end diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 8d612f42f..4d6c5fb7a 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -11,13 +11,16 @@ module Concerns::Domain::Transferable self.registrar = new_registrar regenerate_transfer_code - domain_transfers.create!( - transfer_requested_at: Time.zone.now, - old_registrar: old_registrar, - new_registrar: new_registrar - ) + transaction do + domain_transfers.create!( + transfer_requested_at: Time.zone.now, + old_registrar: old_registrar, + new_registrar: new_registrar + ) - transfer_contacts(new_registrar) + transfer_contacts(new_registrar) + save! + end end private diff --git a/test/api/domain_transfers_test.rb b/test/api/domain_transfers_test.rb index 6cd868314..087d8b2cf 100644 --- a/test/api/domain_transfers_test.rb +++ b/test/api/domain_transfers_test.rb @@ -1,19 +1,37 @@ require 'test_helper' class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest - def test_post_to_domain_transfers - request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, transferCode: domains(:shop).transfer_code }] } + def test_transfers_domain + request_params = { format: :json, + data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } } post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } - assert_response :created + assert_response 204 + assert_equal registrars(:goodnames), domains(:shop).registrar + assert_empty response.body + end - assert_difference -> { domains(:shop).domain_transfers.count } do - post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } - end + def test_fails_if_domain_does_not_exist + request_params = { format: :json, + data: { domainTransfers: [{ domainName: 'non-existent.test', transferCode: 'any' }] } } + post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response 400 + assert_equal ({ errors: [{ title: 'non-existent.test does not exist' }] }), + JSON.parse(response.body, symbolize_names: true) + end + + def test_fails_if_transfer_code_is_wrong + request_params = { format: :json, + data: { domainTransfers: [{ domainName: 'shop.test', transferCode: 'wrong' }] } } + post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key } + assert_response 400 + refute_equal registrars(:goodnames), domains(:shop).registrar + assert_equal ({ errors: [{ title: 'shop.test transfer code is wrong' }] }), + JSON.parse(response.body, symbolize_names: true) end private def http_auth_key - ActionController::HttpAuthentication::Basic.encode_credentials(users(:api_bestnames).username, users(:api_bestnames).password) + ActionController::HttpAuthentication::Basic.encode_credentials('test_goodnames', 'testtest') end end From 98339bc551d98841ead5b1aae0f6c316d44b0278 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 11:36:12 +0200 Subject: [PATCH 108/167] Change `contacts.auth_info` to NOT NULL #660 --- .../20180125092422_change_contacts_auth_info_to_not_null.rb | 5 +++++ db/structure.sql | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180125092422_change_contacts_auth_info_to_not_null.rb diff --git a/db/migrate/20180125092422_change_contacts_auth_info_to_not_null.rb b/db/migrate/20180125092422_change_contacts_auth_info_to_not_null.rb new file mode 100644 index 000000000..4b0581a7c --- /dev/null +++ b/db/migrate/20180125092422_change_contacts_auth_info_to_not_null.rb @@ -0,0 +1,5 @@ +class ChangeContactsAuthInfoToNotNull < ActiveRecord::Migration + def change + change_column_null :contacts, :auth_info, false + end +end diff --git a/db/structure.sql b/db/structure.sql index 8317f545d..2bf928769 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -652,7 +652,7 @@ CREATE TABLE contacts ( updated_at timestamp without time zone, ident character varying, ident_type character varying, - auth_info character varying, + auth_info character varying NOT NULL, name character varying, org_name character varying, registrar_id integer NOT NULL, @@ -5066,3 +5066,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180123165604'); INSERT INTO schema_migrations (version) VALUES ('20180123170112'); +INSERT INTO schema_migrations (version) VALUES ('20180125092422'); + From 4254fa0c94a776b08bd04db08e9f674ff9f23634 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 11:36:29 +0200 Subject: [PATCH 109/167] Update fixtures --- test/fixtures/contacts.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 578ba5920..b59d9cba3 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -7,6 +7,7 @@ john: ident_country_code: US registrar: bestnames code: john-001 + auth_info: cacb5b jane: name: Jane @@ -17,6 +18,7 @@ jane: ident_country_code: US registrar: bestnames code: jane-001 + auth_info: 0aa09f acme_ltd: name: Acme Ltd @@ -27,3 +29,4 @@ acme_ltd: registrar: bestnames ident_country_code: US code: acme-ltd-001 + auth_info: 720b3c From 326ded80102ae0759d6e42cb1e79d57607eb8caa Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:29:08 +0200 Subject: [PATCH 110/167] Extract contact transferable module #660 --- app/models/concerns/contact/transferable.rb | 10 ++++++++++ app/models/contact.rb | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 3805287ac..4124bc7c1 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -1,6 +1,10 @@ module Concerns::Contact::Transferable extend ActiveSupport::Concern + included do + after_initialize :generate_auth_info, if: :new_record? + end + def transfer(new_registrar) new_contact = self.dup new_contact.registrar = new_registrar @@ -10,4 +14,10 @@ module Concerns::Contact::Transferable new_contact.save! new_contact end + + def generate_auth_info + return if @generate_auth_info_disabled + return if auth_info.present? + self.auth_info = SecureRandom.hex(11) + end end diff --git a/app/models/contact.rb b/app/models/contact.rb index 85687cb6f..c0c4c00ee 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -45,7 +45,6 @@ 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, @@ -314,12 +313,6 @@ class Contact < ActiveRecord::Base !org? end - def generate_auth_info - return if @generate_auth_info_disabled - return if auth_info.present? - self.auth_info = SecureRandom.hex(11) - end - # def auth_info=(pw) # self[:auth_info] = pw if new_record? # end From 7ab68032ea664846c768ed06ad953249c338f369 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:29:30 +0200 Subject: [PATCH 111/167] Remove commented code #660 --- app/models/contact.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index c0c4c00ee..16f3e81a2 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -313,10 +313,6 @@ class Contact < ActiveRecord::Base !org? end - # def auth_info=(pw) - # self[:auth_info] = pw if new_record? - # end - def code=(code) self[:code] = code if new_record? # cannot change code later end From a2ee64ebd9a3a742204fc70cb3f1e7f2c800fdaa Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:30:18 +0200 Subject: [PATCH 112/167] Clean up spec #660 --- spec/models/contact_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 80dfb47ad..b9be3b3fa 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -171,11 +171,6 @@ RSpec.describe Contact do end context 'with callbacks' do - before :example do - # Ensure callbacks are not taken out from other specs - Contact.set_callback(:create, :before, :generate_auth_info) - end - context 'after create' do it 'should not allow to use same code' do registrar = create(:registrar, code: 'FIXED') From 954269e580e28316195ceaf26a66c63fcce798ac Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:31:13 +0200 Subject: [PATCH 113/167] Remove unused variable #660 --- app/models/concerns/contact/transferable.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 4124bc7c1..324e18cb2 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -16,7 +16,6 @@ module Concerns::Contact::Transferable end def generate_auth_info - return if @generate_auth_info_disabled return if auth_info.present? self.auth_info = SecureRandom.hex(11) end From f99b8b66b07cc899a98c9e4ecb78f1c69fb7de95 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:40:17 +0200 Subject: [PATCH 114/167] Regenerate `auth_info` on contact transfer #660 --- app/models/concerns/contact/transferable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index 324e18cb2..dab02e6e3 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -10,13 +10,17 @@ module Concerns::Contact::Transferable new_contact.registrar = new_registrar new_contact.generate_code new_contact.original = self + new_contact.regenerate_auth_info new_contact.remove_address unless self.class.address_processing? new_contact.save! new_contact end + protected + def generate_auth_info - return if auth_info.present? self.auth_info = SecureRandom.hex(11) end + + alias_method :regenerate_auth_info, :generate_auth_info end From 28b76a6d9167b7176b8f710eb2e3b45c88627c8a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:43:15 +0200 Subject: [PATCH 115/167] Update tests #660 --- test/models/contact_test.rb | 33 --------------- test/models/contact_transfer_test.rb | 56 +++++++++++++++++++++++++ test/models/domain_test.rb | 55 ------------------------ test/models/domain_transfer_test.rb | 62 ++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 88 deletions(-) create mode 100644 test/models/contact_transfer_test.rb create mode 100644 test/models/domain_transfer_test.rb diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index 017a50c0b..aad044592 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -3,42 +3,9 @@ require 'test_helper' class ContactTest < ActiveSupport::TestCase def setup @contact = contacts(:john) - @new_registrar = registrars(:goodnames) end def test_validates assert @contact.valid? end - - def test_transfer_keeps_original_contact_untouched - original_hash = @contact.to_json - new_contact = @contact.transfer(@new_registrar) - refute_equal original_hash, new_contact.to_json - end - - def test_transfer_creates_new_contact - assert_difference 'Contact.count' do - @contact.transfer(@new_registrar) - end - end - - def test_transfer_changes_registrar - new_contact = @contact.transfer(@new_registrar) - assert_equal @new_registrar, new_contact.registrar - end - - def test_transfer_links_to_original - new_contact = @contact.transfer(@new_registrar) - assert_equal @contact, new_contact.original - end - - def test_transfer_regenerates_new_code - new_contact = @contact.transfer(@new_registrar) - refute_equal @contact.code, new_contact.code - end - - def test_transfer_regenerates_auth_info - new_contact = @contact.transfer(@new_registrar) - refute_equal @contact.auth_info, new_contact.auth_info - end end diff --git a/test/models/contact_transfer_test.rb b/test/models/contact_transfer_test.rb new file mode 100644 index 000000000..814b008da --- /dev/null +++ b/test/models/contact_transfer_test.rb @@ -0,0 +1,56 @@ +require 'test_helper' + +class ContactTransferTest < ActiveSupport::TestCase + def setup + @contact = contacts(:john) + @new_registrar = registrars(:goodnames) + end + + def test_generates_unique_auth_info_if_contact_is_new + contact = Contact.new + another_contact = Contact.new + + refute_empty contact.auth_info + refute_empty another_contact.auth_info + refute_equal contact.auth_info, another_contact.auth_info + end + + def test_does_not_regenerate_auth_info_if_contact_is_persisted + original_auth_info = @contact.auth_info + @contact.save! + @contact.reload + assert_equal original_auth_info, @contact.auth_info + end + + def test_keeps_original_contact_untouched + original_hash = @contact.to_json + new_contact = @contact.transfer(@new_registrar) + refute_equal original_hash, new_contact.to_json + end + + def test_creates_new_contact + assert_difference 'Contact.count' do + @contact.transfer(@new_registrar) + end + end + + def test_changes_registrar + new_contact = @contact.transfer(@new_registrar) + assert_equal @new_registrar, new_contact.registrar + end + + def test_links_to_original + new_contact = @contact.transfer(@new_registrar) + assert_equal @contact, new_contact.original + end + + def test_regenerates_new_code + new_contact = @contact.transfer(@new_registrar) + refute_equal @contact.code, new_contact.code + end + + def test_regenerates_auth_info + new_contact = @contact.transfer(@new_registrar) + refute_equal @contact.auth_info, new_contact.auth_info + end +end diff --git a/test/models/domain_test.rb b/test/models/domain_test.rb index f3baa2e4a..a2c3fae55 100644 --- a/test/models/domain_test.rb +++ b/test/models/domain_test.rb @@ -8,59 +8,4 @@ class DomainTest < ActiveSupport::TestCase def test_validates assert @domain.valid? end - - def test_rejects_absent_transfer_code - @domain.transfer_code = nil - @domain.validate - assert @domain.invalid? - end - - def test_generates_random_transfer_code_if_new - domain = Domain.new - another_domain = Domain.new - - refute_empty domain.transfer_code - refute_empty another_domain.transfer_code - refute_equal domain.transfer_code, another_domain.transfer_code - end - - def test_does_not_regenerate_transfer_code_if_persisted - original_transfer_code = @domain.transfer_code - @domain.save! - @domain.reload - assert_equal original_transfer_code, @domain.transfer_code - end - - def test_changes_registrar - old_transfer_code = @domain.transfer_code - new_registrar = registrars(:goodnames) - @domain.transfer(new_registrar) - - assert_equal new_registrar, @domain.registrar - refute_same @domain.transfer_code, old_transfer_code - end - - def test_regenerates_transfer_code - old_transfer_code = @domain.transfer_code - new_registrar = registrars(:goodnames) - @domain.transfer(new_registrar) - - refute_same @domain.transfer_code, old_transfer_code - end - - def test_transfer_creates_domain_transfer_object - new_registrar = registrars(:goodnames) - - assert_difference 'DomainTransfer.count' do - @domain.transfer(new_registrar) - end - end - - def test_transfer_copies_contacts - new_registrar = registrars(:goodnames) - - assert_difference 'Contact.count', 2 do - @domain.transfer(new_registrar) - end - end end diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb new file mode 100644 index 000000000..b49be5aeb --- /dev/null +++ b/test/models/domain_transfer_test.rb @@ -0,0 +1,62 @@ +require 'test_helper' + +class DomainTest < ActiveSupport::TestCase + def setup + @domain = domains(:shop) + end + + def test_rejects_absent_transfer_code + @domain.transfer_code = nil + @domain.validate + assert @domain.invalid? + end + + def test_generates_random_transfer_code_if_domain_is_new + domain = Domain.new + another_domain = Domain.new + + refute_empty domain.transfer_code + refute_empty another_domain.transfer_code + refute_equal domain.transfer_code, another_domain.transfer_code + end + + def test_does_not_regenerate_transfer_code_if_domain_is_persisted + original_transfer_code = @domain.transfer_code + @domain.save! + @domain.reload + assert_equal original_transfer_code, @domain.transfer_code + end + + def test_changes_registrar + old_transfer_code = @domain.transfer_code + new_registrar = registrars(:goodnames) + @domain.transfer(new_registrar) + + assert_equal new_registrar, @domain.registrar + refute_same @domain.transfer_code, old_transfer_code + end + + def test_regenerates_transfer_code + old_transfer_code = @domain.transfer_code + new_registrar = registrars(:goodnames) + @domain.transfer(new_registrar) + + refute_same @domain.transfer_code, old_transfer_code + end + + def test_creates_domain_transfer + new_registrar = registrars(:goodnames) + + assert_difference 'DomainTransfer.count' do + @domain.transfer(new_registrar) + end + end + + def test_oopies_contacts + new_registrar = registrars(:goodnames) + + assert_difference 'Contact.count', 2 do + @domain.transfer(new_registrar) + end + end +end From 435e1d5d64f4bcba08ed62b7650edd7ba2a3a28c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:46:53 +0200 Subject: [PATCH 116/167] Remove old specs #660 --- spec/models/contact_spec.rb | 42 +++---------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index b9be3b3fa..1703bf90a 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -63,7 +63,7 @@ RSpec.describe Contact do context 'with valid attributes' do before :example do - @contact = create(:contact, auth_info: 'password') + @contact = create(:contact) end it 'should have one version' do @@ -87,10 +87,6 @@ RSpec.describe Contact do @contact.code.should == old_code end - it 'should have static password' do - @contact.auth_info.should == 'password' - end - it 'should have ok status by default' do @contact.statuses.should == %w(ok) end @@ -177,25 +173,16 @@ RSpec.describe Contact do create(:contact, registrar: registrar, - code: 'FIXED:new-code', - auth_info: 'qwe321') + code: 'FIXED:new-code') @contact = build(:contact, registrar: registrar, - code: 'FIXED:new-code', - auth_info: 'qwe321') + code: 'FIXED:new-code') @contact.validate expect(@contact.errors).to have_key(:code) end - it 'should generate a new password' do - @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 = build(:contact, code: 'CID:REG1:12345', registrar: create(:registrar, code: 'FIXED')) @contact.valid? @@ -222,29 +209,6 @@ RSpec.describe Contact do @contact.code.should =~ /FIXED:..../ end end - - context 'after update' do - before :example do - @contact = build(:contact, - registrar: create(:registrar, code: 'FIXED'), - code: '123asd', - auth_info: 'qwe321') - @contact.generate_code - @contact.save - @contact.code.should == 'FIXED:123ASD' - @auth_info = @contact.auth_info - end - - it 'should not generate new code' do - @contact.update_attributes(name: 'qevciherot23') - @contact.code.should == 'FIXED:123ASD' - end - - it 'should not generate new auth_info' do - @contact.update_attributes(name: 'fvrsgbqevciherot23') - @contact.auth_info.should == @auth_info - end - end end end end From 1fdd3482f04e7f05d46dee88faba1eda6c6b4fdd Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 12:53:47 +0200 Subject: [PATCH 117/167] Require Contact#auth_info #660 --- app/models/concerns/contact/transferable.rb | 1 + test/models/contact_transfer_test.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index dab02e6e3..e8f690feb 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -2,6 +2,7 @@ module Concerns::Contact::Transferable extend ActiveSupport::Concern included do + validates :auth_info, presence: true after_initialize :generate_auth_info, if: :new_record? end diff --git a/test/models/contact_transfer_test.rb b/test/models/contact_transfer_test.rb index 814b008da..d1ff96a11 100644 --- a/test/models/contact_transfer_test.rb +++ b/test/models/contact_transfer_test.rb @@ -6,6 +6,12 @@ class ContactTransferTest < ActiveSupport::TestCase @new_registrar = registrars(:goodnames) end + def test_rejects_absent_auth_info + @contact.auth_info = nil + @contact.validate + assert @contact.invalid? + end + def test_generates_unique_auth_info_if_contact_is_new contact = Contact.new another_contact = Contact.new From d3d4785240ba52574e58c230263aea15ca0126d3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 13:19:01 +0200 Subject: [PATCH 118/167] Allow custom domain transfer code #660 --- app/models/concerns/domain/transferable.rb | 2 +- test/models/domain_transfer_test.rb | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/domain/transferable.rb b/app/models/concerns/domain/transferable.rb index 4d6c5fb7a..e36c7be81 100644 --- a/app/models/concerns/domain/transferable.rb +++ b/app/models/concerns/domain/transferable.rb @@ -2,7 +2,7 @@ module Concerns::Domain::Transferable extend ActiveSupport::Concern included do - after_initialize :generate_transfer_code, if: :new_record? + after_initialize :generate_transfer_code, if: 'new_record? && transfer_code.blank?' end def transfer(new_registrar) diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index b49be5aeb..f930df586 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -5,18 +5,20 @@ class DomainTest < ActiveSupport::TestCase @domain = domains(:shop) end - def test_rejects_absent_transfer_code + def test_invalid_without_transfer_code @domain.transfer_code = nil @domain.validate assert @domain.invalid? end - def test_generates_random_transfer_code_if_domain_is_new + def test_generates_default_transfer_code + domain = Domain.new + refute_empty domain.transfer_code + end + + def test_generated_transfer_code_is_random domain = Domain.new another_domain = Domain.new - - refute_empty domain.transfer_code - refute_empty another_domain.transfer_code refute_equal domain.transfer_code, another_domain.transfer_code end @@ -27,6 +29,11 @@ class DomainTest < ActiveSupport::TestCase assert_equal original_transfer_code, @domain.transfer_code end + def test_overrides_default_transfer_code + domain = Domain.new(transfer_code: '1bad4f') + assert_equal '1bad4f', domain.transfer_code + end + def test_changes_registrar old_transfer_code = @domain.transfer_code new_registrar = registrars(:goodnames) From 0a04f19e69fb83f7277d207c09c25be083344ec0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 13:25:42 +0200 Subject: [PATCH 119/167] Fix typo #660 --- test/models/domain_transfer_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/domain_transfer_test.rb b/test/models/domain_transfer_test.rb index f930df586..2b119aa93 100644 --- a/test/models/domain_transfer_test.rb +++ b/test/models/domain_transfer_test.rb @@ -59,7 +59,7 @@ class DomainTest < ActiveSupport::TestCase end end - def test_oopies_contacts + def test_copies_contacts new_registrar = registrars(:goodnames) assert_difference 'Contact.count', 2 do From 29141110cc898d514342172a50d0d22673735041 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 13:26:52 +0200 Subject: [PATCH 120/167] Test contact transfer more extensively #660 --- test/models/contact_transfer_test.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/models/contact_transfer_test.rb b/test/models/contact_transfer_test.rb index d1ff96a11..9a4f2def0 100644 --- a/test/models/contact_transfer_test.rb +++ b/test/models/contact_transfer_test.rb @@ -6,18 +6,20 @@ class ContactTransferTest < ActiveSupport::TestCase @new_registrar = registrars(:goodnames) end - def test_rejects_absent_auth_info + def test_invalid_without_auth_info @contact.auth_info = nil @contact.validate assert @contact.invalid? end - def test_generates_unique_auth_info_if_contact_is_new + def test_generates_default_auth_info + contact = Contact.new + refute_empty contact.auth_info + end + + def test_generated_auth_info_is_random contact = Contact.new another_contact = Contact.new - - refute_empty contact.auth_info - refute_empty another_contact.auth_info refute_equal contact.auth_info, another_contact.auth_info end @@ -28,6 +30,11 @@ class ContactTransferTest < ActiveSupport::TestCase assert_equal original_auth_info, @contact.auth_info end + def test_overrides_default_auth_info + contact = Contact.new(auth_info: '1bad4f') + assert_equal '1bad4f', contact.auth_info + end + def test_keeps_original_contact_untouched original_hash = @contact.to_json new_contact = @contact.transfer(@new_registrar) From e04a049f32079b3683eb157576fc4d97bad86ec4 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 13:28:22 +0200 Subject: [PATCH 121/167] Allow custom contact auth info #660 --- app/models/concerns/contact/transferable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index e8f690feb..e8c10db06 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -3,7 +3,7 @@ module Concerns::Contact::Transferable included do validates :auth_info, presence: true - after_initialize :generate_auth_info, if: :new_record? + after_initialize :generate_auth_info, if: 'new_record? && auth_info.blank?' end def transfer(new_registrar) From a7e101ff32d212f9112a5bb6fd66117bdaf2c989 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 14:32:05 +0200 Subject: [PATCH 122/167] Update EPP spec #660 --- doc/epp/domain.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/epp/domain.md b/doc/epp/domain.md index 856588e88..70d66e877 100644 --- a/doc/epp/domain.md +++ b/doc/epp/domain.md @@ -72,6 +72,9 @@ Domain name mapping protocol short version: 0-1 Attributes to change 0-1 Contact reference to the registrant Optional attribute: verified="yes/no" + 0-1 + 1 Transfer code. Attribute: roid="String" + 0-1 Required if registrant is changing 0-1 Attribute: xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" 0-1 From de58f71756faa34aad9db4b6578b6a7c634ab241 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 14:33:52 +0200 Subject: [PATCH 123/167] Turn off contact address processing in test env #660 --- test/test_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 433f7cf47..2b931a57c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,6 +5,8 @@ require 'minitest/mock' require 'capybara/rails' require 'capybara/minitest' +Setting.address_processing = false + class ActiveSupport::TestCase include FactoryBot::Syntax::Methods From da07639457f5cfdd98e393d94bb3c1a153ad7337 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 14:34:17 +0200 Subject: [PATCH 124/167] Update EPP domain tests #660 --- .../epp/{ => domain}/domain_transfer_test.rb | 8 +++-- .../epp/domain/domain_update_test.rb | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) rename test/integration/epp/{ => domain}/domain_transfer_test.rb (85%) create mode 100644 test/integration/epp/domain/domain_update_test.rb diff --git a/test/integration/epp/domain_transfer_test.rb b/test/integration/epp/domain/domain_transfer_test.rb similarity index 85% rename from test/integration/epp/domain_transfer_test.rb rename to test/integration/epp/domain/domain_transfer_test.rb index 2bf733bd1..e50685aa8 100644 --- a/test/integration/epp/domain_transfer_test.rb +++ b/test/integration/epp/domain/domain_transfer_test.rb @@ -1,6 +1,10 @@ require 'test_helper' -class Epp::DomainTransferTest < ActionDispatch::IntegrationTest +class EppDomainTransferTest < ActionDispatch::IntegrationTest + def setup + login_as users(:api_goodnames) + end + def test_transfers_domain request_xml = <<-XML @@ -20,7 +24,7 @@ class Epp::DomainTransferTest < ActionDispatch::IntegrationTest session_id = epp_sessions(:api_goodnames).session_id post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } - assert_response :ok + assert_response 200 assert_equal registrars(:goodnames), domains(:shop).registrar end end diff --git a/test/integration/epp/domain/domain_update_test.rb b/test/integration/epp/domain/domain_update_test.rb new file mode 100644 index 000000000..7302f8cd6 --- /dev/null +++ b/test/integration/epp/domain/domain_update_test.rb @@ -0,0 +1,32 @@ +require 'test_helper' + +class EppDomainUpdateTest < ActionDispatch::IntegrationTest + def setup + login_as users(:api_bestnames) + end + + def test_updates_transfer_code + request_xml = <<-XML + + + + + + shop.test + + + f0ff7d17b0 + + + + + + + XML + + session_id = epp_sessions(:api_bestnames).session_id + post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + assert_response 200 + assert_equal 'f0ff7d17b0', domains(:shop).transfer_code + end +end From ded3bc846e826a007c3d2ba0ccde8ae629cc47d9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 14:44:39 +0200 Subject: [PATCH 125/167] Update link #660 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a7d2e52ac..1ec31ca48 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,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 'hashie-forbidden_attributes', '0.1.1' # For grape, https://github.com/ruby-grape/grape/tree/v0.12.0#rails gem 'jbuilder', '2.2.16' # json api # registry specfic From bc55bc32bd3838c039b5941b974b62f1089644bb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 15:03:21 +0200 Subject: [PATCH 126/167] Fix API domain list #660 --- app/models/domain.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/domain.rb b/app/models/domain.rb index 3a120d214..994721fdc 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -659,6 +659,12 @@ class Domain < ActiveRecord::Base pending_json['new_registrant_id'] end + def as_json(_options) + hash = super + hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement + hash + end + def self.to_csv CSV.generate do |csv| csv << column_names From 6489106a4ac770d9856c148bdeda62d6fcc877f6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 16:43:38 +0200 Subject: [PATCH 127/167] Add filename time format #660 --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index c82a10d24..dbf1ff54a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,7 @@ en: date: "%Y-%m-%d" date_long: "%d. %B %Y" ydate: "%Y.%m.%d" + filename: "%Y-%m-%d_%H.%M" date: formats: default: "%Y-%m-%d" From 42323014844e9e92eb43cb961fc2a014078fd64b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 16:45:00 +0200 Subject: [PATCH 128/167] Make domain list CSV filename more user-friendly #660 --- app/controllers/registrar/domains_controller.rb | 3 ++- test/integration/registrar/domains_test.rb | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index 78a5b24b6..b85923a02 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -52,7 +52,8 @@ class Registrar end csv = Registrar::DomainListCSVPresenter.new(domains: domain_presenters, view: view_context).to_s - send_data(csv) + filename = "Domains_#{l(Time.zone.now, format: :filename)}.csv" + send_data(csv, filename: filename) end end end diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index c683cce86..c24560bad 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -6,6 +6,8 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest end def test_downloads_domain_list_as_csv + travel_to Time.zone.parse('2010-07-05 10:30') + expected_csv = <<-CSV.strip_heredoc Domain,Transfer code,Registrant name,Registrant code,Date of expiry library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05 @@ -15,6 +17,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest visit registrar_domains_url click_button 'Download as CSV' + assert_equal 'attachment; filename="Domains_2010-07-05_10.30.csv"', response_headers['Content-Disposition'] assert_equal expected_csv, page.body end From 490528ca18d031e3097b92481d45861453e2536d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 25 Jan 2018 19:10:15 +0200 Subject: [PATCH 129/167] Include webmock in test helper --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 2b931a57c..58e45f58e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,6 +4,7 @@ require 'rails/test_help' require 'minitest/mock' require 'capybara/rails' require 'capybara/minitest' +require 'webmock/minitest' Setting.address_processing = false From e60380c60a3f3b8c623fee7b02307eaec3d6db3e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 00:34:55 +0200 Subject: [PATCH 130/167] Allow batch domain transfer #660 --- .../registrar/domain_transfers_controller.rb | 43 +++++++++++++++++-- .../form/_api_errors.html.erb | 9 ++++ .../domain_transfers/form/_batch.html.erb | 5 ++- .../registrar/domain_transfers/new.html.erb | 2 + .../locales/registrar/domain_transfers.en.yml | 4 +- .../files/valid_domains_for_transfer.csv | 2 + .../api/domain_transfers_test.rb | 2 +- .../registrar/domain_transfers_test.rb | 43 +++++++++++++++++++ test/integration/registrar/domains_test.rb | 23 +--------- 9 files changed, 103 insertions(+), 30 deletions(-) create mode 100644 app/views/registrar/domain_transfers/form/_api_errors.html.erb create mode 100644 test/fixtures/files/valid_domains_for_transfer.csv rename test/{ => integration}/api/domain_transfers_test.rb (95%) create mode 100644 test/integration/registrar/domain_transfers_test.rb diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 43d40e70e..cbaa5407c 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -8,10 +8,45 @@ class Registrar end def create - params[:request] = true # EPP domain:transfer "op" attribute - domain = Depp::Domain.new(current_user: depp_current_user) - @data = domain.transfer(params) - render :new unless response_ok? + if params[:batch_file].present? + csv = CSV.read(params[:batch_file].path, headers: true) + domain_transfers = [] + + csv.each do |row| + domain_name = row['Domain'] + transfer_code = row['Transfer code'] + domain_transfers << { 'domainName' => domain_name, 'transferCode' => transfer_code } + end + + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + + uri = URI.parse("#{ENV['repp_url']}domain_transfers") + request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') + request.body = { data: { domainTransfers: domain_transfers } }.to_json + request.basic_auth(current_user.username, current_user.password) + + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE, + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end + + if response.code == '204' + flash[:notice] = t '.transferred' + redirect_to registrar_domains_url + else + @api_errors = JSON.parse(response.body, symbolize_names: true)[:errors] + render :new + end + else + params[:request] = true # EPP domain:transfer "op" attribute + domain = Depp::Domain.new(current_user: depp_current_user) + @data = domain.transfer(params) + render :new unless response_ok? + end end end end diff --git a/app/views/registrar/domain_transfers/form/_api_errors.html.erb b/app/views/registrar/domain_transfers/form/_api_errors.html.erb new file mode 100644 index 000000000..56bf8c404 --- /dev/null +++ b/app/views/registrar/domain_transfers/form/_api_errors.html.erb @@ -0,0 +1,9 @@ +<% if @api_errors %> +
+
    + <% @api_errors.each do |error| %> +
  • <%= error[:title] %>
  • + <% end %> +
+
+<% end %> diff --git a/app/views/registrar/domain_transfers/form/_batch.html.erb b/app/views/registrar/domain_transfers/form/_batch.html.erb index d6953dd05..5b415f1cd 100644 --- a/app/views/registrar/domain_transfers/form/_batch.html.erb +++ b/app/views/registrar/domain_transfers/form/_batch.html.erb @@ -1,10 +1,11 @@ <%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
- <%= label_tag 'file' %> + <%= label_tag :batch_file %>
- <%= file_field_tag 'file' %> + <%= file_field_tag :batch_file %> + <%= t '.batch_file_help' %>
diff --git a/app/views/registrar/domain_transfers/new.html.erb b/app/views/registrar/domain_transfers/new.html.erb index 28e196a83..8ba658023 100644 --- a/app/views/registrar/domain_transfers/new.html.erb +++ b/app/views/registrar/domain_transfers/new.html.erb @@ -2,6 +2,8 @@

<%= t '.header' %>

+<%= render 'registrar/domain_transfers/form/api_errors' %> +
- <%= file_field_tag :batch_file %> + <%= file_field_tag :batch_file, required: true %> <%= t '.batch_file_help' %>
From 0b6e1f5a6a21f9a9ea512d7ac1bad7b921fef316 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 10:19:23 +0200 Subject: [PATCH 141/167] Do not use PKI in test env #660 --- .../registrar/domain_transfers_controller.rb | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index cbaa5407c..58d1b40fc 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -18,20 +18,27 @@ class Registrar domain_transfers << { 'domainName' => domain_name, 'transferCode' => transfer_code } end - client_cert = File.read(ENV['cert_path']) - client_key = File.read(ENV['key_path']) - uri = URI.parse("#{ENV['repp_url']}domain_transfers") request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') request.body = { data: { domainTransfers: domain_transfers } }.to_json request.basic_auth(current_user.username, current_user.password) - response = Net::HTTP.start(uri.hostname, uri.port, - use_ssl: (uri.scheme == 'https'), - verify_mode: OpenSSL::SSL::VERIFY_NONE, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key)) do |http| - http.request(request) + + if Rails.env.test? + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| + http.request(request) + end + else + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end end if response.code == '204' From 01fe3056d99d9f2780538741ff8e89b8e077fe84 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 10:34:55 +0200 Subject: [PATCH 142/167] Reorganize tests #660 --- .../integration/epp/domain/{ => transfer}/domain_transfer_test.rb | 0 test/integration/epp/domain/{ => update}/domain_update_test.rb | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/integration/epp/domain/{ => transfer}/domain_transfer_test.rb (100%) rename test/integration/epp/domain/{ => update}/domain_update_test.rb (100%) diff --git a/test/integration/epp/domain/domain_transfer_test.rb b/test/integration/epp/domain/transfer/domain_transfer_test.rb similarity index 100% rename from test/integration/epp/domain/domain_transfer_test.rb rename to test/integration/epp/domain/transfer/domain_transfer_test.rb diff --git a/test/integration/epp/domain/domain_update_test.rb b/test/integration/epp/domain/update/domain_update_test.rb similarity index 100% rename from test/integration/epp/domain/domain_update_test.rb rename to test/integration/epp/domain/update/domain_update_test.rb From 8e95131a0762b15e07c5e6d27484952ee9a9c3f7 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 10:39:57 +0200 Subject: [PATCH 143/167] Remove unused variable #660 --- app/api/repp/domain_transfers_v1.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index 903cdc95a..4ae8fb76b 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -14,11 +14,10 @@ module Repp end new_registrar = current_user.registrar - request_domain_transfers = params['data']['domainTransfers'] - response_domain_transfers = [] + domain_transfers = params['data']['domainTransfers'] errors = [] - request_domain_transfers.each do |domain_transfer| + domain_transfers.each do |domain_transfer| domain_name = domain_transfer['domainName'] transfer_code = domain_transfer['transferCode'] domain = Domain.find_by(name: domain_name) @@ -32,8 +31,6 @@ module Repp else errors << { title: "#{domain_name} does not exist" } end - - response_domain_transfers << { domainName: domain_name } end if errors.none? From 2c731549484a330f2756766fec5328c20650e070 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 11:00:46 +0200 Subject: [PATCH 144/167] Load JS in async mode --- app/views/layouts/registrant/application.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/registrant/application.haml b/app/views/layouts/registrant/application.haml index 3e55242b9..12d161c94 100644 --- a/app/views/layouts/registrant/application.haml +++ b/app/views/layouts/registrant/application.haml @@ -9,7 +9,6 @@ %title= t(:registrant_head_title) = csrf_meta_tags = stylesheet_link_tag 'registrant-manifest', media: 'all' - = javascript_include_tag 'registrant-manifest' = favicon_link_tag 'favicon.ico' %body / Fixed navbar @@ -52,3 +51,4 @@ .col-md-6.text-right Version = CURRENT_COMMIT_HASH + = javascript_include_tag 'registrant-manifest', async: true From 578d60cf4453892b39a5343b7cc1f471fddf2475 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 11:04:48 +0200 Subject: [PATCH 145/167] Run all inline JS on window.load --- app/views/registrant/sessions/login_mid.haml | 4 +- .../registrar/domains/form/_contacts.haml | 38 +++++++++---------- .../registrar/domains/form/_dnskeys.haml | 12 +++--- .../registrar/domains/form/_nameservers.haml | 6 +-- app/views/registrar/payments/pay.html.haml | 2 +- app/views/registrar/polls/show.haml | 2 +- app/views/registrar/sessions/login_mid.haml | 7 ++-- 7 files changed, 35 insertions(+), 36 deletions(-) diff --git a/app/views/registrant/sessions/login_mid.haml b/app/views/registrant/sessions/login_mid.haml index ad088dafd..227ec23af 100644 --- a/app/views/registrant/sessions/login_mid.haml +++ b/app/views/registrant/sessions/login_mid.haml @@ -12,7 +12,8 @@ %div.text-center 00007, 60000007, 00000766 - :coffee +:coffee + window.onload = -> $('.js-login').attr('disabled', false) status_interval = null @@ -37,4 +38,3 @@ flash_alert(data.responseJSON.message) $('.js-login').attr('disabled', false) ) - diff --git a/app/views/registrar/domains/form/_contacts.haml b/app/views/registrar/domains/form/_contacts.haml index bf34fe5b8..b5a857c98 100644 --- a/app/views/registrar/domains/form/_contacts.haml +++ b/app/views/registrar/domains/form/_contacts.haml @@ -22,22 +22,22 @@ = text_field_tag "domain[contacts_attributes][#{k}][code_helper]", contacts.find_by(code: v['code']).try(:search_name), class: 'form-control', data: {autocomplete: search_contacts_registrar_domains_path}, required: true :coffee - window.ready = -> - clone = $('.js-contact:first').clone() - $("#js-domain-contacts").nestedAttributes - bindAddTo: $(".add-domain-contact") - afterAdd: (item) -> - # preselect type - item.find('select.js-contact-type').each (k, v) -> - $(v).val($(v).find('option:last-child').val()) - # add combobex - item.find('select.js-contact-code').each (k, v) -> - $(v).select2 - width: "100%" - selectOnBlur: true - dropdownAutoWidth: if self==top then true else false - # remove link for temp - item.find('a.add-domain-contact').each (k, v) -> - $(v).hide() - new Autocomplete() - $clone: clone + window.onload = -> + clone = $('.js-contact:first').clone() + $("#js-domain-contacts").nestedAttributes + bindAddTo: $(".add-domain-contact") + afterAdd: (item) -> + # preselect type + item.find('select.js-contact-type').each (k, v) -> + $(v).val($(v).find('option:last-child').val()) + # add combobex + item.find('select.js-contact-code').each (k, v) -> + $(v).select2 + width: "100%" + selectOnBlur: true + dropdownAutoWidth: if self==top then true else false + # remove link for temp + item.find('a.add-domain-contact').each (k, v) -> + $(v).hide() + new Autocomplete() + $clone: clone diff --git a/app/views/registrar/domains/form/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml index dbb6eb935..5574ead13 100644 --- a/app/views/registrar/domains/form/_dnskeys.haml +++ b/app/views/registrar/domains/form/_dnskeys.haml @@ -68,11 +68,11 @@ class: 'form-control' :coffee - window.ready = -> - $("#dnskeys").nestedAttributes - bindAddTo: $(".add-dnskey") - afterAdd: (item) -> - item.find('select').each (k, v) -> - $(v).val($(v).find('option:first-child').val()) + window.onload = -> + $("#dnskeys").nestedAttributes + bindAddTo: $(".add-dnskey") + afterAdd: (item) -> + item.find('select').each (k, v) -> + $(v).val($(v).find('option:first-child').val()) diff --git a/app/views/registrar/domains/form/_nameservers.haml b/app/views/registrar/domains/form/_nameservers.haml index 89691269b..374a1eaba 100644 --- a/app/views/registrar/domains/form/_nameservers.haml +++ b/app/views/registrar/domains/form/_nameservers.haml @@ -27,6 +27,6 @@ = text_field_tag "domain[nameservers_attributes][#{k}][ipv6]", v['ipv6'], class: 'form-control'#, ipv6: true :coffee - window.ready = -> - $("#nameservers").nestedAttributes - bindAddTo: $(".add-nameserver") + window.onload = -> + $("#nameservers").nestedAttributes + bindAddTo: $(".add-nameserver") diff --git a/app/views/registrar/payments/pay.html.haml b/app/views/registrar/payments/pay.html.haml index dcd889f34..b2c5eaedb 100644 --- a/app/views/registrar/payments/pay.html.haml +++ b/app/views/registrar/payments/pay.html.haml @@ -6,5 +6,5 @@ :coffeescript - window.ready = -> + window.onload = -> $('.payment-form form').submit() diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index 791c28cca..4a5ec678c 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -82,7 +82,7 @@ %p.bg-info{style: 'padding: 15px;'}= t(:you_have_no_new_messages) :coffee - window.ready = -> + window.onload = -> $(".js-keyrelay-confirm").on "click", -> $(".js-keyrelay-form").submit() diff --git a/app/views/registrar/sessions/login_mid.haml b/app/views/registrar/sessions/login_mid.haml index f5dcc7c38..3eb2ef172 100644 --- a/app/views/registrar/sessions/login_mid.haml +++ b/app/views/registrar/sessions/login_mid.haml @@ -12,9 +12,9 @@ %div.text-center 00007, 60000007, 00000766 - :coffee - window.ready = -> - $('.js-login').attr('disabled', false) +:coffee + window.onload = -> + $('.js-login').attr('disabled', false) status_interval = null mid_status = () -> @@ -38,4 +38,3 @@ flash_alert(data.responseJSON.message) $('.js-login').attr('disabled', false) ) - From 46f11155cb182a72d233cea0e04b196424396ed3 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 11:18:20 +0200 Subject: [PATCH 146/167] Set verify_mode to OpenSSL::SSL::VERIFY_NONE in dev env #660 --- .../registrar/domain_transfers_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/registrar/domain_transfers_controller.rb b/app/controllers/registrar/domain_transfers_controller.rb index 58d1b40fc..0c72b2d93 100644 --- a/app/controllers/registrar/domain_transfers_controller.rb +++ b/app/controllers/registrar/domain_transfers_controller.rb @@ -30,6 +30,16 @@ class Registrar verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http| http.request(request) end + elsif Rails.env.development? + client_cert = File.read(ENV['cert_path']) + client_key = File.read(ENV['key_path']) + response = Net::HTTP.start(uri.hostname, uri.port, + use_ssl: (uri.scheme == 'https'), + verify_mode: OpenSSL::SSL::VERIFY_NONE, + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key)) do |http| + http.request(request) + end else client_cert = File.read(ENV['cert_path']) client_key = File.read(ENV['key_path']) From 76782c72e3e36ca4ae09c6c718d30e34e0a66ce5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 12:52:58 +0200 Subject: [PATCH 147/167] Add `contacts.code` constraints --- ...80126104536_change_contacts_code_to_not_null.rb | 5 +++++ ...04903_add_unique_constraint_to_contacts_code.rb | 13 +++++++++++++ db/structure.sql | 14 +++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180126104536_change_contacts_code_to_not_null.rb create mode 100644 db/migrate/20180126104903_add_unique_constraint_to_contacts_code.rb diff --git a/db/migrate/20180126104536_change_contacts_code_to_not_null.rb b/db/migrate/20180126104536_change_contacts_code_to_not_null.rb new file mode 100644 index 000000000..fc1c653e2 --- /dev/null +++ b/db/migrate/20180126104536_change_contacts_code_to_not_null.rb @@ -0,0 +1,5 @@ +class ChangeContactsCodeToNotNull < ActiveRecord::Migration + def change + change_column_null :contacts, :code, false + end +end diff --git a/db/migrate/20180126104903_add_unique_constraint_to_contacts_code.rb b/db/migrate/20180126104903_add_unique_constraint_to_contacts_code.rb new file mode 100644 index 000000000..2e7e7e12b --- /dev/null +++ b/db/migrate/20180126104903_add_unique_constraint_to_contacts_code.rb @@ -0,0 +1,13 @@ +class AddUniqueConstraintToContactsCode < ActiveRecord::Migration + def up + execute <<-SQL + ALTER TABLE contacts ADD CONSTRAINT unique_contact_code UNIQUE (code) + SQL + end + + def down + execute <<-SQL + ALTER TABLE contacts DROP CONSTRAINT unique_contact_code + SQL + end +end diff --git a/db/structure.sql b/db/structure.sql index 2bf928769..8b13aa4a4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -644,7 +644,7 @@ ALTER SEQUENCE contact_statuses_id_seq OWNED BY contact_statuses.id; CREATE TABLE contacts ( id integer NOT NULL, - code character varying, + code character varying NOT NULL, phone character varying, email character varying, fax character varying, @@ -3627,6 +3627,14 @@ ALTER TABLE ONLY settings ADD CONSTRAINT settings_pkey PRIMARY KEY (id); +-- +-- Name: unique_contact_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY contacts + ADD CONSTRAINT unique_contact_code UNIQUE (code); + + -- -- Name: unique_zone_origin; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -5068,3 +5076,7 @@ INSERT INTO schema_migrations (version) VALUES ('20180123170112'); INSERT INTO schema_migrations (version) VALUES ('20180125092422'); +INSERT INTO schema_migrations (version) VALUES ('20180126104536'); + +INSERT INTO schema_migrations (version) VALUES ('20180126104903'); + From 0e828afa15e0304a9df14e86ee106613bfc85659 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 13:04:16 +0200 Subject: [PATCH 148/167] Improve readability #660 --- app/models/concerns/contact/transferable.rb | 2 +- app/models/contact.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index e8c10db06..de5b53210 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -9,8 +9,8 @@ module Concerns::Contact::Transferable def transfer(new_registrar) new_contact = self.dup new_contact.registrar = new_registrar - new_contact.generate_code new_contact.original = self + new_contact.regenerate_code new_contact.regenerate_auth_info new_contact.remove_address unless self.class.address_processing? new_contact.save! diff --git a/app/models/contact.rb b/app/models/contact.rb index 16f3e81a2..b9ed99af4 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -336,6 +336,8 @@ class Contact < ActiveRecord::Base end # rubocop:enable Metrics/CyclomaticComplexity + alias_method :regenerate_code, :generate_code + def country Country.new(country_code) end From 30b01a7367e07dd97c0201737a2b84c916dbaeb9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 13:09:56 +0200 Subject: [PATCH 149/167] Fix test #660 --- test/models/contact/contact_transfer_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/models/contact/contact_transfer_test.rb b/test/models/contact/contact_transfer_test.rb index c9a59ce45..ae5955230 100644 --- a/test/models/contact/contact_transfer_test.rb +++ b/test/models/contact/contact_transfer_test.rb @@ -37,8 +37,9 @@ class ContactTransferTest < ActiveSupport::TestCase def test_keeps_original_contact_untouched original_hash = @contact.to_json - new_contact = @contact.transfer(@new_registrar) - refute_equal original_hash, new_contact.to_json + @contact.transfer(@new_registrar) + @contact.reload + assert_equal original_hash, @contact.to_json end def test_creates_new_contact @@ -57,7 +58,7 @@ class ContactTransferTest < ActiveSupport::TestCase assert_equal @contact, new_contact.original end - def test_regenerates_new_code + def test_regenerates_code new_contact = @contact.transfer(@new_registrar) refute_equal @contact.code, new_contact.code end From 6a33aa7999898d67a9c1da66dfc146df199158ea Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 13:31:52 +0200 Subject: [PATCH 150/167] Fix contact code regeneration #660 --- app/models/concerns/contact/transferable.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/concerns/contact/transferable.rb b/app/models/concerns/contact/transferable.rb index de5b53210..e280adfae 100644 --- a/app/models/concerns/contact/transferable.rb +++ b/app/models/concerns/contact/transferable.rb @@ -10,6 +10,7 @@ module Concerns::Contact::Transferable new_contact = self.dup new_contact.registrar = new_registrar new_contact.original = self + new_contact.code = nil new_contact.regenerate_code new_contact.regenerate_auth_info new_contact.remove_address unless self.class.address_processing? From 7edf5d159503e15728dcf45b36e698e07c4a7a86 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 13:38:51 +0200 Subject: [PATCH 151/167] Remove unused HTML - Remove inline CSVV --- app/views/admin/contacts/_form.haml | 4 +--- app/views/admin/domains/_form.haml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/admin/contacts/_form.haml b/app/views/admin/contacts/_form.haml index d1538ab4e..2e0553a98 100644 --- a/app/views/admin/contacts/_form.haml +++ b/app/views/admin/contacts/_form.haml @@ -3,9 +3,7 @@ = render 'shared/errors', object: contact .row .col-md-8 - .tab-content{style:'margin-top: 20px;'} - #general-tab.tab-pane.active - = render 'admin/shared/form/statuses', f: f, + = render 'admin/shared/form/statuses', f: f, model: 'contact', admin_statuses_map: Contact.admin_statuses_map, disabled_statuses: Contact::STATUSES - Contact.admin_statuses, diff --git a/app/views/admin/domains/_form.haml b/app/views/admin/domains/_form.haml index 087930c58..93b6be600 100644 --- a/app/views/admin/domains/_form.haml +++ b/app/views/admin/domains/_form.haml @@ -4,9 +4,7 @@ %hr .row .col-md-8 - .tab-content{style:'margin-top: 20px;'} - #general-tab.tab-pane.active - = render 'admin/shared/form/statuses', f: f, + = render 'admin/shared/form/statuses', f: f, model: 'domain', admin_statuses_map: DomainStatus.admin_statuses_map, disabled_statuses: DomainStatus::STATUSES - DomainStatus.admin_statuses, From f38f4c1024b30faae25eed5e5b85da243588cbf1 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 13:59:12 +0200 Subject: [PATCH 152/167] Update fixtures --- test/fixtures/users.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index e8e17b569..b20bd8a83 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -3,6 +3,7 @@ api_bestnames: password: testtest type: ApiUser registrar: bestnames + active: true roles: - super @@ -11,6 +12,7 @@ api_goodnames: password: testtest type: ApiUser registrar: goodnames + active: true roles: - super From ddeb1fdcd182f03058b50b6291dec0cc47d50b5b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 15:23:02 +0200 Subject: [PATCH 153/167] Remove migration #660 --- .../20180123124342_add_contacts_copy_from_id_fk.rb | 5 ----- db/structure.sql | 10 ---------- 2 files changed, 15 deletions(-) delete mode 100644 db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb diff --git a/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb b/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb deleted file mode 100644 index b1f694bf1..000000000 --- a/db/migrate/20180123124342_add_contacts_copy_from_id_fk.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddContactsCopyFromIdFk < ActiveRecord::Migration - def change - add_foreign_key :contacts, :contacts, column: :copy_from_id - end -end diff --git a/db/structure.sql b/db/structure.sql index 8b13aa4a4..2cad3e06f 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4492,14 +4492,6 @@ ALTER TABLE ONLY account_activities ADD CONSTRAINT fk_rails_b80dbb973d FOREIGN KEY (bank_transaction_id) REFERENCES bank_transactions(id); --- --- Name: fk_rails_c107909cf3; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY contacts - ADD CONSTRAINT fk_rails_c107909cf3 FOREIGN KEY (original_id) REFERENCES contacts(id); - - -- -- Name: fk_rails_c9f635c0b3; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5066,8 +5058,6 @@ INSERT INTO schema_migrations (version) VALUES ('20180121165304'); INSERT INTO schema_migrations (version) VALUES ('20180122105335'); -INSERT INTO schema_migrations (version) VALUES ('20180123124342'); - INSERT INTO schema_migrations (version) VALUES ('20180123154407'); INSERT INTO schema_migrations (version) VALUES ('20180123165604'); From 9a4361cad7fc73960f9974b3f94f9dfe016bea06 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 17:04:26 +0200 Subject: [PATCH 154/167] Update REST API documentation [ci skip] #660 --- doc/repp-doc.md | 1 + doc/repp/v1/domain_transfers.md | 48 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 doc/repp/v1/domain_transfers.md diff --git a/doc/repp-doc.md b/doc/repp-doc.md index 8eab257ab..4a79f093f 100644 --- a/doc/repp-doc.md +++ b/doc/repp-doc.md @@ -17,4 +17,5 @@ Main communication specification through Restful EPP (REPP): [Contact related functions](repp/v1/contact.md) [Domain related functions](repp/v1/domain.md) +[Domain transfers](repp/v1/domain_transfers.md) [Account related functions](repp/v1/account.md) diff --git a/doc/repp/v1/domain_transfers.md b/doc/repp/v1/domain_transfers.md new file mode 100644 index 000000000..228033a7c --- /dev/null +++ b/doc/repp/v1/domain_transfers.md @@ -0,0 +1,48 @@ +# Domain transfers + +## POST /repp/v1/domain_transfers +Transfers domains. + +#### Request +``` +GET /repp/v1/domain_transfers +Accept: application/json +Content-Type: application/json +Authorization: Basic dGVzdDp0ZXN0dGVzdA== + +{ + "data":{ + "domainTransfers":[ + { + "domainName":"example.com", + "transferCode":"63e7" + }, + { + "domainName":"example.org", + "transferCode":"15f9" + } + ] + } +} +``` + +#### Response on success +``` +HTTP/1.1 204 +``` + +#### Response on failure +``` +HTTP/1.1 400 +Content-Type: application/json +{ + "errors":[ + { + "title":"example.com transfer code is wrong" + }, + { + "title":"example.org does not exist" + } + ] +} +``` From f10fa3db8426b86e9565bd6bb2bee7e2dcb24548 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 29 Jan 2018 01:59:22 +0200 Subject: [PATCH 155/167] Update fixtures --- test/fixtures/accounts.yml | 5 +++++ test/fixtures/billing/prices.yml | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 test/fixtures/accounts.yml create mode 100644 test/fixtures/billing/prices.yml diff --git a/test/fixtures/accounts.yml b/test/fixtures/accounts.yml new file mode 100644 index 000000000..ea51ff7eb --- /dev/null +++ b/test/fixtures/accounts.yml @@ -0,0 +1,5 @@ +cash: + account_type: cash + balance: 100 + currency: EUR + registrar: bestnames diff --git a/test/fixtures/billing/prices.yml b/test/fixtures/billing/prices.yml new file mode 100644 index 000000000..ef2cd09a7 --- /dev/null +++ b/test/fixtures/billing/prices.yml @@ -0,0 +1,7 @@ +cash: + duration: 1 year + price_cents: 500 + operation_category: create + valid_from: 2010-07-05 + valid_to: 2010-07-05 + zone: test From 029afdc39cd913c0eaad3aff860c07972b93bc62 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 29 Jan 2018 02:18:40 +0200 Subject: [PATCH 156/167] Update EPP documentation [ci skip] #660 --- doc/epp/domain.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/epp/domain.md b/doc/epp/domain.md index 70d66e877..a9c531f7d 100644 --- a/doc/epp/domain.md +++ b/doc/epp/domain.md @@ -27,6 +27,9 @@ Domain name mapping protocol short version: 1 Contact reference to the registrant 0-n Contact reference. Admin contact is required if registrant is a juridical person. Attribute: type="admin / tech" + 0-1 + 1 Transfer code. Attribute: roid="String" + 1 0-1 Attribute: xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" 1-n From 56576d659016934736fb22f4569871703cabc610 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 29 Jan 2018 02:22:28 +0200 Subject: [PATCH 157/167] Update tests #660 --- .../epp/domain/create/transfer_code_test.rb | 63 +++++++++++++++++++ .../domain/transfer/domain_transfer_test.rb | 27 +++++++- .../epp/domain/transfer/transfer_code_test.rb | 30 +++++++++ ...n_update_test.rb => transfer_code_test.rb} | 3 +- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 test/integration/epp/domain/create/transfer_code_test.rb create mode 100644 test/integration/epp/domain/transfer/transfer_code_test.rb rename test/integration/epp/domain/update/{domain_update_test.rb => transfer_code_test.rb} (94%) diff --git a/test/integration/epp/domain/create/transfer_code_test.rb b/test/integration/epp/domain/create/transfer_code_test.rb new file mode 100644 index 000000000..f7d70a4ea --- /dev/null +++ b/test/integration/epp/domain/create/transfer_code_test.rb @@ -0,0 +1,63 @@ +require 'test_helper' + +class EppDomainCreateTransferCodeTest < ActionDispatch::IntegrationTest + def setup + travel_to Time.zone.parse('2010-07-05') + login_as users(:api_bestnames) + end + + def test_generates_default + request_xml = <<-XML + + + + + + brandnew.test + 1 + john-001 + + + + + #{'test' * 2000} + + + + + XML + + session_id = epp_sessions(:api_bestnames).session_id + post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + refute_empty Domain.find_by(name: 'brandnew.test').transfer_code + end + + def test_honors_custom + request_xml = <<-XML + + + + + + brandnew.test + 1 + john-001 + + 1058ad73 + + + + + + #{'test' * 2000} + + + + + XML + + session_id = epp_sessions(:api_bestnames).session_id + post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code + end +end diff --git a/test/integration/epp/domain/transfer/domain_transfer_test.rb b/test/integration/epp/domain/transfer/domain_transfer_test.rb index e50685aa8..1b1e604ba 100644 --- a/test/integration/epp/domain/transfer/domain_transfer_test.rb +++ b/test/integration/epp/domain/transfer/domain_transfer_test.rb @@ -5,7 +5,7 @@ class EppDomainTransferTest < ActionDispatch::IntegrationTest login_as users(:api_goodnames) end - def test_transfers_domain + def test_successfully_transfers_domain request_xml = <<-XML @@ -24,7 +24,30 @@ class EppDomainTransferTest < ActionDispatch::IntegrationTest session_id = epp_sessions(:api_goodnames).session_id post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } - assert_response 200 assert_equal registrars(:goodnames), domains(:shop).registrar + assert Nokogiri::XML(response.body).at_css('result[code="1000"]') + assert_equal 1, Nokogiri::XML(response.body).css('result').size + end + + def test_non_existent_domain + request_xml = <<-XML + + + + + + non-existent.test + + any + + + + + + XML + + session_id = epp_sessions(:api_goodnames).session_id + post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + assert Nokogiri::XML(response.body).at_css('result[code="2303"]') end end diff --git a/test/integration/epp/domain/transfer/transfer_code_test.rb b/test/integration/epp/domain/transfer/transfer_code_test.rb new file mode 100644 index 000000000..0db6ba0d6 --- /dev/null +++ b/test/integration/epp/domain/transfer/transfer_code_test.rb @@ -0,0 +1,30 @@ +require 'test_helper' + +class EppDomainTransferTransferCodeTest < ActionDispatch::IntegrationTest + def setup + login_as users(:api_goodnames) + end + + def test_wrong + request_xml = <<-XML + + + + + + shop.test + + wrong + + + + + + XML + + session_id = epp_sessions(:api_goodnames).session_id + post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } + refute_equal registrars(:goodnames), domains(:shop).registrar + assert Nokogiri::XML(response.body).at_css('result[code="2201"]') + end +end diff --git a/test/integration/epp/domain/update/domain_update_test.rb b/test/integration/epp/domain/update/transfer_code_test.rb similarity index 94% rename from test/integration/epp/domain/update/domain_update_test.rb rename to test/integration/epp/domain/update/transfer_code_test.rb index 7302f8cd6..6208c2899 100644 --- a/test/integration/epp/domain/update/domain_update_test.rb +++ b/test/integration/epp/domain/update/transfer_code_test.rb @@ -5,7 +5,7 @@ class EppDomainUpdateTest < ActionDispatch::IntegrationTest login_as users(:api_bestnames) end - def test_updates_transfer_code + def test_overwrites_existing request_xml = <<-XML @@ -26,7 +26,6 @@ class EppDomainUpdateTest < ActionDispatch::IntegrationTest session_id = epp_sessions(:api_bestnames).session_id post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => "session=#{session_id}" } - assert_response 200 assert_equal 'f0ff7d17b0', domains(:shop).transfer_code end end From 229a42e2eb00acbe0ed7d5bd9ddce5ec3ce2b62f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 29 Jan 2018 18:24:43 +0200 Subject: [PATCH 158/167] Update domain_transfers.md --- doc/repp/v1/domain_transfers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/repp/v1/domain_transfers.md b/doc/repp/v1/domain_transfers.md index 228033a7c..1f821bc6b 100644 --- a/doc/repp/v1/domain_transfers.md +++ b/doc/repp/v1/domain_transfers.md @@ -5,7 +5,7 @@ Transfers domains. #### Request ``` -GET /repp/v1/domain_transfers +POST /repp/v1/domain_transfers Accept: application/json Content-Type: application/json Authorization: Basic dGVzdDp0ZXN0dGVzdA== From a7e8527395095c79a82313d96b5af71c87da06bc Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 13:06:05 +0200 Subject: [PATCH 159/167] Change test order in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 795074687..dbdacec5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ before_script: - "chmod +x ./cc-test-reporter" - "./cc-test-reporter before-build" script: - - "bundle exec rspec" - "bundle exec rake test" + - "bundle exec rspec" after_script: - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT" services: From a33e415bfb3d2f28a97eac49b39560904e989918 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 13:32:07 +0200 Subject: [PATCH 160/167] Clean up travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbdacec5d..0fddf2817 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,6 @@ env: - DB=postgresql bundler_args: --without development staging production before_script: - - "psql -c 'create database registry_test;' -U postgres" - - "psql -c 'create database registry_whois_test;' -U postgres" - - "psql -c 'create database registry_api_log_test;' -U postgres" - "cp config/application-example.yml config/application.yml" - "cp config/database-travis.yml config/database.yml" - "bundle exec rake db:setup:all" From 0db3dcf4c36c421c2aaf9af446ec7c54e453619a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 13:55:15 +0200 Subject: [PATCH 161/167] Revert "Change test order in .travis.yml" This reverts commit a7e8527395095c79a82313d96b5af71c87da06bc. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0fddf2817..a5fec1a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_script: - "chmod +x ./cc-test-reporter" - "./cc-test-reporter before-build" script: - - "bundle exec rake test" - "bundle exec rspec" + - "bundle exec rake test" after_script: - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT" services: From 316059a46b8d6a8dbf4ea8848ffe4b831a302d67 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 19:30:03 +0200 Subject: [PATCH 162/167] Explicitly save response for logging #660 --- app/api/repp/domain_transfers_v1.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/api/repp/domain_transfers_v1.rb b/app/api/repp/domain_transfers_v1.rb index 4ae8fb76b..195740f54 100644 --- a/app/api/repp/domain_transfers_v1.rb +++ b/app/api/repp/domain_transfers_v1.rb @@ -35,9 +35,11 @@ module Repp if errors.none? status 204 + body false + @response = {} else status 400 - { errors: errors } + @response = { errors: errors } end end end From 762f891b8440f9c09e6e3d212e82c35f0f36a464 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 19:31:49 +0200 Subject: [PATCH 163/167] Add old attribute names aliases for PaperTrail #660 --- app/models/contact.rb | 1 + app/models/domain.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index b9ed99af4..3024551f8 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -18,6 +18,7 @@ class Contact < ActiveRecord::Base attr_accessor :legal_document_id alias_attribute :kind, :ident_type + alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail accepts_nested_attributes_for :legal_documents diff --git a/app/models/domain.rb b/app/models/domain.rb index 994721fdc..31ba838f2 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -16,6 +16,7 @@ class Domain < ActiveRecord::Base alias_attribute :on_hold_time, :outzone_at alias_attribute :outzone_time, :outzone_at + alias_attribute :auth_info, :transfer_code # Old attribute name; for PaperTrail # TODO: whois requests ip whitelist for full info for own domains and partial info for other domains # TODO: most inputs should be trimmed before validatation, probably some global logic? From cefa37d081f39ae73c500067c56d522841ef9db5 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 19:33:00 +0200 Subject: [PATCH 164/167] Use model accessors explicitly instead of `#[]` #660 --- app/models/concerns/versions.rb | 2 +- app/views/admin/contact_versions/index.haml | 2 +- app/views/admin/contact_versions/show.haml | 2 +- app/views/admin/domain_versions/archive.haml | 4 ++-- app/views/admin/domain_versions/show.haml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 49c4298f2..5e2bad90c 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -67,7 +67,7 @@ module Versions map do |ver| o = new(ver.object) o.version_loader = ver - ver.object_changes.to_h.each { |k, v| o[k]=v[-1] } + ver.object_changes.to_h.each { |k, v| o.public_send("#{k}=", v[-1]) } o end not_in_history = where(id: (ids.to_a - from_history.map(&:id))) diff --git a/app/views/admin/contact_versions/index.haml b/app/views/admin/contact_versions/index.haml index 31d8f84e3..0367db3be 100644 --- a/app/views/admin/contact_versions/index.haml +++ b/app/views/admin/contact_versions/index.haml @@ -58,7 +58,7 @@ - @versions.each do |version| - if version - contact = Contact.new(version.object.to_h) - - version.object_changes.to_h.each{|k,v| contact[k]=v.last} + - version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last) } %tr %td= link_to(contact.name, admin_contact_version_path(version.id)) diff --git a/app/views/admin/contact_versions/show.haml b/app/views/admin/contact_versions/show.haml index 82a96daba..e19326fca 100644 --- a/app/views/admin/contact_versions/show.haml +++ b/app/views/admin/contact_versions/show.haml @@ -1,5 +1,5 @@ - contact = Contact.new(@version.object.to_h) -- @version.object_changes.to_h.each{|k,v| contact[k]=v.last} +- @version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last ) } = render 'shared/title', name: contact.name .row diff --git a/app/views/admin/domain_versions/archive.haml b/app/views/admin/domain_versions/archive.haml index 2a22284e9..5e6d8eaa9 100644 --- a/app/views/admin/domain_versions/archive.haml +++ b/app/views/admin/domain_versions/archive.haml @@ -56,7 +56,7 @@ - @versions.each do |version| - if version - domain = Domain.new(version.object.to_h) - - version.object_changes.to_h.each{|k,v| domain[k]=v.last} + - version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) } %tr %td= link_to(domain.name, admin_domain_version_path(version.id)) @@ -66,7 +66,7 @@ - else - contact = Contact.all_versions_for([domain.registrant_id], version.created_at).first - if contact.nil? && ver = ContactVersion.where(item_id: domain.registrant_id).last - - contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}){|(k,v), o| o[k]=v.last } )) + - contact = Contact.new(ver.object.to_h.merge(ver.object_changes.to_h.each_with_object({}){|(k,v), o| o.public_send("#{k}=", v.last) } )) = contact.try(:name) = " ".html_safe = "(#{t(:deleted)})" diff --git a/app/views/admin/domain_versions/show.haml b/app/views/admin/domain_versions/show.haml index d0863eed5..1a17ba3f9 100644 --- a/app/views/admin/domain_versions/show.haml +++ b/app/views/admin/domain_versions/show.haml @@ -1,5 +1,5 @@ - domain = Domain.new(@version.object.to_h) -- @version.object_changes.to_h.each{|k,v| domain[k]=v.last} +- @version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) } - if @version - children = HashWithIndifferentAccess.new(@version.children) From 7b6898b1a1e42ed68633781805e3c2e05490793b Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 19:39:46 +0200 Subject: [PATCH 165/167] Use default time format --- app/views/admin/domains/partials/_version.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/domains/partials/_version.haml b/app/views/admin/domains/partials/_version.haml index 38c4474e8..b15bda0dd 100644 --- a/app/views/admin/domains/partials/_version.haml +++ b/app/views/admin/domains/partials/_version.haml @@ -33,7 +33,7 @@ %td %p.nowrap - = l(domain.updated_at, format: :shorts) + = l domain.updated_at -#- if statuses_link %br= link_to t(:edit_statuses), edit_admin_domain_path(params[:domain_id]) From 592a0fcdcac08b34d1096a90656f4ea7d6db696c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 30 Jan 2018 19:40:43 +0200 Subject: [PATCH 166/167] Remove unused time formats --- config/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 68eeb2010..da6df608a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -22,10 +22,8 @@ en: longer: "%a, %e. %b %Y, %H:%M" long: "%A, %e. %B %Y, %H:%M" short: "%d.%m.%y, %H:%M" - shorts: "%d.%m.%y, %H:%M:%S" date: "%Y-%m-%d" date_long: "%d. %B %Y" - ydate: "%Y.%m.%d" filename: "%Y-%m-%d_%H.%M" date: formats: From 5162a89898a77f4e6735ce8590a67ba921713008 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 31 Jan 2018 16:22:09 +0200 Subject: [PATCH 167/167] Fix JS #660 --- app/views/registrant/sessions/login_mid.haml | 3 ++- app/views/registrar/domains/form/_contacts.haml | 3 ++- app/views/registrar/domains/form/_dnskeys.haml | 5 ++--- app/views/registrar/domains/form/_nameservers.haml | 3 ++- app/views/registrar/payments/pay.html.haml | 3 ++- app/views/registrar/polls/show.haml | 3 ++- app/views/registrar/sessions/login_mid.haml | 3 ++- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/views/registrant/sessions/login_mid.haml b/app/views/registrant/sessions/login_mid.haml index 227ec23af..34da5a2ae 100644 --- a/app/views/registrant/sessions/login_mid.haml +++ b/app/views/registrant/sessions/login_mid.haml @@ -13,7 +13,7 @@ 00007, 60000007, 00000766 :coffee - window.onload = -> + load_listener = -> $('.js-login').attr('disabled', false) status_interval = null @@ -38,3 +38,4 @@ flash_alert(data.responseJSON.message) $('.js-login').attr('disabled', false) ) + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/domains/form/_contacts.haml b/app/views/registrar/domains/form/_contacts.haml index b5a857c98..8e01ffda3 100644 --- a/app/views/registrar/domains/form/_contacts.haml +++ b/app/views/registrar/domains/form/_contacts.haml @@ -22,7 +22,7 @@ = text_field_tag "domain[contacts_attributes][#{k}][code_helper]", contacts.find_by(code: v['code']).try(:search_name), class: 'form-control', data: {autocomplete: search_contacts_registrar_domains_path}, required: true :coffee - window.onload = -> + load_listener = -> clone = $('.js-contact:first').clone() $("#js-domain-contacts").nestedAttributes bindAddTo: $(".add-domain-contact") @@ -41,3 +41,4 @@ $(v).hide() new Autocomplete() $clone: clone + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/domains/form/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml index 5574ead13..630e16303 100644 --- a/app/views/registrar/domains/form/_dnskeys.haml +++ b/app/views/registrar/domains/form/_dnskeys.haml @@ -68,11 +68,10 @@ class: 'form-control' :coffee - window.onload = -> + load_listener = -> $("#dnskeys").nestedAttributes bindAddTo: $(".add-dnskey") afterAdd: (item) -> item.find('select').each (k, v) -> $(v).val($(v).find('option:first-child').val()) - - + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/domains/form/_nameservers.haml b/app/views/registrar/domains/form/_nameservers.haml index 374a1eaba..75d34b924 100644 --- a/app/views/registrar/domains/form/_nameservers.haml +++ b/app/views/registrar/domains/form/_nameservers.haml @@ -27,6 +27,7 @@ = text_field_tag "domain[nameservers_attributes][#{k}][ipv6]", v['ipv6'], class: 'form-control'#, ipv6: true :coffee - window.onload = -> + load_listener = -> $("#nameservers").nestedAttributes bindAddTo: $(".add-nameserver") + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/payments/pay.html.haml b/app/views/registrar/payments/pay.html.haml index b2c5eaedb..c0fd8b6ad 100644 --- a/app/views/registrar/payments/pay.html.haml +++ b/app/views/registrar/payments/pay.html.haml @@ -6,5 +6,6 @@ :coffeescript - window.onload = -> + load_listener = -> $('.payment-form form').submit() + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index 4a5ec678c..69e74751b 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -82,9 +82,10 @@ %p.bg-info{style: 'padding: 15px;'}= t(:you_have_no_new_messages) :coffee - window.onload = -> + load_listener = -> $(".js-keyrelay-confirm").on "click", -> $(".js-keyrelay-form").submit() $(".js-transfer-confirm").on "click", -> $(".js-transfer-form").submit() + window.addEventListener 'load', load_listener diff --git a/app/views/registrar/sessions/login_mid.haml b/app/views/registrar/sessions/login_mid.haml index 3eb2ef172..78e39a3b7 100644 --- a/app/views/registrar/sessions/login_mid.haml +++ b/app/views/registrar/sessions/login_mid.haml @@ -13,7 +13,7 @@ 00007, 60000007, 00000766 :coffee - window.onload = -> + load_listener = -> $('.js-login').attr('disabled', false) status_interval = null @@ -38,3 +38,4 @@ flash_alert(data.responseJSON.message) $('.js-login').attr('disabled', false) ) + window.addEventListener 'load', load_listener
- <%= sort_link(@q, 'name') %> - - <%= sort_link(@q, 'registrant_name', t('.registrant')) %> - - <%= sort_link(@q, 'valid_to', t(:valid_to)) %> - - <%= t('actions') %> -
+ <%= sort_link(@q, 'name') %> + + <%= sort_link(@q, 'registrant_name', t('.registrant')) %> + + <%= sort_link(@q, 'valid_to', t(:valid_to)) %> + + <%= t('actions') %> +
<%= link_to truncate(domain.name), info_registrar_domains_path(domain_name: domain.name) %> <%= link_to domain.registrant, registrar_contact_path(id: domain.registrant.code) %><%= l(domain.valid_to, format: :date_long) %><%= l domain.expire_time %> <%= link_to t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs' %> <%= link_to t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> From a0c11292354de5d5cc9e1d148171e4b2c2ba6349 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 17 Jan 2018 18:12:05 +0200 Subject: [PATCH 028/167] Improve translation --- .../registrar/domains/_search_form.html.erb | 14 +++++++------- app/views/registrar/domains/index.html.erb | 16 +++++++--------- config/locales/en.yml | 1 - config/locales/registrar/domains.en.yml | 3 ++- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/views/registrar/domains/_search_form.html.erb b/app/views/registrar/domains/_search_form.html.erb index 0e31bab91..9ff34032a 100644 --- a/app/views/registrar/domains/_search_form.html.erb +++ b/app/views/registrar/domains/_search_form.html.erb @@ -9,21 +9,21 @@
- <%= f.label t(:registrant_ident) %> + <%= f.label :registrant_ident %> <%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
- <%= f.label t(:contact_ident) %> + <%= f.label :contact_ident %> <%= f.search_field :contacts_ident_eq, class: 'form-control', placeholder: t(:contact_ident) %>
- <%= f.label t(:nameserver_hostname) %> + <%= f.label :nameserver_hostname %> <%= f.search_field :nameservers_hostname_eq, class: 'form-control', placeholder: t(:nameserver_hostname) %>
@@ -32,21 +32,21 @@
- <%= label_tag t(:status) %> + <%= label_tag :status %> <%= select_tag :statuses_contains, options_for_select(DomainStatus::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } %>
- <%= f.label t(:valid_to_from) %> + <%= f.label :valid_to_from %> <%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
- <%= f.label t(:valid_to_until) %> + <%= f.label :valid_to_until %> <%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
@@ -56,7 +56,7 @@
- <%= label_tag t(:results_per_page) %> + <%= label_tag :results_per_page %> <%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
diff --git a/app/views/registrar/domains/index.html.erb b/app/views/registrar/domains/index.html.erb index c48a355b2..a8680b7cf 100644 --- a/app/views/registrar/domains/index.html.erb +++ b/app/views/registrar/domains/index.html.erb @@ -1,12 +1,12 @@
- <%= sort_link(@q, 'registrant_name', t('.registrant')) %> + <%= sort_link @q, 'registrant_name', Registrant.model_name.human %> - <%= sort_link(@q, 'valid_to', t(:valid_to)) %> - - <%= t('actions') %> + <%= sort_link @q, 'valid_to', Domain.human_attribute_name(:expire_time) %>
<%= link_to domain.registrant, registrar_contact_path(id: domain.registrant.code) %> <%= l domain.expire_time %> - <%= link_to t(:edit), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs' %> - <%= link_to t(:renew), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> - <%= link_to t(:delete), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + <%= link_to t('.edit_btn'), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs' %> + <%= link_to t('.renew_btn'), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %>
<%= link_to domain.registrant, registrar_contact_path(id: domain.registrant.code) %> <%= l domain.expire_time %> - <%= link_to t('.edit_btn'), edit_registrar_domains_path(domain_name: domain.name), class: 'btn btn-primary btn-xs' %> - <%= link_to t('.renew_btn'), renew_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> - <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name), class: 'btn btn-default btn-xs' %> + <%= link_to t('.edit_btn'), edit_registrar_domains_path(domain_name: domain.name), + class: 'btn btn-primary btn-xs' %> + <%= link_to t('.renew_btn'), renew_registrar_domains_path(domain_name: domain.name), + class: 'btn btn-default btn-xs' %> + <%= link_to t('.delete_btn'), delete_registrar_domains_path(domain_name: domain.name), + class: 'btn btn-default btn-xs' %>