moo_moo 0.1.0 → 0.1.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.
- data/.travis.yml +3 -1
- data/README.md +29 -14
- data/lib/moo_moo/exceptions.rb +4 -0
- data/lib/moo_moo/opensrs/args.rb +86 -86
- data/lib/moo_moo/opensrs/base.rb +9 -11
- data/lib/moo_moo/opensrs.rb +9 -4
- data/lib/moo_moo/version.rb +1 -1
- data/lib/moo_moo.rb +2 -0
- data/moo_moo.gemspec +3 -7
- data/spec/moo_moo/config_spec.rb +12 -0
- data/spec/moo_moo/opensrs/args_spec.rb +176 -0
- data/spec/moo_moo/opensrs/base_spec.rb +22 -0
- data/spec/moo_moo/opensrs/cookie_spec.rb +76 -0
- data/spec/moo_moo/opensrs/lookup_spec.rb +208 -0
- data/spec/moo_moo/opensrs/nameserver_spec.rb +136 -0
- data/spec/moo_moo/opensrs/provisioning_spec.rb +198 -0
- data/spec/moo_moo/opensrs/transfer_spec.rb +124 -0
- data/spec/moo_moo_spec.rb +16 -0
- data/spec/spec_helper.rb +36 -5
- metadata +79 -105
- data/lib/moo_moo/opensrs/opensrsexception.rb +0 -6
- data/lib/moo_moo/opensrs/utils.rb +0 -13
- data/spec/opensrs/args_spec.rb +0 -179
- data/spec/opensrs/cookie_spec.rb +0 -78
- data/spec/opensrs/lookup_spec.rb +0 -212
- data/spec/opensrs/nameserver_spec.rb +0 -124
- data/spec/opensrs/opensrs_spec.rb +0 -35
- data/spec/opensrs/provisioning_spec.rb +0 -271
- data/spec/opensrs/transfer_spec.rb +0 -197
- data/spec/opensrs/utils_spec.rb +0 -12
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
describe MooMoo::OpenSRS::LookupCommands do
|
5
|
+
before(:each) do
|
6
|
+
@opensrs = MooMoo::OpenSRS::Base.new
|
7
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#belongs_to_rsp" do
|
11
|
+
it "returns false for a domain that is not owned by the rsp" do
|
12
|
+
VCR.use_cassette("lookup/belongs_to_rsp") do
|
13
|
+
res = @opensrs.belongs_to_rsp?('example.com')
|
14
|
+
res.result['belongs_to_rsp'].to_i.should == 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns true for a domain owned by the rsp" do
|
19
|
+
VCR.use_cassette("lookup/belongs_to_rsp_negative") do
|
20
|
+
res = @opensrs.belongs_to_rsp?(@registered_domain)
|
21
|
+
res.result['belongs_to_rsp'].to_i.should == 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#get_balance" do
|
27
|
+
use_vcr_cassette "lookup/get_balance"
|
28
|
+
|
29
|
+
it "returns the balance" do
|
30
|
+
res = @opensrs.get_balance
|
31
|
+
res.result['balance'].to_f.should == 7312.24
|
32
|
+
res.result['hold_balance'].to_f.should == 11.44
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#get_deleted_domains" do
|
37
|
+
use_vcr_cassette "lookup/get_deleted_domains"
|
38
|
+
|
39
|
+
it "returns domains that have been deleted" do
|
40
|
+
result = @opensrs.get_deleted_domains.result
|
41
|
+
result['total'].to_i.should == 2
|
42
|
+
result['del_domains']['0']['name'].should == "example.com"
|
43
|
+
result['del_domains']['0']['delete_date_epoch'].should == "1294426313"
|
44
|
+
result['del_domains']['0']['expiredate_epoch'].should == "1325980310"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#get domain" do
|
49
|
+
it "returns all the info" do
|
50
|
+
VCR.use_cassette("lookup/get_domain") do
|
51
|
+
res = @opensrs.set_cookie(
|
52
|
+
:username => MooMoo.config.user,
|
53
|
+
:password => MooMoo.config.pass,
|
54
|
+
:domain => @registered_domain
|
55
|
+
)
|
56
|
+
result = @opensrs.get_domain(:cookie => res.result['cookie']).result
|
57
|
+
result['auto_renew'].to_i.should == 1
|
58
|
+
result['contact_set']['admin']['org_name'].should == "Example Inc."
|
59
|
+
result['nameserver_list']['0']['name'].should == "ns2.systemdns.com"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#get_domains_contacts" do
|
65
|
+
it "returns the domain's contacts" do
|
66
|
+
VCR.use_cassette("lookup/get_domains_contacts") do
|
67
|
+
result = @opensrs.get_domains_contacts(@registered_domain).result
|
68
|
+
result[@registered_domain]['contact_set']['owner']['address2'].should == "Suite 500"
|
69
|
+
result[@registered_domain]['contact_set']['billing']['org_name'].should == "Example Inc."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "fails for a domain that is not in the registry" do
|
74
|
+
VCR.use_cassette("lookup/get_domains_contacts_fail") do
|
75
|
+
res = @opensrs.get_domains_contacts('example.com')
|
76
|
+
res.success?.should be_true
|
77
|
+
res.result['example.com']['error'].should match(/Domain does not belong to the reseller/i)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#get_domains_by_expiredate" do
|
83
|
+
use_vcr_cassette "lookup/get_domains_by_expiredate"
|
84
|
+
|
85
|
+
it "requires a start date", :wip => true do
|
86
|
+
requires_attr(:start_date) do
|
87
|
+
@opensrs.get_domains_by_expiredate(:end_date => Date.parse('2011-04-21'))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "requires an end date", :wip => true do
|
92
|
+
requires_attr(:end_date) do
|
93
|
+
@opensrs.get_domains_by_expiredate(:start_date => Date.parse('2011-04-21'))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "returns domains within an expiration range" do
|
98
|
+
result = @opensrs.get_domains_by_expiredate(
|
99
|
+
:start_date => Date.parse('2011-04-21'),
|
100
|
+
:end_date => Date.parse('2011-04-21') + 365
|
101
|
+
).result
|
102
|
+
result['total'].to_i.should == 2
|
103
|
+
result['exp_domains']['0']['name'].should == "example.com"
|
104
|
+
result['exp_domains']['0']['f_auto_renew'].should == "N"
|
105
|
+
result['exp_domains']['0']['f_let_expire'].should == "N"
|
106
|
+
result['exp_domains']['0']['expiredate'].should == "2011-11-03 16:14:46"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#get_notes" do
|
111
|
+
it "returns the notes for a domain" do
|
112
|
+
VCR.use_cassette("lookup/get_notes_for_domain") do
|
113
|
+
result = @opensrs.get_notes_for_domain(@registered_domain).result
|
114
|
+
result['total'].to_i.should == 4
|
115
|
+
result['notes']['1']['note'].should match(/Order.*?\d+.*?Domain Registration.*?1 year/i)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns the notes for an order" do
|
120
|
+
VCR.use_cassette("lookup/get_notes_for_order") do
|
121
|
+
result = @opensrs.get_notes_for_order(:domain => @registered_domain, :order_id => 1855625).result
|
122
|
+
result['page'].to_i.should == 1
|
123
|
+
result['notes'].should be_a_kind_of(Hash)
|
124
|
+
result['notes'].should be_empty
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns the notes for a transfer" do
|
129
|
+
VCR.use_cassette("lookup/get_notes_for_transfer") do
|
130
|
+
res = @opensrs.get_notes_for_transfer(:domain => "testingdomain.com", :transfer_id => 37021)
|
131
|
+
res.success?.should be_true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#get_order_info" do
|
137
|
+
use_vcr_cassette "lookup/get_order_info"
|
138
|
+
|
139
|
+
it "returns the order info" do
|
140
|
+
result = @opensrs.get_order_info(1855625).result['field_hash']
|
141
|
+
result['owner_address2'].should == "Suite 500"
|
142
|
+
result['billing_org_name'].should == "Example Inc."
|
143
|
+
result['period'].to_i.should == 1
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "#get_orders_by_domain" do
|
148
|
+
use_vcr_cassette "lookup/get_orders_by_domain"
|
149
|
+
|
150
|
+
it "returns the orders for a domain" do
|
151
|
+
result = @opensrs.get_orders_by_domain(@registered_domain).result
|
152
|
+
result['orders'].should be_a_kind_of(Hash)
|
153
|
+
result['orders'].should have(2).domains
|
154
|
+
result['orders']['0']['id'].to_i.should == 1862773
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#get_price" do
|
159
|
+
use_vcr_cassette "lookup/get_price"
|
160
|
+
|
161
|
+
it "returns the price" do
|
162
|
+
res = @opensrs.get_price('example.com')
|
163
|
+
res.result['price'].to_f.should == 11.62
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#get_product_info" do
|
168
|
+
use_vcr_cassette "lookup/get_product_info"
|
169
|
+
|
170
|
+
it "fails to find an invalid product" do
|
171
|
+
res = @opensrs.get_product_info(99)
|
172
|
+
res.success?.should be_false
|
173
|
+
res.error_code.should == 405
|
174
|
+
res.error_msg.should match(/cannot be found/i)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "#lookup domain" do
|
179
|
+
it "returns the availbility of an available domain" do
|
180
|
+
VCR.use_cassette("lookup/lookup_domain_available") do
|
181
|
+
result = @opensrs.lookup_domain('example.com').result
|
182
|
+
result['status'].should == "available"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
it "returns the availability of a registered domain" do
|
187
|
+
VCR.use_cassette("lookup/lookup_domain_registered") do
|
188
|
+
result = @opensrs.lookup_domain(@registered_domain).result
|
189
|
+
result['status'].should == "taken"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe "#name_suggest" do
|
195
|
+
use_vcr_cassette "lookup/name_suggest"
|
196
|
+
|
197
|
+
it "returns suggested names for a domain" do
|
198
|
+
result = @opensrs.name_suggest("random_domain", [".com", ".net"]).result
|
199
|
+
result['lookup']['count'].to_i.should == 4
|
200
|
+
result['lookup']['items']['0']['domain'].should == "randomdomain.com"
|
201
|
+
result['lookup']['items']['0']['status'].should == "taken"
|
202
|
+
|
203
|
+
result['suggestion']['count'].to_i.should == 49
|
204
|
+
result['suggestion']['items']['0']['domain'].should == "aimlessdomain.com"
|
205
|
+
result['suggestion']['items']['0']['status'].should == "available"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::OpenSRS::NameserverCommands do
|
4
|
+
before(:each) do
|
5
|
+
@opensrs = MooMoo::OpenSRS::Base.new
|
6
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#create_nameserver" do
|
10
|
+
use_vcr_cassette "nameserver/create"
|
11
|
+
|
12
|
+
it "requires a name", :wip => true do
|
13
|
+
requires_attr(:name) do
|
14
|
+
@opensrs.create_nameserver(:ip => '123.123.123.123', :domain => 'example.com')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "requires a ip", :wip => true do
|
19
|
+
requires_attr(:ip) do
|
20
|
+
@opensrs.create_nameserver(:name => 'blah', :domain => 'example.com')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "requires a domain", :wip => true do
|
25
|
+
requires_attr(:domain) do
|
26
|
+
@opensrs.create_nameserver(:name => 'blah', :ip => '123.123.123.123')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "creates the nameserver" do
|
31
|
+
res = @opensrs.create_nameserver(
|
32
|
+
:name => "ns1.#{@registered_domain}",
|
33
|
+
:ip => '212.112.123.11',
|
34
|
+
:domain => @registered_domain
|
35
|
+
)
|
36
|
+
res.success?.should be_true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#delete_nameserver" do
|
41
|
+
use_vcr_cassette "nameserver/delete"
|
42
|
+
|
43
|
+
it "requires a name", :wip => true do
|
44
|
+
requires_attr(:name) do
|
45
|
+
@opensrs.delete_nameserver(:ip => '123.123.123.123', :domain => 'example.com')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "requires a ip", :wip => true do
|
50
|
+
requires_attr(:ip) do
|
51
|
+
@opensrs.delete_nameserver(:name => 'blah', :domain => 'example.com')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "requires a domain", :wip => true do
|
56
|
+
requires_attr(:domain) do
|
57
|
+
@opensrs.delete_nameserver(:name => 'blah', :ip => '123.123.123.123')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "deletes the nameserver" do
|
62
|
+
res = @opensrs.delete_nameserver(
|
63
|
+
:name => "ns1.#{@registered_domain}",
|
64
|
+
:ip => '212.112.123.11',
|
65
|
+
:domain => @registered_domain
|
66
|
+
)
|
67
|
+
res.success?.should be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#get_nameserver" do
|
72
|
+
use_vcr_cassette "nameserver/get"
|
73
|
+
|
74
|
+
it "returns the nameservers" do
|
75
|
+
res = @opensrs.get_nameserver(@registered_domain)
|
76
|
+
result = res.result['nameserver_list']
|
77
|
+
result.should have(2).nameservers
|
78
|
+
result['0']['name'].should == "ns1.#{@registered_domain}"
|
79
|
+
result['1']['ipaddress'].should == "212.112.123.12"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#modify_nameserver" do
|
84
|
+
use_vcr_cassette "nameserver/modify"
|
85
|
+
|
86
|
+
it "requires a name", :wip => true do
|
87
|
+
requires_attr(:name) do
|
88
|
+
@opensrs.modify_nameserver(
|
89
|
+
:ip => '123.123.123.123',
|
90
|
+
:new_name => 'blah',
|
91
|
+
:domain => 'example.com'
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "requires a ip", :wip => true do
|
97
|
+
requires_attr(:ip) do
|
98
|
+
@opensrs.modify_nameserver(
|
99
|
+
:name => 'blah',
|
100
|
+
:new_name => 'blah',
|
101
|
+
:domain => 'example.com'
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "requires a domain", :wip => true do
|
107
|
+
requires_attr(:domain) do
|
108
|
+
@opensrs.modify_nameserver(
|
109
|
+
:name => 'blah',
|
110
|
+
:ip => '123.123.123.123',
|
111
|
+
:new_name => 'blah'
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
it "requires a new_name", :wip => true do
|
117
|
+
requires_attr(:new_name) do
|
118
|
+
@opensrs.modify_nameserver(
|
119
|
+
:name => 'blah',
|
120
|
+
:ip => '123.123.123.123',
|
121
|
+
:domain => 'example.com'
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it "updates the name of the nameserver" do
|
127
|
+
res = @opensrs.modify_nameserver(
|
128
|
+
:name => "ns22.#{@registered_domain}",
|
129
|
+
:ip => '212.112.123.11',
|
130
|
+
:new_name => "ns3.#{@registered_domain}",
|
131
|
+
:domain => @registered_domain
|
132
|
+
)
|
133
|
+
res.success?.should be_true
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
|
5
|
+
describe MooMoo::OpenSRS::ProvisioningCommands do
|
6
|
+
before(:each) do
|
7
|
+
@opensrs = MooMoo::OpenSRS::Base.new
|
8
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
9
|
+
@contacts = test_contacts
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#cancel_order" do
|
13
|
+
it "cancels a trust service order" do
|
14
|
+
VCR.use_cassette("provisioning/cancel_order") do
|
15
|
+
res = @opensrs.cancel_order(123456)
|
16
|
+
res.success?.should be_true
|
17
|
+
res.result['order_id'].to_i.should == 123456
|
18
|
+
res.result['domain'].should == "example.com"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't cancel an invalid trust service order" do
|
23
|
+
VCR.use_cassette("provisioning/cancel_order_invalid") do
|
24
|
+
res = @opensrs.cancel_order(111111)
|
25
|
+
res.success?.should be_false
|
26
|
+
res.error_code.should == 405
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#cancel_pending_orders" do
|
32
|
+
use_vcr_cassette "provisioning/cancel_pending_orders"
|
33
|
+
|
34
|
+
it "cancels all pending orders" do
|
35
|
+
result = @opensrs.cancel_pending_orders(1302890914).result
|
36
|
+
result['total'].to_i.should == 0
|
37
|
+
result['cancelled'].should be_a_kind_of(Hash)
|
38
|
+
result['cancelled'].should be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#modify domain" do
|
43
|
+
it "updates the contact information" do
|
44
|
+
end
|
45
|
+
|
46
|
+
it "updates the expire action" do
|
47
|
+
VCR.use_cassette("provisioning/modify_domain") do
|
48
|
+
res = @opensrs.modify({:type => 'expire_action', :domain => @registered_domain, :auto_renew => 1, :let_expire => 0})
|
49
|
+
res.success?.should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "modifies all domains linked to the profile" do
|
54
|
+
VCR.use_cassette("provisioning/modify_all_domains") do
|
55
|
+
res = @opensrs.modify({
|
56
|
+
:type => 'expire_action',
|
57
|
+
:affect_domains => 1,
|
58
|
+
:auto_renew => 0,
|
59
|
+
:let_expire => 1,
|
60
|
+
:cookie => "0000000000000000:000000:00000"})
|
61
|
+
res.success?.should == true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#process_pending" do
|
67
|
+
use_vcr_cassette "provisioning/process_pending"
|
68
|
+
|
69
|
+
it "processes the pending order" do
|
70
|
+
result = @opensrs.process_pending(1878084).result
|
71
|
+
result['order_id'].to_i.should == 1878084
|
72
|
+
result['id'].to_i.should == 730001
|
73
|
+
result['f_auto_renew'].should == "Y"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#renew_domain" do
|
78
|
+
use_vcr_cassette "provisioning/renew_domain"
|
79
|
+
|
80
|
+
it "requires a domain", :wip => true do
|
81
|
+
requires_attr(:domain) { @opensrs.renew_domain(:term => 1, :current_expiration_year => 2011) }
|
82
|
+
end
|
83
|
+
|
84
|
+
it "requires a term", :wip => true do
|
85
|
+
requires_attr(:term) { @opensrs.renew_domain(:domain => 'example.com', :current_expiration_year => 2011) }
|
86
|
+
end
|
87
|
+
|
88
|
+
it "requires a current_expiration_year", :wip => true do
|
89
|
+
requires_attr(:current_expiration_year) { @opensrs.renew_domain(:domain => 'example.com', :term => 1) }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "renews the domain" do
|
93
|
+
result = @opensrs.renew_domain(
|
94
|
+
:domain => "example.com",
|
95
|
+
:term => 1,
|
96
|
+
:current_expiration_year => 2011
|
97
|
+
).result
|
98
|
+
result['order_id'].to_i.should == 1867227
|
99
|
+
result['id'].to_i.should == 678899
|
100
|
+
result['admin_email'].should == "adams@example.com"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#revoke domain" do
|
105
|
+
use_vcr_cassette "provisioning/revoke_domain"
|
106
|
+
|
107
|
+
it "removes the domain from the registry" do
|
108
|
+
res = @opensrs.revoke(:domain => "example.com", :reseller => MooMoo.config.user)
|
109
|
+
res.success?.should be_true
|
110
|
+
res.result['charge'].to_i.should == 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#register" do
|
115
|
+
it "requires a domain", :wip => true do
|
116
|
+
requires_attr(:domain) { @opensrs.register_domain(:contacts => @contacts, :nameservers => ['ns1.blah.com']) }
|
117
|
+
end
|
118
|
+
|
119
|
+
it "requires a contacts", :wip => true do
|
120
|
+
requires_attr(:contacts) { @opensrs.register_domain(:domain => 'example.com', :nameservers => []) }
|
121
|
+
end
|
122
|
+
|
123
|
+
it "requires a nameservers", :wip => true do
|
124
|
+
requires_attr(:nameservers) { @opensrs.register_domain(:domain => 'example.com', :contacts => @contacts) }
|
125
|
+
end
|
126
|
+
|
127
|
+
it "registers a domain" do
|
128
|
+
VCR.use_cassette("provisioning/register_domain") do
|
129
|
+
res = @opensrs.register_domain(
|
130
|
+
:domain => 'fdsafsfsafafsaexample.com',
|
131
|
+
:contacts => @contacts,
|
132
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
133
|
+
:term => 1)
|
134
|
+
result = res.result
|
135
|
+
result['registration_text'].should match(/successfully completed/i)
|
136
|
+
result['id'].to_i.should == 1885783
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
it "registers a pending domain registration" do
|
141
|
+
VCR.use_cassette("provisioning/register_pending_domain") do
|
142
|
+
res = @opensrs.register_domain(
|
143
|
+
:domain => 'fdsajfkdajfkljfklajfdkljflaexample.com',
|
144
|
+
:contacts => @contacts,
|
145
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
146
|
+
:term => 1,
|
147
|
+
:options => {:handle => :save})
|
148
|
+
res.success?.should be_true
|
149
|
+
res.result['id'].to_i.should == 1888032
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it "fails if the domain is taken" do
|
154
|
+
VCR.use_cassette("provisioning/register_taken_domain") do
|
155
|
+
res = @opensrs.register_domain(
|
156
|
+
:domain => 'example.com',
|
157
|
+
:contacts => @contacts,
|
158
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
159
|
+
:term => 1)
|
160
|
+
res.success?.should be_false
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "#register_trust_service" do
|
166
|
+
use_vcr_cassette "provisioning/trust_service"
|
167
|
+
|
168
|
+
it "registers the trust service" do
|
169
|
+
csr = "-----BEGIN CERTIFICATE REQUEST----- MIIC4TCCAckCAQAwgZsxKTAnBgNVBAMTIHNlY3VyZXNpdGUudGVzdDEyODU4NzYwMzY2MDgub3JnMQswCQYDVQQGEwJDQTELMAkGA1UECBMCT04xEDAOBgNVBAcTB1Rvcm9udG8xDzANBgNVBAoTBm5ld29yZzEPMA0GA1UECxMGUUFEZXB0MSAwHgYJKoZIhvcNAQkBFhFxYWZpdmVAdHVjb3dzLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0FDLurKaddUzayM5FgICBhy8DkOaBuYzCiHSFw6xRUf9CjAHpC/MiUM5TnegMiU02COAPmfeHZAERv21CoB/HPDcshewHJywzs8nwcbGncz37eFhNGFQNIif5ExoGAcLS9+d1EAmR1CupTBCCq86lGBa/RdwgUNlvLF5IgZZeKphd/FKaYB2KZmRBxM51WvV6AYmRKb6IsuUZCfHO2FCelThDE0EF99GbfSapVj7woSIu0/PTJcEX4sHURq6pY3ELfNG0BOzrTsT3Af8T3N5xwD0FMatkDrCPCgVx7sRZ05UqenxBOVWBJQcr5QRZSykxBosGjbqO3QSyGsElIKgkCAwEAAaAAMA0GCSqGSIb3DQEBBAUAA4IBAQCEUGNk45qCJiR4Yuce4relbP22EwK7pyX0+0VZ+F3eUxhpZ6S5WN1Juuru8w48RchQBjGK1jjUfXJIqn/DgX+yAfMj4aW/ohBmovN2ViuNILvNaj0volwoqyMlNrTmBze69qHMfnMGUUUehMr/Nq4QdQTqxy7EYQkNOqx21gfZcUi6zWCeFTRkasD+SYAKsOUIKdrt/Jq5lWFXxhkJHuyA+q1yr/w6zh18JmFAT4y/0q/odFGyIr9yKhQ9usW1sQ8CT3e3AnU4jq7sBrYFxN0f+92W8gX7WADortA7+6PcSFPrZEoQlr5Brki7GSwIuTTSlKFRyZ53DbEGjp2ELnnl -----END CERTIFICATE REQUEST----- "
|
170
|
+
@contacts.delete(:owner)
|
171
|
+
@contacts.delete(:title)
|
172
|
+
@contacts[:admin].delete(:url)
|
173
|
+
@contacts[:billing].delete(:url)
|
174
|
+
@contacts[:tech].delete(:url)
|
175
|
+
res = @opensrs.register_trust_service(
|
176
|
+
:csr => csr,
|
177
|
+
:contacts => @contacts,
|
178
|
+
:server_type => 'apachessl',
|
179
|
+
:product_type => 'securesite',
|
180
|
+
:server_count => 1,
|
181
|
+
:term => 1
|
182
|
+
)
|
183
|
+
res.success?.should be_false
|
184
|
+
res.error_code.should == 501
|
185
|
+
res.error_msg.should match(/Permission denied/i)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#update_contacts" do
|
190
|
+
use_vcr_cassette "provisioning/update_contacts"
|
191
|
+
|
192
|
+
it "updates the contacts" do
|
193
|
+
res = @opensrs.update_contacts(:domain => @registered_domain, :contacts => @contacts, :types => ["owner", "admin", "billing", "tech"])
|
194
|
+
res.success?.should be_true
|
195
|
+
res.result['details'][@registered_domain]['response_code'].to_i.should == 200
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::OpenSRS::TransferCommands do
|
4
|
+
before(:each) do
|
5
|
+
@opensrs = MooMoo::OpenSRS::Base.new
|
6
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
7
|
+
@contacts = test_contacts
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#cancel_transfer" do
|
11
|
+
it "cancels the transfer for a domain" do
|
12
|
+
VCR.use_cassette("transfer/cancel_transfer") do
|
13
|
+
res = @opensrs.cancel_transfer(:domain => 'exampledomain.com', :reseller => MooMoo.config.user)
|
14
|
+
res.success?.should be_false
|
15
|
+
res.error_code.should == 400
|
16
|
+
res.error_msg.should match(/transfer state prohibits cancellation/i)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "cancels the transfer for an order" do
|
21
|
+
VCR.use_cassette("transfer/cancel_trasnfer_order") do
|
22
|
+
res = @opensrs.cancel_transfer_for_order(:order_id => 1884820, :reseller => MooMoo.config.user)
|
23
|
+
res.success?.should be_false
|
24
|
+
res.error_code.should == 400
|
25
|
+
res.error_msg.should match(/transfer state prohibits cancellation/i)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#check_transfer" do
|
31
|
+
it "shows in progress if the transfer is in progress" do
|
32
|
+
VCR.use_cassette("transfer/check_transfer") do
|
33
|
+
res = @opensrs.check_transfer('exampledomain.com')
|
34
|
+
res.result['transferrable'].to_i.should == 0
|
35
|
+
res.result['reason'].should match(/Transfer in progress/i)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "says the domain already exists if it does" do
|
40
|
+
VCR.use_cassette("transfer/check_transfer_exists") do
|
41
|
+
res = @opensrs.check_transfer(@registered_domain)
|
42
|
+
res.result['transferrable'].to_i.should == 0
|
43
|
+
res.result['reason'].should match(/Domain already exists in.*account/i)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#get_transfers_away" do
|
49
|
+
use_vcr_cassette "transfer/get_transfers_away"
|
50
|
+
|
51
|
+
it "lists domains that have been transferred away" do
|
52
|
+
res = @opensrs.get_transfers_away
|
53
|
+
res.result['total'].to_i.should == 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#get_tranfers_in" do
|
58
|
+
use_vcr_cassette "transfer/get_transfers_in"
|
59
|
+
|
60
|
+
it "lists domains that have been transferred in" do
|
61
|
+
res = @opensrs.get_transfers_in
|
62
|
+
res.result['total'].to_i.should == 1
|
63
|
+
res.result['transfers']['0']['domain'].should == "testingdomain.com"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#process_transfer" do
|
68
|
+
it "performs a new order with cancelled order's data" do
|
69
|
+
VCR.use_cassette("transfer/process_transfer") do
|
70
|
+
result = @opensrs.process_transfer(:order_id => 123, :reseller => MooMoo.config.user)
|
71
|
+
result.success?.should be_true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "does not transfer if the status does not allow it" do
|
76
|
+
VCR.use_cassette("transfer/process_transfer_unsuccessful") do
|
77
|
+
result = @opensrs.process_transfer(:order_id => 123, :reseller => MooMoo.config.user)
|
78
|
+
result.success?.should be_false
|
79
|
+
result.error_code.should == 400
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#send_password (transfer)" do
|
85
|
+
use_vcr_cassette "transfer/send_password"
|
86
|
+
|
87
|
+
it "resends email message to admin contact" do
|
88
|
+
result = @opensrs.send_password('fdsafsfsafafsaexample.com')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#push_transfer" do
|
93
|
+
use_vcr_cassette "transfer/rsp2rsp_push_transfer"
|
94
|
+
|
95
|
+
it "transfers the domain" do
|
96
|
+
res = @opensrs.push_transfer(
|
97
|
+
:domain => @registered_domain,
|
98
|
+
:username => MooMoo.config.user,
|
99
|
+
:password => MooMoo.config.pass,
|
100
|
+
:reseller => 'opensrs'
|
101
|
+
)
|
102
|
+
res.success?.should be_false
|
103
|
+
res.error_code.should == 465
|
104
|
+
res.error_msg.should match(/transfer permission denied/i)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#transfer" do
|
109
|
+
use_vcr_cassette "transfer/transfer"
|
110
|
+
|
111
|
+
it "initiates the transfer" do
|
112
|
+
res = @opensrs.register_domain(
|
113
|
+
:domain => 'testingdomain.com',
|
114
|
+
:contacts => @contacts,
|
115
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
116
|
+
:term => 1,
|
117
|
+
:options => { :reg_type => :transfer }
|
118
|
+
)
|
119
|
+
res.success?.should be_true
|
120
|
+
res.result['id'].to_i.should == 1885789
|
121
|
+
res.result['registration_text'].should match(/transfer request initiated/i)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/spec/moo_moo_spec.rb
CHANGED
@@ -9,6 +9,22 @@ describe MooMoo do
|
|
9
9
|
|
10
10
|
describe "::configure" do
|
11
11
|
it { MooMoo.configure.should be_a MooMoo::Config }
|
12
|
+
|
13
|
+
it "loads default settings from config if none are provided" do
|
14
|
+
MooMoo.configure do |config|
|
15
|
+
config.host = 'host.com'
|
16
|
+
config.key = 'secret'
|
17
|
+
config.user = 'username'
|
18
|
+
config.pass = 'secret2'
|
19
|
+
end
|
20
|
+
|
21
|
+
opensrs = MooMoo::OpenSRS::Base.new
|
22
|
+
|
23
|
+
opensrs.host.should == 'host.com'
|
24
|
+
opensrs.key.should == 'secret'
|
25
|
+
opensrs.user.should == 'username'
|
26
|
+
opensrs.pass.should == 'secret2'
|
27
|
+
end
|
12
28
|
end
|
13
29
|
|
14
30
|
describe "::config" do
|