dns_mock 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek.yml +4 -0
- data/CHANGELOG.md +35 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/dns_mock/record/builder/mx.rb +12 -1
- data/lib/dns_mock/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da8634cd856df1f65afef1ba6f87f3b6118fc54525d00843da76c7b0e415dfc0
|
4
|
+
data.tar.gz: 45d0c5f55c9460d3d555ed26ae474fe7a7f30d614e172ec22d430d531f941c61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4c7c08f00e98916c5d10580961bfa8518455d3323718327ca87767f699a78d4ceda1d2ea039150a8e05eec88dd50659519a46dadaf27c8f8c2504590951703c
|
7
|
+
data.tar.gz: 8fc55743a9ff129c5add8e1592b257046150c4267a621afc9bc0257901bfd3e72f4ac658fba03cde7f5608c1683584ebdf0e422af419e94f914eedcc465ed9e6
|
data/.reek.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,41 @@
|
|
2
2
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
4
4
|
|
5
|
+
## [1.2.0] - 2021-02-04
|
6
|
+
|
7
|
+
### Ability to specify MX record priority
|
8
|
+
|
9
|
+
Added ability to specify custom priority of MX record if it needed. Now it impossible to define null or backup MX records. Please note, if you haven't specified a priority of MX record, it will be assigned automatically. MX records builder is assigning priority with step 10 from first item of defined MX records array.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
records = {
|
13
|
+
'example.com' => {
|
14
|
+
mx: %w[.:0 mx1.domain.com:10 mx2.domain.com:10 mx3.domain.com]
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
DnsMock.start_server(records: records)
|
19
|
+
```
|
20
|
+
|
21
|
+
```bash
|
22
|
+
dig @localhost -p 5300 MX example.com
|
23
|
+
```
|
24
|
+
|
25
|
+
```
|
26
|
+
; <<>> DiG 9.10.6 <<>> @localhost -p 5300 MX example.com
|
27
|
+
|
28
|
+
;; ANSWER SECTION:
|
29
|
+
example.com. 1 IN MX 0 .
|
30
|
+
example.com. 1 IN MX 10 mx1.domain.com.
|
31
|
+
example.com. 1 IN MX 10 mx2.domain.com.
|
32
|
+
example.com. 1 IN MX 40 mx3.domain.com.
|
33
|
+
|
34
|
+
;; Query time: 0 msec
|
35
|
+
;; SERVER: 127.0.0.1#5300(127.0.0.1)
|
36
|
+
;; WHEN: Wed Feb 03 20:19:51 EET 2021
|
37
|
+
;; MSG SIZE rcvd: 102
|
38
|
+
```
|
39
|
+
|
5
40
|
## [1.1.0] - 2021-02-01
|
6
41
|
|
7
42
|
### RSpec native support
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -57,13 +57,13 @@ Or install it yourself as:
|
|
57
57
|
## Usage
|
58
58
|
|
59
59
|
```ruby
|
60
|
-
# Example of mocked DNS records structure
|
60
|
+
# Example of mocked DNS records, please follow this data structure
|
61
61
|
records = {
|
62
62
|
'example.com' => {
|
63
63
|
a: %w[1.1.1.1 2.2.2.2],
|
64
64
|
aaaa: %w[2a00:1450:4001:81e::200e],
|
65
65
|
ns: %w[ns1.domain.com ns2.domain.com],
|
66
|
-
mx: %w[mx1.domain.com mx2.domain.com],
|
66
|
+
mx: %w[mx1.domain.com mx2.domain.com:50], # you can specify host(s) or host(s) with priority
|
67
67
|
txt: %w[txt_record_1 txt_record_2],
|
68
68
|
cname: 'some.domain.com',
|
69
69
|
soa: [
|
@@ -132,7 +132,7 @@ require 'dns_mock/test_framework/rspec'
|
|
132
132
|
|
133
133
|
#### DnsMock RSpec helper
|
134
134
|
|
135
|
-
Just add `DnsMock::TestFramework::RSpec::Helper` if you wanna
|
135
|
+
Just add `DnsMock::TestFramework::RSpec::Helper` if you wanna use shortcut `dns_mock_server` for DnsMock server instance into your `RSpec.describe` blocks:
|
136
136
|
|
137
137
|
```ruby
|
138
138
|
# spec/support/config/dns_mock.rb
|
@@ -4,18 +4,29 @@ module DnsMock
|
|
4
4
|
module Record
|
5
5
|
module Builder
|
6
6
|
class Mx < DnsMock::Record::Builder::Base
|
7
|
+
include DnsMock::Error::Helper
|
8
|
+
|
9
|
+
MX_RECORD_REGEX_PATTERN = /\A(.+):(\d+)|(.+)\z/.freeze
|
7
10
|
RECORD_PREFERENCE_STEP = 10
|
8
11
|
|
9
12
|
def build
|
10
13
|
records_data.map.with_index(1) do |record_data, record_preference|
|
14
|
+
record_data, custom_record_preference = parse_mx_record_data(record_data)
|
11
15
|
target_factory.new(
|
12
16
|
record_data: [
|
13
|
-
record_preference * DnsMock::Record::Builder::Mx::RECORD_PREFERENCE_STEP,
|
17
|
+
custom_record_preference&.to_i || record_preference * DnsMock::Record::Builder::Mx::RECORD_PREFERENCE_STEP,
|
14
18
|
record_data
|
15
19
|
]
|
16
20
|
).create
|
17
21
|
end
|
18
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parse_mx_record_data(record_data)
|
27
|
+
raise_record_context_type_error(:mx, record_data, ::String)
|
28
|
+
record_data.scan(DnsMock::Record::Builder::Mx::MX_RECORD_REGEX_PATTERN).flatten.compact
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
data/lib/dns_mock/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|