moo_moo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/.rvmrc +59 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/Rakefile +55 -0
- data/lib/cacert.pem +3910 -0
- data/lib/moo_moo/config.rb +13 -0
- data/lib/moo_moo/opensrs/args.rb +109 -0
- data/lib/moo_moo/opensrs/base.rb +75 -0
- data/lib/moo_moo/opensrs/command.rb +190 -0
- data/lib/moo_moo/opensrs/cookie_commands.rb +52 -0
- data/lib/moo_moo/opensrs/lookup_commands.rb +195 -0
- data/lib/moo_moo/opensrs/nameserver_commands.rb +70 -0
- data/lib/moo_moo/opensrs/opensrsexception.rb +6 -0
- data/lib/moo_moo/opensrs/provisioning_commands.rb +167 -0
- data/lib/moo_moo/opensrs/response.rb +41 -0
- data/lib/moo_moo/opensrs/transfer_commands.rb +83 -0
- data/lib/moo_moo/opensrs/utils.rb +13 -0
- data/lib/moo_moo/opensrs.rb +8 -0
- data/lib/moo_moo/version.rb +3 -0
- data/lib/moo_moo.rb +16 -0
- data/moo_moo.gemspec +33 -0
- data/spec/moo_moo_spec.rb +17 -0
- data/spec/opensrs/args_spec.rb +179 -0
- data/spec/opensrs/cookie_spec.rb +78 -0
- data/spec/opensrs/lookup_spec.rb +212 -0
- data/spec/opensrs/nameserver_spec.rb +124 -0
- data/spec/opensrs/opensrs_spec.rb +35 -0
- data/spec/opensrs/provisioning_spec.rb +271 -0
- data/spec/opensrs/transfer_spec.rb +197 -0
- data/spec/opensrs/utils_spec.rb +12 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/vcr_cassettes/cookie/delete_cookie.yml +219 -0
- data/spec/vcr_cassettes/cookie/quit_session.yml +97 -0
- data/spec/vcr_cassettes/cookie/set_cookie.yml +123 -0
- data/spec/vcr_cassettes/cookie/set_cookie_fail.yml +54 -0
- data/spec/vcr_cassettes/cookie/update_cookie.yml +239 -0
- data/spec/vcr_cassettes/lookup/belongs_to_rsp.yml +54 -0
- data/spec/vcr_cassettes/lookup/belongs_to_rsp_negative.yml +55 -0
- data/spec/vcr_cassettes/lookup/get_balance.yml +55 -0
- data/spec/vcr_cassettes/lookup/get_deleted_domains.yml +80 -0
- data/spec/vcr_cassettes/lookup/get_domain.yml +211 -0
- data/spec/vcr_cassettes/lookup/get_domain_fail.yml +269 -0
- data/spec/vcr_cassettes/lookup/get_domains_by_expiredate.yml +76 -0
- data/spec/vcr_cassettes/lookup/get_domains_contacts.yml +129 -0
- data/spec/vcr_cassettes/lookup/get_domains_contacts_fail.yml +58 -0
- data/spec/vcr_cassettes/lookup/get_notes_for_domain.yml +85 -0
- data/spec/vcr_cassettes/lookup/get_notes_for_order.yml +61 -0
- data/spec/vcr_cassettes/lookup/get_notes_for_transfer.yml +61 -0
- data/spec/vcr_cassettes/lookup/get_order_info.yml +139 -0
- data/spec/vcr_cassettes/lookup/get_orders_by_domain.yml +76 -0
- data/spec/vcr_cassettes/lookup/get_price.yml +54 -0
- data/spec/vcr_cassettes/lookup/get_product_info.yml +49 -0
- data/spec/vcr_cassettes/lookup/lookup_domain_available.yml +55 -0
- data/spec/vcr_cassettes/lookup/lookup_domain_registered.yml +55 -0
- data/spec/vcr_cassettes/lookup/name_suggest.yml +396 -0
- data/spec/vcr_cassettes/nameserver/create.yml +49 -0
- data/spec/vcr_cassettes/nameserver/delete.yml +49 -0
- data/spec/vcr_cassettes/nameserver/get.yml +71 -0
- data/spec/vcr_cassettes/nameserver/modify.yml +49 -0
- data/spec/vcr_cassettes/provisioning/cancel_order.yml +56 -0
- data/spec/vcr_cassettes/provisioning/cancel_order_invalid.yml +49 -0
- data/spec/vcr_cassettes/provisioning/cancel_pending_orders.yml +58 -0
- data/spec/vcr_cassettes/provisioning/modify_all_domains.yml +49 -0
- data/spec/vcr_cassettes/provisioning/modify_domain.yml +49 -0
- data/spec/vcr_cassettes/provisioning/process_pending.yml +57 -0
- data/spec/vcr_cassettes/provisioning/register_domain.yml +57 -0
- data/spec/vcr_cassettes/provisioning/register_pending_domain.yml +55 -0
- data/spec/vcr_cassettes/provisioning/register_taken_domain.yml +55 -0
- data/spec/vcr_cassettes/provisioning/renew_domain.yml +58 -0
- data/spec/vcr_cassettes/provisioning/revoke_domain.yml +55 -0
- data/spec/vcr_cassettes/provisioning/trust_service.yml +60 -0
- data/spec/vcr_cassettes/provisioning/update_contacts.yml +66 -0
- data/spec/vcr_cassettes/transfer/cancel_transfer.yml +49 -0
- data/spec/vcr_cassettes/transfer/cancel_trasnfer_order.yml +49 -0
- data/spec/vcr_cassettes/transfer/check_transfer.yml +56 -0
- data/spec/vcr_cassettes/transfer/check_transfer_exists.yml +57 -0
- data/spec/vcr_cassettes/transfer/get_transfers_away.yml +60 -0
- data/spec/vcr_cassettes/transfer/get_transfers_in.yml +80 -0
- data/spec/vcr_cassettes/transfer/process_transfer.yml +49 -0
- data/spec/vcr_cassettes/transfer/process_transfer_unsuccessful.yml +49 -0
- data/spec/vcr_cassettes/transfer/rsp2rsp_push_transfer.yml +49 -0
- data/spec/vcr_cassettes/transfer/send_password.yml +49 -0
- data/spec/vcr_cassettes/transfer/transfer.yml +58 -0
- metadata +280 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'moo_moo/opensrs'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module MooMoo
|
6
|
+
|
7
|
+
describe OpenSRS do
|
8
|
+
before(:each) do
|
9
|
+
def random_domain
|
10
|
+
"domainthatsnottaken#{Time.now.to_i}.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
@opensrs = OpenSRS::Base.new
|
14
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "LookupCommands" do
|
18
|
+
describe "#belongs_to_rsp" do
|
19
|
+
it "returns false for a domain that is not owned by the rsp" do
|
20
|
+
VCR.use_cassette("lookup/belongs_to_rsp") do
|
21
|
+
res = @opensrs.belongs_to_rsp?('example.com')
|
22
|
+
res.result['belongs_to_rsp'].to_i.should == 0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns true for a domain owned by the rsp" do
|
27
|
+
VCR.use_cassette("lookup/belongs_to_rsp_negative") do
|
28
|
+
res = @opensrs.belongs_to_rsp?(@registered_domain)
|
29
|
+
res.result['belongs_to_rsp'].to_i.should == 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#get_balance" do
|
35
|
+
use_vcr_cassette "lookup/get_balance"
|
36
|
+
|
37
|
+
it "returns the balance" do
|
38
|
+
res = @opensrs.get_balance
|
39
|
+
res.result['balance'].to_f.should == 7312.24
|
40
|
+
res.result['hold_balance'].to_f.should == 11.44
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#get_deleted_domains" do
|
45
|
+
use_vcr_cassette "lookup/get_deleted_domains"
|
46
|
+
|
47
|
+
it "returns domains that have been deleted" do
|
48
|
+
result = @opensrs.get_deleted_domains.result
|
49
|
+
result['total'].to_i.should == 2
|
50
|
+
result['del_domains']['0']['name'].should == "example.com"
|
51
|
+
result['del_domains']['0']['delete_date_epoch'].should == "1294426313"
|
52
|
+
result['del_domains']['0']['expiredate_epoch'].should == "1325980310"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#get domain" do
|
57
|
+
it "returns all the info" do
|
58
|
+
VCR.use_cassette("lookup/get_domain") do
|
59
|
+
res = @opensrs.set_cookie(:username => MooMoo.config.user,
|
60
|
+
:password => MooMoo.config.pass,
|
61
|
+
:domain => @registered_domain)
|
62
|
+
result = @opensrs.get_domain(:cookie => res.result['cookie']).result
|
63
|
+
result['auto_renew'].to_i.should == 1
|
64
|
+
result['contact_set']['admin']['org_name'].should == "Example Inc."
|
65
|
+
result['nameserver_list']['0']['name'].should == "ns2.systemdns.com"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#get_domains_contacts" do
|
71
|
+
it "returns the domain's contacts" do
|
72
|
+
VCR.use_cassette("lookup/get_domains_contacts") do
|
73
|
+
result = @opensrs.get_domains_contacts(@registered_domain).result
|
74
|
+
result[@registered_domain]['contact_set']['owner']['address2'].should == "Suite 500"
|
75
|
+
result[@registered_domain]['contact_set']['billing']['org_name'].should == "Example Inc."
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it "fails for a domain that is not in the registry" do
|
80
|
+
VCR.use_cassette("lookup/get_domains_contacts_fail") do
|
81
|
+
res = @opensrs.get_domains_contacts('example.com')
|
82
|
+
res.success?.should be_true
|
83
|
+
res.result['example.com']['error'].should match(/Domain does not belong to the reseller/i)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#get_domains_by_expiredate" do
|
89
|
+
use_vcr_cassette "lookup/get_domains_by_expiredate"
|
90
|
+
|
91
|
+
it "requires a start date", :wip => true do
|
92
|
+
requires_attr(:start_date) { @opensrs.get_domains_by_expiredate(:end_date => Date.parse('2011-04-21')) }
|
93
|
+
end
|
94
|
+
|
95
|
+
it "requires an end date", :wip => true do
|
96
|
+
requires_attr(:end_date) { @opensrs.get_domains_by_expiredate(:start_date => Date.parse('2011-04-21')) }
|
97
|
+
end
|
98
|
+
|
99
|
+
it "returns domains within an expiration range" do
|
100
|
+
result = @opensrs.get_domains_by_expiredate(
|
101
|
+
:start_date => Date.parse('2011-04-21'),
|
102
|
+
:end_date => Date.parse('2011-04-21') + 365
|
103
|
+
).result
|
104
|
+
result['total'].to_i.should == 2
|
105
|
+
result['exp_domains']['0']['name'].should == "example.com"
|
106
|
+
result['exp_domains']['0']['f_auto_renew'].should == "N"
|
107
|
+
result['exp_domains']['0']['f_let_expire'].should == "N"
|
108
|
+
result['exp_domains']['0']['expiredate'].should == "2011-11-03 16:14:46"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#get_notes" do
|
113
|
+
it "returns the notes for a domain" do
|
114
|
+
VCR.use_cassette("lookup/get_notes_for_domain") do
|
115
|
+
result = @opensrs.get_notes_for_domain(@registered_domain).result
|
116
|
+
result['total'].to_i.should == 4
|
117
|
+
result['notes']['1']['note'].should match(/Order.*?\d+.*?Domain Registration.*?1 year/i)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it "returns the notes for an order" do
|
122
|
+
VCR.use_cassette("lookup/get_notes_for_order") do
|
123
|
+
result = @opensrs.get_notes_for_order(:domain => @registered_domain, :order_id => 1855625).result
|
124
|
+
result['page'].to_i.should == 1
|
125
|
+
result['notes'].should be_a_kind_of(Hash)
|
126
|
+
result['notes'].should be_empty
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it "returns the notes for a transfer" do
|
131
|
+
VCR.use_cassette("lookup/get_notes_for_transfer") do
|
132
|
+
res = @opensrs.get_notes_for_transfer(:domain => "testingdomain.com", :transfer_id => 37021)
|
133
|
+
res.success?.should be_true
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#get_order_info" do
|
139
|
+
use_vcr_cassette "lookup/get_order_info"
|
140
|
+
|
141
|
+
it "returns the order info" do
|
142
|
+
result = @opensrs.get_order_info(1855625).result['field_hash']
|
143
|
+
result['owner_address2'].should == "Suite 500"
|
144
|
+
result['billing_org_name'].should == "Example Inc."
|
145
|
+
result['period'].to_i.should == 1
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "#get_orders_by_domain" do
|
150
|
+
use_vcr_cassette "lookup/get_orders_by_domain"
|
151
|
+
|
152
|
+
it "returns the orders for a domain" do
|
153
|
+
result = @opensrs.get_orders_by_domain(@registered_domain).result
|
154
|
+
result['orders'].should be_a_kind_of(Hash)
|
155
|
+
result['orders'].should have(2).domains
|
156
|
+
result['orders']['0']['id'].to_i.should == 1862773
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "#get_price" do
|
161
|
+
use_vcr_cassette "lookup/get_price"
|
162
|
+
|
163
|
+
it "returns the price" do
|
164
|
+
res = @opensrs.get_price('example.com')
|
165
|
+
res.result['price'].to_f.should == 11.62
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "#get_product_info" do
|
170
|
+
use_vcr_cassette "lookup/get_product_info"
|
171
|
+
|
172
|
+
it "fails to find an invalid product" do
|
173
|
+
res = @opensrs.get_product_info(99)
|
174
|
+
res.success?.should be_false
|
175
|
+
res.error_code.should == 405
|
176
|
+
res.error_msg.should match(/cannot be found/i)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#lookup domain" do
|
181
|
+
it "returns the availbility of an available domain" do
|
182
|
+
VCR.use_cassette("lookup/lookup_domain_available") do
|
183
|
+
result = @opensrs.lookup_domain('example.com').result
|
184
|
+
result['status'].should == "available"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
it "returns the availability of a registered domain" do
|
189
|
+
VCR.use_cassette("lookup/lookup_domain_registered") do
|
190
|
+
result = @opensrs.lookup_domain(@registered_domain).result
|
191
|
+
result['status'].should == "taken"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#name_suggest" do
|
197
|
+
use_vcr_cassette "lookup/name_suggest"
|
198
|
+
|
199
|
+
it "returns suggested names for a domain" do
|
200
|
+
result = @opensrs.name_suggest("random_domain", [".com", ".net"]).result
|
201
|
+
result['lookup']['count'].to_i.should == 4
|
202
|
+
result['lookup']['items']['0']['domain'].should == "randomdomain.com"
|
203
|
+
result['lookup']['items']['0']['status'].should == "taken"
|
204
|
+
|
205
|
+
result['suggestion']['count'].to_i.should == 49
|
206
|
+
result['suggestion']['items']['0']['domain'].should == "aimlessdomain.com"
|
207
|
+
result['suggestion']['items']['0']['status'].should == "available"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'moo_moo/opensrs'
|
3
|
+
|
4
|
+
module MooMoo
|
5
|
+
|
6
|
+
describe OpenSRS do
|
7
|
+
before(:each) do
|
8
|
+
def random_domain
|
9
|
+
"domainthatsnottaken#{Time.now.to_i}.com"
|
10
|
+
end
|
11
|
+
|
12
|
+
@opensrs = OpenSRS::Base.new
|
13
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "NameserverCommands" do
|
17
|
+
describe "#create_nameserver" do
|
18
|
+
use_vcr_cassette "nameserver/create"
|
19
|
+
|
20
|
+
it "requires a name", :wip => true do
|
21
|
+
requires_attr(:name) { @opensrs.create_nameserver(:ip => '123.123.123.123', :domain => 'example.com') }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "requires a ip", :wip => true do
|
25
|
+
requires_attr(:ip) { @opensrs.create_nameserver(:name => 'blah', :domain => 'example.com') }
|
26
|
+
end
|
27
|
+
|
28
|
+
it "requires a domain", :wip => true do
|
29
|
+
requires_attr(:domain) { @opensrs.create_nameserver(:name => 'blah', :ip => '123.123.123.123') }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "creates the nameserver" do
|
33
|
+
res = @opensrs.create_nameserver(
|
34
|
+
:name => "ns1.#{@registered_domain}",
|
35
|
+
:ip => '212.112.123.11',
|
36
|
+
:domain => @registered_domain)
|
37
|
+
res.success?.should be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#delete_nameserver" do
|
42
|
+
use_vcr_cassette "nameserver/delete"
|
43
|
+
|
44
|
+
it "requires a name", :wip => true do
|
45
|
+
requires_attr(:name) { @opensrs.delete_nameserver(:ip => '123.123.123.123', :domain => 'example.com') }
|
46
|
+
end
|
47
|
+
|
48
|
+
it "requires a ip", :wip => true do
|
49
|
+
requires_attr(:ip) { @opensrs.delete_nameserver(:name => 'blah', :domain => 'example.com') }
|
50
|
+
end
|
51
|
+
|
52
|
+
it "requires a domain", :wip => true do
|
53
|
+
requires_attr(:domain) { @opensrs.delete_nameserver(:name => 'blah', :ip => '123.123.123.123') }
|
54
|
+
end
|
55
|
+
|
56
|
+
it "deletes the nameserver" do
|
57
|
+
res = @opensrs.delete_nameserver(
|
58
|
+
:name => "ns1.#{@registered_domain}",
|
59
|
+
:ip => '212.112.123.11',
|
60
|
+
:domain => @registered_domain)
|
61
|
+
res.success?.should be_true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#get_nameserver" do
|
66
|
+
use_vcr_cassette "nameserver/get"
|
67
|
+
|
68
|
+
it "returns the nameservers" do
|
69
|
+
res = @opensrs.get_nameserver(@registered_domain)
|
70
|
+
result = res.result['nameserver_list']
|
71
|
+
result.should have(2).nameservers
|
72
|
+
result['0']['name'].should == "ns1.#{@registered_domain}"
|
73
|
+
result['1']['ipaddress'].should == "212.112.123.12"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#modify_nameserver" do
|
78
|
+
use_vcr_cassette "nameserver/modify"
|
79
|
+
|
80
|
+
it "requires a name", :wip => true do
|
81
|
+
requires_attr(:name) { @opensrs.modify_nameserver(
|
82
|
+
:ip => '123.123.123.123',
|
83
|
+
:new_name => 'blah',
|
84
|
+
:domain => 'example.com')
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "requires a ip", :wip => true do
|
89
|
+
requires_attr(:ip) { @opensrs.modify_nameserver(
|
90
|
+
:name => 'blah',
|
91
|
+
:new_name => 'blah',
|
92
|
+
:domain => 'example.com')
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
it "requires a domain", :wip => true do
|
97
|
+
requires_attr(:domain) { @opensrs.modify_nameserver(
|
98
|
+
:name => 'blah',
|
99
|
+
:ip => '123.123.123.123',
|
100
|
+
:new_name => 'blah')
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
it "requires a new_name", :wip => true do
|
105
|
+
requires_attr(:new_name) { @opensrs.modify_nameserver(
|
106
|
+
:name => 'blah',
|
107
|
+
:ip => '123.123.123.123',
|
108
|
+
:domain => 'example.com')
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
it "updates the name of the nameserver" do
|
113
|
+
res = @opensrs.modify_nameserver(
|
114
|
+
:name => "ns22.#{@registered_domain}",
|
115
|
+
:ip => '212.112.123.11',
|
116
|
+
:new_name => "ns3.#{@registered_domain}",
|
117
|
+
:domain => @registered_domain)
|
118
|
+
res.success?.should be_true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'moo_moo/opensrs'
|
3
|
+
require 'moo_moo/opensrs/utils'
|
4
|
+
|
5
|
+
module MooMoo
|
6
|
+
module OpenSRS
|
7
|
+
describe OpenSRS do
|
8
|
+
include Utils
|
9
|
+
|
10
|
+
describe "Utils" do
|
11
|
+
it "raises an OpenSRSException" do
|
12
|
+
expect {try_opensrs { raise "Exception message" } }.to raise_error OpenSRSException
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Config" do
|
17
|
+
it "loads default settings from config if none are provided" do
|
18
|
+
MooMoo.configure do |config|
|
19
|
+
config.host = 'host.com'
|
20
|
+
config.key = 'secret'
|
21
|
+
config.user = 'username'
|
22
|
+
config.pass = 'secret2'
|
23
|
+
end
|
24
|
+
|
25
|
+
opensrs = OpenSRS::Base.new
|
26
|
+
|
27
|
+
opensrs.host.should == 'host.com'
|
28
|
+
opensrs.key.should == 'secret'
|
29
|
+
opensrs.user.should == 'username'
|
30
|
+
opensrs.pass.should == 'secret2'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'moo_moo/opensrs'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module MooMoo
|
6
|
+
|
7
|
+
describe OpenSRS do
|
8
|
+
before(:each) do
|
9
|
+
def random_domain
|
10
|
+
"domainthatsnottaken#{Time.now.to_i}.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
@opensrs = OpenSRS::Base.new
|
14
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
15
|
+
@contacts = {
|
16
|
+
:title => "blahblah",
|
17
|
+
:owner => {
|
18
|
+
:first_name => "Owen",
|
19
|
+
:last_name => "Ottway",
|
20
|
+
:phone => "+1.4165550123x1902",
|
21
|
+
:fax => "+1.4165550124",
|
22
|
+
:email => "ottway@example.com",
|
23
|
+
:org_name => "Example Inc.",
|
24
|
+
:address1 => "32 Oak Street",
|
25
|
+
:address2 => "Suite 500",
|
26
|
+
:address3 => "Owner",
|
27
|
+
:city => "SomeCity",
|
28
|
+
:state => "CA",
|
29
|
+
:country => "US",
|
30
|
+
:postal_code => "90210",
|
31
|
+
:url => "http://www.example.com"
|
32
|
+
},
|
33
|
+
:admin => {
|
34
|
+
:first_name => "Owen",
|
35
|
+
:last_name => "Ottway",
|
36
|
+
:phone => "+1.4165550123x1902",
|
37
|
+
:fax => "+1.4165550124",
|
38
|
+
:email => "ottway@example.com",
|
39
|
+
:org_name => "Example Inc.",
|
40
|
+
:address1 => "32 Oak Street",
|
41
|
+
:address2 => "Suite 500",
|
42
|
+
:address3 => "Owner",
|
43
|
+
:city => "SomeCity",
|
44
|
+
:state => "CA",
|
45
|
+
:country => "US",
|
46
|
+
:postal_code => "90210",
|
47
|
+
:url => "http://www.example.com"
|
48
|
+
},
|
49
|
+
:billing => {
|
50
|
+
:first_name => "Owen",
|
51
|
+
:last_name => "Ottway",
|
52
|
+
:phone => "+1.4165550123x1902",
|
53
|
+
:fax => "+1.4165550124",
|
54
|
+
:email => "ottway@example.com",
|
55
|
+
:org_name => "Example Inc.",
|
56
|
+
:address1 => "32 Oak Street",
|
57
|
+
:address2 => "Suite 500",
|
58
|
+
:address3 => "Owner",
|
59
|
+
:city => "SomeCity",
|
60
|
+
:state => "CA",
|
61
|
+
:country => "US",
|
62
|
+
:postal_code => "90210",
|
63
|
+
:url => "http://www.example.com"
|
64
|
+
},
|
65
|
+
:tech => {
|
66
|
+
:first_name => "Owen",
|
67
|
+
:last_name => "Ottway",
|
68
|
+
:phone => "+1.4165550123x1902",
|
69
|
+
:fax => "+1.4165550124",
|
70
|
+
:email => "ottway@example.com",
|
71
|
+
:org_name => "Example Inc.",
|
72
|
+
:address1 => "32 Oak Street",
|
73
|
+
:address2 => "Suite 500",
|
74
|
+
:address3 => "Owner",
|
75
|
+
:city => "SomeCity",
|
76
|
+
:state => "CA",
|
77
|
+
:country => "US",
|
78
|
+
:postal_code => "90210",
|
79
|
+
:url => "http://www.example.com"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "ProvisioningCommands" do
|
85
|
+
describe "#cancel_order" do
|
86
|
+
it "cancels a trust service order" do
|
87
|
+
VCR.use_cassette("provisioning/cancel_order") do
|
88
|
+
res = @opensrs.cancel_order(123456)
|
89
|
+
res.success?.should be_true
|
90
|
+
res.result['order_id'].to_i.should == 123456
|
91
|
+
res.result['domain'].should == "example.com"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "doesn't cancel an invalid trust service order" do
|
96
|
+
VCR.use_cassette("provisioning/cancel_order_invalid") do
|
97
|
+
res = @opensrs.cancel_order(111111)
|
98
|
+
res.success?.should be_false
|
99
|
+
res.error_code.should == 405
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#cancel_pending_orders" do
|
105
|
+
use_vcr_cassette "provisioning/cancel_pending_orders"
|
106
|
+
|
107
|
+
it "cancels all pending orders" do
|
108
|
+
result = @opensrs.cancel_pending_orders(1302890914).result
|
109
|
+
result['total'].to_i.should == 0
|
110
|
+
result['cancelled'].should be_a_kind_of(Hash)
|
111
|
+
result['cancelled'].should be_empty
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#modify domain" do
|
116
|
+
it "updates the contact information" do
|
117
|
+
end
|
118
|
+
|
119
|
+
it "updates the expire action" do
|
120
|
+
VCR.use_cassette("provisioning/modify_domain") do
|
121
|
+
res = @opensrs.modify({:type => 'expire_action', :domain => @registered_domain, :auto_renew => 1, :let_expire => 0})
|
122
|
+
res.success?.should be_true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it "modifies all domains linked to the profile" do
|
127
|
+
VCR.use_cassette("provisioning/modify_all_domains") do
|
128
|
+
res = @opensrs.modify({
|
129
|
+
:type => 'expire_action',
|
130
|
+
:affect_domains => 1,
|
131
|
+
:auto_renew => 0,
|
132
|
+
:let_expire => 1,
|
133
|
+
:cookie => "0000000000000000:000000:00000"})
|
134
|
+
res.success?.should == true
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#process_pending" do
|
140
|
+
use_vcr_cassette "provisioning/process_pending"
|
141
|
+
|
142
|
+
it "processes the pending order" do
|
143
|
+
result = @opensrs.process_pending(1878084).result
|
144
|
+
result['order_id'].to_i.should == 1878084
|
145
|
+
result['id'].to_i.should == 730001
|
146
|
+
result['f_auto_renew'].should == "Y"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#renew_domain" do
|
151
|
+
use_vcr_cassette "provisioning/renew_domain"
|
152
|
+
|
153
|
+
it "requires a domain", :wip => true do
|
154
|
+
requires_attr(:domain) { @opensrs.renew_domain(:term => 1, :current_expiration_year => 2011) }
|
155
|
+
end
|
156
|
+
|
157
|
+
it "requires a term", :wip => true do
|
158
|
+
requires_attr(:term) { @opensrs.renew_domain(:domain => 'example.com', :current_expiration_year => 2011) }
|
159
|
+
end
|
160
|
+
|
161
|
+
it "requires a current_expiration_year", :wip => true do
|
162
|
+
requires_attr(:current_expiration_year) { @opensrs.renew_domain(:domain => 'example.com', :term => 1) }
|
163
|
+
end
|
164
|
+
|
165
|
+
it "renews the domain" do
|
166
|
+
result = @opensrs.renew_domain(
|
167
|
+
:domain => "example.com",
|
168
|
+
:term => 1,
|
169
|
+
:current_expiration_year => 2011
|
170
|
+
).result
|
171
|
+
result['order_id'].to_i.should == 1867227
|
172
|
+
result['id'].to_i.should == 678899
|
173
|
+
result['admin_email'].should == "adams@example.com"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#revoke domain" do
|
178
|
+
use_vcr_cassette "provisioning/revoke_domain"
|
179
|
+
|
180
|
+
it "removes the domain from the registry" do
|
181
|
+
res = @opensrs.revoke(:domain => "example.com", :reseller => MooMoo.config.user)
|
182
|
+
res.success?.should be_true
|
183
|
+
res.result['charge'].to_i.should == 1
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "#register" do
|
188
|
+
it "requires a domain", :wip => true do
|
189
|
+
requires_attr(:domain) { @opensrs.register_domain(:contacts => @contacts, :nameservers => ['ns1.blah.com']) }
|
190
|
+
end
|
191
|
+
|
192
|
+
it "requires a contacts", :wip => true do
|
193
|
+
requires_attr(:contacts) { @opensrs.register_domain(:domain => 'example.com', :nameservers => []) }
|
194
|
+
end
|
195
|
+
|
196
|
+
it "requires a nameservers", :wip => true do
|
197
|
+
requires_attr(:nameservers) { @opensrs.register_domain(:domain => 'example.com', :contacts => @contacts) }
|
198
|
+
end
|
199
|
+
|
200
|
+
it "registers a domain" do
|
201
|
+
VCR.use_cassette("provisioning/register_domain") do
|
202
|
+
res = @opensrs.register_domain(
|
203
|
+
:domain => 'fdsafsfsafafsaexample.com',
|
204
|
+
:contacts => @contacts,
|
205
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
206
|
+
:term => 1)
|
207
|
+
result = res.result
|
208
|
+
result['registration_text'].should match(/successfully completed/i)
|
209
|
+
result['id'].to_i.should == 1885783
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it "registers a pending domain registration" do
|
214
|
+
VCR.use_cassette("provisioning/register_pending_domain") do
|
215
|
+
res = @opensrs.register_domain(
|
216
|
+
:domain => 'fdsajfkdajfkljfklajfdkljflaexample.com',
|
217
|
+
:contacts => @contacts,
|
218
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
219
|
+
:term => 1,
|
220
|
+
:options => {:handle => :save})
|
221
|
+
res.success?.should be_true
|
222
|
+
res.result['id'].to_i.should == 1888032
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
it "fails if the domain is taken" do
|
227
|
+
VCR.use_cassette("provisioning/register_taken_domain") do
|
228
|
+
res = @opensrs.register_domain(
|
229
|
+
:domain => 'example.com',
|
230
|
+
:contacts => @contacts,
|
231
|
+
:nameservers => ["ns1.systemdns.com", "ns2.systemdns.com"],
|
232
|
+
:term => 1)
|
233
|
+
res.success?.should be_false
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "#register_trust_service" do
|
239
|
+
use_vcr_cassette "provisioning/trust_service"
|
240
|
+
|
241
|
+
it "registers the trust service" do
|
242
|
+
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----- "
|
243
|
+
@contacts.delete(:owner)
|
244
|
+
@contacts.delete(:title)
|
245
|
+
@contacts[:admin].delete(:url)
|
246
|
+
@contacts[:billing].delete(:url)
|
247
|
+
@contacts[:tech].delete(:url)
|
248
|
+
res = @opensrs.register_trust_service(:csr => csr,
|
249
|
+
:contacts => @contacts,
|
250
|
+
:server_type => 'apachessl',
|
251
|
+
:product_type => 'securesite',
|
252
|
+
:server_count => 1,
|
253
|
+
:term => 1)
|
254
|
+
res.success?.should be_false
|
255
|
+
res.error_code.should == 501
|
256
|
+
res.error_msg.should match(/Permission denied/i)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "#update_contacts" do
|
261
|
+
use_vcr_cassette "provisioning/update_contacts"
|
262
|
+
|
263
|
+
it "updates the contacts" do
|
264
|
+
res = @opensrs.update_contacts(:domain => @registered_domain, :contacts => @contacts, :types => ["owner", "admin", "billing", "tech"])
|
265
|
+
res.success?.should be_true
|
266
|
+
res.result['details'][@registered_domain]['response_code'].to_i.should == 200
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|