Skip to content

Commit

Permalink
Merge pull request #22 from gfish/support-caa
Browse files Browse the repository at this point in the history
Support caa
  • Loading branch information
kaspergrubbe authored May 26, 2023
2 parents 91c7397 + 52fa45c commit 6c2a1d5
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Added an LetsEncrypt guide to the README, including the scripts to communicate with LetsEncrypt.
- Added support for CAA-records, https://blog.qualys.com/product-tech/2017/03/13/caa-mandated-by-cabrowser-forum

## [1.0.2] - 2019-05-11
### Fixed
Expand Down
10 changes: 6 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ GEM
hashdiff (1.0.1)
jmespath (1.6.1)
method_source (1.0.0)
pry (0.13.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.5)
rake (12.3.3)
rexml (3.2.5)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -51,7 +52,7 @@ GEM
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
simplecov-html (0.12.3)
vcr (3.0.3)
webmock (2.3.2)
addressable (>= 2.3.6)
Expand All @@ -62,13 +63,14 @@ PLATFORMS
ruby

DEPENDENCIES
pry (~> 0.12)
pry (~> 0.14.2)
rake (~> 12.3)
rexml (~> 3.2)
rspec (~> 3.8)
simplecov (~> 0.16)
sprinkle_dns!
vcr (~> 3.0)
webmock (~> 2.3)

BUNDLED WITH
1.17.2
2.4.10
2 changes: 1 addition & 1 deletion lib/sprinkle_dns/hosted_zone_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def to_s
private

def valid_record_types
['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/sprinkle_dns/hosted_zone_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def to_s
private

def valid_record_types
['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']
end

end
Expand Down
2 changes: 0 additions & 2 deletions lib/sprinkle_dns/providers/mock_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ def initialize(hosted_zones = [])
end

def fetch_hosted_zones(filter: [])
hosted_zones = []

if filter.empty?
return []
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
SimpleCov.start

require 'vcr'
require 'pry'

require './spec/support/entry_helpers'

Expand Down
24 changes: 24 additions & 0 deletions spec/unit/caa_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

RSpec.describe "CAA-records" do
it 'should allow for CAA records' do
hz = SprinkleDNS::HostedZone.new('colourful.com.')
e1 = SprinkleDNS::HostedZoneEntry.new('A', 'colourful.com.', Array.wrap('80.80.80.80'), 3600, hz.name)
e1.persisted!
hz.resource_record_sets << e1

client = SprinkleDNS::MockClient.new([hz])
sdns = SprinkleDNS::Client.new(client, dry_run: false, delete: true, force: true)

sdns.entry('A', 'colourful.com', '80.80.80.80', 3600)
sdns.entry('CAA', 'colourful.com', '0 issue "letsencrypt.org"', 3600)

existing_hosted_zones, _ = sdns.sprinkle!

shz = client.fetch_hosted_zones(filter: [hz.name]).first

rrs = shz.resource_record_sets.select{|rrs| rrs.type == 'CAA' && rrs.name == 'colourful.com.'}.first
expect(rrs.ttl).to eq 3600
expect(rrs.value).to eq ['0 issue "letsencrypt.org"']
end
end
4 changes: 2 additions & 2 deletions spec/unit/sprinkle_dns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@

context 'record validation' do
it 'should only allow valid string records' do
valid_records = ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
valid_records = ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']

valid_records.each do |record_type|
r53c = SprinkleDNS::Route53Client.new('1','2')
Expand All @@ -280,7 +280,7 @@
end

it 'should not allow symbols for records' do
invalid_records = [:SOA, :A, :TXT, :NS, :CNAME, :MX, :NAPTR, :PTR, :SRV, :SPF, :AAAA]
invalid_records = [:SOA, :A, :TXT, :NS, :CNAME, :MX, :NAPTR, :PTR, :SRV, :SPF, :AAAA, :CAA]

invalid_records.each do |record_type|
r53c = SprinkleDNS::Route53Client.new('1','2')
Expand Down
3 changes: 2 additions & 1 deletion sprinkle_dns.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ Gem::Specification.new do |gem|

gem.add_development_dependency "rspec", '~> 3.8'
gem.add_development_dependency "simplecov", '~> 0.16'
gem.add_development_dependency "pry", '~> 0.12'
gem.add_development_dependency "pry", '~> 0.14.2'
gem.add_development_dependency "rake", '~> 12.3'
gem.add_development_dependency "vcr", '~> 3.0'
gem.add_development_dependency "webmock", '~> 2.3'
gem.add_development_dependency "rexml", '~> 3.2'
end

0 comments on commit 6c2a1d5

Please sign in to comment.