gandirb 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/CHANGELOG +6 -0
  2. data/LICENSE +1 -1
  3. data/README.rdoc +22 -24
  4. data/Rakefile +8 -9
  5. data/USAGE.rdoc +131 -0
  6. data/gandirb.gemspec +7 -9
  7. data/lib/gandi/connection.rb +65 -0
  8. data/lib/gandi/connector.rb +7 -0
  9. data/lib/gandi/contact.rb +175 -0
  10. data/lib/gandi/domain/contacts.rb +21 -0
  11. data/lib/gandi/domain/forward.rb +58 -0
  12. data/lib/gandi/domain/host.rb +63 -0
  13. data/lib/gandi/domain/mailbox.rb +72 -0
  14. data/lib/gandi/domain/nameservers.rb +17 -0
  15. data/lib/gandi/domain/status.rb +19 -0
  16. data/lib/gandi/domain/tld.rb +17 -0
  17. data/lib/gandi/domain/transferin.rb +13 -0
  18. data/lib/gandi/domain.rb +61 -128
  19. data/lib/gandi/errors.rb +10 -0
  20. data/lib/gandi/gandi_object_methods.rb +23 -0
  21. data/lib/gandi/operation.rb +45 -0
  22. data/lib/gandi/version.rb +1 -1
  23. data/lib/gandi.rb +57 -6
  24. data/spec/gandi/connection_spec.rb +39 -0
  25. data/spec/gandi/contact_spec.rb +173 -0
  26. data/spec/gandi/domain/forward_spec.rb +103 -0
  27. data/spec/gandi/domain/host_spec.rb +103 -0
  28. data/spec/gandi/domain/mailbox_spec.rb +117 -0
  29. data/spec/gandi/domain/tld_spec.rb +23 -0
  30. data/spec/gandi/domain_spec.rb +174 -0
  31. data/spec/gandi/errors_spec.rb +18 -0
  32. data/spec/gandi/gandi_spec.rb +57 -0
  33. data/spec/gandi/operation_spec.rb +73 -0
  34. data/spec/spec_helper.rb +5 -0
  35. data/spec/support/contact_macros.rb +18 -0
  36. data/spec/support/domain_macros.rb +103 -0
  37. data/spec/support/operation_macros.rb +22 -0
  38. metadata +58 -51
  39. data/lib/gandi/base.rb +0 -121
  40. data/lib/gandi/domain_modules/contact.rb +0 -36
  41. data/lib/gandi/domain_modules/host.rb +0 -29
  42. data/lib/gandi/domain_modules/mail.rb +0 -80
  43. data/lib/gandi/domain_modules/name_servers.rb +0 -28
  44. data/lib/gandi/domain_modules/operations.rb +0 -30
  45. data/lib/gandi/domain_modules/redirection.rb +0 -25
  46. data/test/gandi/base_test.rb +0 -188
  47. data/test/gandi/domain_test.rb +0 -301
  48. data/test/gandi_test.rb +0 -9
  49. data/test/test_helper.rb +0 -9
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'gandi/errors'
3
+
4
+ describe Gandi::DataError do
5
+ it "should define a custom error class" do
6
+ Gandi::DataError.ancestors.should include(ArgumentError)
7
+ end
8
+ end
9
+ describe Gandi::ServerError do
10
+ it "should define a custom error class" do
11
+ Gandi::ServerError.ancestors.should include(RuntimeError)
12
+ end
13
+ end
14
+ describe Gandi::NoMethodError do
15
+ it "should define a custom error class" do
16
+ Gandi::NoMethodError.ancestors.should include(NoMethodError)
17
+ end
18
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+ require 'gandi'
3
+
4
+ describe Gandi do
5
+ it "should have a settable url defaulting to the test url" do
6
+ Gandi.url.should == Gandi::TEST_URL
7
+ Gandi.url = 'settable url'
8
+ Gandi.url.should == 'settable url'
9
+ end
10
+
11
+ it "should have a settable apikey" do
12
+ Gandi.apikey.should == nil
13
+ Gandi.apikey = 'settable apikey'
14
+ Gandi.apikey.should == 'settable apikey'
15
+ end
16
+
17
+ it "should have a settable connection" do
18
+ Gandi.apikey = 'settable apikey'
19
+ Gandi.url = 'settable url'
20
+ Gandi::Connection.should_receive(:new).with('settable apikey', 'settable url').once.and_return('connection object')
21
+ Gandi.connection.should == 'connection object'
22
+
23
+ Gandi.connection = 'settable connection'
24
+ Gandi.connection.should == 'settable connection'
25
+ end
26
+
27
+ context "with a connection" do
28
+ before do
29
+ @connection = double()
30
+ Gandi.connection = @connection
31
+ end
32
+
33
+ describe "#call" do
34
+ it "passes the called method to the connection" do
35
+ @connection.should_receive(:call).with('called.method', 'arg1', 'arg2').once.and_return('returned value')
36
+ Gandi.call('called.method', 'arg1', 'arg2').should == 'returned value'
37
+ end
38
+ end
39
+
40
+ describe "#api_version" do
41
+ it "returns a string containing the current version" do
42
+ @connection.should_receive(:call).with('version.info').once.and_return({"api_version"=>'X.Y'})
43
+ Gandi.api_version.should == 'X.Y'
44
+ end
45
+ end
46
+
47
+ it "resets the connection when changing the url" do
48
+ Gandi.url = Gandi::TEST_URL
49
+ Gandi.connection.should_not == @connection
50
+ end
51
+
52
+ it "resets the connection when changing the apikey" do
53
+ Gandi.apikey = 'apikey'
54
+ Gandi.connection.should_not == @connection
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+ require 'gandi'
3
+
4
+ describe Gandi::Operation do
5
+ before do
6
+ @connection_mock = double()
7
+ ::Gandi.connection = @connection_mock
8
+ end
9
+
10
+ context "a new instance" do
11
+ before do
12
+ @id = '123'
13
+ @attributes = operation_information_attributes_hash('id' => '123')
14
+ @connection_mock.should_receive(:call).with('operation.info', @id).and_return(@attributes)
15
+ end
16
+ subject { Gandi::Operation.new(@id) }
17
+
18
+ its(:id) { should == @id }
19
+
20
+ it "can read its attributes" do
21
+ subject.to_hash.should == @attributes
22
+ subject['step'].should == @attributes['step']
23
+ end
24
+
25
+ it "can fetch its informations" do
26
+ @connection_mock.should_receive(:call).with('operation.info', @id).and_return(@attributes)
27
+ subject.info['step'].should == @attributes['step']
28
+ end
29
+
30
+ describe '#cancel' do
31
+ context "successful" do
32
+ before do
33
+ @connection_mock.should_receive(:call).with('operation.cancel', @id).and_return(true)
34
+ @cancel_result = subject.cancel
35
+ end
36
+
37
+ specify { @cancel_result.should be_true }
38
+ specify { subject['step'].should == 'CANCEL' }
39
+ end
40
+
41
+ #Can this really happen ?
42
+ context "failed" do
43
+ before do
44
+ @connection_mock.should_receive(:call).with('operation.cancel', @id).and_return(false)
45
+ @cancel_result = subject.cancel
46
+ end
47
+
48
+ specify { @cancel_result.should be_false }
49
+ specify { subject['step'].should == @attributes['step'] }
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '.count' do
55
+ it "returns an integer" do
56
+ @connection_mock.should_receive(:call).with('operation.count', {}).and_return(42)
57
+ Gandi::Operation.count.should == 42
58
+ end
59
+ end
60
+
61
+ describe '.list' do
62
+ it "returns an array of operations" do
63
+ @operations_array = [operation_information_attributes_hash('id' => '123'), operation_information_attributes_hash('id' => '456')]
64
+ @connection_mock.should_receive(:call).with('operation.list', {}).and_return(@operations_array)
65
+
66
+ operations = Gandi::Operation.list
67
+
68
+ operations.length.should == @operations_array.length
69
+ operations.first.should be_a(Gandi::Operation)
70
+ operations.first.id.should == @operations_array.first['id']
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,5 @@
1
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
2
+
3
+ RSpec.configure do |config|
4
+ config.mock_with :rspec
5
+ end
@@ -0,0 +1,18 @@
1
+ module ContactMacros
2
+ def contact_information_attributes_hash(ext_attrs = {})
3
+ {"city"=>"Aix",
4
+ "given"=>"John",
5
+ "family"=>"Doe",
6
+ "zip"=>"13100",
7
+ "country"=>"FR",
8
+ "streetaddr"=>"1 Rue du Pont",
9
+ "phone"=>"+33.400000000",
10
+ "password"=>"password",
11
+ "type"=>0,
12
+ "email"=>"johndoe@domain1.tld"}.merge(ext_attrs)
13
+ end
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.include ContactMacros
18
+ end
@@ -0,0 +1,103 @@
1
+ module DomainMacros
2
+ def domain_information_attributes_hash(ext_attrs = {})
3
+ year, month, day, hour, min, sec = 1970, 1, 1, 1, 1, 1
4
+ {
5
+ "status"=>["clientTransferProhibited"],
6
+ "date_renew_end"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
7
+ "date_pending_delete_end"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
8
+ "zone_id"=> 1,
9
+ "tags"=>[],
10
+ "date_updated"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
11
+ "date_delete"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
12
+ "contacts"=>{
13
+ "owner"=>{"handle"=>"FLN123-GANDI", "id"=>1},
14
+ "admin"=>{"handle"=>"FLN123-GANDI", "id"=>1},
15
+ "bill"=>{"handle"=>"FLN123-GANDI", "id"=>1},
16
+ "tech"=>{"handle"=>"FLN123-GANDI", "id"=>1},
17
+ "reseller"=>{"handle"=>"FLN123-GANDI", "id"=>1}
18
+ },
19
+ "date_registry_end"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
20
+ "nameservers"=>["a.dns.gandi.net", "b.dns.gandi.net", "c.dns.gandi.net"],
21
+ "authinfo"=>"aaa",
22
+ "date_registry_creation"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
23
+ "date_renew_begin"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
24
+ "date_hold_end" => XMLRPC::DateTime.new(year, month, day, hour, min, sec),
25
+ "date_created"=> XMLRPC::DateTime.new(year, month, day, hour, min, sec),
26
+ "date_restore_end"=>XMLRPC::DateTime.new(year, month, day, hour, min, sec),
27
+ "id"=>1,
28
+ "tld"=>"com"
29
+ #"fqdn"=>"domain.com",
30
+ }.merge(ext_attrs)
31
+ end
32
+
33
+ def domain_creation_operation_hash(ext_attrs = {})
34
+ ext_attrs = {"type" => 'domain_create',
35
+ 'id' => 0,
36
+ "session_id"=>0,
37
+ "eta"=>0,
38
+ 'params' => {"domain"=>"fqdn", "bill"=>"FLN123-GANDI", "reseller"=>"FLN123-GANDI", "admin"=>"FLN123-GANDI", "pre_migration"=>true, "source_ip"=>"127.0.0.1", "ns"=>["gandi.net"], "duration"=>1, "source_client"=>"", "backend-version"=>3, "owner"=>"FLN123-GANDI", "tech"=>"FLN123-GANDI", "param_type"=>"domain", "auth_id"=>0},
39
+ "last_error" => "0",
40
+ 'infos' => {"product_action"=>"create", "product_type"=>"domain", "product_name"=>".tld", "extras"=>{}, "label"=>"fqdn", "id"=>"", "quantity"=>""},
41
+ "step"=>"BILL"
42
+ }.merge(ext_attrs)
43
+ operation_information_attributes_hash(ext_attrs)
44
+ end
45
+
46
+ def domain_renew_spec(ext_attrs = {})
47
+ {
48
+ 'duration' => 1,
49
+ 'current_year' => Date.today.year
50
+ }.merge(ext_attrs)
51
+ end
52
+
53
+ def domain_renewal_operation_hash(ext_attrs = {})
54
+ ext_attrs = {"type" => 'domain_renew',
55
+ 'id' => 0,
56
+ "session_id"=>0,
57
+ "eta"=>0,
58
+ 'params' => {"domain"=>"fqdn", "bill"=>"FLN123-GANDI", "reseller"=>"FLN123-GANDI", "admin"=>"FLN123-GANDI", "pre_migration"=>true, "source_ip"=>"127.0.0.1", "ns"=>["gandi.net"], "duration"=>1, "source_client"=>"", "backend-version"=>3, "owner"=>"FLN123-GANDI", "tech"=>"FLN123-GANDI", "param_type"=>"domain", "auth_id"=>0},
59
+ "last_error" => "0",
60
+ 'infos' => {"product_action"=>"renew", "product_type"=>"domain", "product_name"=>".tld", "extras"=>{}, "label"=>"fqdn", "id"=>"", "quantity"=>""},
61
+ "step"=>"BILL"
62
+ }.merge(ext_attrs)
63
+ operation_information_attributes_hash(ext_attrs)
64
+ end
65
+
66
+ def domain_tld_regions
67
+ {"generic"=>["aero", "biz", "com", "coop", "info", "mobi", "name", "net", "org", "pro", "tel", "travel"], "europe"=>["at", "be", "ch", "co.uk", "com.de", "de", "de.com", "es", "eu", "eu.com", "fr", "gb.com", "gb.net", "gr.com", "hu.com", "im", "it", "li", "lt", "lu", "me", "me.uk", "nl", "no", "no.com", "nu", "org.uk", "pl", "pt", "ru", "ru.com", "se", "se.com", "se.net", "uk.com", "uk.net"], "america"=>["ag", "ar.com", "br.com", "bz", "ca", "cc", "co", "gs", "gy", "hn", "ht", "la", "lc", "qc.com", "us", "us.com", "us.org", "uy.com", "vc"], "africa"=>["mu", "re", "sc", "za.com"], "asia"=>["ae.org", "af", "asia", "cn", "cn.com", "cx", "fm", "hk", "jp", "jpn.com", "ki", "kr.com", "mn", "nf", "sa.com", "sb", "tl", "tv", "tw", "ws"]}
68
+ end
69
+
70
+ def domain_tld_list
71
+ [{"region"=>"asia", "id"=>87, "name"=>"ae.org"}, {"region"=>"generic", "id"=>41, "name"=>"aero"}, {"region"=>"asia", "id"=>92, "name"=>"af"}, {"region"=>"america", "id"=>95, "name"=>"ag"}, {"region"=>"america", "id"=>77, "name"=>"ar.com"}, {"region"=>"asia", "id"=>21, "name"=>"asia"}, {"region"=>"europe", "id"=>23, "name"=>"at"}, {"region"=>"europe", "id"=>7, "name"=>"be"}, {"region"=>"generic", "id"=>5, "name"=>"biz"}, {"region"=>"america", "id"=>76, "name"=>"br.com"}, {"region"=>"america", "id"=>46, "name"=>"bz"}, {"region"=>"america", "id"=>115, "name"=>"ca"}, {"region"=>"america", "id"=>18, "name"=>"cc"}, {"region"=>"europe", "id"=>14, "name"=>"ch"}, {"region"=>"asia", "id"=>25, "name"=>"cn"}, {"region"=>"asia", "id"=>70, "name"=>"cn.com"}, {"region"=>"america", "id"=>88, "name"=>"co"}, {"region"=>"europe", "id"=>13, "name"=>"co.uk"}, {"region"=>"generic", "id"=>1, "name"=>"com"}, {"region"=>"europe", "id"=>138, "name"=>"com.de"}, {"region"=>"generic", "id"=>113, "name"=>"coop"}, {"region"=>"asia", "id"=>56, "name"=>"cx"}, {"region"=>"europe", "id"=>22, "name"=>"de"}, {"region"=>"europe", "id"=>82, "name"=>"de.com"}, {"region"=>"europe", "id"=>32, "name"=>"es"}, {"region"=>"europe", "id"=>9, "name"=>"eu"}, {"region"=>"europe", "id"=>64, "name"=>"eu.com"}, {"region"=>"asia", "id"=>61, "name"=>"fm"}, {"region"=>"europe", "id"=>8, "name"=>"fr"}, {"region"=>"europe", "id"=>66, "name"=>"gb.com"}, {"region"=>"europe", "id"=>67, "name"=>"gb.net"}, {"region"=>"europe", "id"=>91, "name"=>"gr.com"}, {"region"=>"america", "id"=>52, "name"=>"gs"}, {"region"=>"america", "id"=>110, "name"=>"gy"}, {"region"=>"asia", "id"=>62, "name"=>"hk"}, {"region"=>"america", "id"=>49, "name"=>"hn"}, {"region"=>"america", "id"=>51, "name"=>"ht"}, {"region"=>"europe", "id"=>85, "name"=>"hu.com"}, {"region"=>"europe", "id"=>33, "name"=>"im"}, {"region"=>"generic", "id"=>4, "name"=>"info"}, {"region"=>"europe", "id"=>20, "name"=>"it"}, {"region"=>"asia", "id"=>39, "name"=>"jp"}, {"region"=>"asia", "id"=>71, "name"=>"jpn.com"}, {"region"=>"asia", "id"=>94, "name"=>"ki"}, {"region"=>"asia", "id"=>72, "name"=>"kr.com"}, {"region"=>"america", "id"=>69, "name"=>"la"}, {"region"=>"america", "id"=>96, "name"=>"lc"}, {"region"=>"europe", "id"=>15, "name"=>"li"}, {"region"=>"europe", "id"=>63, "name"=>"lt"}, {"region"=>"europe", "id"=>29, "name"=>"lu"}, {"region"=>"europe", "id"=>28, "name"=>"me"}, {"region"=>"europe", "id"=>38, "name"=>"me.uk"}, {"region"=>"asia", "id"=>47, "name"=>"mn"}, {"region"=>"generic", "id"=>12, "name"=>"mobi"}, {"region"=>"africa", "id"=>55, "name"=>"mu"}, {"region"=>"generic", "id"=>6, "name"=>"name"}, {"region"=>"generic", "id"=>2, "name"=>"net"}, {"region"=>"asia", "id"=>93, "name"=>"nf"}, {"region"=>"europe", "id"=>37, "name"=>"nl"}, {"region"=>"europe", "id"=>90, "name"=>"no"}, {"region"=>"europe", "id"=>86, "name"=>"no.com"}, {"region"=>"europe", "id"=>19, "name"=>"nu"}, {"region"=>"generic", "id"=>3, "name"=>"org"}, {"region"=>"europe", "id"=>16, "name"=>"org.uk"}, {"region"=>"europe", "id"=>30, "name"=>"pl"}, {"region"=>"generic", "id"=>31, "name"=>"pro"}, {"region"=>"europe", "id"=>42, "name"=>"pt"}, {"region"=>"america", "id"=>79, "name"=>"qc.com"}, {"region"=>"africa", "id"=>11, "name"=>"re"}, {"region"=>"europe", "id"=>36, "name"=>"ru"}, {"region"=>"europe", "id"=>78, "name"=>"ru.com"}, {"region"=>"asia", "id"=>73, "name"=>"sa.com"}, {"region"=>"asia", "id"=>53, "name"=>"sb"}, {"region"=>"africa", "id"=>48, "name"=>"sc"}, {"region"=>"europe", "id"=>40, "name"=>"se"}, {"region"=>"europe", "id"=>83, "name"=>"se.com"}, {"region"=>"europe", "id"=>84, "name"=>"se.net"}, {"region"=>"generic", "id"=>35, "name"=>"tel"}, {"region"=>"asia", "id"=>54, "name"=>"tl"}, {"region"=>"generic", "id"=>112, "name"=>"travel"}, {"region"=>"asia", "id"=>17, "name"=>"tv"}, {"region"=>"asia", "id"=>27, "name"=>"tw"}, {"region"=>"europe", "id"=>65, "name"=>"uk.com"}, {"region"=>"europe", "id"=>68, "name"=>"uk.net"}, {"region"=>"america", "id"=>10, "name"=>"us"}, {"region"=>"america", "id"=>75, "name"=>"us.com"}, {"region"=>"america", "id"=>109, "name"=>"us.org"}, {"region"=>"america", "id"=>80, "name"=>"uy.com"}, {"region"=>"america", "id"=>50, "name"=>"vc"}, {"region"=>"asia", "id"=>103, "name"=>"ws"}, {"region"=>"africa", "id"=>81, "name"=>"za.com"}]
72
+ end
73
+
74
+ def domain_host_attributes_hash(ext_attrs = {})
75
+ {"ips"=>["1.2.3.4"], "name"=>"", 'domain' => ''}.merge(ext_attrs)
76
+ end
77
+
78
+ def mock_domain(fqdn, ext_attrs = {})
79
+ ext_attrs.merge!('fqdn' => fqdn)
80
+ old_connexion = Gandi.connection
81
+ new_connexion = double
82
+ new_connexion.should_receive(:call).with('domain.info', fqdn).and_return(domain_information_attributes_hash(ext_attrs))
83
+ Gandi.connection = new_connexion
84
+
85
+ domain = Gandi::Domain.new(fqdn)
86
+
87
+ Gandi.connection = old_connexion
88
+ return domain
89
+ end
90
+
91
+ #FIXME: domain.mailbox.info is currently defunct in OT&E
92
+ def domain_mailbox_attributes(ext_attrs = {})
93
+ {}.merge(ext_attrs)
94
+ end
95
+
96
+ def domain_forward_attributes(source, destinations = ['john.doe@domain.tld', 'jane.doe@domain2.tld'])
97
+ {'source' => source, 'destinations' => destinations}
98
+ end
99
+ end
100
+
101
+ RSpec.configure do |config|
102
+ config.include DomainMacros
103
+ end
@@ -0,0 +1,22 @@
1
+ module OperationMacros
2
+ def operation_information_attributes_hash(ext_attrs = {})
3
+ year, month, day, hour, min, sec = 1970, 1, 1, 1, 1, 1
4
+ {
5
+ "source" => 'HA0-GANDI',
6
+ "date_created" => XMLRPC::DateTime.new(year, month, day, hour, min, sec),
7
+ "date_updated" => XMLRPC::DateTime.new(year, month, day, hour, min, sec),
8
+ "date_start" => '',
9
+ "step" => 'WAIT'
10
+ #"type" => 'domain_create'
11
+ #"session_id"=>0,
12
+ #"eta"=>0
13
+ #params => {}
14
+ #"last_error" => "0"
15
+ #infos => {}
16
+ }.merge(ext_attrs)
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.include OperationMacros
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gandirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000Z
12
+ date: 2012-01-27 00:00:00.000000000Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: activesupport
16
- requirement: &71303820 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '2.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *71303820
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: rake
27
- requirement: &71303600 !ruby/object:Gem::Requirement
16
+ requirement: &70245430 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: '0'
33
22
  type: :development
34
23
  prerelease: false
35
- version_requirements: *71303600
24
+ version_requirements: *70245430
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: rdoc
38
- requirement: &71303310 !ruby/object:Gem::Requirement
27
+ requirement: &70245170 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ! '>='
@@ -43,60 +32,68 @@ dependencies:
43
32
  version: '0'
44
33
  type: :development
45
34
  prerelease: false
46
- version_requirements: *71303310
35
+ version_requirements: *70245170
47
36
  - !ruby/object:Gem::Dependency
48
- name: shoulda
49
- requirement: &71302990 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - <
53
- - !ruby/object:Gem::Version
54
- version: '3'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *71302990
58
- - !ruby/object:Gem::Dependency
59
- name: mocha
60
- requirement: &71302680 !ruby/object:Gem::Requirement
37
+ name: rspec
38
+ requirement: &70244870 !ruby/object:Gem::Requirement
61
39
  none: false
62
40
  requirements:
63
41
  - - ! '>='
64
42
  - !ruby/object:Gem::Version
65
- version: '0'
43
+ version: '2.8'
66
44
  type: :development
67
45
  prerelease: false
68
- version_requirements: *71302680
69
- description: ! " This is a ruby library for using the Gandi XML-RPC API.\n It currently
70
- only provides methods for using the domain and mail API, but is extensible enough
71
- to add hosting in the future.\n"
46
+ version_requirements: *70244870
47
+ description: ! " A Ruby library for using the Gandi XML-RPC API.\n At the moment
48
+ support is planned for the Domain, Contact and Operation APIs only, but Hosting
49
+ and Catalog APIs support may be added in the future.\n"
72
50
  email: ''
73
51
  executables: []
74
52
  extensions: []
75
53
  extra_rdoc_files:
54
+ - USAGE.rdoc
76
55
  - CHANGELOG
77
56
  - LICENSE
78
57
  files:
79
58
  - CHANGELOG
80
59
  - LICENSE
81
60
  - README.rdoc
61
+ - USAGE.rdoc
82
62
  - Gemfile
83
63
  - Rakefile
84
64
  - gandirb.gemspec
85
- - lib/gandi/domain_modules/mail.rb
86
- - lib/gandi/domain_modules/redirection.rb
87
- - lib/gandi/domain_modules/contact.rb
88
- - lib/gandi/domain_modules/name_servers.rb
89
- - lib/gandi/domain_modules/host.rb
90
- - lib/gandi/domain_modules/operations.rb
65
+ - lib/gandi/contact.rb
66
+ - lib/gandi/domain/forward.rb
67
+ - lib/gandi/domain/nameservers.rb
68
+ - lib/gandi/domain/transferin.rb
69
+ - lib/gandi/domain/tld.rb
70
+ - lib/gandi/domain/mailbox.rb
71
+ - lib/gandi/domain/host.rb
72
+ - lib/gandi/domain/status.rb
73
+ - lib/gandi/domain/contacts.rb
74
+ - lib/gandi/gandi_object_methods.rb
75
+ - lib/gandi/connection.rb
91
76
  - lib/gandi/domain.rb
92
- - lib/gandi/base.rb
77
+ - lib/gandi/connector.rb
78
+ - lib/gandi/operation.rb
93
79
  - lib/gandi/version.rb
80
+ - lib/gandi/errors.rb
94
81
  - lib/gandi.rb
95
- - test/gandi/domain_test.rb
96
- - test/gandi/base_test.rb
97
- - test/gandi_test.rb
98
- - test/test_helper.rb
99
- homepage: http://github.com/pickabee/gandirb
82
+ - spec/gandi/gandi_spec.rb
83
+ - spec/gandi/connection_spec.rb
84
+ - spec/gandi/operation_spec.rb
85
+ - spec/gandi/domain/mailbox_spec.rb
86
+ - spec/gandi/domain/forward_spec.rb
87
+ - spec/gandi/domain/host_spec.rb
88
+ - spec/gandi/domain/tld_spec.rb
89
+ - spec/gandi/contact_spec.rb
90
+ - spec/gandi/errors_spec.rb
91
+ - spec/gandi/domain_spec.rb
92
+ - spec/spec_helper.rb
93
+ - spec/support/domain_macros.rb
94
+ - spec/support/operation_macros.rb
95
+ - spec/support/contact_macros.rb
96
+ homepage: http://github.com/pickabee/gandi
100
97
  licenses: []
101
98
  post_install_message:
102
99
  rdoc_options:
@@ -127,7 +124,17 @@ signing_key:
127
124
  specification_version: 3
128
125
  summary: Ruby library for using the Gandi XML-RPC API
129
126
  test_files:
130
- - test/gandi/domain_test.rb
131
- - test/gandi/base_test.rb
132
- - test/gandi_test.rb
133
- - test/test_helper.rb
127
+ - spec/gandi/gandi_spec.rb
128
+ - spec/gandi/connection_spec.rb
129
+ - spec/gandi/operation_spec.rb
130
+ - spec/gandi/domain/mailbox_spec.rb
131
+ - spec/gandi/domain/forward_spec.rb
132
+ - spec/gandi/domain/host_spec.rb
133
+ - spec/gandi/domain/tld_spec.rb
134
+ - spec/gandi/contact_spec.rb
135
+ - spec/gandi/errors_spec.rb
136
+ - spec/gandi/domain_spec.rb
137
+ - spec/spec_helper.rb
138
+ - spec/support/domain_macros.rb
139
+ - spec/support/operation_macros.rb
140
+ - spec/support/contact_macros.rb
data/lib/gandi/base.rb DELETED
@@ -1,121 +0,0 @@
1
- require 'xmlrpc/client'
2
- require 'openssl'
3
-
4
- #Common session, account and call methods
5
- module Gandi
6
- class Base
7
- TIMEOUT_EXCEPTIONS = [EOFError, Errno::EPIPE, OpenSSL::SSL::SSLError]
8
-
9
- URL = "https://api.gandi.net/xmlrpc/"
10
- TEST_URL = "https://api.ote.gandi.net/xmlrpc/"
11
-
12
- SSL_VERIFY_MODE = OpenSSL::SSL::VERIFY_NONE
13
-
14
- attr_reader :session_id, :handler
15
-
16
- public
17
-
18
- def initialize(login, password, uri = nil)
19
- @login = login
20
- @password = password
21
- @uri = uri
22
- raise ArgumentError.new("You must provide an URL when using Gandi::Base directly") unless @uri
23
- end
24
-
25
- #Calls a RPC method, transparently providing the session id
26
- def call(method, *arguments)
27
- raise "You have to log in before using methods requiring a session id" unless logged_in?
28
- raw_call(method.to_s, @session_id, *arguments)
29
- end
30
-
31
- #Instanciates a rpc handler and log in to the interface to retrieve a session id
32
- def login
33
- @handler = XMLRPC::Client.new_from_uri(@uri)
34
- #Get rid of SSL warnings "peer certificate won't be verified in this SSL session"
35
- #See http://developer.amazonwebservices.com/connect/thread.jspa?threadID=37139
36
- #and http://blog.chmouel.com/2008/03/21/ruby-xmlrpc-over-a-self-certified-ssl-with-a-warning/
37
- #and http://stackoverflow.com/questions/4748633/how-can-i-make-rubys-xmlrpc-client-ignore-ssl-certificate-errors for ruby 1.9 (which does not set @ssl_context before a request)
38
- if @handler.instance_variable_get('@http').use_ssl?
39
- if @handler.instance_variable_get('@http').instance_variable_get("@ssl_context") #Ruby 1.8.7
40
- @handler.instance_variable_get('@http').instance_variable_get("@ssl_context").verify_mode = SSL_VERIFY_MODE
41
- else
42
- @handler.instance_variable_get('@http').instance_variable_set(:@verify_mode, SSL_VERIFY_MODE) #Ruby 1.9
43
- end
44
- end
45
- @session_id = raw_call("login", @login, @password, false)
46
- end
47
-
48
- #Gets a new session id by switching to another handle
49
- def su(handle)
50
- @session_id = call("su", handle)
51
- end
52
-
53
- #Changes password
54
- def password(password)
55
- @password = password
56
- call("password", password)
57
- end
58
-
59
- #Current prepaid account balance
60
- def account_balance
61
- call('account_balance')
62
- end
63
-
64
- #Currency name used with the prepaid account
65
- def account_currency
66
- call('account_currency')
67
- end
68
-
69
- def self.login(login, password, uri = nil)
70
- client = self.new(login, password, uri)
71
- client.login
72
- return client
73
- end
74
-
75
- private
76
-
77
- #Handle RPC calls and exceptions
78
- #A reconnection system is used to work around what seems to be a ruby bug :
79
- #When waiting during 15 seconds between calls, a timeout is reached and the RPC handler starts throwing various exceptions
80
- #EOFError, Errno::EPIPE, then OpenSSL::SSL::SSLError.
81
- #When this happens, another handler and another session are created
82
- #Exceptions are not handled if happening two times consecutively, or during a login call
83
- #TODO: This method may be optimized by only creating another handler and keeping the session id.
84
- #In this case a server timeout of 12 hours (see the Gandi documentation) may be reached more easily and should be handled.
85
- def raw_call(*args)
86
- begin
87
- raise "no connexion handler is set" unless @handler
88
- result = @handler.call(*args)
89
- @reconnected = false unless (args.first == 'login')
90
- return result
91
- rescue StandardError => e
92
- case e
93
- when XMLRPC::FaultException
94
- raise (e.faultCode.to_s.chars.first == '5' ? Gandi::DataError : Gandi::ServerError), e.faultString
95
- when *TIMEOUT_EXCEPTIONS
96
- if @reconnected || (args.first == 'login')
97
- raise e #only one retry, and no retries if logging in
98
- else
99
- @reconnected = true
100
- args[1] = login #use the new session string
101
- raw_call(*args)
102
- end
103
- else
104
- @reconnected = false
105
- raise e
106
- end
107
- end
108
- end
109
-
110
- def logged_in?
111
- @session_id.is_a? String
112
- end
113
-
114
- #Raises a NoMethodError exception.
115
- #Used for methods that are presents in the API but not yet available
116
- def not_supported
117
- raise NoMethodError.new("This method is not supported and will be available in v1.10 of the API")
118
- end
119
-
120
- end
121
- end
@@ -1,36 +0,0 @@
1
- module Gandi
2
- module DomainModules
3
- module Contact
4
- CONTACT_CLASSES = ['individual', 'company', 'public', 'association']
5
-
6
- #Create a Gandi contact of a given type. See glossary, Account.
7
- #Return the Gandi handle of the created contact
8
- #Note: contact_class argument is used instead of class (due to a ruby keyword conflict)
9
- #TODO check contact class
10
- def contact_create(contact_class, firstname, lastname, address, zipcode, city, country, phone, email, params = {})
11
- args = [contact_class, firstname, lastname, address, zipcode, city, country, phone, email, params]
12
- args.pop if params.empty?
13
-
14
- call('contact_create', *args)
15
- end
16
-
17
- #Update a Gandi contact
18
- #Return the operation attributed ID
19
- #TODO: check for frozen params
20
- def contact_update(handle, params)
21
- call('contact_update', handle, params)
22
- end
23
-
24
- #Delete a Gandi contact
25
- #Return the operation attributed ID
26
- def contact_del(handle)
27
- call('contact_del', handle)
28
- end
29
-
30
- #Retrieve a hash of Gandi contact informations
31
- def contact_info(handle)
32
- call('contact_info', handle)
33
- end
34
- end
35
- end
36
- end