Commit 6bd8d24f authored by Colin Shea's avatar Colin Shea

quote the propery value for CAA records

parent 156353bf
......@@ -205,10 +205,10 @@ class Zone
def caa(property, valuelist, ttl=nil)
values = Array(valuelist)
if values.empty?
push :caa, "@", ttl, flags: 0, property: property, value: ';'
push :caa, "@", ttl, flags: 0, property: property, value: '";"'
else
values.each do |ca_auth|
push :caa, "@", ttl, flags: 0, property: property, value: ca_auth
push :caa, "@", ttl, flags: 0, property: property, value: "\"#{ca_auth}\""
end
end
end
......
......@@ -513,6 +513,11 @@ ENDH
out += "#{sshfp[:name]} #{sshfp[:ttl]} #{sshfp[:class]} SSHFP #{sshfp[:key_type]} #{sshfp[:fingerprint_type]} #{sshfp[:fingerprint]}\n"
end
out += "\n; Zone CAA Records\n" unless self.caa.empty?
self.caa.each do |caa|
out += "#{caa[:name]} #{caa[:ttl]} #{caa[:class]} CAA #{caa[:flags]} #{caa[:property]} #{caa[:value]}\n"
end
out
end
......
......@@ -202,18 +202,18 @@ describe Zone do
describe "caa record" do
it "should create a single record" do
subject.caa 'issue', 'letsencrypt.org'
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"letsencrypt.org"}]
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"\"letsencrypt.org\""}]
end
it "should create multiple records" do
subject.caa 'issue', ['letsencrypt.org', 'digicert.com']
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"letsencrypt.org"},
{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"digicert.com"}]
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"\"letsencrypt.org\""},
{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issue', :value=>"\"digicert.com\""}]
end
it "should default to semicolon" do
subject.caa 'issuewild', nil
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issuewild', :value=>";"}]
subject.zonefile.caa.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :flags=>0, :property=>'issuewild', :value=>"\";\""}]
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment