dnsimple-ruby 1.4.1 → 1.5.1
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.
- checksums.yaml +7 -0
 - data/.gitignore +0 -3
 - data/.ruby-version +1 -1
 - data/.travis.yml +1 -0
 - data/CHANGELOG.md +8 -0
 - data/README.md +2 -4
 - data/dnsimple-ruby.gemspec +3 -6
 - data/features/README.md +9 -0
 - data/lib/dnsimple/certificate.rb +37 -36
 - data/lib/dnsimple/client.rb +7 -4
 - data/lib/dnsimple/contact.rb +49 -48
 - data/lib/dnsimple/domain.rb +79 -79
 - data/lib/dnsimple/extended_attribute.rb +1 -1
 - data/lib/dnsimple/record.rb +7 -12
 - data/lib/dnsimple/service.rb +2 -2
 - data/lib/dnsimple/template.rb +11 -17
 - data/lib/dnsimple/template_record.rb +4 -4
 - data/lib/dnsimple/transfer_order.rb +1 -1
 - data/lib/dnsimple/user.rb +6 -14
 - data/lib/dnsimple/version.rb +1 -1
 - data/spec/ci/.dnsimple.test +1 -1
 - data/spec/dnsimple/certificate_spec.rb +40 -30
 - data/spec/dnsimple/client_spec.rb +9 -9
 - data/spec/dnsimple/contact_spec.rb +34 -26
 - data/spec/dnsimple/domain_spec.rb +21 -74
 - data/spec/dnsimple/extended_attributes_spec.rb +42 -9
 - data/spec/dnsimple/record_spec.rb +35 -43
 - data/spec/dnsimple/template_spec.rb +27 -5
 - data/spec/dnsimple/user_spec.rb +22 -14
 - data/spec/files/certificates/index/success.http +19 -0
 - data/spec/files/certificates/show/notfound.http +17 -0
 - data/spec/files/certificates/show/success.http +19 -0
 - data/spec/files/contacts/show/notfound.http +17 -0
 - data/spec/files/contacts/show/success.http +19 -0
 - data/spec/files/domains/show/notfound.http +17 -0
 - data/spec/files/domains/show/success.http +19 -0
 - data/spec/files/extended_attributes/ca.http +19 -0
 - data/spec/files/extended_attributes/com.http +19 -0
 - data/spec/files/extended_attributes/success.http +19 -0
 - data/spec/files/records/index/success.http +19 -0
 - data/spec/files/records/show/notfound.http +17 -0
 - data/spec/files/records/show/success.http +19 -0
 - data/spec/files/templates/show/notfound.http +17 -0
 - data/spec/files/templates/show/success.http +19 -0
 - data/spec/files/users/me/success.http +19 -0
 - data/spec/spec_helper.rb +14 -17
 - data/spec/support/helpers.rb +15 -0
 - data/spec/support/webmock.rb +11 -0
 - metadata +65 -84
 - data/features/README +0 -12
 - data/fixtures/vcr_cassettes/DNSimple_Certificate/_all.yml +0 -57
 - data/fixtures/vcr_cassettes/DNSimple_Certificate/_purchase.yml +0 -57
 - data/fixtures/vcr_cassettes/DNSimple_Certificate/_submit.yml +0 -57
 - data/fixtures/vcr_cassettes/DNSimple_Contact/a_new_contact.yml +0 -50
 - data/fixtures/vcr_cassettes/DNSimple_Contact/an_existing_contact.yml +0 -50
 - data/fixtures/vcr_cassettes/DNSimple_Domain/_all.yml +0 -149
 - data/fixtures/vcr_cassettes/DNSimple_Domain/applying_templates.yml +0 -246
 - data/fixtures/vcr_cassettes/DNSimple_Domain/creating_a_new_domain.yml +0 -51
 - data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_id.yml +0 -51
 - data/fixtures/vcr_cassettes/DNSimple_Domain/finding_an_existing_domain/by_name.yml +0 -51
 - data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_a_new_registrant_contact.yml +0 -52
 - data/fixtures/vcr_cassettes/DNSimple_Domain/registration/with_an_existing_contact.yml +0 -52
 - data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_ca.yml +0 -273
 - data/fixtures/vcr_cassettes/DNSimple_ExtendedAttribute/list_extended_attributes/for_com.yml +0 -46
 - data/fixtures/vcr_cassettes/DNSimple_Record/_all.yml +0 -195
 - data/fixtures/vcr_cassettes/DNSimple_Record/creating_a_new_record.yml +0 -51
 - data/fixtures/vcr_cassettes/DNSimple_Record/find_a_record.yml +0 -51
 - data/fixtures/vcr_cassettes/DNSimple_Template/a_template.yml +0 -53
 - data/fixtures/vcr_cassettes/DNSimple_User/_me.yml +0 -49
 - data/spec/README +0 -10
 
| 
         @@ -1,88 +1,35 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe DNSimple::Domain do
         
     | 
| 
       4 
     | 
    
         
            -
              let(:domain_name) { "example.com" }
         
     | 
| 
       5 
     | 
    
         
            -
              let(:contact_id) { 1 }
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                   
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       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
         
     | 
| 
      
 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"))
         
     | 
| 
       31 
11 
     | 
    
         
             
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
12 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                it "builds the correct request" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  described_class.find("example.com")
         
     | 
| 
       35 
15 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       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
         
     | 
| 
      
 16 
     | 
    
         
            +
                  WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com").
         
     | 
| 
      
 17 
     | 
    
         
            +
                                 with(:headers => { 'Accept' => 'application/json' })
         
     | 
| 
       43 
18 
     | 
    
         
             
                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 
19 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                     
     | 
| 
      
 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.created_at).to eq("2013-11-08T17:22:48Z")
         
     | 
| 
      
 28 
     | 
    
         
            +
                    expect(result.updated_at).to eq("2014-01-14T18:27:04Z")
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(result.name_server_status).to be_nil
         
     | 
| 
       71 
31 
     | 
    
         
             
                  end
         
     | 
| 
       72 
32 
     | 
    
         
             
                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 
33 
     | 
    
         
             
              end
         
     | 
| 
       78 
34 
     | 
    
         | 
| 
       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 
35 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,18 +2,51 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe DNSimple::ExtendedAttribute do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              describe " 
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
       7 
     | 
    
         
            -
                   
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe ".find" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                before do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  stub_request(:get, %r[/v1/extended_attributes/com]).
         
     | 
| 
      
 8 
     | 
    
         
            +
                      to_return(read_fixture("extended_attributes/success.http"))
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                it "builds the correct request" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  described_class.find("com")
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/extended_attributes/com").
         
     | 
| 
      
 15 
     | 
    
         
            +
                                 with(:headers => { 'Accept' => 'application/json' })
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                context "when the TLD has no attributes" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 20 
     | 
    
         
            +
                    stub_request(:get, %r[/v1/extended_attributes/com]).
         
     | 
| 
      
 21 
     | 
    
         
            +
                        to_return(read_fixture("extended_attributes/com.http"))
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  it "returns an empty list" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                    result = described_class.find("com")
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    expect(result).to eq([])
         
     | 
| 
       10 
28 
     | 
    
         
             
                  end
         
     | 
| 
       11 
29 
     | 
    
         
             
                end
         
     | 
| 
       12 
30 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                context " 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
                context "when the TLD has attributes" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 33 
     | 
    
         
            +
                    stub_request(:get, %r[/v1/extended_attributes/ca]).
         
     | 
| 
      
 34 
     | 
    
         
            +
                        to_return(read_fixture("extended_attributes/ca.http"))
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  it "returns the attributes" do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    result = described_class.find("ca")
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                    expect(result).to be_a(Array)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    expect(result).to have(5).attributes
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    attribute = result[0]
         
     | 
| 
      
 44 
     | 
    
         
            +
                    expect(attribute).to be_a(described_class)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    expect(attribute.name).to eq("cira_legal_type")
         
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(attribute.description).to eq("Legal type of registrant contact")
         
     | 
| 
      
 47 
     | 
    
         
            +
                    expect(attribute.required).to be_true
         
     | 
| 
      
 48 
     | 
    
         
            +
                    expect(attribute.options).to be_a(Array)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    expect(attribute.options).to have(18).options
         
     | 
| 
       17 
50 
     | 
    
         
             
                  end
         
     | 
| 
       18 
51 
     | 
    
         
             
                end
         
     | 
| 
       19 
52 
     | 
    
         
             
              end
         
     | 
| 
         @@ -2,58 +2,50 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe DNSimple::Record do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
              let(: 
     | 
| 
       6 
     | 
    
         
            -
              let(:domain) { DNSimple::Domain.new(:name => domain_name) }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:domain) { DNSimple::Domain.new(:name => 'example.com') }
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                   
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                it "strips a blank name" do
         
     | 
| 
       14 
     | 
    
         
            -
                  record = DNSimple::Record.new(:name => '', :domain => domain)
         
     | 
| 
       15 
     | 
    
         
            -
                  record.fqdn.should eq(domain_name)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              describe ".find" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  stub_request(:get, %r[/v1/domains/example.com/records/2]).
         
     | 
| 
      
 11 
     | 
    
         
            +
                      to_return(read_fixture("records/show/success.http"))
         
     | 
| 
       16 
12 
     | 
    
         
             
                end
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
13 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  record.record_type.should eql("A")
         
     | 
| 
       25 
     | 
    
         
            -
                  record.content.should eql("1.2.3.4")
         
     | 
| 
       26 
     | 
    
         
            -
                  record.ttl.should eql(600)
         
     | 
| 
       27 
     | 
    
         
            -
                  record.id.should_not be_nil
         
     | 
| 
      
 14 
     | 
    
         
            +
                it "builds the correct request" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  described_class.find(domain, "2")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/domains/example.com/records/2").
         
     | 
| 
      
 18 
     | 
    
         
            +
                                 with(:headers => { 'Accept' => 'application/json' })
         
     | 
| 
       28 
19 
     | 
    
         
             
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                context "when the record exists" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it "returns the record" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    result = described_class.find(domain, "2")
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    expect(result).to be_a(described_class)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    expect(result.id).to eq(1495)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    expect(result.domain).to be(domain)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    expect(result.name).to eq("www")
         
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(result.content).to eq("1.2.3.4")
         
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(result.ttl).to eq(3600)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    expect(result.prio).to be_nil
         
     | 
| 
      
 32 
     | 
    
         
            +
                    expect(result.record_type).to eq("A")
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
       39 
34 
     | 
    
         
             
                end
         
     | 
| 
       40 
35 
     | 
    
         
             
              end
         
     | 
| 
       41 
36 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                 
     | 
| 
       45 
     | 
    
         
            -
                   
     | 
| 
       46 
     | 
    
         
            -
                  
         
     | 
| 
       47 
     | 
    
         
            -
                  @records << DNSimple::Record.create(domain, "", "A", "4.5.6.7")
         
     | 
| 
       48 
     | 
    
         
            -
                  @records << DNSimple::Record.create(domain, "www", "CNAME", "testdomain.com")
         
     | 
| 
       49 
     | 
    
         
            -
                  @records << DNSimple::Record.create(domain, "", "MX", "mail.foo.com", :prio => 10)
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              describe "#fqdn" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                it "joins the name and domain name" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  record = described_class.new(:name => 'www', :domain => domain)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(record.fqdn).to eq("www.#{domain.name}")
         
     | 
| 
       50 
42 
     | 
    
         
             
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                it " 
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
       54 
     | 
    
         
            -
                   
     | 
| 
       55 
     | 
    
         
            -
                  records.length.should eql(@records.length)
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                it "strips a blank name" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  record = described_class.new(:name => '', :domain => domain)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(record.fqdn).to eq(domain.name)
         
     | 
| 
       56 
47 
     | 
    
         
             
                end
         
     | 
| 
       57 
48 
     | 
    
         
             
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       58 
50 
     | 
    
         
             
            end
         
     | 
| 
       59 
51 
     | 
    
         | 
| 
         @@ -1,9 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            describe DNSimple::Template do
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe ".find" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                before do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  stub_request(:get, %r[/v1/templates/google-apps]).
         
     | 
| 
      
 8 
     | 
    
         
            +
                      to_return(read_fixture("templates/show/success.http"))
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                it "builds the correct request" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  described_class.find("google-apps")
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/templates/google-apps").
         
     | 
| 
      
 15 
     | 
    
         
            +
                                 with(:headers => { 'Accept' => 'application/json' })
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                context "when the template exists" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  it "returns the template" do
         
     | 
| 
      
 20 
     | 
    
         
            +
                    result = described_class.find("google-apps")
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    expect(result).to be_a(described_class)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(result.id).to eq(63)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    expect(result.name).to eq("Google Apps")
         
     | 
| 
      
 25 
     | 
    
         
            +
                    expect(result.short_name).to eq("google-apps")
         
     | 
| 
      
 26 
     | 
    
         
            +
                    expect(result.description).to eq("The Google Mail Servers and Google Apps CNAME records in a single template.")
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
       7 
28 
     | 
    
         
             
                end
         
     | 
| 
       8 
29 
     | 
    
         
             
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       9 
31 
     | 
    
         
             
            end
         
     | 
    
        data/spec/dnsimple/user_spec.rb
    CHANGED
    
    | 
         @@ -2,22 +2,30 @@ require 'spec_helper' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe DNSimple::User do
         
     | 
| 
       4 
4 
     | 
    
         
             
              describe ".me" do
         
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                before do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  stub_request(:get, %r[/v1/users/me]).
         
     | 
| 
      
 7 
     | 
    
         
            +
                      to_return(read_fixture("users/me/success.http"))
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                it "builds the correct request" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  described_class.me
         
     | 
| 
       7 
12 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                  WebMock.should have_requested(:get, "https://#{CONFIG['username']}:#{CONFIG['password']}@#{CONFIG['host']}/v1/users/me").
         
     | 
| 
      
 14 
     | 
    
         
            +
                                 with(:headers => { 'Accept' => 'application/json' })
         
     | 
| 
       10 
15 
     | 
    
         
             
                end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                it " 
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                it "returns the user" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  result = described_class.me
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  expect(result).to be_a(described_class)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(result.id).to eq(2)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  expect(result.email).to eq("example@example.com")
         
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(result.domain_count).to eq(2)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(result.domain_limit).to eq(50)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  expect(result.login_count).to eq(2)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  expect(result.failed_login_count).to eq(0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  expect(result.created_at).to eq("2013-11-08T17:20:58Z")
         
     | 
| 
      
 28 
     | 
    
         
            +
                  expect(result.updated_at).to eq("2014-01-14T17:45:57Z")
         
     | 
| 
       21 
29 
     | 
    
         
             
                end
         
     | 
| 
       22 
30 
     | 
    
         
             
              end
         
     | 
| 
       23 
31 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            HTTP/1.1 200 OK
         
     | 
| 
      
 2 
     | 
    
         
            +
            Server: nginx/1.5.8
         
     | 
| 
      
 3 
     | 
    
         
            +
            Date: Tue, 14 Jan 2014 18:37:59 GMT
         
     | 
| 
      
 4 
     | 
    
         
            +
            Content-Type: application/json; charset=utf-8
         
     | 
| 
      
 5 
     | 
    
         
            +
            Transfer-Encoding: chunked
         
     | 
| 
      
 6 
     | 
    
         
            +
            Connection: close
         
     | 
| 
      
 7 
     | 
    
         
            +
            Status: 200 OK
         
     | 
| 
      
 8 
     | 
    
         
            +
            X-DNSimple-API-Version: 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Access-Control-Allow-Origin: *
         
     | 
| 
      
 10 
     | 
    
         
            +
            Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
         
     | 
| 
      
 11 
     | 
    
         
            +
            Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
         
     | 
| 
      
 12 
     | 
    
         
            +
            X-UA-Compatible: IE=Edge,chrome=1
         
     | 
| 
      
 13 
     | 
    
         
            +
            ETag: "68c94c6eefc81fd3fc85b068a7c65029"
         
     | 
| 
      
 14 
     | 
    
         
            +
            Cache-Control: max-age=0, private, must-revalidate
         
     | 
| 
      
 15 
     | 
    
         
            +
            X-Request-Id: f06a7d3fc56223e9db4c14f548c43d7a
         
     | 
| 
      
 16 
     | 
    
         
            +
            X-Runtime: 0.046608
         
     | 
| 
      
 17 
     | 
    
         
            +
            Strict-Transport-Security: max-age=315360000
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            [{"certificate":{"id":4576,"domain_id":79569,"contact_id":11549,"name":"www","state":"cancelled","csr":"-----BEGIN NEW CERTIFICATE REQUEST-----\nRHr2akB4KMba6FMAsvlStnO/2ika16hNx+d3smPNsER+HA==\n-----END NEW CERTIFICATE REQUEST-----\n","ssl_certificate":null,"private_key":"-----BEGIN RSA PRIVATE KEY-----\nUeXbFi7o+nuPfRhpBFQEKwacKFc3Hnc1hH6UsnC0KY25cUif7yz38A==\n-----END RSA PRIVATE KEY-----\n","approver_email":"example@example.com","expires_on":"2014-09-17","created_at":"2013-09-17T21:54:42Z","updated_at":"2013-09-17T22:25:36Z","configured_at":"2013-09-17T22:25:01Z","available_approver_emails":null,"certificate_status":null}},{"certificate":{"id":4578,"domain_id":79569,"contact_id":11549,"name":"www","state":"cancelled","csr":"-----BEGIN NEW CERTIFICATE REQUEST-----\n2iT9OvY4afImf2ZcXnYZGrfXCx4GOxeMDpNcQm0RT3gLGw==\n-----END NEW CERTIFICATE REQUEST-----\n","ssl_certificate":null,"private_key":"-----BEGIN RSA PRIVATE KEY-----\nwDj89yRezuhCL5K1MSVohQyhyESr9Vz93p4r31DZxAmgFbCRE+g=\n-----END RSA PRIVATE KEY-----\n","approver_email":"example@example.com","expires_on":"2014-09-17","created_at":"2013-09-17T22:30:03Z","updated_at":"2013-09-17T22:30:41Z","configured_at":"2013-09-17T22:30:08Z","available_approver_emails":null,"certificate_status":null}}]
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            HTTP/1.1 404 Not Found
         
     | 
| 
      
 2 
     | 
    
         
            +
            Server: nginx/1.5.8
         
     | 
| 
      
 3 
     | 
    
         
            +
            Date: Tue, 14 Jan 2014 18:40:45 GMT
         
     | 
| 
      
 4 
     | 
    
         
            +
            Content-Type: application/json; charset=utf-8
         
     | 
| 
      
 5 
     | 
    
         
            +
            Transfer-Encoding: chunked
         
     | 
| 
      
 6 
     | 
    
         
            +
            Connection: close
         
     | 
| 
      
 7 
     | 
    
         
            +
            Status: 404 Not Found
         
     | 
| 
      
 8 
     | 
    
         
            +
            X-DNSimple-API-Version: 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Access-Control-Allow-Origin: *
         
     | 
| 
      
 10 
     | 
    
         
            +
            Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
         
     | 
| 
      
 11 
     | 
    
         
            +
            Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
         
     | 
| 
      
 12 
     | 
    
         
            +
            X-UA-Compatible: IE=Edge,chrome=1
         
     | 
| 
      
 13 
     | 
    
         
            +
            Cache-Control: no-cache
         
     | 
| 
      
 14 
     | 
    
         
            +
            X-Request-Id: d38b463c18b96625c085e1ca121a7ffd
         
     | 
| 
      
 15 
     | 
    
         
            +
            X-Runtime: 0.034619
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            {"error":"Couldn't find Certificate with id=12 [WHERE \"certificates\".\"domain_id\" = 79569]"}
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            HTTP/1.1 200 OK
         
     | 
| 
      
 2 
     | 
    
         
            +
            Server: nginx/1.5.8
         
     | 
| 
      
 3 
     | 
    
         
            +
            Date: Tue, 14 Jan 2014 18:40:28 GMT
         
     | 
| 
      
 4 
     | 
    
         
            +
            Content-Type: application/json; charset=utf-8
         
     | 
| 
      
 5 
     | 
    
         
            +
            Transfer-Encoding: chunked
         
     | 
| 
      
 6 
     | 
    
         
            +
            Connection: close
         
     | 
| 
      
 7 
     | 
    
         
            +
            Status: 200 OK
         
     | 
| 
      
 8 
     | 
    
         
            +
            X-DNSimple-API-Version: 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Access-Control-Allow-Origin: *
         
     | 
| 
      
 10 
     | 
    
         
            +
            Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
         
     | 
| 
      
 11 
     | 
    
         
            +
            Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
         
     | 
| 
      
 12 
     | 
    
         
            +
            X-UA-Compatible: IE=Edge,chrome=1
         
     | 
| 
      
 13 
     | 
    
         
            +
            ETag: "2b76f0ea88c7e95384506ac576d23d01"
         
     | 
| 
      
 14 
     | 
    
         
            +
            Cache-Control: max-age=0, private, must-revalidate
         
     | 
| 
      
 15 
     | 
    
         
            +
            X-Request-Id: aaf5915a32924165d4f45779689831fa
         
     | 
| 
      
 16 
     | 
    
         
            +
            X-Runtime: 0.042263
         
     | 
| 
      
 17 
     | 
    
         
            +
            Strict-Transport-Security: max-age=315360000
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            {"certificate":{"id":4576,"domain_id":79569,"contact_id":11549,"name":"www","state":"cancelled","csr":"-----BEGIN NEW CERTIFICATE REQUEST-----\nRHr2akB4KMba6FMAsvlStnO/2ika16hNx+d3smPNsER+HA==\n-----END NEW CERTIFICATE REQUEST-----\n","ssl_certificate":"-----BEGIN CERTIFICATE-----\nXwTkw5UCPpaVyUYcwHlvaprOe9ZbwIyEHm2AT1rW+70=\n-----END CERTIFICATE-----\n","private_key":"-----BEGIN RSA PRIVATE KEY-----\nUeXbFi7o+nuPfRhpBFQEKwacKFc3Hnc1hH6UsnC0KY25cUif7yz38A==\n-----END RSA PRIVATE KEY-----\n","approver_email":"example@example.net","expires_on":"2014-09-17","created_at":"2013-09-17T21:54:42Z","updated_at":"2013-09-17T22:25:36Z","configured_at":"2013-09-17T22:25:01Z","available_approver_emails":null,"certificate_status":null}}
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            HTTP/1.1 404 Not Found
         
     | 
| 
      
 2 
     | 
    
         
            +
            Server: nginx/1.4.4
         
     | 
| 
      
 3 
     | 
    
         
            +
            Date: Tue, 14 Jan 2014 18:03:42 GMT
         
     | 
| 
      
 4 
     | 
    
         
            +
            Content-Type: application/json; charset=utf-8
         
     | 
| 
      
 5 
     | 
    
         
            +
            Transfer-Encoding: chunked
         
     | 
| 
      
 6 
     | 
    
         
            +
            Connection: close
         
     | 
| 
      
 7 
     | 
    
         
            +
            Status: 404 Not Found
         
     | 
| 
      
 8 
     | 
    
         
            +
            X-DNSimple-API-Version: 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Access-Control-Allow-Origin: *
         
     | 
| 
      
 10 
     | 
    
         
            +
            Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
         
     | 
| 
      
 11 
     | 
    
         
            +
            Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
         
     | 
| 
      
 12 
     | 
    
         
            +
            X-UA-Compatible: IE=Edge,chrome=1
         
     | 
| 
      
 13 
     | 
    
         
            +
            Cache-Control: no-cache
         
     | 
| 
      
 14 
     | 
    
         
            +
            X-Request-Id: 06b719043c001f90932f8984c0b5d301
         
     | 
| 
      
 15 
     | 
    
         
            +
            X-Runtime: 0.035035
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            {"error":"Couldn't find Contact with id=20 [WHERE (user_id = 2 or organization_id in (NULL))]"}
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            HTTP/1.1 200 OK
         
     | 
| 
      
 2 
     | 
    
         
            +
            Server: nginx/1.4.4
         
     | 
| 
      
 3 
     | 
    
         
            +
            Date: Tue, 14 Jan 2014 18:03:26 GMT
         
     | 
| 
      
 4 
     | 
    
         
            +
            Content-Type: application/json; charset=utf-8
         
     | 
| 
      
 5 
     | 
    
         
            +
            Transfer-Encoding: chunked
         
     | 
| 
      
 6 
     | 
    
         
            +
            Connection: close
         
     | 
| 
      
 7 
     | 
    
         
            +
            Status: 200 OK
         
     | 
| 
      
 8 
     | 
    
         
            +
            X-DNSimple-API-Version: 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Access-Control-Allow-Origin: *
         
     | 
| 
      
 10 
     | 
    
         
            +
            Access-Control-Allow-Headers: Authorization,Accepts,Content-Type,X-DNSimple-Token,X-DNSimple-Domain-Token,X-CSRF-Token,x-requested-with
         
     | 
| 
      
 11 
     | 
    
         
            +
            Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS
         
     | 
| 
      
 12 
     | 
    
         
            +
            X-UA-Compatible: IE=Edge,chrome=1
         
     | 
| 
      
 13 
     | 
    
         
            +
            ETag: "c8da059d309b1de77a7b400c6c8febb0"
         
     | 
| 
      
 14 
     | 
    
         
            +
            Cache-Control: max-age=0, private, must-revalidate
         
     | 
| 
      
 15 
     | 
    
         
            +
            X-Request-Id: 954fef00cf763b3de6211670a740ebc9
         
     | 
| 
      
 16 
     | 
    
         
            +
            X-Runtime: 0.040477
         
     | 
| 
      
 17 
     | 
    
         
            +
            Strict-Transport-Security: max-age=315360000
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            {"contact":{"id":2,"user_id":2,"label":"Default","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"DNSimple","email_address":"example@example.com","phone":"+1 111 000000","fax":"+1 222 000000","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2013-11-08T17:23:15Z","updated_at":"2013-11-08T17:23:15Z","phone_ext":null}}
         
     |