dnsmadeeasy-rest-api 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile +2 -0
- data/Rakefile +3 -1
- data/dnsmadeeasy-rest-api.gemspec +6 -4
- data/lib/dnsmadeeasy-rest-api.rb +62 -11
- data/spec/lib/dnsmadeeasyapi-rest-api_spec.rb +114 -107
- data/spec/spec_helper.rb +3 -2
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cfef63371c15cdb43f5b3cc10da4f1040e799e80ee4baa25c3022690343eb18b
|
4
|
+
data.tar.gz: 5d1f3555975abd4539f87cb2c1379c8429d1998db641fe442868ed6f6c881b1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff5dbf38737e7b45fb01921cc35567fd18fa7c1aada5fcbc6dd3f872787068d1654b758403b1ae8fc00b42e44c8909a7dfe8a3011d251cf1715fc2520dc9f3d9
|
7
|
+
data.tar.gz: 6799acbfd78fcb37810e1b1785a2b26c58a4d5b9ec13f913cc9cf6c19ee811d7c5d40829d1550991213938f29dd9d44edf3cf20cc857bf63906912aa1a08eedc
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
5
|
require 'rubocop/rake_task'
|
@@ -19,4 +21,4 @@ end
|
|
19
21
|
|
20
22
|
# The default rake task should just run it all
|
21
23
|
desc 'Run all tests'
|
22
|
-
task default: %w
|
24
|
+
task default: %w[style unit]
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'dnsmadeeasy-rest-api'
|
3
|
-
s.version = '1.0.
|
5
|
+
s.version = '1.0.9'
|
4
6
|
s.authors = ['Arnoud Vermeer', 'Paul Henry', 'James Hart']
|
5
7
|
s.email = ['a.vermeer@freshway.biz', 'ops@wanelo.com']
|
6
|
-
s.license = 'Apache'
|
8
|
+
s.license = 'Apache-2.0'
|
7
9
|
s.summary = 'DNS Made Easy V2.0 REST API client for Ruby'
|
8
10
|
s.description = 'DNS Made Easy V2.0 REST API client for Ruby. With tests and no dependencies.'
|
9
11
|
s.homepage = 'https://github.com/funzoneq/dnsmadeeasy-rest-api'
|
10
12
|
|
11
13
|
s.files = `git ls-files`.split("\n")
|
12
14
|
|
13
|
-
s.add_development_dependency 'rspec'
|
14
|
-
s.add_development_dependency 'webmock'
|
15
15
|
s.add_development_dependency 'bundler'
|
16
|
+
s.add_development_dependency 'rspec'
|
16
17
|
s.add_development_dependency 'rubocop'
|
18
|
+
s.add_development_dependency 'webmock'
|
17
19
|
end
|
data/lib/dnsmadeeasy-rest-api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'time'
|
2
4
|
require 'openssl'
|
3
5
|
require 'json'
|
@@ -11,8 +13,8 @@ class DnsMadeEasy
|
|
11
13
|
attr_reader :request_limit
|
12
14
|
|
13
15
|
def initialize(api_key, api_secret, sandbox = false, options = {})
|
14
|
-
|
15
|
-
|
16
|
+
raise 'api_key is undefined' unless api_key
|
17
|
+
raise 'api_secret is undefined' unless api_secret
|
16
18
|
|
17
19
|
@api_key = api_key
|
18
20
|
@api_secret = api_secret
|
@@ -20,11 +22,11 @@ class DnsMadeEasy
|
|
20
22
|
@requests_remaining = -1
|
21
23
|
@request_limit = -1
|
22
24
|
|
23
|
-
if sandbox
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
self.base_uri = if sandbox
|
26
|
+
'https://api.sandbox.dnsmadeeasy.com/V2.0'
|
27
|
+
else
|
28
|
+
'https://api.dnsmadeeasy.com/V2.0'
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
# -----------------------------------
|
@@ -55,6 +57,54 @@ class DnsMadeEasy
|
|
55
57
|
create_domains([domain_name])
|
56
58
|
end
|
57
59
|
|
60
|
+
# -----------------------------------
|
61
|
+
# -------- SECONDARY DOMAINS --------
|
62
|
+
# -----------------------------------
|
63
|
+
|
64
|
+
def secondarys
|
65
|
+
get '/dns/secondary'
|
66
|
+
end
|
67
|
+
|
68
|
+
def secondary(id)
|
69
|
+
get "/dns/secondary/#{id}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def update_secondary(ids = [], ipSetId)
|
73
|
+
put('/dns/secondary/', 'ids' => ids, 'ipSetId' => ipSetId)
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_secondary(names = [], ipSetId)
|
77
|
+
post('/dns/secondary/', "names": names, 'ipSetId' => ipSetId)
|
78
|
+
end
|
79
|
+
|
80
|
+
def delete_secondary(id)
|
81
|
+
delete("/dns/secondary/#{id}")
|
82
|
+
end
|
83
|
+
|
84
|
+
# -----------------------------------
|
85
|
+
# ------------- IP SETS -------------
|
86
|
+
# -----------------------------------
|
87
|
+
|
88
|
+
def ip_sets
|
89
|
+
get '/dns/secondary/ipSet'
|
90
|
+
end
|
91
|
+
|
92
|
+
def ip_set(id)
|
93
|
+
get "/dns/secondary/ipSet/#{id}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def update_ip_set(id, name, ips = [])
|
97
|
+
put("/dns/secondary/ipSet/#{id}", 'name' => name, 'id' => id, 'ips' => ips)
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_ip_set(name, ips = [])
|
101
|
+
post('/dns/secondary/ipSet', 'name' => name, 'ips' => ips)
|
102
|
+
end
|
103
|
+
|
104
|
+
def delete_ip_set(id)
|
105
|
+
delete("/dns/secondary/ipSet/#{id}")
|
106
|
+
end
|
107
|
+
|
58
108
|
# -----------------------------------
|
59
109
|
# ------------- RECORDS -------------
|
60
110
|
# -----------------------------------
|
@@ -80,6 +130,7 @@ class DnsMadeEasy
|
|
80
130
|
|
81
131
|
def delete_records(domain_name, ids = [])
|
82
132
|
return if ids.empty?
|
133
|
+
|
83
134
|
domain_id = get_id_by_domain(domain_name)
|
84
135
|
|
85
136
|
delete "/dns/managed/#{domain_id}/records?ids=#{ids.join(',')}"
|
@@ -172,7 +223,7 @@ class DnsMadeEasy
|
|
172
223
|
get "/monitor/#{record_id}"
|
173
224
|
end
|
174
225
|
|
175
|
-
def update_failover_config(record_id, ips, desc, protocol='TCP', options = {})
|
226
|
+
def update_failover_config(record_id, ips, desc, protocol = 'TCP', options = {})
|
176
227
|
protocolIds = {
|
177
228
|
'TCP' => 1,
|
178
229
|
'UDP' => 2,
|
@@ -197,8 +248,8 @@ class DnsMadeEasy
|
|
197
248
|
body = body.merge(options)
|
198
249
|
|
199
250
|
ip_config = {}
|
200
|
-
(0..
|
201
|
-
ip_config["ip#{idx+1}"] = ips[idx]
|
251
|
+
(0..ips.length - 1).each do |idx|
|
252
|
+
ip_config["ip#{idx + 1}"] = ips[idx]
|
202
253
|
end
|
203
254
|
|
204
255
|
body = body.merge(ip_config)
|
@@ -206,7 +257,7 @@ class DnsMadeEasy
|
|
206
257
|
put "/monitor/#{record_id}", body
|
207
258
|
end
|
208
259
|
|
209
|
-
def disable_failover(record_id, options={})
|
260
|
+
def disable_failover(record_id, options = {})
|
210
261
|
put "/monitor/#{record_id}", { 'failover' => false, 'monitor' => false }.merge(options)
|
211
262
|
end
|
212
263
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require_relative '../../lib/dnsmadeeasy-rest-api'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe DnsMadeEasy do
|
|
5
7
|
let(:api_key) { 'soooo secret' }
|
6
8
|
let(:secret_key) { 'soooo secret' }
|
7
9
|
let(:request_headers) do
|
8
|
-
{'Accept' => 'application/json',
|
10
|
+
{ 'Accept' => 'application/json',
|
9
11
|
'X-Dnsme-Apikey' => 'soooo secret',
|
10
12
|
'X-Dnsme-Hmac' => 'ff6e87e78ff909573362c9a38df13ccc5fa01846',
|
11
|
-
'X-Dnsme-Requestdate' => 'Wed, 21 May 2014 18:08:37 GMT'}
|
13
|
+
'X-Dnsme-Requestdate' => 'Wed, 21 May 2014 18:08:37 GMT' }
|
12
14
|
end
|
13
15
|
|
14
16
|
subject { DnsMadeEasy.new(api_key, secret_key) }
|
@@ -18,71 +20,70 @@ describe DnsMadeEasy do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
describe '#get_id_by_domain' do
|
21
|
-
|
22
23
|
let(:response) do
|
23
|
-
|
24
|
+
'{"name":"something.wanelo.com","id":1130967}'
|
24
25
|
end
|
25
26
|
|
26
27
|
it 'returns the id of the domain' do
|
27
|
-
stub_request(:get,
|
28
|
-
with(:
|
29
|
-
to_return(:
|
28
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/id/something.wanelo.com')
|
29
|
+
.with(headers: request_headers)
|
30
|
+
.to_return(status: 200, body: response, headers: {})
|
30
31
|
|
31
|
-
expect(subject.get_id_by_domain('something.wanelo.com')).to eq(
|
32
|
+
expect(subject.get_id_by_domain('something.wanelo.com')).to eq(1_130_967)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
36
|
describe '#domains' do
|
36
|
-
let(:response) {
|
37
|
+
let(:response) { '{}' }
|
37
38
|
|
38
39
|
it 'returns all the domains' do
|
39
|
-
stub_request(:get,
|
40
|
-
with(:
|
41
|
-
to_return(:
|
40
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/')
|
41
|
+
.with(headers: request_headers)
|
42
|
+
.to_return(status: 200, body: response, headers: {})
|
42
43
|
|
43
44
|
expect(subject.domains).to eq({})
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
|
-
describe
|
48
|
-
let(:response) {
|
48
|
+
describe '#domain' do
|
49
|
+
let(:response) { '{}' }
|
49
50
|
|
50
51
|
before do
|
51
52
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
52
53
|
end
|
53
54
|
|
54
|
-
it
|
55
|
-
stub_request(:get,
|
56
|
-
with(:
|
57
|
-
to_return(:
|
55
|
+
it 'returns the domain given a domain name' do
|
56
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123')
|
57
|
+
.with(headers: request_headers)
|
58
|
+
.to_return(status: 200, body: response, headers: {})
|
58
59
|
|
59
60
|
expect(subject.domain('something.wanelo.com')).to eq({})
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
63
64
|
describe '#delete_domain' do
|
64
|
-
let(:response) {
|
65
|
+
let(:response) { '{}' }
|
65
66
|
|
66
67
|
before do
|
67
68
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
68
69
|
end
|
69
70
|
|
70
71
|
it 'deletes the domain' do
|
71
|
-
stub_request(:delete,
|
72
|
-
with(:
|
73
|
-
to_return(:
|
72
|
+
stub_request(:delete, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123')
|
73
|
+
.with(headers: request_headers)
|
74
|
+
.to_return(status: 200, body: response, headers: {})
|
74
75
|
|
75
76
|
expect(subject.delete_domain('something.wanelo.com')).to eq({})
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
80
|
describe '#create_domains' do
|
80
|
-
let(:response) {
|
81
|
+
let(:response) { '{}' }
|
81
82
|
|
82
83
|
it 'creates the domains' do
|
83
|
-
stub_request(:post,
|
84
|
-
with(:
|
85
|
-
to_return(:
|
84
|
+
stub_request(:post, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/')
|
85
|
+
.with(headers: request_headers, body: '{"names":["something.wanelo.com"]}')
|
86
|
+
.to_return(status: 200, body: response, headers: {})
|
86
87
|
|
87
88
|
expect(subject.create_domains(['something.wanelo.com'])).to eq({})
|
88
89
|
end
|
@@ -95,17 +96,29 @@ describe DnsMadeEasy do
|
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
99
|
+
describe '#secondarys' do
|
100
|
+
let(:response) { '{}' }
|
101
|
+
|
102
|
+
it 'returns all the secondary domains' do
|
103
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/dns/secondary')
|
104
|
+
.with(headers: request_headers)
|
105
|
+
.to_return(status: 200, body: response, headers: {})
|
106
|
+
|
107
|
+
expect(subject.secondarys).to eq({})
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
98
111
|
describe '#records_for' do
|
99
|
-
let(:response) {
|
112
|
+
let(:response) { '{}' }
|
100
113
|
|
101
114
|
before do
|
102
115
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
103
116
|
end
|
104
117
|
|
105
118
|
it 'returns all records for a given domain' do
|
106
|
-
stub_request(:get,
|
107
|
-
with(:
|
108
|
-
to_return(:
|
119
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records')
|
120
|
+
.with(headers: request_headers)
|
121
|
+
.to_return(status: 200, body: response, headers: {})
|
109
122
|
|
110
123
|
expect(subject.records_for('something.wanelo.com')).to eq({})
|
111
124
|
end
|
@@ -115,8 +128,8 @@ describe DnsMadeEasy do
|
|
115
128
|
let(:records_for_response) do
|
116
129
|
{
|
117
130
|
'data' => [
|
118
|
-
{ 'name' => 'demo', 'type' => 'A', 'id' => 123},
|
119
|
-
{ 'name' => 'demo', 'type' => 'A', 'id' => 143}
|
131
|
+
{ 'name' => 'demo', 'type' => 'A', 'id' => 123 },
|
132
|
+
{ 'name' => 'demo', 'type' => 'A', 'id' => 143 }
|
120
133
|
]
|
121
134
|
}
|
122
135
|
end
|
@@ -126,7 +139,7 @@ describe DnsMadeEasy do
|
|
126
139
|
end
|
127
140
|
|
128
141
|
it 'finds the first record that matches name and type' do
|
129
|
-
expect(subject.find('something.wanelo.com', 'demo', 'A')).to eq(
|
142
|
+
expect(subject.find('something.wanelo.com', 'demo', 'A')).to eq('name' => 'demo', 'type' => 'A', 'id' => 123)
|
130
143
|
end
|
131
144
|
end
|
132
145
|
|
@@ -134,8 +147,8 @@ describe DnsMadeEasy do
|
|
134
147
|
let(:records_for_response) do
|
135
148
|
{
|
136
149
|
'data' => [
|
137
|
-
{ 'name' => 'demo', 'type' => 'A', 'id' => 123},
|
138
|
-
{ 'name' => 'demo', 'type' => 'A', 'id' => 143}
|
150
|
+
{ 'name' => 'demo', 'type' => 'A', 'id' => 123 },
|
151
|
+
{ 'name' => 'demo', 'type' => 'A', 'id' => 143 }
|
139
152
|
]
|
140
153
|
}
|
141
154
|
end
|
@@ -150,7 +163,7 @@ describe DnsMadeEasy do
|
|
150
163
|
end
|
151
164
|
|
152
165
|
describe '#delete_records' do
|
153
|
-
let(:response) {
|
166
|
+
let(:response) { '{}' }
|
154
167
|
let(:domain) { 'something.wanelo.com' }
|
155
168
|
let(:domain_id) { 123 }
|
156
169
|
|
@@ -160,9 +173,9 @@ describe DnsMadeEasy do
|
|
160
173
|
before do
|
161
174
|
subject.stub(:get_id_by_domain).with(domain).and_return(domain_id)
|
162
175
|
|
163
|
-
stub_request(:delete, "https://api.dnsmadeeasy.com/V2.0/dns/managed/#{domain_id}/records?ids=#{ids.join(',')}")
|
164
|
-
with(headers: request_headers)
|
165
|
-
to_return(:
|
176
|
+
stub_request(:delete, "https://api.dnsmadeeasy.com/V2.0/dns/managed/#{domain_id}/records?ids=#{ids.join(',')}")
|
177
|
+
.with(headers: request_headers)
|
178
|
+
.to_return(status: 200, body: response, headers: {})
|
166
179
|
end
|
167
180
|
|
168
181
|
it 'deletes a list of records from a given domain' do
|
@@ -178,16 +191,16 @@ describe DnsMadeEasy do
|
|
178
191
|
end
|
179
192
|
|
180
193
|
describe '#delete_all_records' do
|
181
|
-
let(:response) {
|
194
|
+
let(:response) { '{}' }
|
182
195
|
let(:domain) { 'something.wanelo.com' }
|
183
196
|
let(:domain_id) { 123 }
|
184
197
|
|
185
198
|
before do
|
186
199
|
subject.stub(:get_id_by_domain).with(domain).and_return(domain_id)
|
187
200
|
|
188
|
-
stub_request(:delete, "https://api.dnsmadeeasy.com/V2.0/dns/managed/#{domain_id}/records")
|
189
|
-
with(headers: request_headers)
|
190
|
-
to_return(:
|
201
|
+
stub_request(:delete, "https://api.dnsmadeeasy.com/V2.0/dns/managed/#{domain_id}/records")
|
202
|
+
.with(headers: request_headers)
|
203
|
+
.to_return(status: 200, body: response, headers: {})
|
191
204
|
end
|
192
205
|
|
193
206
|
it 'deletes all records from the domain' do
|
@@ -196,23 +209,23 @@ describe DnsMadeEasy do
|
|
196
209
|
end
|
197
210
|
|
198
211
|
describe '#delete_record' do
|
199
|
-
let(:response) {
|
212
|
+
let(:response) { '{}' }
|
200
213
|
|
201
214
|
before do
|
202
215
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
203
216
|
end
|
204
217
|
|
205
218
|
it 'deletes a record' do
|
206
|
-
stub_request(:delete,
|
207
|
-
with(headers: request_headers)
|
208
|
-
to_return(:
|
219
|
+
stub_request(:delete, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/42/')
|
220
|
+
.with(headers: request_headers)
|
221
|
+
.to_return(status: 200, body: response, headers: {})
|
209
222
|
|
210
223
|
expect(subject.delete_record('something.wanelo.com', 42)).to eq({})
|
211
224
|
end
|
212
225
|
end
|
213
226
|
|
214
227
|
describe '#create_record' do
|
215
|
-
let(:response) {
|
228
|
+
let(:response) { '{}' }
|
216
229
|
|
217
230
|
before do
|
218
231
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
@@ -222,61 +235,60 @@ describe DnsMadeEasy do
|
|
222
235
|
let(:name) { 'test' }
|
223
236
|
|
224
237
|
it 'creates a record' do
|
225
|
-
stub_request(:post,
|
226
|
-
with(headers: request_headers, body: {
|
227
|
-
to_return(:
|
228
|
-
|
238
|
+
stub_request(:post, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/')
|
239
|
+
.with(headers: request_headers, body: { 'name' => 'test', 'type' => 'A', 'value' => '192.168.1.1', 'ttl' => 3600, 'gtdLocation' => 'DEFAULT' }.to_json)
|
240
|
+
.to_return(status: 200, body: response, headers: {})
|
229
241
|
|
230
242
|
expect(subject.create_record(domain_name, 'test', 'A', '192.168.1.1')).to eq({})
|
231
243
|
end
|
232
244
|
end
|
233
245
|
|
234
|
-
[
|
246
|
+
%w[a aaaa ptr txt cname ns spf].each do |record_type|
|
235
247
|
method_name = "create_#{record_type}_record"
|
236
248
|
describe "##{method_name}" do
|
237
249
|
upper_record_type = record_type.upcase
|
238
250
|
|
239
251
|
it "calls through to create record with \"#{upper_record_type}\"" do
|
240
|
-
expect(subject).to receive(:create_record).with('something.wanelo.com', 'smellyface',
|
252
|
+
expect(subject).to receive(:create_record).with('something.wanelo.com', 'smellyface', upper_record_type, '192.168.1.1', {}).and_return({})
|
241
253
|
expect(subject.send(method_name, 'something.wanelo.com', 'smellyface', '192.168.1.1')).to eq({})
|
242
254
|
end
|
243
255
|
end
|
244
256
|
end
|
245
257
|
|
246
|
-
describe
|
258
|
+
describe '#create_mx_record' do
|
247
259
|
it 'creates an mx record' do
|
248
|
-
expect(subject).to receive(:create_record).with('something.wanelo.com', 'mail', 'MX', '192.168.1.1',
|
260
|
+
expect(subject).to receive(:create_record).with('something.wanelo.com', 'mail', 'MX', '192.168.1.1', 'mxLevel' => 50).and_return({})
|
249
261
|
expect(subject.create_mx_record('something.wanelo.com', 'mail', 50, '192.168.1.1')).to eq({})
|
250
262
|
end
|
251
263
|
end
|
252
264
|
|
253
|
-
describe
|
265
|
+
describe '#create_srv_record' do
|
254
266
|
let(:weight) { '50' }
|
255
267
|
let(:priority) { '42' }
|
256
268
|
let(:port) { '4040' }
|
257
269
|
|
258
270
|
it 'creates an srv record' do
|
259
|
-
expect(subject).to receive(:create_record).with('something.wanelo.com', 'serv', 'SRV', '192.168.1.1',
|
271
|
+
expect(subject).to receive(:create_record).with('something.wanelo.com', 'serv', 'SRV', '192.168.1.1', 'priority' => priority, 'weight' => weight, 'port' => port).and_return({})
|
260
272
|
|
261
273
|
expect(subject.create_srv_record('something.wanelo.com', 'serv', priority, weight, port, '192.168.1.1')).to eq({})
|
262
274
|
end
|
263
275
|
end
|
264
276
|
|
265
|
-
describe
|
277
|
+
describe '#create_httpred_record' do
|
266
278
|
let(:description) { 'hunky dory redirect description' }
|
267
279
|
let(:keywords) { 'omg,keywords,redirect' }
|
268
280
|
let(:redirect_type) { 'STANDARD - 302' }
|
269
281
|
let(:title) { 'wat' }
|
270
282
|
|
271
283
|
it 'creates an srv record' do
|
272
|
-
expect(subject).to receive(:create_record).with('something.wanelo.com', 'redirect', 'HTTPRED', '192.168.1.1',
|
284
|
+
expect(subject).to receive(:create_record).with('something.wanelo.com', 'redirect', 'HTTPRED', '192.168.1.1', 'redirectType' => redirect_type, 'description' => description, 'keywords' => keywords, 'title' => title).and_return({})
|
273
285
|
|
274
286
|
expect(subject.create_httpred_record('something.wanelo.com', 'redirect', '192.168.1.1', redirect_type, description, keywords, title)).to eq({})
|
275
287
|
end
|
276
288
|
end
|
277
289
|
|
278
|
-
describe
|
279
|
-
let(:response) {
|
290
|
+
describe '#update_record' do
|
291
|
+
let(:response) { '{}' }
|
280
292
|
|
281
293
|
before do
|
282
294
|
subject.stub(:get_id_by_domain).with('something.wanelo.com').and_return(123)
|
@@ -285,11 +297,9 @@ describe DnsMadeEasy do
|
|
285
297
|
it 'updates a record' do
|
286
298
|
body = '{"name":"mail","type":"A","value":"1.1.1.1","ttl":3600,"gtdLocation":"DEFAULT","id":21}'
|
287
299
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
to_return(:status => 200, :body => response, :headers => {})
|
292
|
-
|
300
|
+
stub_request(:put, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/21/')
|
301
|
+
.with(headers: request_headers, body: body)
|
302
|
+
.to_return(status: 200, body: response, headers: {})
|
293
303
|
|
294
304
|
expect(subject.update_record('something.wanelo.com', 21, 'mail', 'A', '1.1.1.1', {})).to eq({})
|
295
305
|
end
|
@@ -324,13 +334,11 @@ describe DnsMadeEasy do
|
|
324
334
|
|
325
335
|
body = '[{"id":21,"name":"mail","type":"A","value":"1.1.1.1","gtdLocation":"DEFAULT","ttl":3600},{"id":22,"name":"post","type":"A","value":"1.1.1.2","gtdLocation":"DEFAULT","ttl":3600}]'
|
326
336
|
|
337
|
+
stub_request(:put, 'https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/updateMulti/')
|
338
|
+
.with(headers: request_headers, body: body)
|
339
|
+
.to_return(status: 200, body: response, headers: {})
|
327
340
|
|
328
|
-
|
329
|
-
with(headers: request_headers, body: body).
|
330
|
-
to_return(status: 200, body: response, headers: {})
|
331
|
-
|
332
|
-
|
333
|
-
expect(subject.update_records('something.wanelo.com', records, { 'ttl' => 3600 })).to eq({})
|
341
|
+
expect(subject.update_records('something.wanelo.com', records, 'ttl' => 3600)).to eq({})
|
334
342
|
end
|
335
343
|
end
|
336
344
|
|
@@ -359,18 +367,18 @@ describe DnsMadeEasy do
|
|
359
367
|
end
|
360
368
|
|
361
369
|
it 'gets the failover config for a failover enabled record' do
|
362
|
-
stub_request(:get,
|
363
|
-
with(headers: request_headers)
|
364
|
-
to_return(status: 200, body: response, headers: {})
|
370
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/monitor/21')
|
371
|
+
.with(headers: request_headers)
|
372
|
+
.to_return(status: 200, body: response, headers: {})
|
365
373
|
|
366
|
-
expect(subject.get_failover_config(21)).to eq(
|
374
|
+
expect(subject.get_failover_config(21)).to eq(
|
367
375
|
'port' => 80,
|
368
376
|
'source' => 1,
|
369
377
|
'failover' => true,
|
370
378
|
'ip1' => '1.1.1.1',
|
371
379
|
'ip2' => '2.2.2.2',
|
372
380
|
'protocolId' => 3,
|
373
|
-
'sourceId' =>
|
381
|
+
'sourceId' => 104_620,
|
374
382
|
'monitor' => true,
|
375
383
|
'sensitivity' => 5,
|
376
384
|
'systemDescription' => 'Test',
|
@@ -382,71 +390,70 @@ describe DnsMadeEasy do
|
|
382
390
|
'ip5Failed' => 0,
|
383
391
|
'recordId' => 21,
|
384
392
|
'autoFailover' => false
|
385
|
-
|
393
|
+
)
|
386
394
|
end
|
387
395
|
end
|
388
396
|
|
389
397
|
describe '#disable_failover' do
|
390
|
-
let(:response) {
|
398
|
+
let(:response) { '{}' }
|
391
399
|
let(:body) { '{"failover":false,"monitor":false,"port":80,"sensitivity":5}' }
|
392
400
|
|
393
401
|
it 'disables the failover config for a failover enabled record' do
|
394
|
-
stub_request(:put,
|
395
|
-
with(headers: request_headers, body: body)
|
396
|
-
to_return(status: 200, body: response, headers: {})
|
402
|
+
stub_request(:put, 'https://api.dnsmadeeasy.com/V2.0/monitor/21')
|
403
|
+
.with(headers: request_headers, body: body)
|
404
|
+
.to_return(status: 200, body: response, headers: {})
|
397
405
|
|
398
|
-
expect(subject.disable_failover(21,
|
406
|
+
expect(subject.disable_failover(21, 'port' => 80, 'sensitivity' => 5)).to eq({})
|
399
407
|
end
|
400
408
|
end
|
401
409
|
|
402
410
|
describe '#update_failover_config' do
|
403
|
-
let(:response) {
|
411
|
+
let(:response) { '{}' }
|
404
412
|
let(:body) do
|
405
413
|
'{"protocolId":3,"port":80,"systemDescription":"Test","sensitivity":3,"failover":true,"monitor":false,"maxEmails":1,"autoFailover":false,"source":1,"httpFqdn":"example.com","httpFile":"/magic","httpQueryString":"more-magic","ip1":"1.1.1.1","ip2":"2.2.2.2"}'
|
406
414
|
end
|
407
415
|
|
408
|
-
it
|
409
|
-
stub_request(:put,
|
410
|
-
with(headers: request_headers, body: body)
|
411
|
-
to_return(status: 200, body: response, headers: {})
|
416
|
+
it 'updates the failover config' do
|
417
|
+
stub_request(:put, 'https://api.dnsmadeeasy.com/V2.0/monitor/21')
|
418
|
+
.with(headers: request_headers, body: body)
|
419
|
+
.to_return(status: 200, body: response, headers: {})
|
412
420
|
|
413
|
-
expect(subject.update_failover_config(21, ['1.1.1.1', '2.2.2.2'], 'Test', 'HTTP',
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
})).to eq({})
|
421
|
+
expect(subject.update_failover_config(21, ['1.1.1.1', '2.2.2.2'], 'Test', 'HTTP',
|
422
|
+
'port' => 80,
|
423
|
+
'httpFqdn' => 'example.com',
|
424
|
+
'httpFile' => '/magic',
|
425
|
+
'httpQueryString' => 'more-magic',
|
426
|
+
'sensitivity' => 3)).to eq({})
|
420
427
|
end
|
421
428
|
end
|
422
429
|
|
423
|
-
describe
|
430
|
+
describe '#request' do
|
424
431
|
before do
|
425
|
-
stub_request(:get,
|
426
|
-
with(headers: request_headers)
|
427
|
-
to_return(status: status, body: body, headers: {})
|
432
|
+
stub_request(:get, 'https://api.dnsmadeeasy.com/V2.0/some_path')
|
433
|
+
.with(headers: request_headers)
|
434
|
+
.to_return(status: status, body: body, headers: {})
|
428
435
|
end
|
429
436
|
|
430
437
|
let(:response) do
|
431
|
-
subject.send(:request,
|
438
|
+
subject.send(:request, '/some_path') do |uri|
|
432
439
|
Net::HTTP::Get.new(uri.path)
|
433
|
-
|
440
|
+
end
|
434
441
|
end
|
435
442
|
|
436
|
-
context
|
443
|
+
context 'with a 2xx, empty-string response' do
|
437
444
|
let(:status) { 200 }
|
438
|
-
let(:body) {
|
445
|
+
let(:body) { '' }
|
439
446
|
|
440
|
-
it
|
447
|
+
it 'handles gracefully' do
|
441
448
|
expect(response).to eq({})
|
442
449
|
end
|
443
450
|
end
|
444
451
|
|
445
|
-
context
|
452
|
+
context 'with a non-2xx response' do
|
446
453
|
let(:status) { 400 }
|
447
454
|
let(:body) { "<xml> JSON.parse won't like this very much </xml>" }
|
448
455
|
|
449
|
-
it
|
456
|
+
it 'raises a Net::HTTPServerException instead of a JSON::ParserError' do
|
450
457
|
expect { response }.to raise_exception(Net::HTTPServerException)
|
451
458
|
end
|
452
459
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsmadeeasy-rest-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnoud Vermeer
|
@@ -10,10 +10,10 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: bundler
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: rspec
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: rubocop
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: webmock
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
@@ -88,7 +88,7 @@ files:
|
|
88
88
|
- spec/spec_helper.rb
|
89
89
|
homepage: https://github.com/funzoneq/dnsmadeeasy-rest-api
|
90
90
|
licenses:
|
91
|
-
- Apache
|
91
|
+
- Apache-2.0
|
92
92
|
metadata: {}
|
93
93
|
post_install_message:
|
94
94
|
rdoc_options: []
|
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.5.2
|
108
|
+
rubygems_version: 3.0.3
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: DNS Made Easy V2.0 REST API client for Ruby
|