mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
commit
b27ce14aa8
15 changed files with 170 additions and 147 deletions
|
@ -5,6 +5,11 @@ module Concerns::Domain::Deletable
|
|||
alias_attribute :delete_time, :delete_at
|
||||
end
|
||||
|
||||
def discard
|
||||
statuses << DomainStatus::DELETE_CANDIDATE
|
||||
save
|
||||
end
|
||||
|
||||
def discarded?
|
||||
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||
end
|
||||
|
|
|
@ -6,6 +6,17 @@ class DomainPresenter
|
|||
@view = view
|
||||
end
|
||||
|
||||
def name_with_status
|
||||
html = domain.name
|
||||
|
||||
if domain.discarded?
|
||||
label = view.content_tag(:span, 'deleteCandidate', class: 'label label-warning')
|
||||
html += " #{label}"
|
||||
end
|
||||
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def expire_time
|
||||
view.l(domain.expire_time)
|
||||
end
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:edit_statuses), edit_admin_domain_path(@domain), class: 'btn btn-primary')
|
||||
= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
|
||||
= render 'shared/title', name: @domain.name
|
||||
|
||||
.row
|
||||
.col-md-6= render 'admin/domains/partials/general'
|
||||
.col-md-6= render 'admin/domains/partials/owner'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/tech_contacts'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/admin_contacts'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/statuses'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/nameservers'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/dnskeys'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/keyrelays'
|
||||
.row
|
||||
.col-md-12
|
||||
= render 'admin/domains/partials/legal_documents', legal_documents: @domain.legal_documents
|
71
app/views/admin/domains/show.html.erb
Normal file
71
app/views/admin/domains/show.html.erb
Normal file
|
@ -0,0 +1,71 @@
|
|||
<% domain = DomainPresenter.new(domain: @domain, view: self) %>
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li><%= link_to t('admin.domains.index.header'), admin_domains_path %></li>
|
||||
</ol>
|
||||
|
||||
<div class="page-header">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h1><%= domain.name_with_status %></h1>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 text-right">
|
||||
<%= link_to t('.edit_btn'), edit_admin_domain_path(@domain), class: 'btn btn-primary' %>
|
||||
<%= link_to t('.history_btn'), admin_domain_domain_versions_path(@domain),
|
||||
class: 'btn btn-primary' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<%= render 'admin/domains/partials/general' %>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<%= render 'admin/domains/partials/owner' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/tech_contacts' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/admin_contacts' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/statuses' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/nameservers' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/dnskeys' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/keyrelays' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= render 'admin/domains/partials/legal_documents', legal_documents:
|
||||
@domain.legal_documents %>
|
||||
</div>
|
||||
</div>
|
|
@ -1,8 +0,0 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:back_to_domain), admin_domain_path(@domain), class: 'btn btn-default')
|
||||
= render 'shared/title', name: t(:zonefile)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= preserve do
|
||||
%pre= @zonefile
|
|
@ -5,6 +5,10 @@ en:
|
|||
header: Domains
|
||||
registrant: Registrant
|
||||
|
||||
show:
|
||||
edit_btn: Edit statuses
|
||||
history_btn: History
|
||||
|
||||
search_form:
|
||||
reset_btn: Reset
|
||||
|
||||
|
|
|
@ -337,7 +337,6 @@ en:
|
|||
|
||||
transfer_requested: 'Transfer requested.'
|
||||
message_was_not_found: 'Message was not found'
|
||||
zonefile: 'Zonefile'
|
||||
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
||||
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
|
||||
ds_data_with_key_allowed: 'Allow DS data with key'
|
||||
|
|
|
@ -11,9 +11,5 @@ FactoryBot.define do
|
|||
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
|
||||
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
||||
end
|
||||
|
||||
factory :domain_discarded do
|
||||
statuses [DomainStatus::DELETE_CANDIDATE]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Domain, db: false do
|
||||
it { is_expected.to alias_attribute(:delete_time, :delete_at) }
|
||||
|
||||
describe '#discarded?' do
|
||||
context 'when :deleteCandidate status is present' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::DELETE_CANDIDATE]) }
|
||||
|
||||
specify { expect(domain).to be_discarded }
|
||||
end
|
||||
|
||||
context 'when :deleteCandidate status is absent' do
|
||||
let(:domain) { described_class.new(statuses: []) }
|
||||
|
||||
specify { expect(domain).to_not be_discarded }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'EPP domain:delete' do
|
||||
let(:registrar) { create(:registrar) }
|
||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
||||
let(:request_xml) { <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>test.com</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
}
|
||||
|
||||
before :example do
|
||||
login_as user
|
||||
end
|
||||
|
||||
context 'when domain is not discarded' do
|
||||
let!(:domain) { create(:domain, name: 'test.com') }
|
||||
|
||||
it 'returns epp code of 1001' do
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
||||
expect(response).to have_code_of(1001)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when domain is discarded' do
|
||||
let!(:domain) { create(:domain_discarded, name: 'test.com') }
|
||||
|
||||
it 'returns epp code of 2105' do
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
||||
expect(response).to have_code_of(2105)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'EPP domain:update' do
|
||||
let(:registrar) { create(:registrar) }
|
||||
let(:user) { create(:api_user_epp, registrar: registrar) }
|
||||
let(:session_id) { create(:epp_session, user: user).session_id }
|
||||
let(:request_xml) { <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>test.com</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
}
|
||||
|
||||
before :example do
|
||||
login_as user
|
||||
end
|
||||
|
||||
context 'when domain is not discarded' do
|
||||
let!(:domain) { create(:domain, name: 'test.com') }
|
||||
|
||||
it 'returns epp code of 1000' do
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
||||
expect(response).to have_code_of(1000)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when domain is discarded' do
|
||||
let!(:domain) { create(:domain_discarded, name: 'test.com') }
|
||||
|
||||
it 'returns epp code of 2105' do
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session_id}"
|
||||
expect(response).to have_code_of(2105)
|
||||
end
|
||||
end
|
||||
end
|
16
test/integration/admin/domains/details_test.rb
Normal file
16
test/integration/admin/domains/details_test.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaDomainDetailsTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
login_as users(:admin)
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discarded_domain_has_corresponding_label
|
||||
visit admin_domain_url(@domain)
|
||||
assert_no_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
@domain.discard
|
||||
visit admin_domain_url(@domain)
|
||||
assert_css 'span.label.label-warning', text: 'deleteCandidate'
|
||||
end
|
||||
end
|
|
@ -25,4 +25,31 @@ class EppDomainDeleteTest < ActionDispatch::IntegrationTest
|
|||
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_deleted
|
||||
domains(:shop).discard
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<delete>
|
||||
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
||||
def test_overwrites_existing
|
||||
def test_update_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
|
@ -20,9 +20,29 @@ class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_equal 'f0ff7d17b0', domains(:shop).transfer_code
|
||||
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_updated
|
||||
domains(:shop).discard
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
end
|
||||
end
|
14
test/models/domain/deletable_test.rb
Normal file
14
test/models/domain/deletable_test.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDeletableTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discard
|
||||
refute @domain.discarded?
|
||||
@domain.discard
|
||||
@domain.reload
|
||||
assert @domain.discarded?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue