Merge branch 'master' of https://github.com/internetee/registry into 1857-covered-registry-by-tests

This commit is contained in:
Oleg Hasjanov 2021-03-04 13:22:52 +02:00
commit 853e4c447b
54 changed files with 19 additions and 1803 deletions

View file

@ -1,3 +1,9 @@
04.03.2021
* Removed old registrant portal from the project [#1826](https://github.com/internetee/registry/issues/1826)
03.03.2021
* Email notification is sent in case of pendingupdate expiry [#897](https://github.com/internetee/registry/issues/897)
26.02.2021
* Domain delete is not affected by updateProhibited [#1844](https://github.com/internetee/registry/issues/1844)
* Registrant API fix for handling eidas personal identificators [#1864](https://github.com/internetee/registry/pull/1864)

View file

@ -1,115 +0,0 @@
class Registrant::ContactsController < RegistrantController
helper_method :domain
helper_method :fax_enabled?
helper_method :domain_filter_params
skip_authorization_check only: %i[edit update]
before_action :set_contact, only: [:show]
def show
@requester_contact = Contact.find_by(ident: current_registrant_user.ident)
authorize! :read, @contact
end
def edit
@contact = current_user_contacts.find(params[:id])
end
def update
@contact = current_user_contacts.find(params[:id])
@contact.attributes = contact_params
response = update_contact_via_api(@contact.uuid)
updated = response.is_a?(Net::HTTPSuccess)
if updated
redirect_to registrant_domain_contact_url(domain, @contact), notice: t('.updated')
else
parsed_response = JSON.parse(response.body, symbolize_names: true)
@errors = parsed_response[:errors]
render :edit
end
end
private
def set_contact
id = params[:id]
contact = domain.contacts.find_by(id: id) || current_user_contacts.find_by(id: id)
contact ||= Contact.find_by(id: id, ident: domain.registrant.ident)
@contact = contact
end
def domain
current_user_domains.find(params[:domain_id])
end
def contact_params
permitted = %i[
name
email
phone
]
permitted << :fax if fax_enabled?
permitted += %i[street zip city state country_code] if Contact.address_processing?
params.require(:contact).permit(*permitted)
end
def access_token
uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/auth/eid")
request = Net::HTTP::Post.new(uri)
request.form_data = access_token_request_params
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
http.request(request)
end
json_doc = JSON.parse(response.body, symbolize_names: true)
json_doc[:access_token]
end
def access_token_request_params
{ ident: current_registrant_user.ident,
first_name: current_registrant_user.first_name,
last_name: current_registrant_user.last_name }
end
def fax_enabled?
ENV['fax_enabled'] == 'true'
end
def contact_update_api_params
params = contact_params
params = normalize_address_attributes_for_api(params) if Contact.address_processing?
params
end
def normalize_address_attributes_for_api(params)
normalized = params
address_parts = {}
Contact.address_attribute_names.each do |attr|
attr = attr.to_sym
address_parts[attr] = params[attr]
normalized.delete(attr)
end
normalized[:address] = address_parts
normalized
end
def update_contact_via_api(uuid)
uri = URI.parse("#{ENV['registrant_api_base_url']}/api/v1/registrant/contacts/#{uuid}")
request = Net::HTTP::Patch.new(uri)
request['Authorization'] = "Bearer #{access_token}"
request['Content-type'] = 'application/json'
request.body = contact_update_api_params.to_json
Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
http.request(request)
end
end
def domain_filter_params
params.permit(:domain_filter)
end
end

View file

@ -1,44 +0,0 @@
class Registrant::DomainDeleteConfirmsController < RegistrantController
skip_before_action :authenticate_registrant_user!, only: [:show, :update]
skip_authorization_check only: [:show, :update]
def show
return if params[:confirmed] || params[:rejected]
@domain = Domain.find(params[:id])
@domain = nil unless @domain.registrant_delete_confirmable?(params[:token])
end
def update
@domain = Domain.find(params[:id])
unless @domain.registrant_delete_confirmable?(params[:token])
flash[:alert] = t(:registrant_domain_verification_failed)
return render 'show'
end
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
verification_token: params[:token])
initiator = current_registrant_user ? current_registrant_user.username :
t(:user_not_authenticated)
confirmed = params[:confirmed] ? true : false
action = if confirmed
@registrant_verification.domain_registrant_delete_confirm!("email link #{initiator}")
else
@registrant_verification.domain_registrant_delete_reject!("email link #{initiator}")
end
fail_msg = t("registrant_domain_delete_#{confirmed ? 'confirmed' : 'rejected'}_failed".to_sym)
success_msg = t("registrant_domain_verification_#{confirmed ? 'confirmed' : 'rejected'}".to_sym)
flash[:alert] = action ? success_msg : fail_msg
(render 'show' && return) unless action
if confirmed
redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true)
else
redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true)
end
end
end

View file

@ -1,44 +0,0 @@
class Registrant::DomainUpdateConfirmsController < RegistrantController
skip_before_action :authenticate_registrant_user!, only: %i[show update]
skip_authorization_check only: %i[show update]
def show
return if params[:confirmed] || params[:rejected]
@domain = Domain.find(params[:id])
@domain = nil unless @domain.registrant_update_confirmable?(params[:token])
end
def update
@domain = Domain.find(params[:id])
unless @domain.registrant_update_confirmable?(params[:token])
flash[:alert] = t(:registrant_domain_verification_failed)
return render 'show'
end
@registrant_verification = RegistrantVerification.new(domain_id: @domain.id,
verification_token: params[:token])
initiator = current_registrant_user ? current_registrant_user.username :
t(:user_not_authenticated)
if params[:rejected]
if @registrant_verification.domain_registrant_change_reject!("email link, #{initiator}")
flash[:notice] = t(:registrant_domain_verification_rejected)
redirect_to registrant_domain_update_confirm_path(@domain.id, rejected: true)
else
flash[:alert] = t(:registrant_domain_verification_rejected_failed)
return render 'show'
end
elsif params[:confirmed]
if @registrant_verification.domain_registrant_change_confirm!("email link, #{initiator}")
Dispute.close_by_domain(@domain.name) if @domain.disputed?
flash[:notice] = t(:registrant_domain_verification_confirmed)
redirect_to registrant_domain_update_confirm_path(@domain.id, confirmed: true)
else
flash[:alert] = t(:registrant_domain_verification_confirmed_failed)
return render 'show'
end
end
end
end

View file

@ -1,79 +0,0 @@
class Registrant::DomainsController < RegistrantController
def index
authorize! :view, :registrant_domains
params[:q] ||= {}
normalize_search_parameters do
@q = current_user_domains.search(search_params)
end
domains = @q.result
respond_to do |format|
format.html do
@domains = domains.page(params[:page])
domains_per_page = params[:results_per_page].to_i
@domains = @domains.per(domains_per_page) if domains_per_page.positive?
end
format.csv do
raw_csv = @q.result.to_csv
send_data raw_csv, filename: 'domains.csv', type: "#{Mime[:csv]}; charset=utf-8"
end
format.pdf do
view = ActionView::Base.new(ActionController::Base.view_paths, domains: domains)
raw_html = view.render(file: 'registrant/domains/list_pdf', layout: false)
raw_pdf = domains.pdf(raw_html)
send_data raw_pdf, filename: 'domains.pdf'
end
end
end
def show
@domain = current_user_domains.find(params[:id])
authorize! :read, @domain
end
def confirmation
authorize! :view, :registrant_domains
domain = current_user_domains.find(params[:id])
if (domain.statuses.include?(DomainStatus::PENDING_UPDATE) ||
domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
domain.pending_json.present?
@domain = domain
@confirmation_url = confirmation_url(domain)
else
flash[:warning] = I18n.t('available_verification_url_not_found')
redirect_to registrant_domain_path(domain)
end
end
private
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
def confirmation_url(domain)
if domain.statuses.include?(DomainStatus::PENDING_UPDATE)
registrant_domain_update_confirm_url(token: domain.registrant_verification_token)
elsif domain.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
registrant_domain_delete_confirm_url(token: domain.registrant_verification_token)
end
end
def search_params
params.require(:q).permit(:name_matches, :registrant_ident_eq, :valid_to_gteq, :valid_to_lteq,
:results_per_page)
end
end

View file

@ -1,6 +0,0 @@
class Registrant::RegistrarsController < RegistrantController
def show
@registrar = Registrar.find(params[:id])
authorize! :read, @registrar
end
end

View file

@ -1,17 +0,0 @@
class Registrant::SessionsController < Devise::SessionsController
layout 'registrant/application'
private
def after_sign_in_path_for(_resource_or_scope)
registrant_root_path
end
def after_sign_out_path_for(_resource_or_scope)
new_registrant_user_session_path
end
def user_for_paper_trail
current_registrant_user.present? ? current_registrant_user.id_role_username : 'anonymous'
end
end

View file

@ -17,7 +17,9 @@ module Domains
def notify_pending_update
RegistrantChangeMailer.expired(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant).deliver_later
registrant: domain.registrant,
send_to: [domain.new_registrant_email,
domain.registrant.email]).deliver_later
end
def notify_pending_delete

View file

@ -1,20 +0,0 @@
class RegistrantChangeExpiredEmailJob < Que::Job
def run(domain_id)
domain = Domain.find(domain_id)
log(domain)
RegistrantChangeMailer.expired(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant).deliver_now
end
private
def log(domain)
message = "Send RegistrantChangeMailer#expired email for domain #{domain.name} (##{domain.id}) to #{domain.new_registrant_email}"
logger.info(message)
end
def logger
Rails.logger
end
end

View file

@ -6,10 +6,6 @@ class ApplicationMailer < ActionMailer::Base
token = domain.registrant_verification_token
base_url = ENV['registrant_portal_verifications_base_url']
url = registrant_domain_delete_confirm_url(domain, token: token) if method == 'delete'
url ||= registrant_domain_update_confirm_url(domain, token: token)
return url if base_url.blank?
"#{base_url}/confirmation/#{domain.name_puny}/#{method}/#{token}"
end
end

View file

@ -38,13 +38,13 @@ class RegistrantChangeMailer < ApplicationMailer
mail(to: domain.new_registrant_email, subject: subject)
end
def expired(domain:, registrar:, registrant:)
def expired(domain:, registrar:, registrant:, send_to:)
@domain = DomainPresenter.new(domain: domain, view: view_context)
@registrar = RegistrarPresenter.new(registrar: registrar, view: view_context)
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
subject = default_i18n_subject(domain_name: domain.name)
mail(to: domain.new_registrant_email, subject: subject)
mail(to: send_to, subject: subject)
end
private

View file

@ -1,7 +0,0 @@
<div class="alert alert-danger">
<ul>
<% errors.each_value do |errors| %>
<li><%= errors.join('<br>') %></li>
<% end %>
</ul>
</div>

View file

@ -1,64 +0,0 @@
<%= form_for [:registrant, domain, @contact], html: { class: 'form-horizontal' } do |f| %>
<% if @errors.present? %>
<%= render 'api_errors', errors: @errors %>
<% end %>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :name %>
</div>
<div class="col-md-4">
<%= f.text_field :name, required: true, autofocus: true, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :email %>
</div>
<div class="col-md-4">
<%= f.email_field :email, required: true, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :phone %>
</div>
<div class="col-md-4">
<%= f.text_field :phone, required: true, class: 'form-control' %>
</div>
</div>
<% if Contact.address_processing? %>
<div class="panel panel-default">
<div class="panel-heading"><%= t '.address' %></div>
<div class="panel-body">
<%= render 'registrant/contacts/form/address', f: f %>
</div>
</div>
<% end %>
<% if fax_enabled? %>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :fax %>
</div>
<div class="col-md-4">
<%= f.text_field :fax, class: 'form-control' %>
</div>
</div>
<% end %>
<hr/>
<div class="row">
<div class="col-md-6 text-right">
<%= button_tag t('.submit_btn'), class: 'btn btn-success' %>
</div>
</div>
<% end %>

View file

@ -1,12 +0,0 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
<li><%= link_to domain, registrant_domain_path(domain) %></li>
<li><%= t 'registrant.contacts.contact_index' %></li>
<li><%= link_to @contact, registrant_domain_contact_path(domain, @contact) %></li>
</ol>
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<%= render 'form' %>

View file

@ -1,51 +0,0 @@
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :street %>
</div>
<div class="col-md-4">
<%= f.text_field :street, required: true, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :zip %>
</div>
<div class="col-md-4">
<%= f.text_field :zip, required: true, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :city %>
</div>
<div class="col-md-4">
<%= f.text_field :city, required: true, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :state %>
</div>
<div class="col-md-4">
<%= f.text_field :state, class: 'form-control' %>
</div>
</div>
<div class="form-group">
<div class="col-md-2 control-label">
<%= f.label :country_code, 'Country' %>
</div>
<div class="col-md-4">
<%= f.select :country_code, SortedCountry.all_options(f.object.country_code), {},
required: true,
class: 'form-control' %>
</div>
</div>

View file

@ -1,42 +0,0 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
<li><%= link_to domain, registrant_domain_path(domain) %></li>
<li><%= t 'registrant.contacts.contact_index' %></li>
</ol>
<div class="page-header">
<div class="row">
<div class="col-md-6">
<h1><%= @contact %></h1>
</div>
<% if @contact.managed_by?(current_registrant_user) %>
<div class="col-md-6 text-right">
<%= link_to t('.edit_btn'), edit_registrant_domain_contact_path(domain, @contact),
class: 'btn btn-primary' %>
</div>
<% end %>
</div>
</div>
<div class="row">
<div class="col-md-6">
<%= render 'registrant/contacts/show/general' %>
</div>
<div class="col-md-6">
<%= render 'registrant/contacts/show/address' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/contacts/show/statuses', contact: @contact %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/contacts/show/domains', contact: @contact %>
</div>
</div>

View file

@ -1,31 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<%= t '.header' %>
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<% if @contact.org_name.present? %>
<dt><%= Contact.human_attribute_name :org_name %></dt>
<dd><%= @contact.org_name %></dd>
<% end %>
<dt><%= Contact.human_attribute_name :street %></dt>
<dd><%= @contact.street %></dd>
<dt><%= Contact.human_attribute_name :city %></dt>
<dd><%= @contact.city %></dd>
<dt><%= Contact.human_attribute_name :zip %></dt>
<dd><%= @contact.zip %></dd>
<dt><%= Contact.human_attribute_name :state %></dt>
<dd><%= @contact.state %></dd>
<dt><%= Contact.human_attribute_name :country %></dt>
<dd><%= @contact.country %></dd>
</dl>
</div>
</div>

View file

@ -1,6 +0,0 @@
<tr>
<td><%= link_to domain.name, registrant_domain_path(domain) %></td>
<td><%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %></td>
<td><%= l domain.valid_to %></td>
<td><%= domain.roles.join(", ") %></td>
</tr>

View file

@ -1,54 +0,0 @@
<% domains = contact.all_domains(page: params[:domain_page], per: 20,
params: domain_filter_params.to_h, requester: @requester_contact) %>
<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
<div class="col-sm-6">
<%= t '.header' %>
</div>
<div class="col-sm-6 text-right">
<%= form_tag request.path, method: :get, class: 'form-inline' do %>
<%= select_tag :domain_filter,
options_for_select(%w(Registrant AdminDomainContact TechDomainContact),
selected: params[:domain_filter]),
include_blank: t('.all'),
class: 'form-control' %>
<button class="btn btn-primary">
<span class="glyphicon glyphicon-search"></span>
</button>
<% end %>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-3">
<%= custom_sort_link Domain.human_attribute_name(:name), :name %>
</th>
<th class="col-xs-3">
<%= custom_sort_link Registrar.model_name.human, :registrar_name %>
</th>
<th class="col-xs-3">
<%= custom_sort_link Domain.human_attribute_name(:valid_to), :valid_to %>
</th>
<th class="col-xs-3">
<%= custom_sort_link Domain.human_attribute_name(:roles), :roles %>
</th>
</tr>
</thead>
<tbody>
<%= render partial: 'registrant/contacts/show/domain', collection: domains %>
</tbody>
</table>
</div>
<div class="panel-footer">
<%= paginate domains, param_name: :domain_page %>
</div>
</div>

View file

@ -1,48 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<%= t '.header' %>
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Contact.human_attribute_name :code %></dt>
<dd><%= @contact.code %></dd>
<dt><%= Contact.human_attribute_name :name %></dt>
<dd><%= @contact.name %></dd>
<dt><%= Contact.human_attribute_name :auth_info %></dt>
<dd>
<%= tag :input, type: 'text', value: @contact.auth_info, readonly: true,
class: 'form-control input-sm' %>
</dd>
<dt><%= Contact.human_attribute_name :ident %></dt>
<dd><%= ident_for(@contact) %></dd>
<dt><%= Contact.human_attribute_name :email %></dt>
<dd><%= @contact.email %></dd>
<dt><%= Contact.human_attribute_name :phone %></dt>
<dd><%= @contact.phone %></dd>
<% if @contact.fax %>
<dt><%= Contact.human_attribute_name :fax %></dt>
<dd><%= @contact.fax %></dd>
<% end %>
<dt><%= Contact.human_attribute_name :created_at %></dt>
<dd><%= l @contact.created_at %></dd>
<dt><%= Contact.human_attribute_name :updated_at %></dt>
<dd><%= l @contact.updated_at %></dd>
<dt><%= Registrar.model_name.human %></dt>
<dd>
<%= link_to @contact.registrar, registrant_registrar_path(@contact.registrar) %>
</dd>
</dl>
</div>
</div>

View file

@ -1,6 +0,0 @@
<%= search_form_for [:registrant, @q] do |f| %>
<%= f.search_field :name_cont %>
<%= f.submit do %>
<span class="glyphicon glyphicon-search"></span>
<% end %>
<% end %>

View file

@ -1,25 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-6"><%= t '.status' %></th>
<th class="col-xs-6"><%= t '.notes' %></th>
</tr>
</thead>
<tbody>
<% contact.statuses.each do |status| %>
<tr>
<td><%= status %></td>
<td><%= contact.status_notes[status] %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View file

@ -1,44 +0,0 @@
- if params[:confirmed].present?
.row
.col-md-12
%h1= t(:domain_delete_confirmed_title)
.row
.col-md-12
%p= t(:domain_delete_confirmed_body)
- elsif params[:rejected].present?
.row
.col-md-12
%h1= t(:domain_delete_rejected_title)
.row
.col-md-12
%p= t(:domain_delete_rejected_body)
- else
- if @domain.present?
.row
.col-md-12
%h1= t(:domain_delete_title)
.row
.col-md-12
%p= t(:domain_delete_body)
%hr
.row
.col-md-12.text-center.confirmation
.column-keys
%p= t(:domain_name) + ':'
%p= t('.registrant') + ':'
.column-values
%p= @domain.name
%p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
.row
.col-md-12.text-center
.confirmation
= form_for registrant_domain_delete_confirm_path(@domain.id), method: :patch do |f|
= hidden_field_tag :token, params[:token]
= f.button t(:confirm_domain_delete), name: 'confirmed', class: 'btn btn-primary'
= f.button t(:reject_domain_delete), name: 'rejected', class: 'btn btn-warning'
%hr
- else
%h1= t(:not_valid_domain_verification_title).html_safe
%p= t(:not_valid_domain_verification_body).html_safe

View file

@ -1,46 +0,0 @@
- if params[:confirmed].present?
.row
.col-md-12
%h1= t(:domain_registrant_change_confirmed_title)
.row
.col-md-12
%p= t(:domain_registrant_change_confirmed_body)
- elsif params[:rejected].present?
.row
.col-md-12
%h1= t(:domain_registrant_change_rejected_title)
.row
.col-md-12
%p= t(:domain_registrant_change_rejected_body)
- else
- if @domain.present?
.row
.col-md-12
%h1= t(:domain_registrant_change_title)
.row
.col-md-12
%p= t(:domain_registrant_change_body)
%hr
.row
.col-md-12.text-center.confirmation
.column-keys
%p= t(:domain_name) + ':'
%p= t(:current_registrant) + ':'
%p= t(:new_pending_registrant) + ':'
.column-values
%p= @domain.name
%p= "#{@domain.registrant.name} (#{@domain.registrant.ident})"
%p= "#{@domain.pending_registrant.try(:name)} (#{@domain.pending_registrant.try(:ident)})"
.row
.col-md-12.text-center
.confirmation
= form_for registrant_domain_update_confirm_path(@domain.id), method: :patch do |f|
= hidden_field_tag :token, params[:token]
= f.button t(:confirm_domain_registrant_update), name: 'confirmed', class: 'btn btn-primary'
= f.button t(:reject_domain_registrant_update), name: 'rejected', class: 'btn btn-warning'
%hr
- else
%h1= t(:not_valid_domain_verification_title).html_safe
%p= t(:not_valid_domain_verification_body).html_safe

View file

@ -1,9 +0,0 @@
<tr class="domain">
<td><%= link_to domain, registrant_domain_path(domain) %></td>
<td>
<%= link_to domain.registrant.name,
registrant_domain_contact_path(domain, domain.registrant) %>
</td>
<td><%= l domain.expire_time %></td>
<td><%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %></td>
</tr>

View file

@ -1,13 +0,0 @@
- content_for :actions do
= render 'shared/title', name: @domain.name
.row
.col-md-12
.panel.panel-default
.panel-heading
%h3.panel-title= t('.header')
.panel-body
.input-group.input-group-lg
%span#sizing-addon1.input-group-addon.glyphicon.glyphicon-link
%input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @confirmation_url}

View file

@ -1,102 +0,0 @@
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<div class="row">
<div class="col-md-12">
<%= search_form_for [:registrant, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<%= f.label :name, for: nil %>
<%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<%= f.label t(:registrant_ident), for: nil %>
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
</div>
</div>
<div class="col-md-3">
<div class="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) %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<%= f.label t(: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) %>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<%= f.label t(: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) %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 text-right">
<button class="btn btn-primary search">
&nbsp;
<span class="glyphicon glyphicon-search"></span>
&nbsp;
</button>
<%= button_tag t('.download_pdf_btn'),
formaction: registrant_domains_path(format: :pdf),
name: nil,
class: 'btn btn-default' %>
<%= button_tag t('.download_csv_btn'),
formaction: registrant_domains_path(format: :csv),
name: nil,
class: 'btn btn-default' %>
<%= link_to t('.reset_btn'), registrant_domains_path,
class: 'btn btn-default' %>
</div>
</div>
<% end %>
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed domains">
<thead>
<tr>
<th class="col-xs-2">
<%= sort_link(@q, 'name') %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'registrant_name', t('.registrant')) %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'valid_to', t(:valid_to)) %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'registrar_name', t(:registrar_name)) %>
</th>
</tr>
</thead>
<tbody>
<%= render @domains %>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<%= paginate @domains %>
</div>
<div class="col-md-6 text-right">
<div class="pagination">
<%= t(:result_count, count: @domains.total_count) %>
</div>
</div>
</div>

View file

@ -1,32 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-2"><%= Domain.human_attribute_name :name %></th>
<th class="col-xs-2"><%= Registrant.model_name.human %></th>
<th class="col-xs-2"><%= Domain.human_attribute_name :valid_to %></th>
<th class="col-xs-2"><%= Registrar.model_name.human %></th>
</tr>
</thead>
<tbody>
<% @domains.each do |domain| %>
<tr>
<td><%= domain.name %></td>
<td><%= domain.registrant %></td>
<td><%= l(domain.valid_to, format: :short) %></td>
<td><%= domain.registrar %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>

View file

@ -1,18 +0,0 @@
.panel.panel-default
.panel-heading.clearfix
= t(:dnskeys)
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-1'}= t(:flag)
%th{class: 'col-xs-1'}= t(:protocol)
%th{class: 'col-xs-1'}= t(:algorithm)
%th{class: 'col-xs-9'}= t(:public_key)
%tbody
- @domain.dnskeys.each do |x|
%tr
%td= x.flags
%td= x.protocol
%td= x.alg
%td= x.public_key

View file

@ -1,7 +0,0 @@
<% contact = domain_contact.contact %>
<tr class="<%= domain_contact.model_name.singular.dasherize %>">
<td><%= link_to contact, registrant_domain_contact_path(domain, contact) %></td>
<td><%= contact.code %></td>
<td><%= contact.email %></td>
</tr>

View file

@ -1,24 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed
<%= domain_contacts.model_name.plural.dasherize %>">
<thead>
<tr>
<th class="col-xs-4"><%= Contact.human_attribute_name :name %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :code %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :email %></th>
</tr>
</thead>
<tbody>
<%= render partial: 'registrant/domains/partials/domain_contact',
collection: domain_contacts,
locals: { domain: domain } %>
</tbody>
</table>
</div>
</div>

View file

@ -1,38 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<%= t(:general) %>
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= t(:name) %></dt>
<dd><%= @domain.name %></dd>
<dt><%= Domain.human_attribute_name :registered_at %></dt>
<dd><%= l(@domain.registered_at) %></dd>
<dt><%= Registrar.model_name.human %></dt>
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
<dt><%= Domain.human_attribute_name :transfer_code %></dt>
<dd>
<%= tag :input, type: 'text', value: @domain.transfer_code, readonly: true,
class: 'form-control input-sm' %>
</dd>
<dt><%= t(:valid_to) %></dt>
<dd><%= l(@domain.valid_to) %></dd>
<dt><%= Domain.human_attribute_name :outzone_at %></dt>
<dd><%= l(@domain.outzone_at) %></dd>
<dt><%= Domain.human_attribute_name :delete_date %></dt>
<dd><%= l @domain.delete_date %></dd>
<dt><%= Domain.human_attribute_name :force_delete_date %></dt>
<dd><%= l @domain.force_delete_date %></dd>
</dl>
</div>
</div>

View file

@ -1,14 +0,0 @@
.panel.panel-default
.panel-heading.clearfix
= t(:legal_documents)
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-8'}= t(:created_at)
%th{class: 'col-xs-4'}= t(:type)
%tbody
- legal_documents.each do |x|
%tr
%td= link_to(x.created_at, [:registrar, x])
%td= x.document_type

View file

@ -1,16 +0,0 @@
.panel.panel-default
.panel-heading.clearfix
= t(:nameservers)
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:hostname)
%th{class: 'col-xs-4'}= t(:ipv4)
%th{class: 'col-xs-4'}= t(:ipv6)
%tbody
- @domain.nameservers.each do |x|
%tr
%td= x
%td= x.ipv4
%td= x.ipv6

View file

@ -1,26 +0,0 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrant.human_attribute_name :name %></dt>
<dd>
<%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %>
</dd>
<dt><%= Registrant.human_attribute_name :code %></dt>
<dd><%= registrant.code %></dd>
<dt><%= Registrant.human_attribute_name :ident %></dt>
<dd><%= registrant.ident %></dd>
<dt><%= Registrant.human_attribute_name :email %></dt>
<dd><%= registrant.email %></dd>
<dt><%= Registrant.human_attribute_name :phone %></dt>
<dd><%= registrant.phone %></dd>
</dl>
</div>
</div>

View file

@ -1,18 +0,0 @@
#domain_statuses.panel.panel-default
.panel-heading.clearfix
= t(:statuses)
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-6'}= t(:status)
%th{class: 'col-xs-6'}= t(:notes)
%tbody
- @domain.statuses.each do |status|
%tr
%td
- if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION].include?(status) && @domain.pending_json.present?
= link_to(status, confirmation_registrant_domain_path(@domain))
- else
= status
%td= @domain.status_notes[status]

View file

@ -1,52 +0,0 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
</ol>
<div class="page-header">
<h1><%= @domain %></h1>
</div>
<div class="row">
<div class="col-md-6">
<%= render 'registrant/domains/partials/general' %>
</div>
<div class="col-md-6">
<%= render partial: 'registrant/domains/partials/registrant',
locals: { registrant: @domain.registrant, domain: @domain } %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.tech_domain_contacts %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.admin_domain_contacts %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/statuses' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/nameservers' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/dnskeys' %>
</div>
</div>

View file

@ -1,44 +0,0 @@
= render 'shared/title', name: @registrar.name
- if @registrar.errors.any?
- @registrar.errors.each do |attr, err|
= err
%br
- if @registrar.errors.any?
%hr
.row
.col-md-6
.panel.panel-default
.panel-heading
%h3.panel-title= t(:general)
.panel-body
%dl.dl-horizontal
%dt= Registrar.human_attribute_name :name
%dd= @registrar.name
%dt= Registrar.human_attribute_name :reg_no
%dd= @registrar.reg_no
%dt= Registrar.human_attribute_name :vat_no
%dd= @registrar.vat_no
%dt= Registrar.human_attribute_name :code
%dd= @registrar.code
.col-md-6
.panel.panel-default
.panel-heading
%h3.panel-title= t(:contact)
.panel-body
%dl.dl-horizontal
%dt= Registrar.human_attribute_name :country
%dd= @registrar.country
%dt= Registrar.human_attribute_name :address
%dd= @registrar.address
%dt= Registrar.human_attribute_name :phone
%dd= @registrar.phone
%dt= Registrar.human_attribute_name :email
%dd= @registrar.email

View file

@ -1,13 +0,0 @@
<div class="row">
<div class="form-signin col-md-6 center-block text-center">
<h2 class="form-signin-heading text-center">
<%= t '.header' %>
</h2>
<hr/>
<div class="row">
<%= t '.hint' %>
</div>
<br/>
<%= link_to t(:sign_in), "/auth/rant_tara", method: :post, class: 'btn btn-lg btn-primary btn-block' %>
</div>
</div>

View file

@ -1,17 +0,0 @@
= render 'shared/title', name: t(:whois)
.row
.col-md-12{style: 'margin-bottom: -15px;'}
= form_tag registrant_whois_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
&nbsp;
%span.glyphicon.glyphicon-search
&nbsp;
%hr
- if @domain
%pre= @domain.body

View file

@ -191,35 +191,8 @@ Rails.application.routes.draw do
end
end
scope :registrant do
devise_scope :registrant_user do
get 'sign_in', to: 'registrant/sessions#new', as: :new_registrant_user_session
post 'sessions', to: 'registrant/sessions#create', as: :registrant_user_session
delete 'sign_out', to: 'registrant/sessions#destroy', as: :destroy_registrant_user_session
# TARA
match '/open_id/callback', via: %i[get post], to: 'sso/tara#registrant_callback'
match '/open_id/cancel', via: %i[get post delete], to: 'sso/tara#cancel'
end
end
namespace :registrant do
root 'domains#index'
# POST /registrant/sign_in is not used
devise_for :users, path: '', class_name: 'RegistrantUser'
resources :registrars, only: :show
# resources :companies, only: :index
resources :domains, only: %i[index show] do
resources :contacts, only: %i[show edit update]
member do
get 'confirmation'
end
end
resources :domain_update_confirms, only: %i[show update]
resources :domain_delete_confirms, only: %i[show update]
end
# ADMIN ROUTES

View file

@ -1,19 +0,0 @@
require 'test_helper'
class RegistrantAreaContactsIntegrationTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@registrant = users(:registrant)
sign_in @registrant
end
def test_can_view_other_domain_contacts
secondary_contact = contacts(:jane)
visit registrant_domain_path(@domain)
assert_text secondary_contact.name
click_link secondary_contact.name
assert_text @domain.name
assert_text secondary_contact.email
end
end

View file

@ -1,30 +0,0 @@
require 'test_helper'
class RegistrantAreaDomainDeleteConfirmationIntegrationTest < ActionDispatch::IntegrationTest
include ActionMailer::TestHelper
setup do
@domain = domains(:shop)
ActionMailer::Base.deliveries.clear
end
def test_notifies_registrant_by_email_when_accepted
@domain.update!(registrant_verification_asked_at: Time.zone.now,
registrant_verification_token: 'test',
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
patch registrant_domain_delete_confirm_path(@domain, token: 'test', confirmed: true)
assert_emails 1
end
def test_notifies_registrant_by_email_when_rejected
@domain.update!(registrant_verification_asked_at: Time.zone.now,
registrant_verification_token: 'test',
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
patch registrant_domain_delete_confirm_path(@domain, token: 'test', rejected: true)
assert_emails 1
end
end

View file

@ -1,25 +0,0 @@
require 'test_helper'
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:registrant)
end
def test_downloads_list_as_csv
get registrant_domains_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_downloads_list_as_pdf
get registrant_domains_path(format: :pdf)
assert_response :ok
assert_equal Mime[:pdf], response.headers['Content-Type']
assert_equal "attachment; filename=\"domains.pdf\"; filename*=UTF-8''domains.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -21,7 +21,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
status: 'reserved',
punycode_name: 'reserved.test' }]
assert_equal response_json[:domains], expected_objects
assert_empty response_json[:domains] - expected_objects
end
def test_get_index_with_type_parameter
@ -77,7 +77,7 @@ class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
status: 'disputed',
punycode_name: 'reserved.test' }]
assert_equal response_json[:domains], expected_objects
assert_empty response_json[:domains] - expected_objects
end
def test_etags_cache

View file

@ -72,11 +72,14 @@ class RegistrantChangeMailerTest < ActionMailer::TestCase
email = RegistrantChangeMailer.expired(domain: @domain,
registrar: @domain.registrar,
registrant: @domain.registrant).deliver_now
registrant: @domain.registrant,
send_to: [@domain.new_registrant_email,
@domain.registrant.email],
).deliver_now
assert_emails 1
assert_equal ['william@inbox.test'], email.to
assert_equal ['william@inbox.test', @domain.registrant.email], email.to
assert_equal 'Domeeni shop.test registreerija vahetuse taotlus on tühistatud' \
' / shop.test registrant change cancelled', email.subject
end
end
end

View file

@ -1,33 +0,0 @@
require 'application_system_test_case'
class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
@contact = contacts(:john)
end
def test_general_data
visit registrant_domain_contact_url(@domain, @contact)
assert_text 'Code john-001'
assert_text 'Name John'
assert_text 'Auth info'
assert_css('[value="cacb5b"]')
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
assert_text "Created at #{l Time.zone.parse('2010-07-05')}"
assert_text "Updated at #{l Time.zone.parse('2010-07-06')}"
end
def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user
suppress(ActiveRecord::RecordNotFound) do
visit registrant_domain_contact_url(domains(:metro), @contact)
assert_response :not_found
assert_no_text 'Name John'
end
end
end

View file

@ -1,172 +0,0 @@
require 'application_system_test_case'
class RegistrantAreaContactUpdateTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@contact = contacts(:john)
sign_in users(:registrant)
@original_address_processing = Setting.address_processing
@original_fax_enabled_setting = ENV['fax_enabled']
@original_registrant_api_base_url_setting = ENV['registrant_api_base_url']
ENV['registrant_api_base_url'] = 'https://api.test'
end
teardown do
Setting.address_processing = @original_address_processing
ENV['fax_enabled'] = @original_fax_enabled_setting
ENV['registrant_api_base_url'] = @original_registrant_api_base_url_setting
end
def test_form_is_pre_populated_with_contact_data
visit edit_registrant_domain_contact_url(@domain, @contact)
assert_field 'Name', with: 'John'
assert_field 'Email', with: 'john@inbox.test'
assert_field 'Phone', with: '+555.555'
end
def test_update_contact
stub_auth_request
request_body = { name: 'new name', email: 'new@inbox.test', phone: '+666.6' }.to_json
headers = { 'Content-Type' => Mime[:json],
'Authorization' => 'Bearer test-access-token' }
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
.to_return(body: '{}', status: 200)
visit registrant_domain_contact_url(@domain, @contact)
click_link_or_button 'Edit'
fill_in 'Name', with: 'new name'
fill_in 'Email', with: 'new@inbox.test'
fill_in 'Phone', with: '+666.6'
click_link_or_button 'Update contact'
assert_requested update_request_stub
assert_current_path registrant_domain_contact_path(@domain, @contact)
assert_text 'Contact has been successfully updated'
end
def test_form_is_pre_populated_with_fax_when_enabled
ENV['fax_enabled'] = 'true'
@contact.update!(fax: '+111.1')
visit edit_registrant_domain_contact_url(@domain, @contact)
assert_field 'Fax', with: '+111.1'
end
def test_update_fax_when_enabled
ENV['fax_enabled'] = 'true'
stub_auth_request
request_body = { email: 'john@inbox.test', name: 'John', phone: '+555.555', fax: '+222.2' }
headers = { 'Authorization' => 'Bearer test-access-token' }
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
.to_return(body: '{}', status: 200)
visit edit_registrant_domain_contact_url(@domain, @contact)
fill_in 'Fax', with: '+222.2'
click_link_or_button 'Update contact'
assert_requested update_request_stub
assert_current_path registrant_domain_contact_path(@domain, @contact)
assert_text 'Contact has been successfully updated'
end
def test_hide_fax_field_when_disabled
visit edit_registrant_domain_contact_url(@domain, @contact)
assert_no_field 'Fax'
end
def test_form_is_pre_populated_with_address_when_enabled
Setting.address_processing = true
@contact.update!(street: 'Main Street',
zip: '12345',
city: 'New York',
state: 'New York State',
country_code: 'US')
visit edit_registrant_domain_contact_url(@domain, @contact)
assert_field 'Street', with: 'Main Street'
assert_field 'Zip', with: '12345'
assert_field 'City', with: 'New York'
assert_field 'State', with: 'New York State'
assert_select 'Country', selected: 'United States'
end
def test_update_address_when_enabled
Setting.address_processing = true
stub_auth_request
request_body = { name: 'John',
email: 'john@inbox.test',
phone: '+555.555',
address: {
city: 'new city',
street: 'new street',
zip: '93742',
country_code: 'AT',
state: 'new state',
} }.to_json
headers = { 'Content-type' => Mime[:json],
'Authorization' => 'Bearer test-access-token' }
url = "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}"
update_request_stub = stub_request(:patch, url).with(body: request_body, headers: headers)
.to_return(body: '{}', status: 200)
visit edit_registrant_domain_contact_url(@domain, @contact)
fill_in 'Street', with: 'new street'
fill_in 'City', with: 'new city'
fill_in 'State', with: 'new state'
fill_in 'Zip', with: '93742'
select 'Austria', from: 'Country'
click_link_or_button 'Update contact'
assert_requested update_request_stub
assert_current_path registrant_domain_contact_path(@domain, @contact)
assert_text 'Contact has been successfully updated'
end
def test_hide_address_field_when_disabled
visit edit_registrant_domain_contact_url(@domain, @contact)
assert_no_field 'Address'
assert_no_field 'Street'
end
def test_fail_gracefully
stub_auth_request
response_body = { errors: { name: ['Name is invalid'] } }.to_json
headers = { 'Authorization' => 'Bearer test-access-token' }
stub_request(:patch, "https://api.test/api/v1/registrant/contacts/#{@contact.uuid}")
.with(headers: headers)
.to_return(body: response_body, status: 400)
visit edit_registrant_domain_contact_url(@domain, @contact)
fill_in 'Name', with: 'invalid name'
click_link_or_button 'Update contact'
assert_current_path registrant_domain_contact_path(@domain, @contact)
assert_text 'Name is invalid'
assert_field 'Name', with: 'invalid name'
assert_no_text 'Contact has been successfully updated'
end
private
def stub_auth_request
body = { ident: '1234', first_name: 'Registrant', last_name: 'User' }
stub_request(:post, 'https://api.test/api/v1/registrant/auth/eid').with(body: body)
.to_return(body: { access_token: 'test-access-token' }.to_json,
headers: { 'Content-type' => Mime[:json] },
status: 200)
end
end

View file

@ -1,76 +0,0 @@
require 'application_system_test_case'
class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
end
def test_general_data
@domain.update_columns(force_delete_date: '2010-07-08', statuses: [DomainStatus::FORCE_DELETE])
visit registrant_domain_url(@domain)
assert_text 'Name shop.test'
assert_text "Registered at #{l @domain.registered_at}"
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text 'Transfer code'
assert_css('[value="65078d5"]')
assert_text "Valid to #{l Time.zone.parse('2010-07-05')}"
assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}"
assert_text "Delete date #{l Date.parse('2010-07-07')}"
assert_text "Force delete date #{l Date.parse('2010-07-08')}"
end
def test_registrant
visit registrant_domain_url(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_text 'Code john-001'
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
end
def test_admin_contacts
visit registrant_domain_url(@domain)
within('.admin-domain-contacts') do
assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane))
assert_text 'jane-001'
assert_text 'jane@mail.test'
assert_css '.admin-domain-contact', count: 1
end
end
def test_tech_contacts
visit registrant_domain_url(@domain)
within('.tech-domain-contacts') do
assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william))
assert_text 'william-001'
assert_text 'william@inbox.test'
assert_css '.tech-domain-contact', count: 2
end
end
def test_registrant_user_cannot_access_domains_of_other_users
suppress(ActiveRecord::RecordNotFound) do
visit registrant_domain_url(domains(:metro))
assert_response :not_found
assert_no_text 'metro.test'
end
end
def test_confirmation_url
@domain.update!(registrant_verification_token: 'a01',
pending_json: { new_registrant_email: 'any' },
statuses: [DomainStatus::PENDING_UPDATE])
visit registrant_domain_url(@domain)
click_on 'pendingUpdate'
assert_field nil, with: registrant_domain_update_confirm_url(@domain, token: 'a01')
end
end

View file

@ -1,46 +0,0 @@
require 'application_system_test_case'
class DomainDeleteConfirmsTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
setup do
@user = users(:registrant)
sign_in @user
@domain = domains(:shop)
@domain.registrant_verification_asked!('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp></epp>', @user.id)
@domain.pending_delete!
end
def test_enqueues_approve_job_after_verification
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
perform_enqueued_jobs do
click_on 'Confirm domain delete'
end
assert_text 'Domain registrant change has successfully received.'
@domain.reload
assert_includes @domain.statuses, 'serverHold'
end
def test_enqueues_reject_job_after_verification
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
perform_enqueued_jobs do
click_on 'Reject domain delete'
end
assert_text 'Domain registrant change has been rejected successfully.'
@domain.reload
assert_equal ['ok'], @domain.statuses
end
def test_saves_whodunnit_info_after_verifivation
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
token = @domain.registrant_verification_token
click_on 'Confirm domain delete'
assert_text 'Domain registrant change has successfully received.'
refute RegistrantVerification.find_by(verification_token:token).updator_str.empty?
end
end

View file

@ -1,71 +0,0 @@
require 'application_system_test_case'
CompanyRegisterClientStub = Struct.new(:any_method) do
def representation_rights(citizen_personal_code:, citizen_country_code:)
raise CompanyRegister::NotAvailableError
end
end
class RegistrantAreaDomainListTest < ApplicationSystemTestCase
setup do
@user = users(:registrant)
sign_in @user
@domain = domains(:shop)
end
def test_show_domain_list
visit registrant_domains_url
assert_link 'shop.test', href: registrant_domain_path(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text l(Time.zone.parse('2010-07-05'))
assert_css '.domains .domain', count: 4
end
def test_do_not_show_domains_of_other_registrant_users
visit registrant_domains_url
assert_no_text 'metro.test'
end
def test_only_shows_direct_relation_and_or_company_domains
# case https://github.com/internetee/registry/issues/1690
tech_contact = contacts(:registrar_ltd)
# All domains share the same tech contact object
Domain.all.each do |domain|
DomainContact.create(domain: domain, contact: tech_contact, type: TechDomainContact)
end
visit registrant_domains_url
assert_no_text 'Company register is unavailable.'
assert_no_text 'metro.test'
end
def test_notification_when_company_register_is_unavailable
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
visit registrant_domains_url
end
assert_text 'Company register is unavailable. Domains and contacts associated via' \
' organizations are not shown.'
end
def test_show_direct_domains_when_company_register_is_unavailable
assert_equal 'US-1234', @user.registrant_ident
contact = contacts(:john)
assert_equal '1234', contact.ident
assert_equal Contact::PRIV, contact.ident_type
assert_equal 'US', contact.ident_country_code
assert_equal contact.becomes(Registrant), @domain.registrant
assert_equal 'shop.test', @domain.name
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
visit registrant_domains_url
end
assert_text 'shop.test'
end
end

View file

@ -1,22 +0,0 @@
require 'application_system_test_case'
class RegistrantDomainsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
end
def test_shows_domains_where_current_user_is_registrant
visit registrant_domains_url
assert_text 'shop.test'
end
def test_shows_domains_where_current_user_is_contact_person
visit registrant_domains_url
assert_text 'airport.test'
end
def test_shows_domains_where_current_user_has_associated_organizations
visit registrant_domains_url
assert_text 'library.test'
end
end

View file

@ -1,15 +0,0 @@
require 'application_system_test_case'
class RegistrantLayoutTest < ApplicationSystemTestCase
def setup
super
sign_in(users(:registrant))
end
def test_has_link_to_rest_whois_and_internet_ee
visit registrant_domains_url
assert(has_link?('Internet.ee', href: 'https://internet.ee'))
assert(has_link?('WHOIS', href: 'https://whois.internet.ee'))
end
end

View file

@ -1,51 +0,0 @@
require 'application_system_test_case'
class RegistrantAreaTaraUsersTest < ApplicationSystemTestCase
def setup
super
OmniAuth.config.test_mode = true
@registrant = users(:registrant)
@existing_user_hash = {
'provider' => 'rant_tara',
'uid' => "US1234",
'info': { 'first_name': 'Registrant', 'last_name': 'User' }
}
@new_user_hash = {
'provider' => 'rant_tara',
'uid' => 'EE51007050604',
'info': { 'first_name': 'New Registrant', 'last_name': 'User'}
}
end
def teardown
super
OmniAuth.config.test_mode = false
OmniAuth.config.mock_auth['rant_tara'] = nil
end
def test_existing_user_gets_signed_in
OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@existing_user_hash)
visit new_registrant_user_session_path
click_link('Sign in')
assert_text('Signed in successfully')
end
def test_new_user_is_created_and_signed_in
OmniAuth.config.mock_auth[:rant_tara] = OmniAuth::AuthHash.new(@new_user_hash)
assert_difference 'RegistrantUser.count' do
visit new_registrant_user_session_path
click_link('Sign in')
assert_equal 'New Registrant User', RegistrantUser.last.username
assert_equal 'EE-51007050604', RegistrantUser.last.registrant_ident
assert_text('Signed in successfully')
end
end
end