mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Merge branch 'master' into improve-test-env-config
This commit is contained in:
commit
31b96c20b6
53 changed files with 708 additions and 2778 deletions
|
@ -1,12 +1,12 @@
|
|||
version: "2"
|
||||
prepare:
|
||||
fetch:
|
||||
- "https://raw.githubusercontent.com/internetee/style-guide/master/ruby/.rubocop.yml"
|
||||
plugins:
|
||||
brakeman:
|
||||
enabled: true
|
||||
bundler-audit:
|
||||
enabled: true
|
||||
csslint:
|
||||
enabled: true
|
||||
coffeelint:
|
||||
enabled: true
|
||||
duplication:
|
||||
enabled: true
|
||||
config:
|
||||
|
@ -17,22 +17,12 @@ plugins:
|
|||
enabled: true
|
||||
fixme:
|
||||
enabled: true
|
||||
config:
|
||||
strings:
|
||||
- FIXME
|
||||
- TODO
|
||||
- HACK
|
||||
rubocop:
|
||||
enabled: true
|
||||
channel: rubocop-0-51
|
||||
reek:
|
||||
enabled: true
|
||||
checks:
|
||||
IrresponsibleModule:
|
||||
enabled: false
|
||||
exclude_patterns:
|
||||
- "config/"
|
||||
- "db/"
|
||||
- "vendor/"
|
||||
- "spec/"
|
||||
- "test/"
|
||||
- "bin/"
|
||||
- "config/"
|
||||
- "db/"
|
||||
- "vendor/"
|
||||
- "test/"
|
||||
- "spec/"
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
--exclude-exts=.min.css
|
||||
--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes
|
|
@ -1 +0,0 @@
|
|||
**/*{.,-}min.js
|
|
@ -1,7 +0,0 @@
|
|||
env:
|
||||
browser: true
|
||||
es6: true
|
||||
jquery: true
|
||||
extends: google
|
||||
rules:
|
||||
require-jsdoc: off
|
24
.gitignore
vendored
24
.gitignore
vendored
|
@ -1,25 +1,13 @@
|
|||
*.rbc
|
||||
capybara-*.html
|
||||
.rspec
|
||||
/log
|
||||
/tmp
|
||||
/db/*.sqlite3
|
||||
/public/system
|
||||
/public/assets
|
||||
/coverage/
|
||||
/spec/tmp
|
||||
**.orig
|
||||
config/initializers/secret_token.rb
|
||||
config/deploy.rb
|
||||
config/database.yml
|
||||
config/application.yml
|
||||
config/environments/development.rb
|
||||
misc
|
||||
/export
|
||||
/import
|
||||
/ca
|
||||
/.bundle
|
||||
/vendor/bundle
|
||||
/config/database.yml
|
||||
/config/application.yml
|
||||
/config/environments/development.rb
|
||||
/config/deploy.rb
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
|
||||
.rubocop.yml
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
inherit_from: .rubocop_todo.yml
|
||||
|
||||
Style/Alias:
|
||||
EnforcedStyle: prefer_alias_method
|
||||
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
1282
.rubocop_todo.yml
1282
.rubocop_todo.yml
File diff suppressed because it is too large
Load diff
|
@ -59,5 +59,6 @@ module Repp
|
|||
mount Repp::AccountV1
|
||||
mount Repp::DomainTransfersV1
|
||||
mount Repp::NameserversV1
|
||||
mount Repp::DomainContactsV1
|
||||
end
|
||||
end
|
||||
|
|
47
app/api/repp/domain_contacts_v1.rb
Normal file
47
app/api/repp/domain_contacts_v1.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
module Repp
|
||||
class DomainContactsV1 < Grape::API
|
||||
version 'v1', using: :path
|
||||
|
||||
resource :domains do
|
||||
resource :contacts do
|
||||
patch '/' do
|
||||
current_contact = current_user.registrar.contacts
|
||||
.find_by(code: params[:current_contact_id])
|
||||
new_contact = current_user.registrar.contacts.find_by(code: params[:new_contact_id])
|
||||
|
||||
unless current_contact
|
||||
error!({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: "No such contact: #{params[:current_contact_id]}"} },
|
||||
:bad_request)
|
||||
end
|
||||
|
||||
unless new_contact
|
||||
error!({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: "No such contact: #{params[:new_contact_id]}" } },
|
||||
:bad_request)
|
||||
end
|
||||
|
||||
if new_contact.invalid?
|
||||
error!({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'New contact must be valid' } },
|
||||
:bad_request)
|
||||
end
|
||||
|
||||
if current_contact == new_contact
|
||||
error!({ error: { type: 'invalid_request_error',
|
||||
message: 'New contact ID must be different from current' \
|
||||
' contact ID' } },
|
||||
:bad_request)
|
||||
end
|
||||
|
||||
affected_domains, skipped_domains = TechDomainContact
|
||||
.replace(current_contact, new_contact)
|
||||
@response = { affected_domains: affected_domains, skipped_domains: skipped_domains }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
9
app/assets/javascripts/popover.js
Normal file
9
app/assets/javascripts/popover.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
(function() {
|
||||
function initPopover() {
|
||||
$(function () {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
})
|
||||
}
|
||||
|
||||
initPopover();
|
||||
})();
|
|
@ -7,6 +7,8 @@
|
|||
#= require select2
|
||||
#= require datepicker
|
||||
#= require spell_check
|
||||
#= require popover
|
||||
#= require text_field_trimmer
|
||||
#= require shared/general
|
||||
#= require registrar/autocomplete
|
||||
#= require registrar/application
|
||||
|
|
15
app/assets/javascripts/text_field_trimmer.js
Normal file
15
app/assets/javascripts/text_field_trimmer.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
(function () {
|
||||
function trimTextFields() {
|
||||
let selector = 'input[type=text], input[type=search], input[type=email], textarea';
|
||||
let textFields = document.querySelectorAll(selector);
|
||||
let listener = function () {
|
||||
this.value = this.value.trim();
|
||||
};
|
||||
|
||||
for (let field of textFields) {
|
||||
field.addEventListener('change', listener);
|
||||
}
|
||||
}
|
||||
|
||||
trimTextFields();
|
||||
})();
|
20
app/controllers/registrar/bulk_change_controller.rb
Normal file
20
app/controllers/registrar/bulk_change_controller.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Registrar
|
||||
class BulkChangeController < DeppController
|
||||
helper_method :available_contacts
|
||||
|
||||
def new
|
||||
authorize! :manage, :repp
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: default_tab }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def available_contacts
|
||||
current_user.registrar.contacts.order(:name).pluck(:name, :code)
|
||||
end
|
||||
|
||||
def default_tab
|
||||
:technical_contact
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class Registrar
|
||||
class DomainTransfersController < DeppController
|
||||
class DomainTransfersController < BulkChangeController
|
||||
before_action do
|
||||
authorize! :transfer, Depp::Domain
|
||||
end
|
||||
|
@ -58,7 +58,7 @@ class Registrar
|
|||
redirect_to registrar_domains_url
|
||||
else
|
||||
@api_errors = parsed_response[:errors]
|
||||
render :new
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_transfer }
|
||||
end
|
||||
else
|
||||
params[:request] = true # EPP domain:transfer "op" attribute
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
class Registrar
|
||||
class RegistrarNameserversController < DeppController
|
||||
def edit
|
||||
authorize! :manage, :repp
|
||||
end
|
||||
|
||||
class NameserversController < BulkChangeController
|
||||
def update
|
||||
authorize! :manage, :repp
|
||||
|
||||
|
@ -52,7 +48,7 @@ class Registrar
|
|||
redirect_to registrar_domains_url
|
||||
else
|
||||
@api_errors = parsed_response[:errors]
|
||||
render :edit
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :nameserver }
|
||||
end
|
||||
end
|
||||
end
|
59
app/controllers/registrar/tech_contacts_controller.rb
Normal file
59
app/controllers/registrar/tech_contacts_controller.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
class Registrar
|
||||
class TechContactsController < BulkChangeController
|
||||
def update
|
||||
authorize! :manage, :repp
|
||||
|
||||
uri = URI.parse("#{ENV['repp_url']}domains/contacts")
|
||||
|
||||
request = Net::HTTP::Patch.new(uri)
|
||||
request.set_form_data(current_contact_id: params[:current_contact_id],
|
||||
new_contact_id: params[:new_contact_id])
|
||||
request.basic_auth(current_user.username, current_user.password)
|
||||
|
||||
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
|
||||
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'])
|
||||
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
|
||||
|
||||
parsed_response = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
if response.code == '200'
|
||||
notices = [t('.replaced')]
|
||||
|
||||
notices << "#{t('.affected_domains')}: #{parsed_response[:affected_domains].join(', ')}"
|
||||
|
||||
if parsed_response[:skipped_domains]
|
||||
notices << "#{t('.skipped_domains')}: #{parsed_response[:skipped_domains].join(', ')}"
|
||||
end
|
||||
|
||||
flash[:notice] = notices
|
||||
redirect_to registrar_domains_url
|
||||
else
|
||||
@error = parsed_response[:error]
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :technical_contact }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,2 +1,23 @@
|
|||
class TechDomainContact < DomainContact
|
||||
# Audit log is needed, therefore no raw SQL
|
||||
def self.replace(current_contact, new_contact)
|
||||
affected_domains = []
|
||||
skipped_domains = []
|
||||
tech_contacts = where(contact: current_contact)
|
||||
|
||||
transaction do
|
||||
tech_contacts.each do |tech_contact|
|
||||
if tech_contact.domain.discarded?
|
||||
skipped_domains << tech_contact.domain.name
|
||||
next
|
||||
end
|
||||
|
||||
tech_contact.contact = new_contact
|
||||
tech_contact.save!
|
||||
affected_domains << tech_contact.domain.name
|
||||
end
|
||||
end
|
||||
|
||||
return affected_domains.sort, skipped_domains.sort
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<% if flash[:notice] %>
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<button class="close" data-dismiss="alert" type=button><span>×</span></button>
|
||||
<p><%= flash[:notice] %></p>
|
||||
<% if flash[:notice].respond_to?(:join) %>
|
||||
<p><%= flash[:notice].join('<br>').html_safe %></p>
|
||||
<% else %>
|
||||
<p><%= flash[:notice] %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button">
|
||||
<button aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button">
|
||||
<button aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
|
@ -39,7 +39,7 @@
|
|||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<%= render 'shared/flash' %>
|
||||
<%= render 'flash_messages' %>
|
||||
<% if depp_controller? %>
|
||||
<%= render 'registrar/shared/epp_results' %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,45 +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', id: 'registrar-home-btn' do
|
||||
= t(:registrar_head_title)
|
||||
- if unstable_env.present?
|
||||
.text-center
|
||||
%small{style: 'color: #0074B3;'}= unstable_env
|
||||
- if current_user
|
||||
= 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
|
54
app/views/layouts/registrar/sessions.html.erb
Normal file
54
app/views/layouts/registrar/sessions.html.erb
Normal file
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="<%= locale %>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<% if content_for? :head_title %>
|
||||
<%= yield :head_title %>
|
||||
<% else %>
|
||||
<title>
|
||||
<%= t(:registrar_head_title) %>
|
||||
</title>
|
||||
<% end %>
|
||||
<%= csrf_meta_tags %>
|
||||
<%= stylesheet_link_tag 'registrar-manifest', media: 'all' %>
|
||||
<%= javascript_include_tag 'registrar-manifest' %>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<%= link_to registrar_root_path, class: 'navbar-brand',
|
||||
id: 'registrar-home-btn' do %>
|
||||
<%= t(:registrar_head_title) %>
|
||||
<% if unstable_env.present? %>
|
||||
<div class="text-center">
|
||||
<small style="color: #0074B3;">
|
||||
<%= unstable_env %>
|
||||
</small>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<%= render 'flash_messages' %>
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<%= image_tag 'eis-logo-et.png' %>
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
Version
|
||||
<%= CURRENT_COMMIT_HASH %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
34
app/views/registrar/bulk_change/_bulk_transfer_form.html.erb
Normal file
34
app/views/registrar/bulk_change/_bulk_transfer_form.html.erb
Normal file
|
@ -0,0 +1,34 @@
|
|||
<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
|
||||
<%= render 'registrar/domain_transfers/form/api_errors' %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :batch_file %>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<%= file_field_tag :batch_file, required: true %>
|
||||
<span class="help-block"><%= t '.file_field_hint' %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-4 col-md-offset-2 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.submit_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-default btn-xs" role="button" data-toggle="collapse"
|
||||
href="#bulk_change_bulk_transfer_help"><%= t '.help_btn' %>
|
||||
</a>
|
||||
<div class="collapse" id="bulk_change_bulk_transfer_help">
|
||||
<div class="well">
|
||||
<%= t '.help' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,12 +1,13 @@
|
|||
<%= form_tag registrar_update_registrar_nameserver_path, method: :put, class: 'form-horizontal' do %>
|
||||
<%= form_tag registrar_nameservers_path, method: :patch, class: 'form-horizontal' do %>
|
||||
<%= render 'registrar/domain_transfers/form/api_errors' %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :old_hostname %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5">
|
||||
<%= text_field_tag :old_hostname, params[:old_hostname], autofocus: true,
|
||||
required: true,
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :old_hostname, params[:old_hostname], required: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -16,7 +17,7 @@
|
|||
<%= label_tag :new_hostname %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :new_hostname, params[:new_hostname], required: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
|
@ -27,7 +28,7 @@
|
|||
<%= label_tag :ipv4 %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<%= text_area_tag :ipv4, params[:ipv4], class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,17 +38,30 @@
|
|||
<%= label_tag :ipv6 %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-4">
|
||||
<%= text_area_tag :ipv6, params[:ipv6], class: 'form-control' %>
|
||||
<span class="help-block"><%= t '.ip_hint' %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-5 col-md-offset-2 text-right">
|
||||
<div class="col-md-4 col-md-offset-2 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.replace_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-default btn-xs" role="button" data-toggle="collapse"
|
||||
href="#bulk_change_nameserver_help"><%= t '.help_btn' %>
|
||||
</a>
|
||||
<div class="collapse" id="bulk_change_nameserver_help">
|
||||
<div class="well">
|
||||
<%= t '.help' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
60
app/views/registrar/bulk_change/_tech_contact_form.html.erb
Normal file
60
app/views/registrar/bulk_change/_tech_contact_form.html.erb
Normal file
|
@ -0,0 +1,60 @@
|
|||
<%= form_tag registrar_tech_contacts_path, method: :patch, class: 'form-horizontal' do %>
|
||||
<% if @error %>
|
||||
<div class="alert alert-danger">
|
||||
<%= @error[:message] %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :current_contact_id, t('.current_contact_id') %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :current_contact_id, params[:current_contact_id],
|
||||
list: :contacts,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-2 control-label">
|
||||
<%= label_tag :new_contact_id, t('.new_contact_id') %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= text_field_tag :new_contact_id, params[:new_contact_id],
|
||||
list: :contacts,
|
||||
required: true,
|
||||
class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-4 col-md-offset-2 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.submit_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-default btn-xs" role="button" data-toggle="collapse"
|
||||
href="#bulk_change_tech_contact_help"><%= t '.help_btn' %></a>
|
||||
<div class="collapse" id="bulk_change_tech_contact_help">
|
||||
<div class="well">
|
||||
<%= t '.help' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<datalist id="contacts">
|
||||
<% available_contacts.each do |data| %>
|
||||
<option value="<%= data.second %>"><%= data.first %></option>
|
||||
<% end %>
|
||||
</datalist>
|
37
app/views/registrar/bulk_change/new.html.erb
Normal file
37
app/views/registrar/bulk_change/new.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
|||
<ol class="breadcrumb">
|
||||
<li><%= link_to t('registrar.domains.index.header'), registrar_domains_path %></li>
|
||||
</ol>
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="<%= 'active' if active_tab == :technical_contact %>">
|
||||
<a href="#technical_contact" data-toggle="tab"><%= t '.technical_contact' %></a>
|
||||
</li>
|
||||
|
||||
<li class="<%= 'active' if active_tab == :nameserver %>">
|
||||
<a href="#nameserver" data-toggle="tab"><%= t '.nameserver' %></a>
|
||||
</li>
|
||||
|
||||
<li class="<%= 'active' if active_tab == :bulk_transfer %>">
|
||||
<a href="#bulk_transfer" data-toggle="tab"><%= t '.bulk_transfer' %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane<%= ' active' if active_tab == :technical_contact %>"
|
||||
id="technical_contact">
|
||||
<%= render 'tech_contact_form', available_contacts: available_contacts %>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane<%= ' active' if active_tab == :nameserver %>" id="nameserver">
|
||||
<%= render 'nameserver_form' %>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane<%= ' active' if active_tab == :bulk_transfer %>" id="bulk_transfer">
|
||||
<%= render 'bulk_transfer_form' %>
|
||||
</div>
|
||||
</div>
|
|
@ -1,4 +1,6 @@
|
|||
<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
|
||||
<%= render 'registrar/domain_transfers/form/api_errors' %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-3 control-label">
|
||||
<%= label_tag :domain_name, nil, class: 'required' %>
|
||||
|
@ -30,7 +32,7 @@
|
|||
<div class="form-group">
|
||||
<div class="col-md-10 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.transfer_btn' %>
|
||||
<%= t '.submit_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
<%= form_tag registrar_domain_transfers_path, multipart: true, class: 'form-horizontal' do %>
|
||||
<div class="form-group">
|
||||
<div class="col-md-3 control-label">
|
||||
<%= label_tag :batch_file %>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<%= file_field_tag :batch_file, required: true %>
|
||||
<span class="help-block"><%= t '.batch_file_help' %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-10 text-right">
|
||||
<button class="btn btn-warning">
|
||||
<%= t '.transfer_btn' %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -6,24 +6,6 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active">
|
||||
<a href="#single" data-toggle="tab"><%= t '.single' %></a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#batch" data-toggle="tab"><%= t '.batch' %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="single">
|
||||
<%= render 'registrar/domain_transfers/form/single' %>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="batch">
|
||||
<%= render 'registrar/domain_transfers/form/batch' %>
|
||||
</div>
|
||||
</div>
|
||||
<%= render 'form' %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<div class="page-header">
|
||||
<div class="row">
|
||||
<div class="col-sm-7">
|
||||
<div class="col-sm-5">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 text-right">
|
||||
<div class="col-sm-7 text-right">
|
||||
<%= link_to t('.new_btn'), new_registrar_domain_path, class: 'btn btn-primary' %>
|
||||
<%= link_to t('.transfer_btn'), new_registrar_domain_transfer_path, class: 'btn btn-default' %>
|
||||
<%= link_to t('.replace_nameserver_btn'), registrar_edit_registrar_nameserver_path,
|
||||
<%= link_to t('.bulk_change_btn'), new_registrar_bulk_change_path,
|
||||
class: 'btn btn-default' %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,22 +24,22 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table table-hover table-bordered table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link(@q, 'name') %>
|
||||
</th>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link @q, 'registrant_name', Registrant.model_name.human %>
|
||||
</th>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link @q, 'valid_to', Domain.human_attribute_name(:expire_time) %>
|
||||
</th>
|
||||
<th class="col-xs-2"></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link(@q, 'name') %>
|
||||
</th>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link @q, 'registrant_name', Registrant.model_name.human %>
|
||||
</th>
|
||||
<th class="col-xs-2">
|
||||
<%= sort_link @q, 'valid_to', Domain.human_attribute_name(:expire_time) %>
|
||||
</th>
|
||||
<th class="col-xs-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<%= render @domains %>
|
||||
<%= render @domains %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<ol class="breadcrumb">
|
||||
<li><%= link_to t('registrar.domains.index.header'), registrar_domains_path %></li>
|
||||
</ol>
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<%= render 'registrar/domain_transfers/form/api_errors' %>
|
||||
|
||||
<%= render 'form' %>
|
129
coffeelint.json
129
coffeelint.json
|
@ -1,129 +0,0 @@
|
|||
{
|
||||
"arrow_spacing": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"braces_spacing": {
|
||||
"level": "ignore",
|
||||
"spaces": 0,
|
||||
"empty_object_spaces": 0
|
||||
},
|
||||
"camel_case_classes": {
|
||||
"level": "error"
|
||||
},
|
||||
"coffeescript_error": {
|
||||
"level": "error"
|
||||
},
|
||||
"colon_assignment_spacing": {
|
||||
"level": "ignore",
|
||||
"spacing": {
|
||||
"left": 0,
|
||||
"right": 0
|
||||
}
|
||||
},
|
||||
"cyclomatic_complexity": {
|
||||
"value": 10,
|
||||
"level": "ignore"
|
||||
},
|
||||
"duplicate_key": {
|
||||
"level": "error"
|
||||
},
|
||||
"empty_constructor_needs_parens": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"ensure_comprehensions": {
|
||||
"level": "warn"
|
||||
},
|
||||
"eol_last": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"indentation": {
|
||||
"value": 2,
|
||||
"level": "error"
|
||||
},
|
||||
"line_endings": {
|
||||
"level": "ignore",
|
||||
"value": "unix"
|
||||
},
|
||||
"max_line_length": {
|
||||
"value": 80,
|
||||
"level": "error",
|
||||
"limitComments": true
|
||||
},
|
||||
"missing_fat_arrows": {
|
||||
"level": "ignore",
|
||||
"is_strict": false
|
||||
},
|
||||
"newlines_after_classes": {
|
||||
"value": 3,
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_backticks": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_debugger": {
|
||||
"level": "warn",
|
||||
"console": false
|
||||
},
|
||||
"no_empty_functions": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_empty_param_list": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_implicit_braces": {
|
||||
"level": "ignore",
|
||||
"strict": true
|
||||
},
|
||||
"no_implicit_parens": {
|
||||
"strict": true,
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_interpolation_in_single_quotes": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_plusplus": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_stand_alone_at": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_tabs": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_this": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_throwing_strings": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_trailing_semicolons": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_trailing_whitespace": {
|
||||
"level": "error",
|
||||
"allowed_in_comments": false,
|
||||
"allowed_in_empty_lines": true
|
||||
},
|
||||
"no_unnecessary_double_quotes": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_unnecessary_fat_arrows": {
|
||||
"level": "warn"
|
||||
},
|
||||
"non_empty_constructor_needs_parens": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"prefer_english_operator": {
|
||||
"level": "ignore",
|
||||
"doubleNotLevel": "ignore"
|
||||
},
|
||||
"space_operators": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"spacing_after_comma": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"transform_messes_up_line_numbers": {
|
||||
"level": "warn"
|
||||
}
|
||||
}
|
31
config/locales/registrar/bulk_change.en.yml
Normal file
31
config/locales/registrar/bulk_change.en.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
en:
|
||||
registrar:
|
||||
bulk_change:
|
||||
new:
|
||||
header: Bulk change
|
||||
technical_contact: Technical contact
|
||||
nameserver: Nameserver
|
||||
bulk_transfer: Bulk transfer
|
||||
|
||||
tech_contact_form:
|
||||
current_contact_id: Current contact ID
|
||||
new_contact_id: New contact ID
|
||||
submit_btn: Replace technical contacts
|
||||
help_btn: Toggle help
|
||||
help: >-
|
||||
Replace technical contact specified in "current contact ID" with the one in "new
|
||||
contact ID" on any domain registered under this registrar
|
||||
|
||||
nameserver_form:
|
||||
ip_hint: One IP per line
|
||||
replace_btn: Replace nameserver
|
||||
help_btn: Toggle help
|
||||
help: >-
|
||||
Replace nameserver specified in the "old hostname" with the one in "new hostname" with
|
||||
optional IPv4 and IPv6 addresses on any domain registered under this registrar
|
||||
|
||||
bulk_transfer_form:
|
||||
file_field_hint: CSV file with domain list provided by another registrar
|
||||
submit_btn: Transfer
|
||||
help_btn: Toggle help
|
||||
help: Transfer domains in the csv file with correct transfer code to this registrar
|
|
@ -3,17 +3,10 @@ en:
|
|||
domain_transfers:
|
||||
new:
|
||||
header: Domain transfer
|
||||
single: One by one
|
||||
batch: Batch
|
||||
|
||||
create:
|
||||
header: Domain transfer
|
||||
transferred: "%{count} domains have been successfully transferred"
|
||||
|
||||
form:
|
||||
single:
|
||||
transfer_btn: Transfer
|
||||
|
||||
batch:
|
||||
batch_file_help: CSV file with domain list provided by another registrar
|
||||
transfer_btn: Transfer batch
|
||||
submit_btn: Transfer
|
||||
|
|
|
@ -5,7 +5,7 @@ en:
|
|||
header: Domains
|
||||
new_btn: New domain
|
||||
transfer_btn: Transfer
|
||||
replace_nameserver_btn: Replace nameserver
|
||||
bulk_change_btn: Bulk change
|
||||
csv:
|
||||
domain_name: Domain
|
||||
transfer_code: Transfer code
|
||||
|
|
5
config/locales/registrar/nameservers.en.yml
Normal file
5
config/locales/registrar/nameservers.en.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
en:
|
||||
registrar:
|
||||
nameservers:
|
||||
update:
|
||||
replaced: Nameserver have been successfully replaced
|
|
@ -1,13 +0,0 @@
|
|||
en:
|
||||
registrar:
|
||||
registrar_nameservers:
|
||||
edit:
|
||||
header: Replace nameserver
|
||||
replace_btn: Replace
|
||||
|
||||
form:
|
||||
ip_hint: One IP per line
|
||||
replace_btn: Replace nameserver
|
||||
|
||||
update:
|
||||
replaced: Nameserver have been successfully replaced
|
7
config/locales/registrar/tech_contacts.en.yml
Normal file
7
config/locales/registrar/tech_contacts.en.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
en:
|
||||
registrar:
|
||||
tech_contacts:
|
||||
update:
|
||||
replaced: Technical contacts have been successfully replaced.
|
||||
affected_domains: Affected domains
|
||||
skipped_domains: Skipped domains
|
|
@ -62,9 +62,9 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
resources :domain_transfers, only: %i[new create]
|
||||
get 'registrar/nameservers', to: 'registrar_nameservers#edit', as: :edit_registrar_nameserver
|
||||
put 'registrar/nameservers', to: 'registrar_nameservers#update', as: :update_registrar_nameserver
|
||||
|
||||
resource :bulk_change, controller: :bulk_change, only: :new
|
||||
resource :tech_contacts, only: :update
|
||||
resource :nameservers, only: :update
|
||||
resources :contacts, constraints: {:id => /[^\/]+(?=#{ ActionController::Renderers::RENDERERS.map{|e| "\\.#{e}\\z"}.join("|") })|[^\/]+/} do
|
||||
member do
|
||||
get 'delete'
|
||||
|
|
19
doc/repp/v1/domain_contacts.md
Normal file
19
doc/repp/v1/domain_contacts.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Domain contacts
|
||||
|
||||
## PATCH https://repp.internet.ee/v1/domains/contacts
|
||||
Replaces all domain contacts of the current registrar.
|
||||
|
||||
### Example request
|
||||
```
|
||||
$ curl https://repp.internet.ee/v1/domains/contacts \
|
||||
-X PATCH \
|
||||
-u username:password \
|
||||
-d current_contact_id=foo \
|
||||
-d new_contact_id=bar
|
||||
```
|
||||
### Example response
|
||||
```
|
||||
{
|
||||
"affected_domains": ["example.com", "example.org"]
|
||||
}
|
||||
```
|
2
test/fixtures/contacts.yml
vendored
2
test/fixtures/contacts.yml
vendored
|
@ -76,7 +76,7 @@ not_in_use:
|
|||
|
||||
invalid:
|
||||
name: any
|
||||
code: any
|
||||
code: invalid
|
||||
email: invalid@invalid.test
|
||||
auth_info: any
|
||||
registrar: bestnames
|
||||
|
|
15
test/fixtures/domain_contacts.yml
vendored
15
test/fixtures/domain_contacts.yml
vendored
|
@ -8,11 +8,26 @@ shop_william:
|
|||
contact: william
|
||||
type: TechDomainContact
|
||||
|
||||
shop_acme_ltd:
|
||||
domain: shop
|
||||
contact: acme_ltd
|
||||
type: TechDomainContact
|
||||
|
||||
airport_john:
|
||||
domain: airport
|
||||
contact: john
|
||||
type: AdminDomainContact
|
||||
|
||||
airport_william_admin:
|
||||
domain: airport
|
||||
contact: william
|
||||
type: AdminDomainContact
|
||||
|
||||
airport_william_tech:
|
||||
domain: airport
|
||||
contact: william
|
||||
type: TechDomainContact
|
||||
|
||||
library_john:
|
||||
domain: library
|
||||
contact: john
|
||||
|
|
4
test/fixtures/nameservers.yml
vendored
4
test/fixtures/nameservers.yml
vendored
|
@ -18,6 +18,10 @@ airport_ns1:
|
|||
hostname: ns1.bestnames.test
|
||||
domain: airport
|
||||
|
||||
airport_ns2:
|
||||
hostname: ns2.bestnames.test
|
||||
domain: airport
|
||||
|
||||
metro_ns1:
|
||||
hostname: ns1.bestnames.test
|
||||
domain: metro
|
||||
|
|
124
test/integration/api/domain_contacts_test.rb
Normal file
124
test/integration/api/domain_contacts_test.rb
Normal file
|
@ -0,0 +1,124 @@
|
|||
require 'test_helper'
|
||||
|
||||
class APIDomainContactsTest < ActionDispatch::IntegrationTest
|
||||
def test_replace_all_tech_contacts_of_the_current_registrar
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_nil domains(:shop).tech_contacts.find_by(code: 'william-001')
|
||||
assert domains(:shop).tech_contacts.find_by(code: 'john-001')
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'john-001')
|
||||
end
|
||||
|
||||
def test_skip_discarded_domains
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).tech_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_return_affected_domains_in_alphabetical_order
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ affected_domains: %w[airport.test shop.test],
|
||||
skipped_domains: [] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_return_skipped_domains_in_alphabetical_order
|
||||
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
|
||||
symbolize_names: true)[:skipped_domains]
|
||||
end
|
||||
|
||||
def test_keep_other_tech_contacts_intact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:shop).tech_contacts.find_by(code: 'acme-ltd-001')
|
||||
end
|
||||
|
||||
def test_keep_admin_contacts_intact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert domains(:airport).admin_contacts.find_by(code: 'william-001')
|
||||
end
|
||||
|
||||
def test_restrict_contacts_to_the_current_registrar
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'jack-001',
|
||||
new_contact_id: 'william-002' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: jack-001' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_current_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'non-existent',
|
||||
new_contact_id: 'john-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_non_existent_new_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'non-existent' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_invalid_new_contact
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'invalid' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'New contact must be valid' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_disallow_self_replacement
|
||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||
new_contact_id: 'william-001' },
|
||||
{ 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
message: 'New contact ID must be different from current contact ID' } }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials('test_bestnames', 'testtest')
|
||||
end
|
||||
end
|
|
@ -53,7 +53,7 @@ class APIDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 2 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class EppDomainTransferRequestTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 2 do
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaBulkTransferTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
||||
def test_batch_transfer_succeeds
|
||||
def test_transfer_multiple_domains_in_bulk
|
||||
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
|
||||
|
@ -16,28 +16,26 @@ class RegistrarDomainTransfersTest < ActionDispatch::IntegrationTest
|
|||
}] }.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Bulk transfer'
|
||||
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
|
||||
click_button 'Transfer batch'
|
||||
click_button 'Transfer'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text '1 domains have been successfully transferred'
|
||||
end
|
||||
|
||||
def test_batch_transfer_fails_gracefully
|
||||
def test_fail_gracefully
|
||||
body = { errors: [{ title: 'epic fail' }] }.to_json
|
||||
headers = { 'Content-type' => 'application/json' }
|
||||
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Transfer'
|
||||
|
||||
click_on 'Batch'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Bulk transfer'
|
||||
attach_file 'Batch file', Rails.root.join('test', 'fixtures', 'files', 'valid_domains_for_transfer.csv').to_s
|
||||
click_button 'Transfer batch'
|
||||
click_button 'Transfer'
|
||||
|
||||
assert_text 'epic fail'
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
||||
class RegistrarAreaNameserverBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
login_as users(:api_goodnames)
|
||||
end
|
||||
|
@ -20,7 +20,8 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
|||
}] }.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Replace nameserver'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Nameserver'
|
||||
|
||||
fill_in 'Old hostname', with: 'ns1.bestnames.test'
|
||||
fill_in 'New hostname', with: 'new-ns.bestnames.test'
|
||||
|
@ -39,7 +40,8 @@ class RegistrarNameserverReplacementTest < ActionDispatch::IntegrationTest
|
|||
headers: { 'Content-type' => 'application/json' })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Replace nameserver'
|
||||
click_link 'Bulk change'
|
||||
click_link 'Nameserver'
|
||||
|
||||
fill_in 'Old hostname', with: 'old hostname'
|
||||
fill_in 'New hostname', with: 'new hostname'
|
47
test/integration/registrar/bulk_change/tech_contact_test.rb
Normal file
47
test/integration/registrar/bulk_change/tech_contact_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAreaTechContactBulkChangeTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
login_as users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_replace_domain_contacts_of_current_registrar
|
||||
request_stub = stub_request(:patch, /domains\/contacts/)
|
||||
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
|
||||
basic_auth: ['test_bestnames', 'testtest'])
|
||||
.to_return(body: { affected_domains: %w[foo.test bar.test],
|
||||
skipped_domains: %w[baz.test qux.test] }.to_json,
|
||||
status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_requested request_stub
|
||||
assert_current_path registrar_domains_path
|
||||
assert_text 'Technical contacts have been successfully replaced'
|
||||
assert_text 'Affected domains: foo.test, bar.test'
|
||||
assert_text 'Skipped domains: baz.test, qux.test'
|
||||
end
|
||||
|
||||
def test_fails_gracefully
|
||||
stub_request(:patch, /domains\/contacts/)
|
||||
.to_return(status: 400,
|
||||
body: { error: { message: 'epic fail' } }.to_json,
|
||||
headers: { 'Content-type' => 'application/json' })
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
||||
fill_in 'Current contact ID', with: 'william-001'
|
||||
fill_in 'New contact ID', with: 'john-001'
|
||||
click_on 'Replace technical contacts'
|
||||
|
||||
assert_text 'epic fail'
|
||||
assert_field 'Current contact ID', with: 'william-001'
|
||||
assert_field 'New contact ID', with: 'john-001'
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest
|
|||
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
|
||||
invalid.test,1438d6,any,any,2010-07-05
|
||||
invalid.test,1438d6,any,invalid,2010-07-05
|
||||
airport.test,55438j5,John,john-001,2010-07-05
|
||||
CSV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class DomainTransferTest < ActiveSupport::TestCase
|
|||
|
||||
body = 'Transfer of domain shop.test has been approved.' \
|
||||
' It was associated with registrant john-001' \
|
||||
' and contacts jane-001, william-001.'
|
||||
' and contacts acme-ltd-001, jane-001, william-001.'
|
||||
id = @domain_transfer.id
|
||||
class_name = @domain_transfer.class.name
|
||||
|
||||
|
|
|
@ -50,9 +50,11 @@ class NameserverTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_hostnames
|
||||
assert_equal %w[ns1.bestnames.test
|
||||
assert_equal %w[
|
||||
ns1.bestnames.test
|
||||
ns2.bestnames.test
|
||||
ns1.bestnames.test
|
||||
ns2.bestnames.test
|
||||
ns1.bestnames.test], Nameserver.hostnames
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue