dnsimple 2.0.0.alpha3 → 2.0.0.alpha4

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.markdown +5 -3
  4. data/lib/dnsimple/client.rb +6 -55
  5. data/lib/dnsimple/client/{certificates_service.rb → certificates.rb} +1 -1
  6. data/lib/dnsimple/client/clients.rb +121 -0
  7. data/lib/dnsimple/client/{contacts_service.rb → contacts.rb} +1 -1
  8. data/lib/dnsimple/client/domains.rb +65 -0
  9. data/lib/dnsimple/client/domains_autorenewals.rb +35 -0
  10. data/lib/dnsimple/client/domains_forwards.rb +70 -0
  11. data/lib/dnsimple/client/domains_privacy.rb +35 -0
  12. data/lib/dnsimple/client/domains_records.rb +89 -0
  13. data/lib/dnsimple/client/domains_sharing.rb +53 -0
  14. data/lib/dnsimple/client/domains_zones.rb +22 -0
  15. data/lib/dnsimple/client/{name_servers_service.rb → name_servers.rb} +1 -1
  16. data/lib/dnsimple/client/{registrars_service.rb → registrar.rb} +1 -1
  17. data/lib/dnsimple/client/services.rb +34 -0
  18. data/lib/dnsimple/client/{services_service.rb → services_domains.rb} +1 -28
  19. data/lib/dnsimple/client/templates.rb +98 -0
  20. data/lib/dnsimple/client/{templates_service.rb → templates_records.rb} +1 -93
  21. data/lib/dnsimple/client/{users_service.rb → users.rb} +1 -1
  22. data/lib/dnsimple/version.rb +1 -1
  23. data/spec/dnsimple/client/{certificates_service_spec.rb → certificates_spec.rb} +0 -0
  24. data/spec/dnsimple/client/{contacts_service_spec.rb → contacts_spec.rb} +0 -0
  25. data/spec/dnsimple/client/domains_autorenewals_spec.rb +72 -0
  26. data/spec/dnsimple/client/domains_forwards_spec.rb +146 -0
  27. data/spec/dnsimple/client/domains_privacy_spec.rb +74 -0
  28. data/spec/dnsimple/client/domains_records_spec.rb +191 -0
  29. data/spec/dnsimple/client/domains_sharing_spec.rb +109 -0
  30. data/spec/dnsimple/client/domains_spec.rb +139 -0
  31. data/spec/dnsimple/client/domains_zones_spec.rb +40 -0
  32. data/spec/dnsimple/client/{name_servers_service_spec.rb → name_servers_spec.rb} +0 -0
  33. data/spec/dnsimple/client/{registrars_service_spec.rb → registrar_spec.rb} +9 -9
  34. data/spec/dnsimple/client/{services_service_spec.rb → services_domains_spec.rb} +1 -62
  35. data/spec/dnsimple/client/services_spec.rb +69 -0
  36. data/spec/dnsimple/client/{templates_service_spec.rb → templates_records_spec.rb} +1 -192
  37. data/spec/dnsimple/client/templates_spec.rb +198 -0
  38. data/spec/dnsimple/client/{users_service_spec.rb → users_spec.rb} +0 -0
  39. data/spec/files/{domains_whois_privacy → domains_privacy}/disable/success.http +0 -0
  40. data/spec/files/{domains_whois_privacy → domains_privacy}/enable/success.http +0 -0
  41. data/spec/files/domains_privacy/notfound-domain.http +19 -0
  42. data/spec/files/{registrars → registrar}/check/available.http +0 -0
  43. data/spec/files/{registrars → registrar}/check/registered.http +0 -0
  44. data/spec/files/{registrars → registrar}/register/badrequest-missingdomain.http +0 -0
  45. data/spec/files/{registrars → registrar}/register/badrequest-missingregistrant.http +0 -0
  46. data/spec/files/{registrars → registrar}/register/success.http +0 -0
  47. data/spec/files/{registrars → registrar}/renew/badrequest-missingrenewal.http +0 -0
  48. data/spec/files/{registrars → registrar}/renew/badrequest-unable.http +0 -0
  49. data/spec/files/{registrars → registrar}/renew/success.http +0 -0
  50. data/spec/files/{registrars → registrar}/transfer/success.http +0 -0
  51. data/spec/files/{registrars_extended_attributes → registrar_extended_attributes}/list/success.http +0 -0
  52. data/spec/files/{registrars_prices → registrar_prices}/list/success.http +0 -0
  53. data/spec/files/{subscription → subscriptions}/show/success.http +0 -0
  54. metadata +82 -56
  55. data/lib/dnsimple/client/client_service.rb +0 -8
  56. data/lib/dnsimple/client/domains_service.rb +0 -333
  57. data/spec/dnsimple/client/domains_service_spec.rb +0 -662
@@ -1,201 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dnsimple::Client, ".templates" do
3
+ describe Dnsimple::Client, ".templates / records" do
4
4
 
5
5
  subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").templates }
6
6
 
7
7
 
8
- describe "#list" do
9
- before do
10
- stub_request(:get, %r[/v1/templates$]).
11
- to_return(read_fixture("templates/index/success.http"))
12
- end
13
-
14
- it "builds the correct request" do
15
- subject.list
16
-
17
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates").
18
- with(headers: { 'Accept' => 'application/json' })
19
- end
20
-
21
- it "returns the templates" do
22
- results = subject.list
23
-
24
- expect(results).to be_a(Array)
25
- expect(results.size).to eq(1)
26
-
27
- results.each do |result|
28
- expect(result).to be_a(Dnsimple::Struct::Template)
29
- expect(result.id).to be_a(Fixnum)
30
- end
31
- end
32
- end
33
-
34
- describe "#create" do
35
- before do
36
- stub_request(:post, %r[/v1/templates]).
37
- to_return(read_fixture("templates/create/created.http"))
38
- end
39
-
40
- let(:attributes) { { name: "", short_name: "" } }
41
-
42
- it "builds the correct request" do
43
- subject.create(attributes)
44
-
45
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/templates").
46
- with(body: { dns_template: attributes }).
47
- with(headers: { 'Accept' => 'application/json' })
48
- end
49
-
50
- it "returns the template" do
51
- result = subject.create(attributes)
52
-
53
- expect(result).to be_a(Dnsimple::Struct::Template)
54
- expect(result.id).to be_a(Fixnum)
55
- end
56
- end
57
-
58
- describe "#find" do
59
- before do
60
- stub_request(:get, %r[/v1/templates/.+$]).
61
- to_return(read_fixture("templates/show/success.http"))
62
- end
63
-
64
- it "builds the correct request" do
65
- subject.find(1)
66
-
67
- expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates/1").
68
- with(headers: { 'Accept' => 'application/json' })
69
- end
70
-
71
- it "returns the template" do
72
- result = subject.find(1)
73
-
74
- expect(result).to be_a(Dnsimple::Struct::Template)
75
- expect(result.id).to eq(2651)
76
- expect(result.name).to eq("Localhost")
77
- expect(result.short_name).to eq("localhost")
78
- expect(result.description).to eq("This is a test.")
79
- end
80
-
81
- context "when something does not exist" do
82
- it "raises RecordNotFound" do
83
- stub_request(:get, %r[/v1]).
84
- to_return(read_fixture("templates/notfound.http"))
85
-
86
- expect {
87
- subject.find(1)
88
- }.to raise_error(Dnsimple::RecordNotFound)
89
- end
90
- end
91
- end
92
-
93
- describe "#update" do
94
- before do
95
- stub_request(:put, %r[/v1/templates/.+$]).
96
- to_return(read_fixture("templates/update/success.http"))
97
- end
98
-
99
- it "builds the correct request" do
100
- subject.update(1, { name: "Updated" })
101
-
102
- expect(WebMock).to have_requested(:put, "https://api.zone/v1/templates/1").
103
- with(body: { dns_template: { name: "Updated" } }).
104
- with(headers: { 'Accept' => 'application/json' })
105
- end
106
-
107
- it "returns the template" do
108
- result = subject.update(1, {})
109
-
110
- expect(result).to be_a(Dnsimple::Struct::Template)
111
- expect(result.id).to be_a(Fixnum)
112
- end
113
-
114
- context "when something does not exist" do
115
- it "raises RecordNotFound" do
116
- stub_request(:put, %r[/v1]).
117
- to_return(read_fixture("templates/notfound.http"))
118
-
119
- expect {
120
- subject.update(1, {})
121
- }.to raise_error(Dnsimple::RecordNotFound)
122
- end
123
- end
124
- end
125
-
126
- describe "#delete" do
127
- before do
128
- stub_request(:delete, %r[/v1/templates/.+$]).
129
- to_return(read_fixture("templates/delete/success.http"))
130
- end
131
-
132
- it "builds the correct request" do
133
- subject.delete(1)
134
-
135
- expect(WebMock).to have_requested(:delete, "https://api.zone/v1/templates/1").
136
- with(headers: { 'Accept' => 'application/json' })
137
- end
138
-
139
- it "returns nothing" do
140
- result = subject.delete(1)
141
-
142
- expect(result).to be_truthy
143
- end
144
-
145
- it "supports HTTP 204" do
146
- stub_request(:delete, %r[/v1]).
147
- to_return(read_fixture("templates/delete/success-204.http"))
148
-
149
- result = subject.delete(1)
150
-
151
- expect(result).to be_truthy
152
- end
153
-
154
- context "when something does not exist" do
155
- it "raises RecordNotFound" do
156
- stub_request(:delete, %r[/v1]).
157
- to_return(read_fixture("templates/notfound.http"))
158
-
159
- expect {
160
- subject.delete(1)
161
- }.to raise_error(Dnsimple::RecordNotFound)
162
- end
163
- end
164
- end
165
-
166
-
167
- describe "#apply" do
168
- before do
169
- stub_request(:post, %r[/v1/domains/.+/templates/.+/apply$]).
170
- to_return(read_fixture("templates/apply/success.http"))
171
- end
172
-
173
- it "builds the correct request" do
174
- subject.apply(1, 2)
175
-
176
- expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/1/templates/2/apply").
177
- with(headers: { 'Accept' => 'application/json' })
178
- end
179
-
180
- it "returns nothing" do
181
- result = subject.apply(1, 2)
182
-
183
- expect(result).to be_truthy
184
- end
185
-
186
- context "when something does not exist" do
187
- it "raises RecordNotFound" do
188
- stub_request(:post, %r[/v1]).
189
- to_return(read_fixture("templates/notfound.http"))
190
-
191
- expect {
192
- subject.apply(1, 2)
193
- }.to raise_error(Dnsimple::RecordNotFound)
194
- end
195
- end
196
- end
197
-
198
-
199
8
  describe "#list_records" do
200
9
  before do
201
10
  stub_request(:get, %r[/v1/templates/.+/records$]).
@@ -0,0 +1,198 @@
1
+ require 'spec_helper'
2
+
3
+ describe Dnsimple::Client, ".templates" do
4
+
5
+ subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").templates }
6
+
7
+
8
+ describe "#list" do
9
+ before do
10
+ stub_request(:get, %r[/v1/templates$]).
11
+ to_return(read_fixture("templates/index/success.http"))
12
+ end
13
+
14
+ it "builds the correct request" do
15
+ subject.list
16
+
17
+ expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates").
18
+ with(headers: { 'Accept' => 'application/json' })
19
+ end
20
+
21
+ it "returns the templates" do
22
+ results = subject.list
23
+
24
+ expect(results).to be_a(Array)
25
+ expect(results.size).to eq(1)
26
+
27
+ results.each do |result|
28
+ expect(result).to be_a(Dnsimple::Struct::Template)
29
+ expect(result.id).to be_a(Fixnum)
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#create" do
35
+ before do
36
+ stub_request(:post, %r[/v1/templates]).
37
+ to_return(read_fixture("templates/create/created.http"))
38
+ end
39
+
40
+ let(:attributes) { { name: "", short_name: "" } }
41
+
42
+ it "builds the correct request" do
43
+ subject.create(attributes)
44
+
45
+ expect(WebMock).to have_requested(:post, "https://api.zone/v1/templates").
46
+ with(body: { dns_template: attributes }).
47
+ with(headers: { 'Accept' => 'application/json' })
48
+ end
49
+
50
+ it "returns the template" do
51
+ result = subject.create(attributes)
52
+
53
+ expect(result).to be_a(Dnsimple::Struct::Template)
54
+ expect(result.id).to be_a(Fixnum)
55
+ end
56
+ end
57
+
58
+ describe "#find" do
59
+ before do
60
+ stub_request(:get, %r[/v1/templates/.+$]).
61
+ to_return(read_fixture("templates/show/success.http"))
62
+ end
63
+
64
+ it "builds the correct request" do
65
+ subject.find(1)
66
+
67
+ expect(WebMock).to have_requested(:get, "https://api.zone/v1/templates/1").
68
+ with(headers: { 'Accept' => 'application/json' })
69
+ end
70
+
71
+ it "returns the template" do
72
+ result = subject.find(1)
73
+
74
+ expect(result).to be_a(Dnsimple::Struct::Template)
75
+ expect(result.id).to eq(2651)
76
+ expect(result.name).to eq("Localhost")
77
+ expect(result.short_name).to eq("localhost")
78
+ expect(result.description).to eq("This is a test.")
79
+ end
80
+
81
+ context "when something does not exist" do
82
+ it "raises RecordNotFound" do
83
+ stub_request(:get, %r[/v1]).
84
+ to_return(read_fixture("templates/notfound.http"))
85
+
86
+ expect {
87
+ subject.find(1)
88
+ }.to raise_error(Dnsimple::RecordNotFound)
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "#update" do
94
+ before do
95
+ stub_request(:put, %r[/v1/templates/.+$]).
96
+ to_return(read_fixture("templates/update/success.http"))
97
+ end
98
+
99
+ it "builds the correct request" do
100
+ subject.update(1, { name: "Updated" })
101
+
102
+ expect(WebMock).to have_requested(:put, "https://api.zone/v1/templates/1").
103
+ with(body: { dns_template: { name: "Updated" } }).
104
+ with(headers: { 'Accept' => 'application/json' })
105
+ end
106
+
107
+ it "returns the template" do
108
+ result = subject.update(1, {})
109
+
110
+ expect(result).to be_a(Dnsimple::Struct::Template)
111
+ expect(result.id).to be_a(Fixnum)
112
+ end
113
+
114
+ context "when something does not exist" do
115
+ it "raises RecordNotFound" do
116
+ stub_request(:put, %r[/v1]).
117
+ to_return(read_fixture("templates/notfound.http"))
118
+
119
+ expect {
120
+ subject.update(1, {})
121
+ }.to raise_error(Dnsimple::RecordNotFound)
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "#delete" do
127
+ before do
128
+ stub_request(:delete, %r[/v1/templates/.+$]).
129
+ to_return(read_fixture("templates/delete/success.http"))
130
+ end
131
+
132
+ it "builds the correct request" do
133
+ subject.delete(1)
134
+
135
+ expect(WebMock).to have_requested(:delete, "https://api.zone/v1/templates/1").
136
+ with(headers: { 'Accept' => 'application/json' })
137
+ end
138
+
139
+ it "returns nothing" do
140
+ result = subject.delete(1)
141
+
142
+ expect(result).to be_truthy
143
+ end
144
+
145
+ it "supports HTTP 204" do
146
+ stub_request(:delete, %r[/v1]).
147
+ to_return(read_fixture("templates/delete/success-204.http"))
148
+
149
+ result = subject.delete(1)
150
+
151
+ expect(result).to be_truthy
152
+ end
153
+
154
+ context "when something does not exist" do
155
+ it "raises RecordNotFound" do
156
+ stub_request(:delete, %r[/v1]).
157
+ to_return(read_fixture("templates/notfound.http"))
158
+
159
+ expect {
160
+ subject.delete(1)
161
+ }.to raise_error(Dnsimple::RecordNotFound)
162
+ end
163
+ end
164
+ end
165
+
166
+
167
+ describe "#apply" do
168
+ before do
169
+ stub_request(:post, %r[/v1/domains/.+/templates/.+/apply$]).
170
+ to_return(read_fixture("templates/apply/success.http"))
171
+ end
172
+
173
+ it "builds the correct request" do
174
+ subject.apply(1, 2)
175
+
176
+ expect(WebMock).to have_requested(:post, "https://api.zone/v1/domains/1/templates/2/apply").
177
+ with(headers: { 'Accept' => 'application/json' })
178
+ end
179
+
180
+ it "returns nothing" do
181
+ result = subject.apply(1, 2)
182
+
183
+ expect(result).to be_truthy
184
+ end
185
+
186
+ context "when something does not exist" do
187
+ it "raises RecordNotFound" do
188
+ stub_request(:post, %r[/v1]).
189
+ to_return(read_fixture("templates/notfound.http"))
190
+
191
+ expect {
192
+ subject.apply(1, 2)
193
+ }.to raise_error(Dnsimple::RecordNotFound)
194
+ end
195
+ end
196
+ end
197
+
198
+ end
@@ -0,0 +1,19 @@
1
+ HTTP/1.1 404 Not Found
2
+ Server: nginx
3
+ Date: Sun, 21 Dec 2014 19:25:07 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Transfer-Encoding: chunked
6
+ Connection: close
7
+ Status: 404 Not Found
8
+ Strict-Transport-Security: max-age=631138519
9
+ X-Frame-Options: SAMEORIGIN
10
+ X-XSS-Protection: 1
11
+ X-Content-Type-Options: nosniff
12
+ Access-Control-Allow-Origin: *
13
+ Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
14
+ Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
15
+ Cache-Control: no-cache
16
+ X-Request-Id: 35965625-5a4d-40cb-be29-1c49f8d207b6
17
+ X-Runtime: 0.059820
18
+
19
+ {"message":"Domain `0' not found"}