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.
- data/CHANGELOG +6 -0
- data/LICENSE +1 -1
- data/README.rdoc +22 -24
- data/Rakefile +8 -9
- data/USAGE.rdoc +131 -0
- data/gandirb.gemspec +7 -9
- data/lib/gandi/connection.rb +65 -0
- data/lib/gandi/connector.rb +7 -0
- data/lib/gandi/contact.rb +175 -0
- data/lib/gandi/domain/contacts.rb +21 -0
- data/lib/gandi/domain/forward.rb +58 -0
- data/lib/gandi/domain/host.rb +63 -0
- data/lib/gandi/domain/mailbox.rb +72 -0
- data/lib/gandi/domain/nameservers.rb +17 -0
- data/lib/gandi/domain/status.rb +19 -0
- data/lib/gandi/domain/tld.rb +17 -0
- data/lib/gandi/domain/transferin.rb +13 -0
- data/lib/gandi/domain.rb +61 -128
- data/lib/gandi/errors.rb +10 -0
- data/lib/gandi/gandi_object_methods.rb +23 -0
- data/lib/gandi/operation.rb +45 -0
- data/lib/gandi/version.rb +1 -1
- data/lib/gandi.rb +57 -6
- data/spec/gandi/connection_spec.rb +39 -0
- data/spec/gandi/contact_spec.rb +173 -0
- data/spec/gandi/domain/forward_spec.rb +103 -0
- data/spec/gandi/domain/host_spec.rb +103 -0
- data/spec/gandi/domain/mailbox_spec.rb +117 -0
- data/spec/gandi/domain/tld_spec.rb +23 -0
- data/spec/gandi/domain_spec.rb +174 -0
- data/spec/gandi/errors_spec.rb +18 -0
- data/spec/gandi/gandi_spec.rb +57 -0
- data/spec/gandi/operation_spec.rb +73 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/contact_macros.rb +18 -0
- data/spec/support/domain_macros.rb +103 -0
- data/spec/support/operation_macros.rb +22 -0
- metadata +58 -51
- data/lib/gandi/base.rb +0 -121
- data/lib/gandi/domain_modules/contact.rb +0 -36
- data/lib/gandi/domain_modules/host.rb +0 -29
- data/lib/gandi/domain_modules/mail.rb +0 -80
- data/lib/gandi/domain_modules/name_servers.rb +0 -28
- data/lib/gandi/domain_modules/operations.rb +0 -30
- data/lib/gandi/domain_modules/redirection.rb +0 -25
- data/test/gandi/base_test.rb +0 -188
- data/test/gandi/domain_test.rb +0 -301
- data/test/gandi_test.rb +0 -9
- data/test/test_helper.rb +0 -9
@@ -1,29 +0,0 @@
|
|
1
|
-
module Gandi
|
2
|
-
module DomainModules
|
3
|
-
module Host
|
4
|
-
#Returns the array of glue records for the specified domain.
|
5
|
-
def host_list(domain)
|
6
|
-
call('host_list', domain)
|
7
|
-
end
|
8
|
-
|
9
|
-
#Retrieve an array of the IP addresses linked to this hostname.
|
10
|
-
def host_info(fqdn)
|
11
|
-
call('host_info', fqdn)
|
12
|
-
end
|
13
|
-
|
14
|
-
#Create a glue record with the specified IP addresses.
|
15
|
-
#This implementation does not respect the original API specifications and allow for a single IP to be provided.
|
16
|
-
#An array of IPs can be provided but only the first IP is used (this is an API limitation).
|
17
|
-
#Return the operation attributed ID
|
18
|
-
def host_create(host, ip)
|
19
|
-
call('host_create', host, [ip].flatten)
|
20
|
-
end
|
21
|
-
|
22
|
-
#Delete a host.
|
23
|
-
#Return the operation attributed ID
|
24
|
-
def host_delete(host)
|
25
|
-
call('host_delete', host)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module Gandi
|
2
|
-
module DomainModules
|
3
|
-
module Mail
|
4
|
-
|
5
|
-
#Enables the Gandimail service for one domain
|
6
|
-
def domain_gandimail_activate(domain)
|
7
|
-
call('domain_gandimail_activate', domain)
|
8
|
-
end
|
9
|
-
|
10
|
-
#Disables the Gandimail service for one domain: mail servers won't accept mail sent to this domain anymore
|
11
|
-
#Does not delete forwards, aliases or mailboxes
|
12
|
-
def domain_gandimail_deactivate(domain)
|
13
|
-
call('domain_gandimail_deactivate', domain)
|
14
|
-
end
|
15
|
-
|
16
|
-
#Returns a structure associating each forward with its destinations
|
17
|
-
def domain_forward_list(domain)
|
18
|
-
call('domain_forward_list', domain)
|
19
|
-
end
|
20
|
-
|
21
|
-
#Setup a forward to redirect to one or more destinations.
|
22
|
-
#Warning: it overwrites the forward (the source), so if you try to add one destination to a forward, you shall include the existing destinations
|
23
|
-
#TODO: keep existing forwards ?
|
24
|
-
def domain_forward_set(domain, source, destinations)
|
25
|
-
call('domain_forward_set', domain, source, destinations)
|
26
|
-
end
|
27
|
-
|
28
|
-
#Deletes a forward. This does the same thing as domain_forward_set(domain, [])
|
29
|
-
def domain_forward_delete(domain, source)
|
30
|
-
call('domain_forward_delete', domain, source)
|
31
|
-
end
|
32
|
-
|
33
|
-
#Return the list of mailboxes associated with a domain
|
34
|
-
def domain_mailbox_list(domain)
|
35
|
-
call('domain_mailbox_list', domain)
|
36
|
-
end
|
37
|
-
|
38
|
-
#Provides information about a mailbox
|
39
|
-
def domain_mailbox_info(domain, mailbox)
|
40
|
-
call('domain_mailbox_info', domain, mailbox)
|
41
|
-
end
|
42
|
-
|
43
|
-
#Creates a new mailbox
|
44
|
-
#Accepted options:
|
45
|
-
# integer quota
|
46
|
-
# boolean antivirus
|
47
|
-
# boolean antispam
|
48
|
-
# string fallback_email
|
49
|
-
def domain_mailbox_add(domain, mailbox, password, options = {})
|
50
|
-
call('domain_mailbox_add', domain, mailbox, password, options)
|
51
|
-
end
|
52
|
-
|
53
|
-
#Updates an existing mailbox
|
54
|
-
#Accepted options are the same as the ones for domain_mailbox_add, with password added
|
55
|
-
def domain_mailbox_update(domain, mailbox, options)
|
56
|
-
call('domain_mailbox_update', domain, mailbox, options)
|
57
|
-
end
|
58
|
-
|
59
|
-
#Deletes a mailbox
|
60
|
-
def domain_mailbox_delete(domain, mailbox)
|
61
|
-
call('domain_mailbox_delete', domain, mailbox)
|
62
|
-
end
|
63
|
-
|
64
|
-
#List the aliases of a mailbox
|
65
|
-
def domain_mailbox_alias_list(domain, mailbox)
|
66
|
-
call('domain_mailbox_alias_list', domain, mailbox)
|
67
|
-
end
|
68
|
-
|
69
|
-
#Affect aliases to a mailbox
|
70
|
-
def domain_mailbox_alias_set(domain, mailbox, aliases)
|
71
|
-
call('domain_mailbox_alias_set', domain, mailbox, aliases)
|
72
|
-
end
|
73
|
-
|
74
|
-
#Delete all messages from a mailbox
|
75
|
-
def domain_mailbox_purge(domain, mailbox)
|
76
|
-
call('domain_mailbox_purge', domain, mailbox)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Gandi
|
2
|
-
module DomainModules
|
3
|
-
module NameServers
|
4
|
-
#Retrieve an array of name servers for a domain
|
5
|
-
def domain_ns_list(domain)
|
6
|
-
call('domain_ns_list', domain)
|
7
|
-
end
|
8
|
-
|
9
|
-
#Add the specified name servers to the name servers list of a domain
|
10
|
-
#Return the operation attributed ID
|
11
|
-
def domain_ns_add(domain, ns_list)
|
12
|
-
call('domain_ns_add', domain, ns_list)
|
13
|
-
end
|
14
|
-
|
15
|
-
#Remove the specified name servers from the name servers list of a domain
|
16
|
-
#Return the operation attributed ID
|
17
|
-
def domain_ns_del(domain, ns_list)
|
18
|
-
call('domain_ns_del', domain, ns_list)
|
19
|
-
end
|
20
|
-
|
21
|
-
#Set a domain name servers list
|
22
|
-
#Return the operation attributed ID
|
23
|
-
def domain_ns_set(domain, ns_list)
|
24
|
-
call('domain_ns_set', domain, ns_list)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Gandi
|
2
|
-
module DomainModules
|
3
|
-
module Operations
|
4
|
-
#Retrieve an array of the last 300 operation IDs matching the optional criterias
|
5
|
-
def operation_list(filter = {})
|
6
|
-
unless filter.empty?
|
7
|
-
call('operation_list', filter)
|
8
|
-
else
|
9
|
-
call('operation_list')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
#Retrieve an operation details
|
14
|
-
def operation_details(opid)
|
15
|
-
call('operation_details', opid)
|
16
|
-
end
|
17
|
-
|
18
|
-
#Relaunch an operation, modifying the given parameters
|
19
|
-
#TODO: check param
|
20
|
-
def operation_relaunch(opid, param)
|
21
|
-
call('operation_relaunch', opid, param)
|
22
|
-
end
|
23
|
-
|
24
|
-
#Cancel an operation
|
25
|
-
def operation_cancel(opid)
|
26
|
-
call('operation_cancel', opid)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Gandi
|
2
|
-
module DomainModules
|
3
|
-
module Redirection
|
4
|
-
DOMAIN_WEB_REDIR_REDIRECTION_TYPES = ['http302', 'http301', 'cloak']
|
5
|
-
|
6
|
-
#Retrieve an array of web redirections for a domain
|
7
|
-
def domain_web_redir_list(domain)
|
8
|
-
call('domain_web_redir_list', domain)
|
9
|
-
end
|
10
|
-
|
11
|
-
#Add a web redirection to a domain. All HTTP requests to http://fqdn/ will be redirected to 'destination_url' with a HTTP redirection 'type'
|
12
|
-
#Return the operation attributed ID
|
13
|
-
def domain_web_redir_add(fqdn, destination_url, type)
|
14
|
-
raise ArgumentError.new("Redirection type is invalid") unless DOMAIN_WEB_REDIR_REDIRECTION_TYPES.include?(type)
|
15
|
-
call('domain_web_redir_add', fqdn, destination_url, type)
|
16
|
-
end
|
17
|
-
|
18
|
-
#Delete the web redirection of the fully qualified domain name fqdn
|
19
|
-
#Return the operation attributed ID
|
20
|
-
def domain_web_redir_del(fqdn)
|
21
|
-
call('domain_web_redir_del', fqdn)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/test/gandi/base_test.rb
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BaseTest < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@login = 'XX000-Gandi'
|
6
|
-
@password = 'dummy'
|
7
|
-
@uri = Gandi::Domain::TEST_URL
|
8
|
-
|
9
|
-
@session_id = "session id"
|
10
|
-
end
|
11
|
-
|
12
|
-
context "an instance of Gandi::Base without an URL provided" do
|
13
|
-
should "raise an error when trying to initialize" do
|
14
|
-
assert_raise ArgumentError do
|
15
|
-
Gandi::Base.new @login, @password
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
should "raise an error when trying to login directly" do
|
20
|
-
assert_raise ArgumentError do
|
21
|
-
Gandi::Base.login @login, @password
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "an instance of Gandi::Base with an URL provided" do
|
27
|
-
setup do
|
28
|
-
@gandi_base = Gandi::Base.new @login, @password, @uri
|
29
|
-
end
|
30
|
-
|
31
|
-
context "without logging in" do
|
32
|
-
should "raise a runtime error error when trying to call an arbitrary method" do
|
33
|
-
assert_raise RuntimeError do
|
34
|
-
@gandi_base.call "mymethod"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
should "raise a runtime error error when trying to call an account method" do
|
39
|
-
%w(account_balance account_currency).each do |method|
|
40
|
-
assert_raise RuntimeError do
|
41
|
-
@gandi_base.send(method)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
should "raise a runtime error error when trying to su or change password" do
|
47
|
-
assert_raise RuntimeError do
|
48
|
-
@gandi_base.su 'anotherhandle-Gandi'
|
49
|
-
end
|
50
|
-
|
51
|
-
assert_raise RuntimeError do
|
52
|
-
@gandi_base.password 'mypassword'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
should "raise a runtime error error when trying to use raw_call" do
|
57
|
-
assert_raise RuntimeError do
|
58
|
-
@gandi_base.send :raw_call, "mymethod"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
should "have a handler set to nil" do
|
63
|
-
assert @gandi_base.handler.nil?
|
64
|
-
end
|
65
|
-
|
66
|
-
should "have a session id set to nil" do
|
67
|
-
assert @gandi_base.session_id.nil?
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "logging in" do
|
72
|
-
should "raise an error if the account does not exist" do
|
73
|
-
XMLRPC::Client.any_instance.expects(:call).raises(Gandi::DataError.new("DataError: account does not exist [login: #{@login}]"))
|
74
|
-
assert_raise Gandi::DataError do
|
75
|
-
@gandi_base.login
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
should "raise an error if the password is wrong" do
|
80
|
-
XMLRPC::Client.any_instance.expects(:call).raises(Gandi::DataError.new("DataError: invalid value for password [incorrect password]"))
|
81
|
-
assert_raise Gandi::DataError do
|
82
|
-
@gandi_base.login
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "with correct credentials" do
|
87
|
-
setup do
|
88
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns(@session_id)
|
89
|
-
end
|
90
|
-
|
91
|
-
should "return a session string when using correct credentials and store it" do
|
92
|
-
session_id = @gandi_base.login
|
93
|
-
assert session_id.is_a? String
|
94
|
-
assert_equal session_id, @gandi_base.session_id
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "An instance of Gandi::Base using login directly" do
|
101
|
-
setup do
|
102
|
-
XMLRPC::Client.any_instance.expects(:call).at_least_once.with("login", @login, @password, false).returns(@session_id)
|
103
|
-
@gandi_base = Gandi::Base.login @login, @password, @uri
|
104
|
-
end
|
105
|
-
|
106
|
-
should "have a session id" do
|
107
|
-
assert_equal @session_id, @gandi_base.session_id
|
108
|
-
end
|
109
|
-
|
110
|
-
should "have a handler" do
|
111
|
-
assert @gandi_base.handler
|
112
|
-
end
|
113
|
-
|
114
|
-
should "get the account balance" do
|
115
|
-
@gandi_base.handler.expects(:call).with("account_balance", @session_id).returns(1000)
|
116
|
-
assert @gandi_base.account_balance.is_a? Numeric
|
117
|
-
end
|
118
|
-
|
119
|
-
should "get the currency name" do
|
120
|
-
@gandi_base.handler.expects(:call).with("account_currency", @session_id).returns("EUR")
|
121
|
-
assert_match /\w{3}/, @gandi_base.account_currency
|
122
|
-
end
|
123
|
-
|
124
|
-
should "change the session id when suing to another handle" do
|
125
|
-
@gandi_base.handler.expects(:call).with("su", @session_id, "NEWHANDLE-Gandi").returns("new session id")
|
126
|
-
|
127
|
-
@gandi_base.su "NEWHANDLE-Gandi"
|
128
|
-
assert_equal "new session id", @gandi_base.session_id
|
129
|
-
end
|
130
|
-
|
131
|
-
should "change the password" do
|
132
|
-
@gandi_base.handler.expects(:call).with("password", @session_id, "newpassword").returns(true)
|
133
|
-
|
134
|
-
assert @gandi_base.password "newpassword"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "An instance of Gandi::Base expecting failures" do
|
139
|
-
setup do
|
140
|
-
end
|
141
|
-
|
142
|
-
should "retry once when failing after a timeout" do
|
143
|
-
tries = states('tries').starts_as('none')
|
144
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns('sid1').when(tries.is('none')).then(tries.is('first'))
|
145
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns('sid2').when(tries.is('first')).then(tries.is('second'))
|
146
|
-
XMLRPC::Client.any_instance.expects(:call).with("account_balance", 'sid1').raises(EOFError).when(tries.is('first'))
|
147
|
-
XMLRPC::Client.any_instance.expects(:call).with("account_balance", 'sid2').returns(1000).when(tries.is('second'))
|
148
|
-
|
149
|
-
@gandi_base = Gandi::Base.login @login, @password, @uri
|
150
|
-
assert_equal 1000, @gandi_base.account_balance
|
151
|
-
end
|
152
|
-
|
153
|
-
should "fail after trying unsuccesfully two times" do
|
154
|
-
tries = states('tries').starts_as('none')
|
155
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns('sid1').when(tries.is('none')).then(tries.is('first'))
|
156
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns('sid2').when(tries.is('first')).then(tries.is('second'))
|
157
|
-
XMLRPC::Client.any_instance.expects(:call).with("account_balance", 'sid1').raises(EOFError).when(tries.is('first'))
|
158
|
-
XMLRPC::Client.any_instance.expects(:call).with("account_balance", 'sid2').raises(Errno::EPIPE).when(tries.is('second'))
|
159
|
-
|
160
|
-
@gandi_base = Gandi::Base.login @login, @password, @uri
|
161
|
-
|
162
|
-
assert_raise *Gandi::Base::TIMEOUT_EXCEPTIONS do
|
163
|
-
@gandi_base.account_balance
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
should "fail when directly failing on login" do
|
168
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).raises(EOFError)
|
169
|
-
|
170
|
-
assert_raise *Gandi::Base::TIMEOUT_EXCEPTIONS do
|
171
|
-
@gandi_base = Gandi::Base.login @login, @password, @uri
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
should "fail after trying to login when retrying" do
|
176
|
-
tries = states('tries').starts_as('none')
|
177
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).returns('sid1').when(tries.is('none')).then(tries.is('first'))
|
178
|
-
XMLRPC::Client.any_instance.expects(:call).with("login", @login, @password, false).raises(EOFError).when(tries.is('first')).then(tries.is('second'))
|
179
|
-
XMLRPC::Client.any_instance.expects(:call).with("account_balance", 'sid1').raises(EOFError).when(tries.is('first'))
|
180
|
-
|
181
|
-
@gandi_base = Gandi::Base.login @login, @password, @uri
|
182
|
-
|
183
|
-
assert_raise *Gandi::Base::TIMEOUT_EXCEPTIONS do
|
184
|
-
@gandi_base.account_balance
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
data/test/gandi/domain_test.rb
DELETED
@@ -1,301 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DomainTest < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@login = 'XX000-Gandi'
|
6
|
-
@password = 'dummy'
|
7
|
-
@uri = Gandi::Domain::TEST_URL
|
8
|
-
|
9
|
-
@session_id = "session id"
|
10
|
-
@sample_domain_name = "mydomain.com"
|
11
|
-
end
|
12
|
-
|
13
|
-
context "a new logged in Gandi::Domain instance" do
|
14
|
-
setup do
|
15
|
-
XMLRPC::Client.any_instance.expects(:call).at_least_once.with("login", @login, @password, false).returns(@session_id)
|
16
|
-
@gandi_domain = Gandi::Domain.login @login, @password, @uri
|
17
|
-
end
|
18
|
-
|
19
|
-
should "get domain list" do
|
20
|
-
@gandi_domain.handler.expects(:call).with("domain_list", @session_id).returns(["mydomain.com"])
|
21
|
-
|
22
|
-
assert @gandi_domain.domain_list.is_a? Array
|
23
|
-
end
|
24
|
-
|
25
|
-
context "mocking domain_available calls" do
|
26
|
-
setup do
|
27
|
-
@gandi_domain.handler.expects(:call).with("domain_available", @session_id, ['testdomain.com']).returns({"testdomain.com" => false})
|
28
|
-
end
|
29
|
-
|
30
|
-
should "return a hash when providing an array" do
|
31
|
-
assert_equal({"testdomain.com" => false}, @gandi_domain.domain_available(['testdomain.com']))
|
32
|
-
end
|
33
|
-
|
34
|
-
should "return a boolean when providing a single domain" do
|
35
|
-
assert_equal false, @gandi_domain.domain_available('testdomain.com')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "with an existing domain" do
|
40
|
-
should "lock a domain" do
|
41
|
-
@gandi_domain.handler.expects(:call).with("domain_lock", @session_id, @sample_domain_name).returns(rand(9000))
|
42
|
-
|
43
|
-
assert @gandi_domain.domain_lock(@sample_domain_name).is_a? Integer
|
44
|
-
end
|
45
|
-
|
46
|
-
should "unlock a domain" do
|
47
|
-
@gandi_domain.handler.expects(:call).with("domain_unlock", @session_id, @sample_domain_name).returns(rand(9000))
|
48
|
-
|
49
|
-
assert @gandi_domain.domain_unlock(@sample_domain_name).is_a? Integer
|
50
|
-
end
|
51
|
-
|
52
|
-
#TODO: better test (use a hash similar to a real api call result)
|
53
|
-
should "get infos on a domain" do
|
54
|
-
@gandi_domain.handler.expects(:call).with("domain_info", @session_id, @sample_domain_name).returns({})
|
55
|
-
|
56
|
-
assert @gandi_domain.domain_info(@sample_domain_name).is_a? Hash
|
57
|
-
end
|
58
|
-
|
59
|
-
should "renew a domain for 8 years" do
|
60
|
-
@gandi_domain.handler.expects(:call).with("domain_renew", @session_id, @sample_domain_name, 8).returns(rand(9000))
|
61
|
-
|
62
|
-
assert @gandi_domain.domain_renew(@sample_domain_name, 8).is_a? Integer
|
63
|
-
end
|
64
|
-
|
65
|
-
should "not renew a domain for 11 years" do
|
66
|
-
assert_raise ArgumentError do
|
67
|
-
@gandi_domain.domain_renew(@sample_domain_name, 11)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
should "restore a domain" do
|
72
|
-
@gandi_domain.handler.expects(:call).with("domain_restore", @session_id, @sample_domain_name).returns(rand(9000))
|
73
|
-
|
74
|
-
assert @gandi_domain.domain_restore(@sample_domain_name).is_a? Integer
|
75
|
-
end
|
76
|
-
|
77
|
-
should "not delete a domain" do
|
78
|
-
assert_raise NoMethodError do
|
79
|
-
@gandi_domain.domain_del(@sample_domain_name)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
should "check if domain can be transferred" do
|
84
|
-
@gandi_domain.handler.expects(:call).with("domain_transfer_in_available", @session_id, @sample_domain_name).twice.returns(true)
|
85
|
-
|
86
|
-
available = @gandi_domain.domain_transfer_in_available(@sample_domain_name)
|
87
|
-
assert_equal true, available
|
88
|
-
|
89
|
-
assert_equal available, @gandi_domain.domain_transfer_in_available?(@sample_domain_name)
|
90
|
-
end
|
91
|
-
|
92
|
-
should "transfer a domain in" do
|
93
|
-
owner_handle, admin_handle, tech_handle, billing_handle = 'owner_handle', "admin_handle", 'tech_handle', 'billing_handle'
|
94
|
-
nameservers = ['127.0.0.1']
|
95
|
-
@gandi_domain.handler.expects(:call).with("domain_transfer_in", @session_id, @sample_domain_name, owner_handle, admin_handle, tech_handle, billing_handle, nameservers).returns(rand(9000))
|
96
|
-
|
97
|
-
assert @gandi_domain.domain_transfer_in(@sample_domain_name, owner_handle, admin_handle, tech_handle, billing_handle, nameservers).is_a? Integer
|
98
|
-
end
|
99
|
-
|
100
|
-
should "not transfer a domain out" do
|
101
|
-
assert_raise NoMethodError do
|
102
|
-
@gandi_domain.domain_transfer_out(@sample_domain_name, true)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
should "not trade a domain" do
|
107
|
-
assert_raise NoMethodError do
|
108
|
-
@gandi_domain.domain_trade(@sample_domain_name, 'owner_handle', 'admin_handle', 'tech_handle', 'billing_handle')
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
should "not change owner of a domain" do
|
113
|
-
assert_raise NoMethodError do
|
114
|
-
@gandi_domain.domain_change_owner(@sample_domain_name, 'new_owner')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
should "change contact for a domain" do
|
119
|
-
@gandi_domain.handler.expects(:call).with("domain_change_contact", @session_id, @sample_domain_name, 'admin', 'new-handle').returns(rand(9000))
|
120
|
-
|
121
|
-
assert @gandi_domain.domain_change_contact(@sample_domain_name, 'admin', 'new-handle').is_a? Integer
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
should "create a domain" do
|
126
|
-
domain, period, owner_handle, admin_handle, tech_handle, billing_handle = 'mynewdomain.com', 7, 'owner_handle', "admin_handle", 'tech_handle', 'billing_handle'
|
127
|
-
nameservers = ['127.0.0.1']
|
128
|
-
@gandi_domain.handler.expects(:call).with("domain_create", @session_id, domain, period, owner_handle, admin_handle, tech_handle, billing_handle, nameservers).returns(rand(9000))
|
129
|
-
|
130
|
-
assert @gandi_domain.domain_create(domain, period, owner_handle, admin_handle, tech_handle, billing_handle, nameservers).is_a? Integer
|
131
|
-
end
|
132
|
-
|
133
|
-
should "get domains list" do
|
134
|
-
tlds = ["info", "be", "eu", "name", "biz", "us", "org", "com", "net", "mobi", "ch", "li", "at", "asia", "de", "nu", "cz", "tw", "es", "lu", "pl", "pro", "me", "in"]
|
135
|
-
|
136
|
-
@gandi_domain.handler.expects(:call).with("tld_list", @session_id).returns(tlds)
|
137
|
-
|
138
|
-
assert_equal tlds, @gandi_domain.tld_list
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
should "list name servers for a domain" do
|
143
|
-
@gandi_domain.handler.expects(:call).with("domain_ns_list", @session_id, @sample_domain_name).returns([])
|
144
|
-
|
145
|
-
assert @gandi_domain.domain_ns_list(@sample_domain_name).is_a? Array
|
146
|
-
end
|
147
|
-
|
148
|
-
should "add name servers for a domain" do
|
149
|
-
@gandi_domain.handler.expects(:call).with("domain_ns_add", @session_id, @sample_domain_name, ['127.0.0.1']).returns(rand(9000))
|
150
|
-
|
151
|
-
assert @gandi_domain.domain_ns_add(@sample_domain_name, ['127.0.0.1']).is_a? Integer
|
152
|
-
end
|
153
|
-
|
154
|
-
should "remove name servers for a domain" do
|
155
|
-
@gandi_domain.handler.expects(:call).with("domain_ns_del", @session_id, @sample_domain_name, ['127.0.0.1']).returns(rand(9000))
|
156
|
-
|
157
|
-
assert @gandi_domain.domain_ns_del(@sample_domain_name, ['127.0.0.1']).is_a? Integer
|
158
|
-
end
|
159
|
-
|
160
|
-
should "set name servers for a domain" do
|
161
|
-
@gandi_domain.handler.expects(:call).with("domain_ns_set", @session_id, @sample_domain_name, ['127.0.0.1']).returns(rand(9000))
|
162
|
-
|
163
|
-
assert @gandi_domain.domain_ns_set(@sample_domain_name, ['127.0.0.1']).is_a? Integer
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
should "list hosts for a domain" do
|
168
|
-
@gandi_domain.handler.expects(:call).with("host_list", @session_id, @sample_domain_name).returns([])
|
169
|
-
|
170
|
-
assert @gandi_domain.host_list(@sample_domain_name).is_a? Array
|
171
|
-
end
|
172
|
-
|
173
|
-
should "get IPs for a domain" do
|
174
|
-
ips = ['127.0.0.1']
|
175
|
-
@gandi_domain.handler.expects(:call).with("host_info", @session_id, @sample_domain_name).returns(ips)
|
176
|
-
|
177
|
-
assert @gandi_domain.host_info(@sample_domain_name).is_a? Array
|
178
|
-
end
|
179
|
-
|
180
|
-
should "create a glue record for a host when providing multiple IPs" do
|
181
|
-
ip_list = ["1.2.3.4", "1.2.3.5"]
|
182
|
-
@gandi_domain.handler.expects(:call).with("host_create", @session_id, @sample_domain_name, ip_list).returns(rand(9000))
|
183
|
-
|
184
|
-
assert @gandi_domain.host_create(@sample_domain_name, ip_list).is_a? Integer
|
185
|
-
end
|
186
|
-
|
187
|
-
should "create a glue record for a host when providing an unique IP" do
|
188
|
-
ip = "1.2.3.4"
|
189
|
-
@gandi_domain.handler.expects(:call).with("host_create", @session_id, @sample_domain_name, [ip]).returns(rand(9000))
|
190
|
-
|
191
|
-
assert @gandi_domain.host_create(@sample_domain_name, ip).is_a? Integer
|
192
|
-
end
|
193
|
-
|
194
|
-
should "delete a host" do
|
195
|
-
@gandi_domain.handler.expects(:call).with("host_delete", @session_id, @sample_domain_name).returns(rand(9000))
|
196
|
-
|
197
|
-
assert @gandi_domain.host_delete(@sample_domain_name).is_a? Integer
|
198
|
-
end
|
199
|
-
|
200
|
-
|
201
|
-
should "list redirections for a domain" do
|
202
|
-
redirections = [{"type" => "http302", "from" => "w3.example.net", "to" => "http://www.example.net"}]
|
203
|
-
@gandi_domain.handler.expects(:call).with("domain_web_redir_list", @session_id, @sample_domain_name).returns(redirections)
|
204
|
-
|
205
|
-
assert_equal redirections, @gandi_domain.domain_web_redir_list(@sample_domain_name)
|
206
|
-
end
|
207
|
-
|
208
|
-
should "check redirection type when adding a redirection for a domain" do
|
209
|
-
destination_url = "http://www.example.net"
|
210
|
-
|
211
|
-
calls = states('calls').starts_as('none')
|
212
|
-
@gandi_domain.handler.expects(:call).with("domain_web_redir_add", @session_id, @sample_domain_name, destination_url, 'http302').returns(rand(9000)).when(calls.is('none')).then(calls.is('first'))
|
213
|
-
@gandi_domain.handler.expects(:call).with("domain_web_redir_add", @session_id, @sample_domain_name, destination_url, 'http301').returns(rand(9000)).when(calls.is('first')).then(calls.is('second'))
|
214
|
-
@gandi_domain.handler.expects(:call).with("domain_web_redir_add", @session_id, @sample_domain_name, destination_url, 'cloak').returns(rand(9000)).when(calls.is('second'))
|
215
|
-
|
216
|
-
Gandi::DomainModules::Redirection::DOMAIN_WEB_REDIR_REDIRECTION_TYPES.each do |type|
|
217
|
-
assert @gandi_domain.domain_web_redir_add(@sample_domain_name, destination_url, type).is_a? Integer
|
218
|
-
end
|
219
|
-
|
220
|
-
assert_raise ArgumentError do
|
221
|
-
@gandi_domain.domain_web_redir_add(@sample_domain_name, destination_url, 'bad')
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
should "delete the redirection on a fqdn" do
|
226
|
-
@gandi_domain.handler.expects(:call).with("domain_web_redir_del", @session_id, 'w3.example.net').returns(rand(9000))
|
227
|
-
|
228
|
-
assert @gandi_domain.domain_web_redir_del('w3.example.net').is_a? Integer
|
229
|
-
end
|
230
|
-
|
231
|
-
|
232
|
-
should "create a contact" do
|
233
|
-
contact_class, firstname, lastname, address, zipcode, city, country, phone, email = 'individual', 'John', 'Doe', '24 Rue du Pont', '13000', 'Mars', 'France', '+33491909090', 'john@doe.com'
|
234
|
-
@gandi_domain.handler.expects(:call).with("contact_create", @session_id, contact_class, firstname, lastname, address, zipcode, city, country, phone, email).returns('XXXZZ-Gandi')
|
235
|
-
|
236
|
-
assert_match /.+-Gandi/, @gandi_domain.contact_create(contact_class, firstname, lastname, address, zipcode, city, country, phone, email)
|
237
|
-
end
|
238
|
-
|
239
|
-
should "update a contact" do
|
240
|
-
handle = 'XXXYY-Gandi'
|
241
|
-
params = {}
|
242
|
-
@gandi_domain.handler.expects(:call).with("contact_update", @session_id, handle, params).returns(rand(9000))
|
243
|
-
|
244
|
-
assert @gandi_domain.contact_update(handle, params).is_a? Integer
|
245
|
-
end
|
246
|
-
|
247
|
-
should "delete a contact" do
|
248
|
-
handle = 'XXXYY-Gandi'
|
249
|
-
@gandi_domain.handler.expects(:call).with("contact_del", @session_id, handle).returns(rand(9000))
|
250
|
-
|
251
|
-
assert @gandi_domain.contact_del(handle).is_a? Integer
|
252
|
-
end
|
253
|
-
|
254
|
-
should "retrieve infos on a contact" do
|
255
|
-
handle = 'XXXYY-Gandi'
|
256
|
-
infos = {}
|
257
|
-
@gandi_domain.handler.expects(:call).with("contact_info", @session_id, handle).returns(infos)
|
258
|
-
|
259
|
-
assert @gandi_domain.contact_info(handle).is_a? Hash
|
260
|
-
end
|
261
|
-
|
262
|
-
|
263
|
-
should "list operations" do
|
264
|
-
operations = [5555, 5642, 6213]
|
265
|
-
@gandi_domain.handler.expects(:call).with("operation_list", @session_id).returns(operations)
|
266
|
-
|
267
|
-
assert_equal operations, @gandi_domain.operation_list()
|
268
|
-
end
|
269
|
-
|
270
|
-
should "list pending operations with a filter" do
|
271
|
-
operations = [5555]
|
272
|
-
filter = {'state' => 'PENDING'}
|
273
|
-
@gandi_domain.handler.expects(:call).with("operation_list", @session_id, filter).returns(operations)
|
274
|
-
|
275
|
-
assert_equal operations, @gandi_domain.operation_list(filter)
|
276
|
-
end
|
277
|
-
|
278
|
-
should "get operation details" do
|
279
|
-
opid = 5555
|
280
|
-
details = {}
|
281
|
-
@gandi_domain.handler.expects(:call).with("operation_details", @session_id, opid).returns(details)
|
282
|
-
|
283
|
-
assert @gandi_domain.operation_details(opid).is_a? Hash
|
284
|
-
end
|
285
|
-
|
286
|
-
should "relaunch an operation" do
|
287
|
-
opid = 5555
|
288
|
-
param = {'authcode' => 'xxxyyyzzz'}
|
289
|
-
@gandi_domain.handler.expects(:call).with("operation_relaunch", @session_id, opid, param).returns(true)
|
290
|
-
|
291
|
-
assert @gandi_domain.operation_relaunch(opid, param)
|
292
|
-
end
|
293
|
-
|
294
|
-
should "cancel an operation" do
|
295
|
-
opid = 5555
|
296
|
-
@gandi_domain.handler.expects(:call).with("operation_cancel", @session_id, opid).returns(true)
|
297
|
-
|
298
|
-
assert @gandi_domain.operation_cancel(opid)
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|