From 0c16146ebb15d120ddab2d5c88b0c8b2dd55f846 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Thu, 29 Jan 2015 18:51:04 +0200 Subject: [PATCH] Save legal doc on domain info request --- app/controllers/epp/domains_controller.rb | 4 ++++ spec/epp/domain_spec.rb | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 0da3e4f51..11fda68e9 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -15,6 +15,10 @@ class Epp::DomainsController < EppController def info @domain = find_domain handle_errors(@domain) and return unless @domain + + @domain.attach_legal_document(Epp::EppDomain.parse_legal_document_from_frame(params[:parsed_frame])) + @domain.save!(validate: false) + render_epp_response '/epp/domains/info' end diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 34a3efce8..8c87f7f7f 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -1421,7 +1421,7 @@ describe 'EPP Domain', epp: true do end end - it 'validates legal document type' do + it 'validates legal document type in info request' do xml = epp_xml.domain.info({ name: { value: domain.name } }, { @@ -1450,6 +1450,27 @@ describe 'EPP Domain', epp: true do response[:msg].should == 'Attribute is invalid: type' end + it 'saves legal document on info request' do + xml = epp_xml.domain.info({ + name: { value: domain.name } + }, { + _anonymus: [ + legalDocument: { + value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==', + attrs: { type: 'pdf' } + } + ] + }) + + response = epp_plain_request(xml, :xml) + response[:msg].should == 'Command completed successfully' + + docs = domain.legal_documents + docs.count.should == 1 + docs.first.body.should == 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==' + docs.first.document_type.should == 'pdf' + end + ### DELETE ### it 'deletes domain' do response = epp_plain_request(epp_xml.domain.delete({