Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Priit Tark 2015-08-12 00:41:39 +03:00
commit 7da3804321
12 changed files with 1650 additions and 1358 deletions

View file

@ -2,21 +2,41 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
before_action :init_domain, except: :new
before_action :init_contacts_autocomplete_map, only: [:new, :edit, :create, :update]
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/AbcSize
def index
authorize! :view, Depp::Domain
limit, offset = pagination_details
res = depp_current_user.repp_request('domains', { details: true, limit: limit, offset: offset })
if res.code == '200'
@response = res.parsed_body.with_indifferent_access
@contacts = @response ? @response[:contacts] : []
@paginatable_array = Kaminari.paginate_array(
[], total_count: @response[:total_number_of_records]
).page(params[:page]).per(limit)
params[:q] ||= {}
if params[:statuses_contains]
domains = current_user.registrar.domains.includes(:registrar, :registrant).where(
"statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}"
)
else
domains = current_user.registrar.domains.includes(:registrar, :registrant)
end
flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }]
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
if @domains.count == 1 && params[:q][:name_matches].present?
redirect_to info_registrar_domains_path(domain_name: @domains.first.name) and return
elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/
# if we do not get any results, add wildcards to the name field and search again
n_cache = params[:q][:name_matches]
params[:q][:name_matches] = "%#{params[:q][:name_matches]}%"
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
params[:q][:name_matches] = n_cache # we don't want to show wildcards in search form
end
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
# rubocop: enable Metrics/AbcSize
def info
authorize! :view, Depp::Domain
@ -123,4 +143,18 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
# @priv_contacts_autocomplete_map ||=
# current_user.registrar.priv_contacts.pluck(:name, :code).map { |c| ["#{c.second} #{c.first}", c.second] }
end
def normalize_search_parameters
ca_cache = params[:q][:valid_to_lteq]
begin
end_time = params[:q][:valid_to_lteq].try(:to_date)
params[:q][:valid_to_lteq] = end_time.try(:end_of_day)
rescue
logger.warn('Invalid date')
end
yield
params[:q][:valid_to_lteq] = ca_cache
end
end

View file

@ -47,7 +47,7 @@
%th{class: 'col-xs-6'}= t(:setting)
%th{class: 'col-xs-6'}= t(:value)
%tbody
= render 'setting_row', var: :transfer_wait_time
/= render 'setting_row', var: :transfer_wait_time
= render 'setting_row', var: :ds_algorithm
= render 'setting_row', var: :client_side_status_editing_enabled
= render 'setting_row', var: :api_ip_whitelist_enabled

View file

@ -7,42 +7,89 @@
= render 'shared/title', name: t(:domains)
.row
.col-md-12{style: 'margin-bottom: -15px;'}
= form_tag info_registrar_domains_path, class: 'form-horizontal', method: :get do
.col-md-11
.form-group
= text_field_tag :domain_name, params[:domain_name], class: 'form-control', placeholder: t(:domain_name), autocomplete: 'off', autofocus: true
.col-md-1.text-right.text-center-xs
.form-group
%button.btn.btn-default
.col-md-12
= search_form_for [:registrar, @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
= 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 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 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{style: 'padding-top: 25px;'}
%button.btn.btn-primary.search
&nbsp;
%span.glyphicon.glyphicon-search
&nbsp;
%button.btn.btn-default.js-reset-form
= t(:clear_fields)
%hr
- if @response
.table-responsive
%table.table.table-hover.table-condensed
%thead
%tr
%th{class: 'col-xs-3'}= t(:name)
%th{class: 'col-xs-6'}= t(:valid)
%th{class: 'col-xs-3'}= t(:actions)
%tbody
- @response['domains'].each do |x|
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%td= link_to(x['name'], info_registrar_domains_path(domain_name: x['name']))
%td
= Time.zone.parse(x['valid_from']).try(:to_date)
\-
= Time.zone.parse(x['valid_to']).try(:to_date)
%td
= link_to(t(:edit), edit_registrar_domains_path(domain_name: x['name']),
class: 'btn btn-primary btn-xs')
= link_to(t(:renew), renew_registrar_domains_path(domain_name: x['name']),
class: 'btn btn-default btn-xs')
= link_to(t(:delete), delete_registrar_domains_path(domain_name: x['name']),
%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 |x|
%tr
%td= link_to(truncate(x.name), info_registrar_domains_path(domain_name: x.name))
%td
- if x.registrant
= link_to(x.registrant, registrar_contact_path(id: x.registrant.code))
%td= l(x.valid_to, format: :date_long)
%td
= link_to(t(:edit), edit_registrar_domains_path(domain_name: x.name),
class: 'btn btn-primary btn-xs')
= link_to(t(:renew), renew_registrar_domains_path(domain_name: x.name),
class: 'btn btn-default btn-xs')
= link_to(t(:delete), delete_registrar_domains_path(domain_name: x.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)
= paginate @paginatable_array
:coffee
$(".js-reset-form").on "click", (e) ->
e.preventDefault();
window.location = "#{registrar_domains_path}"

View file

@ -22,6 +22,7 @@ if con.present? && con.table_exists?('settings')
Setting.save_default(:ns_max_count, 11)
Setting.save_default(:transfer_wait_time, 0)
Setting.transfer_wait_time = 0
Setting.save_default(:request_confrimation_on_registrant_change_enabled, true)
Setting.save_default(:request_confirmation_on_domain_deletion_enabled, true)

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
(function(){$(document).on("page:change",function(){return $(".selectize").selectize({allowEmptyOption:!0}),$("form").each(function(){return $(this).validate()}),$(".js-contact-form").on("restoreDefault",function(t){var e;switch(e=$(t.target),e.find(".js-ident-tip").hide(),$(".js-ident-country-code option:selected").val()){case"EE":return $(".js-ident-type").find("option[value=birthday]").prop("disabled",!0);default:return $(".js-ident-type").find("option[value=birthday]").prop("disabled",!1)}}),$(".js-ident-country-code").change(function(){var t;return t=$(".js-contact-form"),t.trigger("restoreDefault")}),$(".js-ident-type").change(function(t){var e;switch(e=$(".js-contact-form"),e.trigger("restoreDefault"),t.target.value){case"birthday":return e.find(".js-ident-tip").show()}}),$(".js-contact-form").trigger("restoreDefault")})}).call(this);

View file

@ -907,7 +907,6 @@ describe 'EPP Domain', epp: true do
context 'with valid domain' do
let(:domain) { Fabricate(:domain, registrar: @registrar1, dnskeys: []) }
### TRANSFER ###
it 'transfers a domain' do
domain.registrar = @registrar1
domain.save
@ -928,6 +927,67 @@ describe 'EPP Domain', epp: true do
old_contact_codes = domain.contacts.pluck(:code).sort.uniq
old_registrant_code = domain.registrant.code
login_as :registrar2 do
response = epp_plain_request(xml)
domain.reload
dtl = domain.domain_transfers.last
trn_data = response[:parsed].css('trnData')
trn_data.css('name').text.should == domain.name
trn_data.css('trStatus').text.should == 'serverApproved'
trn_data.css('reID').text.should == 'REGDOMAIN2'
trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
trn_data.css('acID').text.should == 'REGDOMAIN1'
trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601
trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
domain.registrar.should == @registrar2
end
response = epp_plain_request(@epp_xml.session.poll)
response[:msg].should == 'Command completed successfully; ack to dequeue'
msg_q = response[:parsed].css('msgQ')
msg_q.css('qDate').text.should_not be_blank
msg_q.css('msg').text.should == "Domain transfer was approved, associated contacts were: " \
"#{old_contact_codes} and registrant was #{old_registrant_code}"
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '1'
xml = @epp_xml.session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_plain_request(xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '0'
end
### TRANSFER ###
# Do not place this test to epp-examples (epp: false)
it 'transfers a domain with wait time > 0', epp: false do
domain.registrar = @registrar1
domain.save
pw = domain.auth_info
xml = domain_transfer_xml({
name: { value: domain.name },
authInfo: { pw: { value: pw } }
}, 'request', {
_anonymus: [
legalDocument: {
value: 'dGVzdCBmYWlsCg==',
attrs: { type: 'pdf' }
}
]
})
old_contact_codes = domain.contacts.pluck(:code).sort.uniq
old_registrant_code = domain.registrant.code
response = login_as :registrar2 do
epp_plain_request(xml)
end
@ -1008,35 +1068,30 @@ describe 'EPP Domain', epp: true do
# should show up in other registrar's poll
response = login_as :registrar2 do
epp_plain_request(@epp_xml.session.poll)
login_as :registrar2 do
response = epp_plain_request(@epp_xml.session.poll)
response[:msg].should == 'Command completed successfully; ack to dequeue'
msg_q = response[:parsed].css('msgQ')
msg_q.css('qDate').text.should_not be_blank
msg_q.css('msg').text.should == 'Transfer requested.'
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '1'
xml = @epp_xml.session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = epp_plain_request(xml)
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '0'
end
response[:msg].should == 'Command completed successfully; ack to dequeue'
msg_q = response[:parsed].css('msgQ')
msg_q.css('qDate').text.should_not be_blank
msg_q.css('msg').text.should == 'Transfer requested.'
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '1'
xml = @epp_xml.session.poll(poll: {
value: '', attrs: { op: 'ack', msgID: msg_q.first['id'] }
})
response = login_as :registrar2 do
epp_plain_request(xml)
end
response[:msg].should == 'Command completed successfully'
msg_q = response[:parsed].css('msgQ')
msg_q.first['id'].should_not be_blank
msg_q.first['count'].should == '0'
create_settings
end
it 'creates a domain transfer with legal document' do
Setting.transfer_wait_time = 1
domain.legal_documents.count.should == 0
pw = domain.auth_info
xml = domain_transfer_xml({
@ -1070,11 +1125,6 @@ describe 'EPP Domain', epp: true do
response = login_as :registrar2 do
epp_plain_request(xml)
end
response[:result_code].should == '1000'
domain.legal_documents.count.should == 1 # does not add another legal documen
create_settings
end
it 'creates transfer successfully without legal document' do
@ -1572,7 +1622,18 @@ describe 'EPP Domain', epp: true do
response[:results][0][:result_code].should == '2303'
end
it 'should allow querying domain transfer' do
it 'should not cancel transfer when there are none' do
xml = domain_transfer_xml({
name: { value: domain.name },
authInfo: { pw: { value: domain.auth_info } }
}, 'cancel')
response = epp_plain_request(xml)
response[:results][0][:msg].should == 'No transfers found'
response[:results][0][:result_code].should == '2303'
end
it 'should allow querying domain transfer', epp: false do
Setting.transfer_wait_time = 1
pw = domain.auth_info
xml = domain_transfer_xml({

View file

@ -54,6 +54,47 @@ feature 'Domains', type: :feature do
page.should_not have_text(d1.name)
page.should have_text(d2.name)
end
it 'should search domains' do
# having shared state across tests is really annoying sometimes...
click_link "#{@user} (#{@user.roles.first}) - #{@user.registrar}"
Fabricate(:domain, name: 'abcde.ee', registrar: @user.registrar)
Fabricate(:domain, name: 'abcdee.ee', registrar: @user.registrar)
Fabricate(:domain, name: 'defgh.pri.ee', registrar: @user.registrar)
visit '/registrar/domains'
click_link 'Domains'
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcde.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains/info"
visit '/registrar/domains'
fill_in 'q_name_matches', with: '.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains"
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd%.ee'
find('.btn.btn-primary.search').click
page.should have_content('abcde.ee')
page.should have_content('abcdee.ee')
page.should_not have_content('defgh.pri.ee')
fill_in 'q_name_matches', with: 'abcd_.ee'
find('.btn.btn-primary.search').click
current_path.should == "/registrar/domains/info"
end
end
end