From f6bd51875094978cdbb1c3123b8b09fa5374c4a4 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Mon, 2 Feb 2015 18:28:57 +0200 Subject: [PATCH] Do not validate domain presence in dnskey --- app/controllers/epp_controller.rb | 4 +-- app/models/dnskey.rb | 4 +-- spec/epp/domain_spec.rb | 57 ++++++++++++++++--------------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 7c2cf2e33..79e48780d 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -23,9 +23,9 @@ class EppController < ApplicationController def current_api_user @current_api_user ||= ApiUser.find_by_id(epp_session[:api_user_id]) - # by default PaperTrail uses before filter and at that + # by default PaperTrail uses before filter and at that # time current_api_user is not yet present - ::PaperTrail.whodunnit = api_user_log_str(@current_api_user) + ::PaperTrail.whodunnit = api_user_log_str(@current_api_user) ::PaperSession.session = epp_session.session_id if epp_session.session_id.present? @current_api_user end diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index e0888148b..426d86b8c 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -4,11 +4,11 @@ class Dnskey < ActiveRecord::Base belongs_to :domain - validates :domain, :alg, :protocol, :flags, :public_key, presence: true, if: :validate_key_data + validates :alg, :protocol, :flags, :public_key, presence: true, if: :validate_key_data validate :validate_algorithm validate :validate_protocol validate :validate_flags - + before_save -> { generate_digest if public_key_changed? && !ds_digest_changed? } diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index dc078bfc9..9a4023737 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -74,43 +74,44 @@ describe 'EPP Domain', epp: true do end context 'with citizen as an owner' do - # it 'creates a domain' do - # dn = next_domain_name - # response = epp_plain_request(domain_create_xml({ - # name: { value: dn } - # }), :xml) - # d = Domain.last - # response[:msg].should == 'Command completed successfully' - # response[:result_code].should == '1000' + it 'creates a domain' do + dn = next_domain_name + response = epp_plain_request(domain_create_xml({ + name: { value: dn } + }), :xml) - # cre_data = response[:parsed].css('creData') + d = Domain.last + response[:msg].should == 'Command completed successfully' + response[:result_code].should == '1000' - # cre_data.css('name').text.should == dn - # cre_data.css('crDate').text.should == d.created_at.to_time.utc.to_s - # cre_data.css('exDate').text.should == d.valid_to.to_time.utc.to_s + cre_data = response[:parsed].css('creData') - # response[:clTRID].should == 'ABC-12345' + cre_data.css('name').text.should == dn + cre_data.css('crDate').text.should == d.created_at.to_time.utc.to_s + cre_data.css('exDate').text.should == d.valid_to.to_time.utc.to_s - # d.registrar.name.should == 'Registrar 0' - # d.tech_contacts.count.should == 2 - # d.admin_contacts.count.should == 1 + response[:clTRID].should == 'ABC-12345' - # d.nameservers.count.should == 2 - # d.auth_info.should_not be_empty + d.registrar.name.should == 'registrar1' + d.tech_contacts.count.should == 2 + d.admin_contacts.count.should == 1 - # d.dnskeys.count.should == 1 + d.nameservers.count.should == 2 + d.auth_info.should_not be_empty - # key = d.dnskeys.last + d.dnskeys.count.should == 1 - # key.ds_alg.should == 3 - # key.ds_key_tag.should_not be_blank + key = d.dnskeys.last - # key.ds_digest_type.should == Setting.ds_algorithm - # key.flags.should == 257 - # key.protocol.should == 3 - # key.alg.should == 5 - # key.public_key.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' - # end + key.ds_alg.should == 3 + key.ds_key_tag.should_not be_blank + + key.ds_digest_type.should == Setting.ds_algorithm + key.flags.should == 257 + key.protocol.should == 3 + key.alg.should == 5 + key.public_key.should == 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8' + end it 'creates a domain with legal document' do response = epp_plain_request(domain_create_xml_with_legal_doc, :xml)