mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
parent
7cca7b2976
commit
d57c737a80
8 changed files with 69 additions and 112 deletions
|
@ -5,6 +5,11 @@ module Concerns::Domain::Deletable
|
||||||
alias_attribute :delete_time, :delete_at
|
alias_attribute :delete_time, :delete_at
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def discard
|
||||||
|
self.statuses << DomainStatus::DELETE_CANDIDATE
|
||||||
|
save
|
||||||
|
end
|
||||||
|
|
||||||
def discarded?
|
def discarded?
|
||||||
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
statuses.include?(DomainStatus::DELETE_CANDIDATE)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,5 @@ FactoryBot.define do
|
||||||
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
|
domain.admin_domain_contacts << FactoryBot.build(:admin_domain_contact)
|
||||||
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :domain_discarded do
|
|
||||||
statuses [DomainStatus::DELETE_CANDIDATE]
|
|
||||||
end
|
|
||||||
end
|
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
|
|
|
@ -25,4 +25,31 @@ class EppDomainDeleteTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
|
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||||
end
|
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
|
end
|
||||||
|
|
23
test/integration/epp/domain/domain_update_test.rb
Normal file
23
test/integration/epp/domain/domain_update_test.rb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class EppDomainUpdateTest < ActionDispatch::IntegrationTest
|
||||||
|
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
|
||||||
|
def setup
|
||||||
|
@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