dnsimple-ruby 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -9
- data/{CHANGELOG.markdown → CHANGELOG.md} +4 -0
- data/Gemfile +0 -2
- data/LICENSE +1 -1
- data/README.md +5 -0
- data/Rakefile +0 -15
- data/dnsimple-ruby.gemspec +11 -19
- data/lib/dnsimple-ruby.rb +2 -0
- metadata +20 -288
- data/README.markdown +0 -159
- data/bin/dnsimple +0 -4
- data/bin/dnsimple.rb +0 -156
- data/features/README.md +0 -9
- data/features/cli/certificates/purchase_certificate.feature +0 -10
- data/features/cli/contacts/create_contact.feature +0 -10
- data/features/cli/domains/check_domain.feature +0 -10
- data/features/cli/domains/create_domain.feature +0 -10
- data/features/cli/domains/delete_domain.feature +0 -11
- data/features/cli/domains/register_domain.feature +0 -10
- data/features/cli/records/create_ptr_record.feature +0 -11
- data/features/cli/records/create_record.feature +0 -12
- data/features/cli/records/delete_record.feature +0 -14
- data/features/cli/templates/apply_template.feature +0 -11
- data/features/step_definitions/certificate_steps.rb +0 -3
- data/features/step_definitions/cli_steps.rb +0 -8
- data/features/step_definitions/domain_steps.rb +0 -32
- data/features/step_definitions/record_steps.rb +0 -38
- data/features/step_definitions/template_steps.rb +0 -9
- data/features/support/env.rb +0 -19
- data/lib/dnsimple.rb +0 -33
- data/lib/dnsimple/base.rb +0 -10
- data/lib/dnsimple/certificate.rb +0 -140
- data/lib/dnsimple/cli.rb +0 -121
- data/lib/dnsimple/client.rb +0 -128
- data/lib/dnsimple/commands/certificate_describe.rb +0 -34
- data/lib/dnsimple/commands/certificate_list.rb +0 -15
- data/lib/dnsimple/commands/certificate_purchase.rb +0 -17
- data/lib/dnsimple/commands/certificate_submit.rb +0 -17
- data/lib/dnsimple/commands/contact_create.rb +0 -23
- data/lib/dnsimple/commands/contact_delete.rb +0 -14
- data/lib/dnsimple/commands/contact_describe.rb +0 -25
- data/lib/dnsimple/commands/contact_list.rb +0 -13
- data/lib/dnsimple/commands/contact_update.rb +0 -25
- data/lib/dnsimple/commands/domain_apply_template.rb +0 -15
- data/lib/dnsimple/commands/domain_check.rb +0 -11
- data/lib/dnsimple/commands/domain_clear.rb +0 -16
- data/lib/dnsimple/commands/domain_create.rb +0 -16
- data/lib/dnsimple/commands/domain_delete.rb +0 -14
- data/lib/dnsimple/commands/domain_describe.rb +0 -14
- data/lib/dnsimple/commands/domain_list.rb +0 -13
- data/lib/dnsimple/commands/domain_register.rb +0 -33
- data/lib/dnsimple/commands/domain_transfer.rb +0 -21
- data/lib/dnsimple/commands/extended_attribute_list.rb +0 -25
- data/lib/dnsimple/commands/me.rb +0 -18
- data/lib/dnsimple/commands/record_create.rb +0 -18
- data/lib/dnsimple/commands/record_delete.rb +0 -16
- data/lib/dnsimple/commands/record_describe.rb +0 -16
- data/lib/dnsimple/commands/record_list.rb +0 -19
- data/lib/dnsimple/commands/record_update.rb +0 -23
- data/lib/dnsimple/commands/service_add.rb +0 -14
- data/lib/dnsimple/commands/service_describe.rb +0 -12
- data/lib/dnsimple/commands/service_list.rb +0 -14
- data/lib/dnsimple/commands/service_list_applied.rb +0 -16
- data/lib/dnsimple/commands/service_list_available.rb +0 -16
- data/lib/dnsimple/commands/service_remove.rb +0 -14
- data/lib/dnsimple/commands/template_create.rb +0 -14
- data/lib/dnsimple/commands/template_delete.rb +0 -13
- data/lib/dnsimple/commands/template_list.rb +0 -13
- data/lib/dnsimple/commands/template_record_create.rb +0 -18
- data/lib/dnsimple/commands/template_record_delete.rb +0 -16
- data/lib/dnsimple/commands/template_record_list.rb +0 -17
- data/lib/dnsimple/contact.rb +0 -154
- data/lib/dnsimple/domain.rb +0 -217
- data/lib/dnsimple/error.rb +0 -32
- data/lib/dnsimple/extended_attribute.rb +0 -52
- data/lib/dnsimple/record.rb +0 -94
- data/lib/dnsimple/service.rb +0 -42
- data/lib/dnsimple/template.rb +0 -63
- data/lib/dnsimple/template_record.rb +0 -80
- data/lib/dnsimple/transfer_order.rb +0 -34
- data/lib/dnsimple/user.rb +0 -51
- data/lib/dnsimple/version.rb +0 -3
- data/spec/ci/.dnsimple.test +0 -3
- data/spec/commands/certificate_purchase_spec.rb +0 -25
- data/spec/commands/certificate_submit_spec.rb +0 -18
- data/spec/commands/record_create_spec.rb +0 -23
- data/spec/commands/record_list_spec.rb +0 -23
- data/spec/commands/service_add_spec.rb +0 -20
- data/spec/dnsimple/certificate_spec.rb +0 -59
- data/spec/dnsimple/client_spec.rb +0 -154
- data/spec/dnsimple/contact_spec.rb +0 -45
- data/spec/dnsimple/domain_spec.rb +0 -133
- data/spec/dnsimple/extended_attributes_spec.rb +0 -54
- data/spec/dnsimple/record_spec.rb +0 -51
- data/spec/dnsimple/template_spec.rb +0 -31
- data/spec/dnsimple/user_spec.rb +0 -70
- data/spec/files/2fa/error-badtoken.http +0 -22
- data/spec/files/2fa/error-required.http +0 -23
- data/spec/files/2fa/exchange-token.http +0 -25
- data/spec/files/account/user/success.http +0 -19
- data/spec/files/certificates/index/success.http +0 -19
- data/spec/files/certificates/show/notfound.http +0 -17
- data/spec/files/certificates/show/success.http +0 -19
- data/spec/files/contacts/show/notfound.http +0 -17
- data/spec/files/contacts/show/success.http +0 -19
- data/spec/files/domains/auto_renewal_disable/notfound.http +0 -21
- data/spec/files/domains/auto_renewal_disable/success.http +0 -23
- data/spec/files/domains/auto_renewal_enable/notfound.http +0 -21
- data/spec/files/domains/auto_renewal_enable/success.http +0 -23
- data/spec/files/domains/show/notfound.http +0 -17
- data/spec/files/domains/show/success.http +0 -19
- data/spec/files/extended_attributes/ca.http +0 -19
- data/spec/files/extended_attributes/com.http +0 -19
- data/spec/files/extended_attributes/success.http +0 -19
- data/spec/files/records/index/success.http +0 -19
- data/spec/files/records/show/notfound.http +0 -17
- data/spec/files/records/show/success.http +0 -19
- data/spec/files/templates/show/notfound.http +0 -17
- data/spec/files/templates/show/success.http +0 -19
- data/spec/spec_helper.rb +0 -39
- data/spec/support/helpers.rb +0 -15
- data/spec/support/webmock.rb +0 -11
data/lib/dnsimple/version.rb
DELETED
data/spec/ci/.dnsimple.test
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dnsimple/certificate'
|
3
|
-
require 'dnsimple/commands/certificate_purchase'
|
4
|
-
|
5
|
-
describe DNSimple::Commands::CertificatePurchase do
|
6
|
-
let(:domain_name) { 'example.com' }
|
7
|
-
let(:domain) { stub('domain') }
|
8
|
-
let(:contact) { stub('contact') }
|
9
|
-
|
10
|
-
context "with one argument" do
|
11
|
-
before :each do
|
12
|
-
DNSimple::Domain.stubs(:find).returns(domain)
|
13
|
-
DNSimple::Contact.stubs(:find).returns(contact)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "purchases the certificate" do
|
17
|
-
DNSimple::Certificate.expects(:purchase).
|
18
|
-
with(domain, 'certname', contact).
|
19
|
-
returns(stub("certificate", :fqdn => domain_name))
|
20
|
-
|
21
|
-
DNSimple::Commands::CertificatePurchase.new.
|
22
|
-
execute([domain_name, 'certname', stub('contact id')])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dnsimple/commands/certificate_submit'
|
3
|
-
|
4
|
-
describe DNSimple::Commands::CertificateSubmit do
|
5
|
-
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
6
|
-
let(:domain_name) { 'example.com' }
|
7
|
-
let(:name) { 'www' }
|
8
|
-
let(:certificate) { DNSimple::Certificate.new(:id => certificate_id, :domain => domain) }
|
9
|
-
let(:certificate_id) { 1 }
|
10
|
-
let(:approver_email) { 'admin@example.com' }
|
11
|
-
|
12
|
-
it "submits the certificate" do
|
13
|
-
DNSimple::Domain.stubs(:find).with(domain_name).returns(domain)
|
14
|
-
DNSimple::Certificate.expects(:find).with(domain, certificate_id).returns(certificate)
|
15
|
-
certificate.expects(:submit).with(approver_email)
|
16
|
-
DNSimple::Commands::CertificateSubmit.new.execute([domain_name, certificate_id, approver_email])
|
17
|
-
end
|
18
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dnsimple/domain'
|
3
|
-
require 'dnsimple/record'
|
4
|
-
require 'dnsimple/commands/record_create'
|
5
|
-
|
6
|
-
describe DNSimple::Commands::RecordCreate do
|
7
|
-
let(:domain_name) { 'example.com' }
|
8
|
-
let(:record_name) { 'www' }
|
9
|
-
let(:record_type) { 'CNAME' }
|
10
|
-
let(:ttl) { "3600" }
|
11
|
-
|
12
|
-
context "with one argument" do
|
13
|
-
it "purchases the certificate" do
|
14
|
-
domain_stub = stub("domain", :name => domain_name)
|
15
|
-
record_stub = stub("record", :id => 1, :record_type => record_type)
|
16
|
-
DNSimple::Domain.expects(:find).with(domain_name).returns(domain_stub)
|
17
|
-
DNSimple::Record.expects(:create).with(domain_stub, record_name, record_type, domain_name, :ttl => ttl, :prio => nil).returns(record_stub)
|
18
|
-
|
19
|
-
DNSimple::Commands::RecordCreate.new.execute([domain_name, record_name, record_type, domain_name, ttl])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dnsimple/commands/record_list'
|
3
|
-
|
4
|
-
describe DNSimple::Commands::RecordList do
|
5
|
-
before do
|
6
|
-
DNSimple::Record.expects(:all).with(instance_of(DNSimple::Domain)).returns(records)
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:records) { [ record ] }
|
10
|
-
let(:record) { stub(:ttl => ttl, :id => id, :record_type => record_type, :name => name, :domain => domain, :content => content) }
|
11
|
-
|
12
|
-
let(:ttl) { 'ttl' }
|
13
|
-
let(:id) { 'id' }
|
14
|
-
let(:record_type) { 'A' }
|
15
|
-
let(:name) { 'name' }
|
16
|
-
let(:content) { 'content' }
|
17
|
-
|
18
|
-
let(:args) { [ domain_name ] }
|
19
|
-
let(:domain_name) { 'example.com' }
|
20
|
-
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
21
|
-
|
22
|
-
end
|
23
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'dnsimple/commands/service_add'
|
3
|
-
|
4
|
-
describe DNSimple::Commands::ServiceAdd do
|
5
|
-
let(:domain_name) { 'example.com' }
|
6
|
-
let(:short_name) { 'service-name' }
|
7
|
-
|
8
|
-
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
9
|
-
let(:service) { stub("service", :name => "Service") }
|
10
|
-
|
11
|
-
before do
|
12
|
-
DNSimple::Domain.expects(:find).with(domain_name).returns(domain)
|
13
|
-
DNSimple::Service.expects(:find).with(short_name).returns(service)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "adds a service to a domain" do
|
17
|
-
domain.expects(:add_service).with(short_name)
|
18
|
-
DNSimple::Commands::ServiceAdd.new.execute([domain_name, short_name])
|
19
|
-
end
|
20
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DNSimple::Certificate do
|
4
|
-
|
5
|
-
let(:domain) { DNSimple::Domain.new(:name => "example.com") }
|
6
|
-
|
7
|
-
|
8
|
-
describe ".find" do
|
9
|
-
before do
|
10
|
-
stub_request(:get, %r[/v1/domains/example.com/certificates/2]).
|
11
|
-
to_return(read_fixture("certificates/show/success.http"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "builds the correct request" do
|
15
|
-
described_class.find(domain, "2")
|
16
|
-
|
17
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/certificates/2").
|
18
|
-
with(:headers => { 'Accept' => 'application/json' })
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when the certificate exists" do
|
22
|
-
it "returns the certificate" do
|
23
|
-
result = described_class.find(domain, "2")
|
24
|
-
|
25
|
-
expect(result.id).to eq(4576)
|
26
|
-
expect(result.domain_id).to eq(79569)
|
27
|
-
expect(result.contact_id).to eq(11549)
|
28
|
-
expect(result.name).to eq("www")
|
29
|
-
expect(result.state).to eq("cancelled")
|
30
|
-
expect(result.csr).to eq("-----BEGIN NEW CERTIFICATE REQUEST-----\nRHr2akB4KMba6FMAsvlStnO/2ika16hNx+d3smPNsER+HA==\n-----END NEW CERTIFICATE REQUEST-----\n")
|
31
|
-
expect(result.ssl_certificate).to eq("-----BEGIN CERTIFICATE-----\nXwTkw5UCPpaVyUYcwHlvaprOe9ZbwIyEHm2AT1rW+70=\n-----END CERTIFICATE-----\n")
|
32
|
-
expect(result.private_key).to eq("-----BEGIN RSA PRIVATE KEY-----\nUeXbFi7o+nuPfRhpBFQEKwacKFc3Hnc1hH6UsnC0KY25cUif7yz38A==\n-----END RSA PRIVATE KEY-----\n")
|
33
|
-
expect(result.approver_email).to eq("example@example.net")
|
34
|
-
expect(result.created_at).to eq("2013-09-17T21:54:42Z")
|
35
|
-
expect(result.updated_at).to eq("2013-09-17T22:25:36Z")
|
36
|
-
expect(result.configured_at).to eq("2013-09-17T22:25:01Z")
|
37
|
-
expect(result.expires_on).to eq("2014-09-17")
|
38
|
-
|
39
|
-
expect(result.domain).to eq(domain)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
describe "#fqdn" do
|
46
|
-
it "joins the name and domain name" do
|
47
|
-
certificate = described_class.new(:name => 'www')
|
48
|
-
certificate.domain = domain
|
49
|
-
expect(certificate.fqdn).to eq("www.#{domain.name}")
|
50
|
-
end
|
51
|
-
|
52
|
-
it "strips blank parts from name" do
|
53
|
-
certificate = described_class.new(:name => '')
|
54
|
-
certificate.domain = domain
|
55
|
-
expect(certificate.fqdn).to eq(domain.name)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
@@ -1,154 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DNSimple::Client do
|
4
|
-
|
5
|
-
let(:klass) { described_class }
|
6
|
-
let(:response) { stub('response', :code => 200) }
|
7
|
-
|
8
|
-
before do
|
9
|
-
@_username = described_class.username
|
10
|
-
@_password = described_class.password
|
11
|
-
@_api_token = described_class.api_token
|
12
|
-
@_base_uri = described_class.base_uri
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
described_class.username = @_username
|
17
|
-
described_class.password = @_password
|
18
|
-
described_class.api_token = @_api_token
|
19
|
-
described_class.base_uri = @_base_uri
|
20
|
-
end
|
21
|
-
|
22
|
-
[:get, :post, :put, :delete].each do |method|
|
23
|
-
describe ".#{method}" do
|
24
|
-
it "delegates to .request" do
|
25
|
-
described_class.expects(:request).with(method, '/domains', { :foo => 'bar' })
|
26
|
-
described_class.send(method, '/domains', { :foo => 'bar' })
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".request" do
|
32
|
-
before do
|
33
|
-
[:username, :password, :exchange_token, :api_token, :domain_api_token].each do |attribute|
|
34
|
-
described_class.send("#{attribute}=", nil)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "uses HTTP authentication if there's a password provided" do
|
39
|
-
described_class.username = 'user'
|
40
|
-
described_class.password = 'pass'
|
41
|
-
described_class.base_uri = 'https://api.example.com/'
|
42
|
-
|
43
|
-
HTTParty.expects(:get).
|
44
|
-
with('https://api.example.com/domains', has_entries(:basic_auth => { :username => 'user', :password => 'pass' })).
|
45
|
-
returns(response)
|
46
|
-
|
47
|
-
described_class.request(:get, '/domains', {})
|
48
|
-
end
|
49
|
-
|
50
|
-
it "uses header authentication if there's a domain api token provided" do
|
51
|
-
described_class.domain_api_token = 'domaintoken'
|
52
|
-
described_class.base_uri = 'https://api.example.com/'
|
53
|
-
|
54
|
-
HTTParty.expects(:get).
|
55
|
-
with('https://api.example.com/domains', has_entries(:headers => has_entries({ 'X-DNSimple-Domain-Token' => 'domaintoken' }))).
|
56
|
-
returns(response)
|
57
|
-
|
58
|
-
described_class.request(:get, '/domains', {})
|
59
|
-
end
|
60
|
-
|
61
|
-
it "uses header authentication if there's an api token provided" do
|
62
|
-
described_class.username = 'user'
|
63
|
-
described_class.api_token = 'token'
|
64
|
-
described_class.base_uri = 'https://api.example.com/'
|
65
|
-
|
66
|
-
HTTParty.expects(:get).
|
67
|
-
with('https://api.example.com/domains', has_entries(:headers => has_entries({ 'X-DNSimple-Token' => 'user:token' }))).
|
68
|
-
returns(response)
|
69
|
-
|
70
|
-
described_class.request(:get, '/domains', {})
|
71
|
-
end
|
72
|
-
|
73
|
-
it "uses HTTP authentication via exchange token if there's an exchange token provided" do
|
74
|
-
described_class.username = 'user'
|
75
|
-
described_class.password = 'pass'
|
76
|
-
described_class.exchange_token = 'exchange-token'
|
77
|
-
described_class.base_uri = 'https://api.example.com/'
|
78
|
-
|
79
|
-
HTTParty.expects(:get).
|
80
|
-
with('https://api.example.com/domains', has_entries(:basic_auth => { :username => 'exchange-token', :password => 'x-2fa-basic' })).
|
81
|
-
returns(response)
|
82
|
-
|
83
|
-
described_class.request(:get, '/domains', {})
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises an error if there's no password or api token provided" do
|
87
|
-
described_class.username = 'user'
|
88
|
-
described_class.base_uri = 'https://api.example.com/'
|
89
|
-
|
90
|
-
expect {
|
91
|
-
described_class.request(:get, '/domains', {})
|
92
|
-
}.to raise_error(DNSimple::Error, 'A password or API token is required for all API requests.')
|
93
|
-
end
|
94
|
-
|
95
|
-
it "adds a custom user-agent" do
|
96
|
-
described_class.api_token = 'token'
|
97
|
-
|
98
|
-
HTTParty.expects(:get).
|
99
|
-
with(is_a(String), has_entries(:headers => has_entries({ 'User-Agent' => "dnsimple-ruby/#{DNSimple::VERSION}" }))).
|
100
|
-
returns(response)
|
101
|
-
|
102
|
-
described_class.request(:get, '/foo', {})
|
103
|
-
end
|
104
|
-
|
105
|
-
it "performs a request" do
|
106
|
-
described_class.username = 'user'
|
107
|
-
described_class.password = 'pass'
|
108
|
-
|
109
|
-
HTTParty.expects(:get).
|
110
|
-
with("#{described_class.base_uri}/foo",
|
111
|
-
:format => :json,
|
112
|
-
:basic_auth => { :username => described_class.username, :password => described_class.password },
|
113
|
-
:headers => { 'Accept' => 'application/json', 'User-Agent' => "dnsimple-ruby/#{DNSimple::VERSION}" }
|
114
|
-
).
|
115
|
-
returns(response)
|
116
|
-
|
117
|
-
described_class.request(:get, '/foo', {})
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
describe ".base_uri" do
|
123
|
-
it "returns the qualified API uri" do
|
124
|
-
klass.base_uri = "http://api.dnsimple.com"
|
125
|
-
expect(klass.base_uri).to eq("http://api.dnsimple.com")
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe ".base_uri=" do
|
130
|
-
it "sets the base_uri" do
|
131
|
-
klass.base_uri = "http://api1.dnsimple.com/"
|
132
|
-
expect(klass.base_uri).to eq("http://api1.dnsimple.com")
|
133
|
-
klass.base_uri = "http://api2.dnsimple.com"
|
134
|
-
expect(klass.base_uri).to eq("http://api2.dnsimple.com")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
|
-
describe "authentication" do
|
140
|
-
context "when 2FA is required" do
|
141
|
-
before do
|
142
|
-
stub_request(:get, %r[/foo]).
|
143
|
-
to_return(read_fixture("2fa/error-required.http"))
|
144
|
-
end
|
145
|
-
|
146
|
-
it "raises a TwoFactorAuthenticationRequired error" do
|
147
|
-
expect {
|
148
|
-
described_class.get('/foo', {})
|
149
|
-
}.to raise_error(DNSimple::TwoFactorAuthenticationRequired)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DNSimple::Contact do
|
4
|
-
|
5
|
-
describe ".find" do
|
6
|
-
before do
|
7
|
-
stub_request(:get, %r[/v1/contacts/2]).
|
8
|
-
to_return(read_fixture("contacts/show/success.http"))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "builds the correct request" do
|
12
|
-
described_class.find("2")
|
13
|
-
|
14
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/contacts/2").
|
15
|
-
with(:headers => { 'Accept' => 'application/json' })
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when the contact exists" do
|
19
|
-
it "returns the contact" do
|
20
|
-
result = described_class.find("2")
|
21
|
-
|
22
|
-
expect(result).to be_a(described_class)
|
23
|
-
expect(result.id).to eq(2)
|
24
|
-
expect(result.first_name).to eq("Simone")
|
25
|
-
expect(result.last_name).to eq("Carletti")
|
26
|
-
expect(result.job_title).to eq("Underwater Programmer")
|
27
|
-
expect(result.organization_name).to eq("DNSimple")
|
28
|
-
expect(result.email_address).to eq("example@example.com")
|
29
|
-
expect(result.phone).to eq("+1 111 000000")
|
30
|
-
expect(result.fax).to eq("+1 222 000000")
|
31
|
-
expect(result.address1).to eq("Awesome Street")
|
32
|
-
expect(result.address2).to eq("c/o Someone")
|
33
|
-
expect(result.city).to eq("Rome")
|
34
|
-
expect(result.state_province).to eq("RM")
|
35
|
-
expect(result.postal_code).to eq("00171")
|
36
|
-
expect(result.country).to eq("IT")
|
37
|
-
expect(result.created_at).to eq("2013-11-08T17:23:15Z")
|
38
|
-
expect(result.updated_at).to eq("2013-11-08T17:23:15Z")
|
39
|
-
|
40
|
-
expect(result.phone_ext).to be_nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DNSimple::Domain do
|
4
|
-
|
5
|
-
let(:contact_id) { 1001 }
|
6
|
-
|
7
|
-
describe ".find" do
|
8
|
-
before do
|
9
|
-
stub_request(:get, %r[/v1/domains/example.com]).
|
10
|
-
to_return(read_fixture("domains/show/success.http"))
|
11
|
-
end
|
12
|
-
|
13
|
-
it "builds the correct request" do
|
14
|
-
described_class.find("example.com")
|
15
|
-
|
16
|
-
expect(WebMock).to have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com").
|
17
|
-
with(:headers => { 'Accept' => 'application/json' })
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when the domain exists" do
|
21
|
-
it "returns the domain" do
|
22
|
-
result = described_class.find("example.com")
|
23
|
-
|
24
|
-
expect(result).to be_a(described_class)
|
25
|
-
expect(result.id).to eq(6)
|
26
|
-
expect(result.name).to eq("test-1383931357.com")
|
27
|
-
expect(result.expires_on).to eq('2015-11-08')
|
28
|
-
expect(result.created_at).to eq("2013-11-08T17:22:48Z")
|
29
|
-
expect(result.updated_at).to eq("2014-01-14T18:27:04Z")
|
30
|
-
expect(result.state).to eq("registered")
|
31
|
-
expect(result.registrant_id).to eq(2)
|
32
|
-
expect(result.user_id).to eq(2)
|
33
|
-
expect(result.lockable).to eq(true)
|
34
|
-
expect(result.auto_renew).to eq(true)
|
35
|
-
expect(result.whois_protected).to eq(false)
|
36
|
-
|
37
|
-
expect(result.name_server_status).to be_nil
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#enable_auto_renew" do
|
43
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
44
|
-
|
45
|
-
context "when response is not 200" do
|
46
|
-
before do
|
47
|
-
stub_request(:post, %r[/v1/domains/example.com/auto_renewal]).
|
48
|
-
to_return(read_fixture("domains/auto_renewal_enable/notfound.http"))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "raises a RequestError" do
|
52
|
-
expect { domain.enable_auto_renew }.to raise_error(DNSimple::RequestError)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when auto_renew is true" do
|
57
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
58
|
-
|
59
|
-
it "does not send a web request" do
|
60
|
-
domain.enable_auto_renew
|
61
|
-
expect(WebMock).to have_not_been_made
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when auto_renew is false" do
|
66
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
67
|
-
|
68
|
-
before do
|
69
|
-
stub_request(:post, %r[/v1/domains/example.com/auto_renewal]).
|
70
|
-
to_return(read_fixture("domains/auto_renewal_enable/success.http"))
|
71
|
-
end
|
72
|
-
|
73
|
-
it "builds the correct request to enable auto_renew" do
|
74
|
-
domain.enable_auto_renew
|
75
|
-
|
76
|
-
expect(WebMock).to have_requested(:post, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/auto_renewal").
|
77
|
-
with(:headers => { 'Accept' => 'application/json' })
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets auto_renew to true on the domain" do
|
81
|
-
domain.enable_auto_renew
|
82
|
-
expect(domain.auto_renew).to be_truthy
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#disable_auto_renew" do
|
89
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
90
|
-
|
91
|
-
context "when response is not 200" do
|
92
|
-
before do
|
93
|
-
stub_request(:delete, %r[/v1/domains/example.com/auto_renewal]).
|
94
|
-
to_return(read_fixture("domains/auto_renewal_disable/notfound.http"))
|
95
|
-
end
|
96
|
-
|
97
|
-
it "raises a RequestError" do
|
98
|
-
expect { domain.disable_auto_renew }.to raise_error(DNSimple::RequestError)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "when auto_renew is false" do
|
103
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => false) }
|
104
|
-
|
105
|
-
it "does not send a web request" do
|
106
|
-
domain.disable_auto_renew
|
107
|
-
expect(WebMock).to have_not_been_made
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context "when auto_renew is true" do
|
112
|
-
let(:domain) { described_class.new(:name => 'example.com', :auto_renew => true) }
|
113
|
-
|
114
|
-
before do
|
115
|
-
stub_request(:delete, %r[/v1/domains/example.com/auto_renewal]).
|
116
|
-
to_return(read_fixture("domains/auto_renewal_disable/success.http"))
|
117
|
-
end
|
118
|
-
|
119
|
-
it "builds the correct request to disable auto_renew" do
|
120
|
-
domain.disable_auto_renew
|
121
|
-
|
122
|
-
expect(WebMock).to have_requested(:delete, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/auto_renewal").
|
123
|
-
with(:headers => { 'Accept' => 'application/json' })
|
124
|
-
end
|
125
|
-
|
126
|
-
it "sets auto_renew to false on the domain" do
|
127
|
-
domain.disable_auto_renew
|
128
|
-
expect(domain.auto_renew).to be_falsey
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
end
|