dnsmadeeasy-rest-api 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ea11e9f3e4bd98ca1e7c96fa950103ced863745b
4
- data.tar.gz: 1bef7b48f3f0941cd6c8b5eae87f7cac2b08abac
2
+ SHA256:
3
+ metadata.gz: cfef63371c15cdb43f5b3cc10da4f1040e799e80ee4baa25c3022690343eb18b
4
+ data.tar.gz: 5d1f3555975abd4539f87cb2c1379c8429d1998db641fe442868ed6f6c881b1d
5
5
  SHA512:
6
- metadata.gz: e667b4ebdc8a24286130def23c20009d6fb55132e42daa12bb9366c1fcb5d8d46002d21ddb9336a0dd7df3331b09dc4f819735431f09e356359f97ceea5aab0a
7
- data.tar.gz: 1a58213c6cc533fa722f75403694302ea115aa1c1f7576657c575555eadf3547d711abdd1c714966c06ac2353a2c4b5d494b00b26c094769fcc635e14d3469ff
6
+ metadata.gz: ff5dbf38737e7b45fb01921cc35567fd18fa7c1aada5fcbc6dd3f872787068d1654b758403b1ae8fc00b42e44c8909a7dfe8a3011d251cf1715fc2520dc9f3d9
7
+ data.tar.gz: 6799acbfd78fcb37810e1b1785a2b26c58a4d5b9ec13f913cc9cf6c19ee811d7c5d40829d1550991213938f29dd9d44edf3cf20cc857bf63906912aa1a08eedc
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
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(style unit)
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.8'
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
@@ -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
- fail 'api_key is undefined' unless api_key
15
- fail 'api_secret is undefined' unless api_secret
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
- self.base_uri = 'https://api.sandbox.dnsmadeeasy.com/V2.0'
25
- else
26
- self.base_uri = 'https://api.dnsmadeeasy.com/V2.0'
27
- end
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.. ips.length-1).each do |idx|
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
- "{\"name\":\"something.wanelo.com\",\"id\":1130967}"
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/id/something.wanelo.com").
28
- with(:headers => request_headers).
29
- to_return(:status => 200, :body => response, :headers => {})
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(1130967)
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/").
40
- with(:headers => request_headers).
41
- to_return(:status => 200, :body => response, :headers => {})
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 "#domain" do
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 "returns the domain given a domain name" do
55
- stub_request(:get, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123").
56
- with(:headers => request_headers).
57
- to_return(:status => 200, :body => response, :headers => {})
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123").
72
- with(:headers => request_headers).
73
- to_return(:status => 200, :body => response, :headers => {})
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/").
84
- with(:headers => request_headers, :body => '{"names":["something.wanelo.com"]}').
85
- to_return(:status => 200, :body => response, :headers => {})
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records").
107
- with(:headers => request_headers).
108
- to_return(:status => 200, :body => response, :headers => {})
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({ 'name' => 'demo', 'type' => 'A', 'id' => 123})
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(:status => 200, :body => response, :headers => {})
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(:status => 200, :body => response, :headers => {})
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/42/").
207
- with(headers: request_headers).
208
- to_return(:status => 200, :body => response, :headers => {})
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, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/").
226
- with(headers: request_headers, body: {"name" => 'test', "type" => 'A', "value" => '192.168.1.1', "ttl" => 3600, "gtdLocation" => "DEFAULT"}.to_json).
227
- to_return(:status => 200, :body => response, :headers => {})
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
- ["a", "aaaa", "ptr", "txt", "cname", "ns", "spf"].each do |record_type|
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', upper_record_type, '192.168.1.1', {}).and_return({})
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 "#create_mx_record" do
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', {'mxLevel' => 50}).and_return({})
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 "#create_srv_record" do
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', {"priority" => priority, "weight" => weight, "port" => port}).and_return({})
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 "#create_httpred_record" do
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', {"redirectType" => redirect_type, "description" => description, "keywords" => keywords, "title" => title}).and_return({})
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 "#update_record" do
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
- stub_request(:put, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/21/").
290
- with(headers: request_headers, body: body).
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
- stub_request(:put, "https://api.dnsmadeeasy.com/V2.0/dns/managed/123/records/updateMulti/").
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, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
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' => 104620,
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, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
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, { 'port' => 80, 'sensitivity' => 5 })).to eq({})
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 "updates the failover config" do
409
- stub_request(:put, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
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
- 'port' => 80,
415
- 'httpFqdn' => 'example.com',
416
- 'httpFile' => '/magic',
417
- 'httpQueryString' => 'more-magic',
418
- 'sensitivity' => 3
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 "#request" do
430
+ describe '#request' do
424
431
  before do
425
- stub_request(:get, "https://api.dnsmadeeasy.com/V2.0/some_path").
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, "/some_path") { |uri|
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 "with a 2xx, empty-string response" do
443
+ context 'with a 2xx, empty-string response' do
437
444
  let(:status) { 200 }
438
- let(:body) { "" }
445
+ let(:body) { '' }
439
446
 
440
- it "handles gracefully" do
447
+ it 'handles gracefully' do
441
448
  expect(response).to eq({})
442
449
  end
443
450
  end
444
451
 
445
- context "with a non-2xx response" do
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 "raises a Net::HTTPServerException instead of a JSON::ParserError" do
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
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'webmock/rspec'
2
4
 
3
5
  RSpec.configure do |config|
4
-
5
- config.filter_run :focus => true
6
+ config.filter_run focus: true
6
7
  config.run_all_when_everything_filtered = true
7
8
 
8
9
  if config.files_to_run.one?
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.8
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: 2018-03-30 00:00:00.000000000 Z
13
+ date: 2020-02-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rspec
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: webmock
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: bundler
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: rubocop
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
- rubyforge_project:
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