sparqcode-dnsimple-ruby 1.2.6
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.
- data/.bundle/config +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +71 -0
- data/LICENSE +22 -0
- data/README +125 -0
- data/README.rdoc +125 -0
- data/README.textile +161 -0
- data/Rakefile +33 -0
- data/VERSION +1 -0
- data/bin/dnsimple +4 -0
- data/bin/dnsimple.rb +153 -0
- data/dnsimple-ruby.gemspec +191 -0
- data/features/README +12 -0
- data/features/cli/certificates/purchase_certificate.feature +10 -0
- data/features/cli/contacts/create_contact.feature +10 -0
- data/features/cli/domains/check_domain.feature +10 -0
- data/features/cli/domains/create_domain.feature +10 -0
- data/features/cli/domains/delete_domain.feature +11 -0
- data/features/cli/domains/register_domain.feature +10 -0
- data/features/cli/records/create_ptr_record.feature +11 -0
- data/features/cli/records/create_record.feature +12 -0
- data/features/cli/records/delete_record.feature +14 -0
- data/features/cli/templates/apply_template.feature +11 -0
- data/features/step_definitions/certificate_steps.rb +3 -0
- data/features/step_definitions/cli_steps.rb +8 -0
- data/features/step_definitions/domain_steps.rb +32 -0
- data/features/step_definitions/record_steps.rb +38 -0
- data/features/step_definitions/template_steps.rb +9 -0
- data/features/support/env.rb +17 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +42 -0
- data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +42 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +130 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +216 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Domain/setting_name_servers.yml +30 -0
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +40 -0
- data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +40 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +173 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +44 -0
- data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +42 -0
- data/lib/dnsimple.rb +19 -0
- data/lib/dnsimple/certificate.rb +158 -0
- data/lib/dnsimple/cli.rb +122 -0
- data/lib/dnsimple/client.rb +74 -0
- data/lib/dnsimple/command.rb +10 -0
- data/lib/dnsimple/commands/add_service.rb +16 -0
- data/lib/dnsimple/commands/add_template_record.rb +18 -0
- data/lib/dnsimple/commands/apply_template.rb +15 -0
- data/lib/dnsimple/commands/check_domain.rb +11 -0
- data/lib/dnsimple/commands/clear_domain.rb +16 -0
- data/lib/dnsimple/commands/create_contact.rb +21 -0
- data/lib/dnsimple/commands/create_domain.rb +16 -0
- data/lib/dnsimple/commands/create_record.rb +20 -0
- data/lib/dnsimple/commands/create_template.rb +14 -0
- data/lib/dnsimple/commands/delete_contact.rb +14 -0
- data/lib/dnsimple/commands/delete_domain.rb +14 -0
- data/lib/dnsimple/commands/delete_record.rb +16 -0
- data/lib/dnsimple/commands/delete_template.rb +13 -0
- data/lib/dnsimple/commands/delete_template_record.rb +16 -0
- data/lib/dnsimple/commands/describe_certificate.rb +34 -0
- data/lib/dnsimple/commands/describe_contact.rb +25 -0
- data/lib/dnsimple/commands/describe_domain.rb +14 -0
- data/lib/dnsimple/commands/describe_record.rb +16 -0
- data/lib/dnsimple/commands/describe_service.rb +12 -0
- data/lib/dnsimple/commands/describe_user.rb +18 -0
- data/lib/dnsimple/commands/list_applied_services.rb +16 -0
- data/lib/dnsimple/commands/list_available_services.rb +16 -0
- data/lib/dnsimple/commands/list_certificates.rb +15 -0
- data/lib/dnsimple/commands/list_contacts.rb +13 -0
- data/lib/dnsimple/commands/list_domains.rb +13 -0
- data/lib/dnsimple/commands/list_extended_attributes.rb +25 -0
- data/lib/dnsimple/commands/list_records.rb +21 -0
- data/lib/dnsimple/commands/list_services.rb +14 -0
- data/lib/dnsimple/commands/list_template_records.rb +17 -0
- data/lib/dnsimple/commands/list_templates.rb +13 -0
- data/lib/dnsimple/commands/purchase_certificate.rb +19 -0
- data/lib/dnsimple/commands/register_domain.rb +33 -0
- data/lib/dnsimple/commands/remove_service.rb +14 -0
- data/lib/dnsimple/commands/submit_certificate.rb +19 -0
- data/lib/dnsimple/commands/transfer_domain.rb +21 -0
- data/lib/dnsimple/commands/update_contact.rb +25 -0
- data/lib/dnsimple/commands/update_record.rb +23 -0
- data/lib/dnsimple/contact.rb +181 -0
- data/lib/dnsimple/domain.rb +246 -0
- data/lib/dnsimple/error.rb +32 -0
- data/lib/dnsimple/extended_attribute.rb +73 -0
- data/lib/dnsimple/record.rb +128 -0
- data/lib/dnsimple/service.rb +58 -0
- data/lib/dnsimple/template.rb +91 -0
- data/lib/dnsimple/template_record.rb +103 -0
- data/lib/dnsimple/transfer_order.rb +45 -0
- data/lib/dnsimple/user.rb +44 -0
- data/spec/README +10 -0
- data/spec/certificate_spec.rb +46 -0
- data/spec/command_spec.rb +19 -0
- data/spec/commands/add_service_spec.rb +29 -0
- data/spec/commands/create_record_spec.rb +23 -0
- data/spec/commands/list_records_spec.rb +34 -0
- data/spec/commands/purchase_certificate_spec.rb +24 -0
- data/spec/commands/submit_certificate_spec.rb +19 -0
- data/spec/contact_spec.rb +35 -0
- data/spec/domain_spec.rb +97 -0
- data/spec/extended_attributes_spec.rb +19 -0
- data/spec/record_spec.rb +59 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/template_spec.rb +11 -0
- data/spec/user_spec.rb +23 -0
- metadata +353 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module DNSimple #:nodoc:
|
|
2
|
+
# Class representing a transfer order in DNSimple
|
|
3
|
+
class TransferOrder
|
|
4
|
+
include HTTParty
|
|
5
|
+
|
|
6
|
+
attr_accessor :id
|
|
7
|
+
|
|
8
|
+
attr_accessor :status
|
|
9
|
+
|
|
10
|
+
def initialize(attributes)
|
|
11
|
+
attributes.each do |key, value|
|
|
12
|
+
m = "#{key}=".to_sym
|
|
13
|
+
self.send(m, value) if self.respond_to?(m)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.create(name, authinfo='', registrant={}, extended_attributes={}, options={})
|
|
18
|
+
body = {:domain => {:name => name}, :transfer_order => {:authinfo => authinfo}}
|
|
19
|
+
|
|
20
|
+
if registrant[:id]
|
|
21
|
+
body[:domain][:registrant_id] = registrant[:id]
|
|
22
|
+
else
|
|
23
|
+
body.merge!(:contact => Contact.resolve_attributes(registrant))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
body.merge!(:extended_attribute => extended_attributes)
|
|
27
|
+
|
|
28
|
+
options.merge!({:body => body})
|
|
29
|
+
options.merge!({:basic_auth => Client.credentials})
|
|
30
|
+
|
|
31
|
+
response = self.post("#{Client.base_uri}/domain_transfers.json", options)
|
|
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
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module DNSimple
|
|
2
|
+
class User
|
|
3
|
+
include HTTParty
|
|
4
|
+
|
|
5
|
+
attr_accessor :id
|
|
6
|
+
|
|
7
|
+
attr_accessor :created_at
|
|
8
|
+
|
|
9
|
+
attr_accessor :updated_at
|
|
10
|
+
|
|
11
|
+
attr_accessor :email
|
|
12
|
+
|
|
13
|
+
attr_accessor :login_count
|
|
14
|
+
|
|
15
|
+
attr_accessor :failed_login_count
|
|
16
|
+
|
|
17
|
+
attr_accessor :domain_count
|
|
18
|
+
|
|
19
|
+
attr_accessor :domain_limit
|
|
20
|
+
|
|
21
|
+
def initialize(attributes)
|
|
22
|
+
attributes.each do |key, value|
|
|
23
|
+
m = "#{key}=".to_sym
|
|
24
|
+
self.send(m, value) if self.respond_to?(m)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
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
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/spec/README
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Before running the DNSimple Ruby Client specifications, you must do the following:
|
|
2
|
+
|
|
3
|
+
1.) If you haven't already create a new account at https://test.dnsimple.com and activate it using the credit card number of "1"
|
|
4
|
+
|
|
5
|
+
2.) Create a file in your home directory called .dnsimple.test and include the following:
|
|
6
|
+
|
|
7
|
+
username: YOUR_USERNAME
|
|
8
|
+
password: YOUR_PASSWORD
|
|
9
|
+
site: https://test.dnsimple.com
|
|
10
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DNSimple::Certificate do
|
|
4
|
+
let(:domain_name) { 'example.com' }
|
|
5
|
+
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
|
6
|
+
|
|
7
|
+
describe "#fqdn" do
|
|
8
|
+
it "joins the name and domain name" do
|
|
9
|
+
certificate = DNSimple::Certificate.new(:name => 'www')
|
|
10
|
+
certificate.domain = domain
|
|
11
|
+
certificate.fqdn.should eq("www.#{domain_name}")
|
|
12
|
+
end
|
|
13
|
+
it "strips blank parts from name" do
|
|
14
|
+
certificate = DNSimple::Certificate.new(:name => '')
|
|
15
|
+
certificate.domain = domain
|
|
16
|
+
certificate.fqdn.should eq(domain_name)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe ".purchase" do
|
|
21
|
+
let(:contact) { DNSimple::Contact.new(:id => 1) }
|
|
22
|
+
use_vcr_cassette
|
|
23
|
+
it "purchases a certificate" do
|
|
24
|
+
certificate = DNSimple::Certificate.purchase(domain, 'www', contact)
|
|
25
|
+
certificate.fqdn.should eq("www.#{domain_name}")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe ".all" do
|
|
30
|
+
use_vcr_cassette
|
|
31
|
+
it "returns all certificates for the specific domain" do
|
|
32
|
+
certificates = DNSimple::Certificate.all(domain)
|
|
33
|
+
certificates.length.should eq(1)
|
|
34
|
+
certificates.first.fqdn.should eq('www.example.com')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "#submit" do
|
|
39
|
+
use_vcr_cassette
|
|
40
|
+
let(:certificate) { DNSimple::Certificate.new(:id => 1, :domain => domain) }
|
|
41
|
+
it "submits a certificate for purchase" do
|
|
42
|
+
certificate.submit("admin@example.com")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/command'
|
|
3
|
+
|
|
4
|
+
class FakeCommand < DNSimple::Command
|
|
5
|
+
def execute
|
|
6
|
+
say "done"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe DNSimple::Command do
|
|
11
|
+
describe "#say" do
|
|
12
|
+
it "writes to the output" do
|
|
13
|
+
s = StringIO.new
|
|
14
|
+
command = FakeCommand.new(s)
|
|
15
|
+
command.execute
|
|
16
|
+
s.string.should eq("done\n")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/commands/add_service'
|
|
3
|
+
|
|
4
|
+
describe DNSimple::Commands::AddService do
|
|
5
|
+
let(:out) { StringIO.new }
|
|
6
|
+
|
|
7
|
+
let(:domain_name) { 'example.com' }
|
|
8
|
+
let(:short_name) { 'service-name' }
|
|
9
|
+
let(:args) { [domain_name, short_name] }
|
|
10
|
+
|
|
11
|
+
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
|
12
|
+
let(:service) { stub("service", :name => "Service") }
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
DNSimple::Domain.expects(:find).with(domain_name).returns(domain)
|
|
16
|
+
DNSimple::Service.expects(:find).with(short_name).returns(service)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "adds a service to a domain" do
|
|
20
|
+
domain.expects(:add_service).with(short_name)
|
|
21
|
+
DNSimple::Commands::AddService.new(out).execute(args)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "reports to the caller" do
|
|
25
|
+
domain.stubs(:add_service)
|
|
26
|
+
DNSimple::Commands::AddService.new(out).execute(args)
|
|
27
|
+
out.string.should eq("Added #{service.name} to #{domain_name}\n")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/domain'
|
|
3
|
+
require 'dnsimple/record'
|
|
4
|
+
require 'dnsimple/commands/create_record'
|
|
5
|
+
|
|
6
|
+
describe DNSimple::Commands::CreateRecord do
|
|
7
|
+
let(:out) { StringIO.new }
|
|
8
|
+
let(:domain_name) { 'example.com' }
|
|
9
|
+
let(:record_name) { 'www' }
|
|
10
|
+
let(:record_type) { 'CNAME' }
|
|
11
|
+
let(:ttl) { "3600" }
|
|
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::CreateRecord.new(out).execute([domain_name, record_name, record_type, domain_name, ttl])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/commands/list_records'
|
|
3
|
+
|
|
4
|
+
describe DNSimple::Commands::ListRecords 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
|
+
let(:out) { StringIO.new }
|
|
22
|
+
|
|
23
|
+
it 'should retrieve all records and print them' do
|
|
24
|
+
described_class.new(out).execute(args)
|
|
25
|
+
|
|
26
|
+
out.string.should include(ttl)
|
|
27
|
+
out.string.should include(id)
|
|
28
|
+
out.string.should include(record_type)
|
|
29
|
+
out.string.should include(name)
|
|
30
|
+
out.string.should include(domain_name)
|
|
31
|
+
out.string.should include(content)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/certificate'
|
|
3
|
+
require 'dnsimple/commands/purchase_certificate'
|
|
4
|
+
|
|
5
|
+
describe DNSimple::Commands::PurchaseCertificate do
|
|
6
|
+
|
|
7
|
+
let(:out) { StringIO.new }
|
|
8
|
+
let(:domain_name) { 'example.com' }
|
|
9
|
+
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
|
10
|
+
let(:contact_id) { 123 }
|
|
11
|
+
let(:contact) { DNSimple::Contact.new(:first_name => 'John', :last_name => 'Doe') }
|
|
12
|
+
let(:name) { "John Doe" }
|
|
13
|
+
|
|
14
|
+
context "with one argument" do
|
|
15
|
+
it "purchases the certificate" do
|
|
16
|
+
|
|
17
|
+
DNSimple::Domain.expects(:find).with(domain_name).returns(domain)
|
|
18
|
+
DNSimple::Contact.expects(:find).with(contact_id).returns(contact)
|
|
19
|
+
DNSimple::Certificate.expects(:purchase).with(domain, name, contact).returns(stub("certificate", :fqdn => domain_name))
|
|
20
|
+
|
|
21
|
+
DNSimple::Commands::PurchaseCertificate.new(out).execute([domain_name, name, contact_id])
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'dnsimple/commands/submit_certificate'
|
|
3
|
+
|
|
4
|
+
describe DNSimple::Commands::SubmitCertificate do
|
|
5
|
+
let(:out) { StringIO.new }
|
|
6
|
+
let(:domain) { DNSimple::Domain.new(:name => domain_name) }
|
|
7
|
+
let(:domain_name) { 'example.com' }
|
|
8
|
+
let(:name) { 'www' }
|
|
9
|
+
let(:certificate) { DNSimple::Certificate.new(:id => certificate_id, :domain => domain) }
|
|
10
|
+
let(:certificate_id) { 1 }
|
|
11
|
+
let(:approver_email) { 'admin@example.com' }
|
|
12
|
+
|
|
13
|
+
it "submits the certificate" do
|
|
14
|
+
DNSimple::Domain.stubs(:find).with(domain_name).returns(domain)
|
|
15
|
+
DNSimple::Certificate.expects(:find).with(domain, certificate_id).returns(certificate)
|
|
16
|
+
certificate.expects(:submit).with(approver_email)
|
|
17
|
+
DNSimple::Commands::SubmitCertificate.new(out).execute([domain_name, certificate_id, approver_email])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DNSimple::Contact do
|
|
4
|
+
|
|
5
|
+
describe "a new contact" do
|
|
6
|
+
use_vcr_cassette
|
|
7
|
+
|
|
8
|
+
let(:contact_attributes) {
|
|
9
|
+
{
|
|
10
|
+
:first_name => 'John',
|
|
11
|
+
:last_name => 'Doe',
|
|
12
|
+
:address1 => '1 SW 1st Street',
|
|
13
|
+
:city => 'Miami',
|
|
14
|
+
:state_province => 'FL',
|
|
15
|
+
:postal_code => '33143',
|
|
16
|
+
:country => 'US',
|
|
17
|
+
:email_address => 'john.doe@example.com',
|
|
18
|
+
:phone => '305 111 2222'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
it "has specific attributes" do
|
|
22
|
+
contact = DNSimple::Contact.create(contact_attributes)
|
|
23
|
+
contact.first_name.should eql(contact_attributes[:first_name])
|
|
24
|
+
contact.id.should_not be_nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "an existing contact" do
|
|
29
|
+
use_vcr_cassette
|
|
30
|
+
it "can be found by id" do
|
|
31
|
+
contact = DNSimple::Contact.find(1)
|
|
32
|
+
contact.should_not be_nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/spec/domain_spec.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DNSimple::Domain do
|
|
4
|
+
let(:domain_name) { "example.com" }
|
|
5
|
+
let(:contact_id) { 1 }
|
|
6
|
+
|
|
7
|
+
describe "creating a new domain" do
|
|
8
|
+
use_vcr_cassette
|
|
9
|
+
it "has specific attributes" do
|
|
10
|
+
@domain = DNSimple::Domain.create(domain_name)
|
|
11
|
+
@domain.name.should eql(domain_name)
|
|
12
|
+
@domain.id.should_not be_nil
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
describe "finding an existing domain" do
|
|
16
|
+
context "by id" do
|
|
17
|
+
use_vcr_cassette
|
|
18
|
+
it "can be found" do
|
|
19
|
+
domain = DNSimple::Domain.find(39)
|
|
20
|
+
domain.name.should eql(domain_name)
|
|
21
|
+
domain.id.should_not be_nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
context "by name" do
|
|
25
|
+
use_vcr_cassette
|
|
26
|
+
it "can be found" do
|
|
27
|
+
domain = DNSimple::Domain.find(domain_name)
|
|
28
|
+
domain.name.should eql(domain_name)
|
|
29
|
+
domain.id.should_not be_nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "registration" do
|
|
35
|
+
|
|
36
|
+
context "with an existing contact" do
|
|
37
|
+
let(:domain_name) { "dnsimple-example-1321042237.com" }
|
|
38
|
+
use_vcr_cassette
|
|
39
|
+
it "can be registered" do
|
|
40
|
+
domain = DNSimple::Domain.register(domain_name, {:id => contact_id})
|
|
41
|
+
domain.name.should eql(domain_name)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "with a new registrant contact" do
|
|
46
|
+
let(:domain_name) { "dnsimple-example-1321042288.com" }
|
|
47
|
+
use_vcr_cassette
|
|
48
|
+
it "can be registered" do
|
|
49
|
+
registrant = {
|
|
50
|
+
:first_name => 'John',
|
|
51
|
+
:last_name => 'Smith',
|
|
52
|
+
:address1 => '123 SW 1st Street',
|
|
53
|
+
:city => 'Miami',
|
|
54
|
+
:state_or_province => 'FL',
|
|
55
|
+
:country => 'US',
|
|
56
|
+
:postal_code => '33143',
|
|
57
|
+
:phone => '321 555 1212'
|
|
58
|
+
}
|
|
59
|
+
domain = DNSimple::Domain.register(domain_name, registrant)
|
|
60
|
+
domain.name.should eql(domain_name)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe ".all" do
|
|
66
|
+
use_vcr_cassette
|
|
67
|
+
before do
|
|
68
|
+
@domains = []
|
|
69
|
+
2.times do |n|
|
|
70
|
+
@domains << DNSimple::Domain.create("example#{n}.com")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
it "returns a list of domains" do
|
|
74
|
+
domains = DNSimple::Domain.all
|
|
75
|
+
domains.map { |d| d.name }.should include(*@domains.map { |d| d.name })
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe "applying templates" do
|
|
80
|
+
use_vcr_cassette
|
|
81
|
+
let(:domain) { DNSimple::Domain.find("example.com") }
|
|
82
|
+
it "applies a named template" do
|
|
83
|
+
DNSimple::Record.all(domain).should be_empty
|
|
84
|
+
domain.apply("googleapps")
|
|
85
|
+
DNSimple::Record.all(domain).should_not be_empty
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe "setting name servers" do
|
|
90
|
+
use_vcr_cassette
|
|
91
|
+
let(:domain) { DNSimple::Domain.new(:name => 'example.com') }
|
|
92
|
+
|
|
93
|
+
it "overwrites name servers" do
|
|
94
|
+
domain.update_name_servers(["n1.fake.com", "ns2.fake.com"])
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DNSimple::ExtendedAttribute do
|
|
4
|
+
|
|
5
|
+
describe "list extended attributes" do
|
|
6
|
+
context "for com" do
|
|
7
|
+
use_vcr_cassette
|
|
8
|
+
it "is an empty array" do
|
|
9
|
+
DNSimple::ExtendedAttribute.find('com').should be_empty
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
context "for ca" do
|
|
13
|
+
use_vcr_cassette
|
|
14
|
+
it "is not empty" do
|
|
15
|
+
DNSimple::ExtendedAttribute.find('ca').should_not be_empty
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|