-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow EPP domain:update/transfer/delete if a domain has "deleteCan…
…didate" status #355
- Loading branch information
Artur Beljajev
committed
Jan 24, 2017
1 parent
d4ddb5d
commit edf1e33
Showing
10 changed files
with
193 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Concerns::Domain::Deletable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
alias_attribute :delete_time, :delete_at | ||
end | ||
|
||
def discarded? | ||
statuses.include?(DomainStatus::DELETE_CANDIDATE) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'EPP domain:delete' do | ||
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 | ||
} | ||
|
||
subject(:response_xml) { Nokogiri::XML(response.body) } | ||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] } | ||
subject(:response_description) { response_xml.css('result msg').text } | ||
|
||
before :example do | ||
sign_in_to_epp_area | ||
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 | ||
expect(response_code).to eq('1001'), "Expected EPP code of 1001, got #{response_code} (#{response_description})" | ||
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 | ||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'EPP domain:transfer' do | ||
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> | ||
<transfer op="request"> | ||
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd"> | ||
<domain:name>test.com</domain:name> | ||
<domain:authInfo> | ||
<domain:pw>98oiewslkfkd</domain:pw> | ||
</domain:authInfo> | ||
</domain:transfer> | ||
</transfer> | ||
</command> | ||
</epp> | ||
XML | ||
} | ||
|
||
subject(:response_xml) { Nokogiri::XML(response.body) } | ||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] } | ||
subject(:response_description) { response_xml.css('result msg').text } | ||
|
||
before :example do | ||
sign_in_to_epp_area | ||
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/transfer', frame: request_xml | ||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})" | ||
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/transfer', frame: request_xml | ||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'EPP domain:update' do | ||
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 | ||
} | ||
|
||
subject(:response_xml) { Nokogiri::XML(response.body) } | ||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] } | ||
subject(:response_description) { response_xml.css('result msg').text } | ||
|
||
before :example do | ||
sign_in_to_epp_area | ||
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 | ||
expect(response_code).to eq('1000'), "Expected EPP code of 1000, got #{response_code} (#{response_description})" | ||
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 | ||
expect(response_code).to eq('2105'), "Expected EPP code of 2105, got #{response_code} (#{response_description})" | ||
end | ||
end | ||
end |