mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Basic contact delete command implementation
This commit is contained in:
parent
1645b3e96f
commit
65bb5166cc
7 changed files with 65 additions and 1 deletions
|
@ -11,4 +11,8 @@ class Epp::CommandsController < ApplicationController
|
||||||
def check
|
def check
|
||||||
send("check_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
send("check_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete
|
||||||
|
send("delete_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,22 @@ module Epp::ContactsHelper
|
||||||
@contact.save
|
@contact.save
|
||||||
render '/epp/contacts/create'
|
render '/epp/contacts/create'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_contact
|
||||||
|
ph = params_hash['epp']['command']['delete']['delete']
|
||||||
|
|
||||||
|
begin
|
||||||
|
@contact = Contact.where(code: ph[:id]).first
|
||||||
|
@contact.destroy
|
||||||
|
render '/epp/contacts/delete'
|
||||||
|
rescue NoMethodError => e
|
||||||
|
@code = '2303'
|
||||||
|
@msg = "Object does not exist"
|
||||||
|
render '/epp/error'
|
||||||
|
rescue
|
||||||
|
@code = '2400'
|
||||||
|
@msg = "Command failed"
|
||||||
|
render '/epp/error'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class Contact < ActiveRecord::Base
|
class Contact < ActiveRecord::Base
|
||||||
#TODO Foreign contact will get email with activation link/username/temp password
|
#TODO Foreign contact will get email with activation link/username/temp password
|
||||||
#TODO Phone number validation, in first phase very minimam in order to support current registries
|
#TODO Phone number validation, in first phase very minimam in order to support current registries
|
||||||
|
|
||||||
has_many :addresses
|
has_many :addresses
|
||||||
|
|
||||||
validate :ident_must_be_valid
|
validate :ident_must_be_valid
|
||||||
|
|
9
app/views/epp/contacts/delete.xml.builder
Normal file
9
app/views/epp/contacts/delete.xml.builder
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
xml.epp_head do
|
||||||
|
xml.response do
|
||||||
|
xml.result('code' => '1000') do
|
||||||
|
xml.msg 'Command completed successfully'
|
||||||
|
end
|
||||||
|
|
||||||
|
xml << render('/epp/shared/trID')
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,15 +17,34 @@ describe 'EPP Contact', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates a contact with same ident' do
|
it 'updates a contact with same ident' do
|
||||||
|
Fabricate(:contact)
|
||||||
response = epp_request('contacts/create.xml')
|
response = epp_request('contacts/create.xml')
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
|
||||||
|
expect(Contact.first.name).to eq("John Doe")
|
||||||
|
|
||||||
expect(Contact.count).to eq(1)
|
expect(Contact.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO tests for missing/invalid/etc ident
|
#TODO tests for missing/invalid/etc ident
|
||||||
|
|
||||||
|
it 'deletes contact' do
|
||||||
|
Fabricate(:contact)
|
||||||
|
response = epp_request('contacts/delete.xml')
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
|
||||||
|
expect(Contact.count).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'deletes an nil object' do
|
||||||
|
response = epp_request('contacts/delete.xml')
|
||||||
|
expect(response[:result_code]).to eq('2303')
|
||||||
|
expect(response[:msg]).to eq('Object does not exist')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
12
spec/epp/requests/contacts/delete.xml
Normal file
12
spec/epp/requests/contacts/delete.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<delete>
|
||||||
|
<contact:delete
|
||||||
|
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
|
||||||
|
<contact:id>sh8913</contact:id>
|
||||||
|
</contact:delete>
|
||||||
|
</delete>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -3,4 +3,5 @@ Fabricator(:contact) do
|
||||||
phone '+372.12345678'
|
phone '+372.12345678'
|
||||||
email Faker::Internet.email
|
email Faker::Internet.email
|
||||||
ident '37605030299'
|
ident '37605030299'
|
||||||
|
code 'sh8913'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue