From 5634103cfdab1990a60df7beb9a083823661cc02 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Sat, 17 Mar 2018 00:33:54 +0100 Subject: [PATCH] feat: use dig for tests --- test/integration/bind/default.yml | 6 +++++- test/integration/bind/serverspec/bind_spec.rb | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/test/integration/bind/default.yml b/test/integration/bind/default.yml index 5de4cea..e393ae4 100644 --- a/test/integration/bind/default.yml +++ b/test/integration/bind/default.yml @@ -32,4 +32,8 @@ - { name: hello, type: a, value: 4.3.2.1 } roles: - - ansible-role-bind + - ansible-role-bind + + tasks: + - apt: + name: dnsutils diff --git a/test/integration/bind/serverspec/bind_spec.rb b/test/integration/bind/serverspec/bind_spec.rb index 2f7f078..8bd5e8b 100644 --- a/test/integration/bind/serverspec/bind_spec.rb +++ b/test/integration/bind/serverspec/bind_spec.rb @@ -3,9 +3,9 @@ require 'serverspec' set :backend, :exec puts -puts "================================" +puts '================================' puts %x(ansible --version) -puts "================================" +puts '================================' %w[ bind9 @@ -56,17 +56,22 @@ describe port(53) do it { should be_listening.with('udp') } end -describe command('host hello.test.local 127.0.0.1') do +describe command('dig +nocmd +noall +answer hello.test.local @127.0.0.1') do its(:exit_status) { should eq 0 } - its(:stdout) { should contain('1.2.3.4') } + its(:stdout) { should contain(/hello\.test\.local\.\s+300\s+IN\s+A\s+1\.2\.3\.4/) } end -describe command('host hello.hello.local 127.0.0.1') do +describe command('dig +nocmd +noall +answer -t mx test.local @127.0.0.1') do its(:exit_status) { should eq 0 } - its(:stdout) { should contain('4.3.2.1') } + its(:stdout) { should contain(/test\.local\.\s+3600\s+IN\s+MX\s+20 mail\.test\.local\./) } end -describe command('host -t TXT hello.local 127.0.0.1') do +describe command('dig +nocmd +noall +answer hello.hello.local @127.0.0.1') do its(:exit_status) { should eq 0 } - its(:stdout) { should contain('hello.local descriptive text') } + its(:stdout) { should contain(/hello\.hello\.local\.\s+3600\s+IN\s+A\s+4\.3\.2\.1/) } +end + +describe command('dig +nocmd +noall +answer -t txt hello.local @127.0.0.1') do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain('"0L4M99yv8ZLptmS2GP6goHXZgTdFIyYCdfziQgoENcloUI3KshDscsoh6H6I2LA"') } end