dnsimple-ruby 1.2.6 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +2 -13
- data/Gemfile.lock +7 -7
- data/Rakefile +2 -18
- data/dnsimple-ruby.gemspec +24 -178
- data/features/support/env.rb +5 -3
- data/lib/dnsimple-ruby.rb +1 -0
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/base.rb +8 -0
- data/lib/dnsimple/certificate.rb +95 -130
- data/lib/dnsimple/client.rb +94 -56
- data/lib/dnsimple/contact.rb +111 -144
- data/lib/dnsimple/domain.rb +145 -194
- data/lib/dnsimple/extended_attribute.rb +33 -60
- data/lib/dnsimple/record.rb +70 -103
- data/lib/dnsimple/service.rb +24 -47
- data/lib/dnsimple/template.rb +47 -75
- data/lib/dnsimple/template_record.rb +53 -84
- data/lib/dnsimple/transfer_order.rb +17 -34
- data/lib/dnsimple/user.rb +18 -32
- data/lib/dnsimple/version.rb +3 -0
- data/spec/commands/purchase_certificate_spec.rb +16 -4
- data/spec/dnsimple/client_spec.rb +58 -0
- data/spec/spec_helper.rb +4 -2
- metadata +59 -92
- data/.bundle/config +0 -3
- data/.rvmrc +0 -1
- data/VERSION +0 -1
@@ -1,45 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class TransferOrder
|
4
|
-
include HTTParty
|
1
|
+
class DNSimple::TransferOrder # Class representing a transfer order in DNSimple
|
2
|
+
attr_accessor :id
|
5
3
|
|
6
|
-
|
4
|
+
attr_accessor :status
|
7
5
|
|
8
|
-
|
6
|
+
def self.create(name, authinfo='', registrant={}, extended_attributes={}, options={})
|
7
|
+
body = {:domain => {:name => name}, :transfer_order => {:authinfo => authinfo}}
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
if registrant[:id]
|
10
|
+
body[:domain][:registrant_id] = registrant[:id]
|
11
|
+
else
|
12
|
+
body.merge!(:contact => Contact.resolve_attributes(registrant))
|
15
13
|
end
|
16
14
|
|
17
|
-
|
18
|
-
body = {:domain => {:name => name}, :transfer_order => {:authinfo => authinfo}}
|
15
|
+
body.merge!(:extended_attribute => extended_attributes)
|
19
16
|
|
20
|
-
|
21
|
-
body[:domain][:registrant_id] = registrant[:id]
|
22
|
-
else
|
23
|
-
body.merge!(:contact => Contact.resolve_attributes(registrant))
|
24
|
-
end
|
17
|
+
options.merge!({:body => body})
|
25
18
|
|
26
|
-
|
19
|
+
response = DNSimple::Client.post 'domain_transfers.json', options
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
pp response if Client.debug?
|
34
|
-
|
35
|
-
case response.code
|
36
|
-
when 201
|
37
|
-
return TransferOrder.new(response["transfer_order"])
|
38
|
-
when 401
|
39
|
-
raise RuntimeError, "Authentication failed"
|
40
|
-
else
|
41
|
-
raise DNSimple::Error.new(name, response["errors"])
|
42
|
-
end
|
21
|
+
case response.code
|
22
|
+
when 201
|
23
|
+
return new(response["transfer_order"])
|
24
|
+
else
|
25
|
+
raise DNSimple::Error.new(name, response["errors"])
|
43
26
|
end
|
44
27
|
end
|
45
28
|
end
|
data/lib/dnsimple/user.rb
CHANGED
@@ -1,44 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
include HTTParty
|
1
|
+
class DNSimple::User < DNSimple::Base
|
2
|
+
attr_accessor :id
|
4
3
|
|
5
|
-
|
4
|
+
attr_accessor :created_at
|
6
5
|
|
7
|
-
|
6
|
+
attr_accessor :updated_at
|
8
7
|
|
9
|
-
|
8
|
+
attr_accessor :email
|
10
9
|
|
11
|
-
|
10
|
+
attr_accessor :login_count
|
12
11
|
|
13
|
-
|
12
|
+
attr_accessor :failed_login_count
|
14
13
|
|
15
|
-
|
14
|
+
attr_accessor :domain_count
|
16
15
|
|
17
|
-
|
16
|
+
attr_accessor :domain_limit
|
18
17
|
|
19
|
-
|
18
|
+
def self.me(options={})
|
19
|
+
response = DNSimple::Client.get("users/me.json", options)
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
def self.me(options={})
|
29
|
-
options.merge!({:basic_auth => Client.credentials})
|
30
|
-
response = self.get("#{Client.base_uri}/users/me.json", options)
|
31
|
-
|
32
|
-
case response.code
|
33
|
-
when 200
|
34
|
-
return User.new(response["user"])
|
35
|
-
when 401
|
36
|
-
raise DNSimple::AuthenticationFailed, "Authentication failed"
|
37
|
-
when 404
|
38
|
-
raise DNSimple::UserNotFound, "Could not find user"
|
39
|
-
else
|
40
|
-
raise DNSimple::Error, "Error: #{response.code} #{response.message}"
|
41
|
-
end
|
21
|
+
case response.code
|
22
|
+
when 200
|
23
|
+
return new(response["user"])
|
24
|
+
when 404
|
25
|
+
raise DNSimple::UserNotFound, "Could not find user"
|
26
|
+
else
|
27
|
+
raise DNSimple::Error, "Error: #{response.code} #{response.message}"
|
42
28
|
end
|
43
29
|
end
|
44
30
|
end
|
@@ -3,12 +3,24 @@ require 'dnsimple/certificate'
|
|
3
3
|
require 'dnsimple/commands/purchase_certificate'
|
4
4
|
|
5
5
|
describe DNSimple::Commands::PurchaseCertificate do
|
6
|
-
let(:out)
|
6
|
+
let(:out) { StringIO.new }
|
7
7
|
let(:domain_name) { 'example.com' }
|
8
|
+
let(:domain) { stub('domain') }
|
9
|
+
let(:contact) { stub('contact') }
|
10
|
+
|
8
11
|
context "with one argument" do
|
9
|
-
|
10
|
-
DNSimple::
|
11
|
-
DNSimple::
|
12
|
+
before :each do
|
13
|
+
DNSimple::Domain.stubs(:find).returns(domain)
|
14
|
+
DNSimple::Contact.stubs(:find).returns(contact)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "purchases the certificate" do
|
18
|
+
DNSimple::Certificate.expects(:purchase).
|
19
|
+
with(domain, 'certname', contact).
|
20
|
+
returns(stub("certificate", :fqdn => domain_name))
|
21
|
+
|
22
|
+
DNSimple::Commands::PurchaseCertificate.new(out).
|
23
|
+
execute([domain_name, 'certname', stub('contact id')])
|
12
24
|
end
|
13
25
|
end
|
14
26
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DNSimple::Client do
|
4
|
+
before :each do
|
5
|
+
@username, @password, @api_token = DNSimple::Client.username,
|
6
|
+
DNSimple::Client.password, DNSimple::Client.api_token
|
7
|
+
end
|
8
|
+
|
9
|
+
after :each do
|
10
|
+
DNSimple::Client.username = @username
|
11
|
+
DNSimple::Client.password = @password
|
12
|
+
DNSimple::Client.api_token = @api_token
|
13
|
+
end
|
14
|
+
|
15
|
+
[:get, :post, :put, :delete].each do |method|
|
16
|
+
describe ".#{method}" do
|
17
|
+
let(:response) { stub('response', :code => 200) }
|
18
|
+
|
19
|
+
it "uses HTTP authentication if there's a password provided" do
|
20
|
+
DNSimple::Client.username = 'user'
|
21
|
+
DNSimple::Client.password = 'pass'
|
22
|
+
DNSimple::Client.api_token = nil
|
23
|
+
|
24
|
+
HTTParty.expects(method).
|
25
|
+
with('http://localhost:3000/domains',
|
26
|
+
:format => :json, :headers => {'Accept' => 'application/json'},
|
27
|
+
:basic_auth => {:username => 'user', :password => 'pass'}).
|
28
|
+
returns(response)
|
29
|
+
|
30
|
+
DNSimple::Client.send(method, 'domains')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "uses header authentication if there's an api token provided" do
|
34
|
+
DNSimple::Client.username = 'user'
|
35
|
+
DNSimple::Client.password = nil
|
36
|
+
DNSimple::Client.api_token = 'token'
|
37
|
+
|
38
|
+
HTTParty.expects(method).
|
39
|
+
with('http://localhost:3000/domains',
|
40
|
+
:format => :json, :headers => {'Accept' => 'application/json',
|
41
|
+
'X-DNSimple-Token' => 'user:token'}).
|
42
|
+
returns(response)
|
43
|
+
|
44
|
+
DNSimple::Client.send(method, 'domains')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises an error if there's no password or api token provided" do
|
48
|
+
DNSimple::Client.username = 'user'
|
49
|
+
DNSimple::Client.password = nil
|
50
|
+
DNSimple::Client.api_token = nil
|
51
|
+
|
52
|
+
lambda {
|
53
|
+
DNSimple::Client.send(method, 'domains')
|
54
|
+
}.should raise_error(RuntimeError, 'A password or API token is required for all API requests.')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsimple-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Anthony Eden
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
22
|
none: false
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
@@ -27,12 +27,12 @@ dependencies:
|
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
version: "0"
|
30
|
-
version_requirements: *id001
|
31
|
-
name: httparty
|
32
30
|
prerelease: false
|
33
31
|
type: :runtime
|
32
|
+
name: httparty
|
33
|
+
requirement: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
36
|
none: false
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
@@ -41,12 +41,12 @@ dependencies:
|
|
41
41
|
segments:
|
42
42
|
- 0
|
43
43
|
version: "0"
|
44
|
-
version_requirements: *id002
|
45
|
-
name: rake
|
46
44
|
prerelease: false
|
47
45
|
type: :development
|
46
|
+
name: aruba
|
47
|
+
requirement: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
49
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
@@ -55,28 +55,12 @@ dependencies:
|
|
55
55
|
segments:
|
56
56
|
- 0
|
57
57
|
version: "0"
|
58
|
-
version_requirements: *id003
|
59
|
-
name: jeweler
|
60
|
-
prerelease: false
|
61
|
-
type: :development
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
hash: 15
|
69
|
-
segments:
|
70
|
-
- 2
|
71
|
-
- 0
|
72
|
-
- 0
|
73
|
-
version: 2.0.0
|
74
|
-
version_requirements: *id004
|
75
|
-
name: rspec
|
76
58
|
prerelease: false
|
77
59
|
type: :development
|
60
|
+
name: cucumber
|
61
|
+
requirement: *id003
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
63
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
80
64
|
none: false
|
81
65
|
requirements:
|
82
66
|
- - ">="
|
@@ -85,12 +69,12 @@ dependencies:
|
|
85
69
|
segments:
|
86
70
|
- 0
|
87
71
|
version: "0"
|
88
|
-
version_requirements: *id005
|
89
|
-
name: mocha
|
90
72
|
prerelease: false
|
91
73
|
type: :development
|
74
|
+
name: fakeweb
|
75
|
+
requirement: *id004
|
92
76
|
- !ruby/object:Gem::Dependency
|
93
|
-
|
77
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
94
78
|
none: false
|
95
79
|
requirements:
|
96
80
|
- - ">="
|
@@ -99,12 +83,12 @@ dependencies:
|
|
99
83
|
segments:
|
100
84
|
- 0
|
101
85
|
version: "0"
|
102
|
-
version_requirements: *id006
|
103
|
-
name: ruby-debug
|
104
86
|
prerelease: false
|
105
87
|
type: :development
|
88
|
+
name: mocha
|
89
|
+
requirement: *id005
|
106
90
|
- !ruby/object:Gem::Dependency
|
107
|
-
|
91
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
108
92
|
none: false
|
109
93
|
requirements:
|
110
94
|
- - ">="
|
@@ -113,40 +97,28 @@ dependencies:
|
|
113
97
|
segments:
|
114
98
|
- 0
|
115
99
|
version: "0"
|
116
|
-
version_requirements: *id007
|
117
|
-
name: cucumber
|
118
100
|
prerelease: false
|
119
101
|
type: :development
|
102
|
+
name: rake
|
103
|
+
requirement: *id006
|
120
104
|
- !ruby/object:Gem::Dependency
|
121
|
-
|
105
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
122
106
|
none: false
|
123
107
|
requirements:
|
124
108
|
- - ">="
|
125
109
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
110
|
+
hash: 15
|
127
111
|
segments:
|
112
|
+
- 2
|
128
113
|
- 0
|
129
|
-
version: "0"
|
130
|
-
version_requirements: *id008
|
131
|
-
name: aruba
|
132
|
-
prerelease: false
|
133
|
-
type: :development
|
134
|
-
- !ruby/object:Gem::Dependency
|
135
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
114
|
- 0
|
143
|
-
version:
|
144
|
-
version_requirements: *id009
|
145
|
-
name: ruby-debug
|
115
|
+
version: 2.0.0
|
146
116
|
prerelease: false
|
147
117
|
type: :development
|
118
|
+
name: rspec
|
119
|
+
requirement: *id007
|
148
120
|
- !ruby/object:Gem::Dependency
|
149
|
-
|
121
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
150
122
|
none: false
|
151
123
|
requirements:
|
152
124
|
- - ">="
|
@@ -155,42 +127,16 @@ dependencies:
|
|
155
127
|
segments:
|
156
128
|
- 0
|
157
129
|
version: "0"
|
158
|
-
version_requirements: *id010
|
159
|
-
name: fakeweb
|
160
130
|
prerelease: false
|
161
131
|
type: :development
|
162
|
-
- !ruby/object:Gem::Dependency
|
163
|
-
requirement: &id011 !ruby/object:Gem::Requirement
|
164
|
-
none: false
|
165
|
-
requirements:
|
166
|
-
- - ">="
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
hash: 3
|
169
|
-
segments:
|
170
|
-
- 0
|
171
|
-
version: "0"
|
172
|
-
version_requirements: *id011
|
173
132
|
name: vcr
|
174
|
-
|
175
|
-
type: :development
|
176
|
-
- !ruby/object:Gem::Dependency
|
177
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
178
|
-
none: false
|
179
|
-
requirements:
|
180
|
-
- - ">="
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
hash: 3
|
183
|
-
segments:
|
184
|
-
- 0
|
185
|
-
version: "0"
|
186
|
-
version_requirements: *id012
|
187
|
-
name: httparty
|
188
|
-
prerelease: false
|
189
|
-
type: :runtime
|
133
|
+
requirement: *id008
|
190
134
|
description: A ruby wrapper for the DNSimple API that also includes a command-line client.
|
191
|
-
email:
|
135
|
+
email:
|
136
|
+
- anthony.eden@dnsimple.com
|
192
137
|
executables:
|
193
138
|
- dnsimple
|
139
|
+
- dnsimple.rb
|
194
140
|
extensions: []
|
195
141
|
|
196
142
|
extra_rdoc_files:
|
@@ -199,8 +145,7 @@ extra_rdoc_files:
|
|
199
145
|
- README.rdoc
|
200
146
|
- README.textile
|
201
147
|
files:
|
202
|
-
- .
|
203
|
-
- .rvmrc
|
148
|
+
- .gitignore
|
204
149
|
- Gemfile
|
205
150
|
- Gemfile.lock
|
206
151
|
- LICENSE
|
@@ -208,7 +153,6 @@ files:
|
|
208
153
|
- README.rdoc
|
209
154
|
- README.textile
|
210
155
|
- Rakefile
|
211
|
-
- VERSION
|
212
156
|
- bin/dnsimple
|
213
157
|
- bin/dnsimple.rb
|
214
158
|
- dnsimple-ruby.gemspec
|
@@ -248,7 +192,9 @@ files:
|
|
248
192
|
- fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml
|
249
193
|
- fixtures/vcr_cassettes/DNSimple_Template/a_template.yml
|
250
194
|
- fixtures/vcr_cassettes/DNSimple_User/_me.yml
|
195
|
+
- lib/dnsimple-ruby.rb
|
251
196
|
- lib/dnsimple.rb
|
197
|
+
- lib/dnsimple/base.rb
|
252
198
|
- lib/dnsimple/certificate.rb
|
253
199
|
- lib/dnsimple/cli.rb
|
254
200
|
- lib/dnsimple/client.rb
|
@@ -300,6 +246,7 @@ files:
|
|
300
246
|
- lib/dnsimple/template_record.rb
|
301
247
|
- lib/dnsimple/transfer_order.rb
|
302
248
|
- lib/dnsimple/user.rb
|
249
|
+
- lib/dnsimple/version.rb
|
303
250
|
- spec/README
|
304
251
|
- spec/certificate_spec.rb
|
305
252
|
- spec/command_spec.rb
|
@@ -309,6 +256,7 @@ files:
|
|
309
256
|
- spec/commands/purchase_certificate_spec.rb
|
310
257
|
- spec/commands/submit_certificate_spec.rb
|
311
258
|
- spec/contact_spec.rb
|
259
|
+
- spec/dnsimple/client_spec.rb
|
312
260
|
- spec/domain_spec.rb
|
313
261
|
- spec/extended_attributes_spec.rb
|
314
262
|
- spec/record_spec.rb
|
@@ -344,11 +292,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
292
|
requirements: []
|
345
293
|
|
346
294
|
rubyforge_project:
|
347
|
-
rubygems_version: 1.8.
|
295
|
+
rubygems_version: 1.8.24
|
348
296
|
signing_key:
|
349
297
|
specification_version: 3
|
350
298
|
summary: A ruby wrapper for the DNSimple API
|
351
299
|
test_files:
|
300
|
+
- features/README
|
301
|
+
- features/cli/certificates/purchase_certificate.feature
|
302
|
+
- features/cli/contacts/create_contact.feature
|
303
|
+
- features/cli/domains/check_domain.feature
|
304
|
+
- features/cli/domains/create_domain.feature
|
305
|
+
- features/cli/domains/delete_domain.feature
|
306
|
+
- features/cli/domains/register_domain.feature
|
307
|
+
- features/cli/records/create_ptr_record.feature
|
308
|
+
- features/cli/records/create_record.feature
|
309
|
+
- features/cli/records/delete_record.feature
|
310
|
+
- features/cli/templates/apply_template.feature
|
311
|
+
- features/step_definitions/certificate_steps.rb
|
312
|
+
- features/step_definitions/cli_steps.rb
|
313
|
+
- features/step_definitions/domain_steps.rb
|
314
|
+
- features/step_definitions/record_steps.rb
|
315
|
+
- features/step_definitions/template_steps.rb
|
316
|
+
- features/support/env.rb
|
317
|
+
- spec/README
|
352
318
|
- spec/certificate_spec.rb
|
353
319
|
- spec/command_spec.rb
|
354
320
|
- spec/commands/add_service_spec.rb
|
@@ -357,6 +323,7 @@ test_files:
|
|
357
323
|
- spec/commands/purchase_certificate_spec.rb
|
358
324
|
- spec/commands/submit_certificate_spec.rb
|
359
325
|
- spec/contact_spec.rb
|
326
|
+
- spec/dnsimple/client_spec.rb
|
360
327
|
- spec/domain_spec.rb
|
361
328
|
- spec/extended_attributes_spec.rb
|
362
329
|
- spec/record_spec.rb
|