Skip to content

Releases: mocktools/ruby-dns-mock

v1.1.0: Feature/RSpec integration

01 Feb 22:03
819726d
Compare
Choose a tag to compare

Added DnsMock helper which can simplify integration with RSpec:

# spec/support/config/dns_mock.rb
require 'dns_mock/test_framework/rspec'

RSpec.configure do |config|
  config.include DnsMock::TestFramework::RSpec::Helper
end

# your awesome first_a_record_spec.rb
RSpec.describe FirstARecord do
  subject(:service) do
    described_class.call(
      hostname,
      dns_gateway_host: 'localhost',
      dns_gateway_port: dns_mock_server.port
    )
  end

  let(:hostname) { 'example.com' }
  let(:first_a_record) { '1.2.3.4' }
  let(:records) { { hostname => { a: [first_a_record] } } }

  before { dns_mock_server.assign_mocks(records) }

  it { is_expected.to eq(first_a_record) }
end
  1. Added DnsMock::TestFramework::RSpec::Interface, tests
  2. Added DnsMock::TestFramework::RSpec::Helper, tests
  3. Added RSpec DnsMock config
  4. Updated readme, changelog
  5. Updated gem version to 1.1.0

v1.0.0: Feature/Configurable record not found behaviour

29 Jan 07:05
130779a
Compare
Choose a tag to compare

Added configurable strategy for record not found case. By default it won't raise an exception when DNS record not found in mocked records dictionary:

DnsMock.start_server(port: 5300)
dig @localhost -p 5300 A example.com
; <<>> DiG 9.10.6 <<>> @localhost -p 5300 A example.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38632
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com.			IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.1#5300(127.0.0.1)
;; WHEN: Fri Jan 29 08:21:30 EET 2021
;; MSG SIZE  rcvd: 40

If you want raise an exception when record not found, just start DnsMock with exception_if_not_found: true option:

DnsMock.start_server(exception_if_not_found: true)
  1. Updated DnsMock.start_server
  2. Updated DnsMock::Server
  3. Updated DnsMock::Response::Message
  4. Updated DnsMock::Response::Answer
  5. Updated readme, changelog
  6. Updated gem version to 1.0.0

v0.2.1: Bugfix/RDNS lookup representation

27 Jan 10:25
7a098e9
Compare
Choose a tag to compare

Fixed RDNS lookup representatin for IP address in PTR record feature.

  1. Updated DnsMock::Server::RecordsDictionaryBuilder
  2. Updated gem version to 0.2.1

v0.2.0: Feature/PTR record support

25 Jan 22:22
e0d77ec
Compare
Choose a tag to compare

Added ability to mock PTR records. Please note, you can define host address without RDNS lookup prefix (.in-addr.arpa). DnsMock will do it for you.

records = {
  '1.1.1.1' => {
    ptr: %w[domain_1.com domain_2.com]
  }
}

DnsMock.start_server(records: records)
dig @localhost -p 5300 -x 1.1.1.1
; <<>> DiG 9.10.6 <<>> @localhost -p 5300 -x 1.1.1.1
; (2 servers found)

;; ANSWER SECTION:
1.1.1.1.in-addr.arpa.	1	IN	PTR	domain_1.com.
1.1.1.1.in-addr.arpa.	1	IN	PTR	domain_2.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#5300(127.0.0.1)
;; WHEN: Mon Jan 25 19:58:39 EET 2021
;; MSG SIZE  rcvd: 98
  1. Added PTR record support
  2. Updated gem version to 0.2.0

v0.1.0: First release

19 Jan 12:21
780a287
Compare
Choose a tag to compare

Ruby DnsMock first release 🚀 Thanks @le0pard for idea & support.