moo_moo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,27 +1,42 @@
|
|
1
|
-
MooMoo
|
2
|
-
|
1
|
+
MooMoo [![MooMoo Build Status][Build Icon]][Build Status]
|
2
|
+
=========================================================
|
3
3
|
|
4
|
-
Ruby library for
|
4
|
+
MooMoo is a Ruby library for working with the [Tucows OpenSRS XML API][].
|
5
|
+
|
6
|
+
MooMoo has been tested on MRI 1.8.7, MRI 1.9.2, MRI 1.9.3 Preview 1,
|
7
|
+
Rubinius 2.0.0pre, and JRuby 1.6.2.
|
8
|
+
|
9
|
+
Documentation is available in [RDoc][] format.
|
10
|
+
|
11
|
+
[Build Status]: http://travis-ci.org/site5/moo_moo
|
12
|
+
[Build Icon]: https://secure.travis-ci.org/site5/moo_moo.png?branch=master
|
13
|
+
[Tucows OpenSRS XML API]: http://www.opensrs.com/site/resources/documentation
|
14
|
+
[RDoc]: http://rdoc.info/github/site5/moo_moo/master/frames
|
5
15
|
|
6
16
|
Description
|
7
|
-
|
17
|
+
-----------
|
8
18
|
|
9
19
|
Implements most of the functionality of the OpenSRS XML API. For full
|
10
20
|
documentation of the OpenSRS XML API see
|
11
|
-
http://opensrs.com/
|
21
|
+
<http://www.opensrs.com/site/resources/documentation>
|
12
22
|
|
13
23
|
Usage
|
14
|
-
|
24
|
+
-----
|
15
25
|
|
16
26
|
First, create an opensrs object from which all commands are called:
|
17
27
|
|
18
|
-
opensrs = MooMoo::OpenSRS::Base.new(
|
28
|
+
opensrs = MooMoo::OpenSRS::Base.new(
|
29
|
+
"horizon.opensrs.net",
|
30
|
+
"<YOUR_KEY>",
|
31
|
+
"<YOUR_RESELLER_USER>",
|
32
|
+
"<YOUR_PASSWORD>"
|
33
|
+
)
|
19
34
|
|
20
35
|
Or configure MooMoo and you can initialize it without any arguments:
|
21
36
|
|
22
37
|
MooMoo.configure do |config|
|
23
38
|
config.host = "horizon.opensrs.net"
|
24
|
-
config.key
|
39
|
+
config.key = "<YOUR_KEY>"
|
25
40
|
config.user = "<YOUR_RESELLER_USER>"
|
26
41
|
config.pass = "<YOUR_PASSWORD>"
|
27
42
|
end
|
@@ -40,13 +55,13 @@ Here's how to check the availability of a domain name:
|
|
40
55
|
true
|
41
56
|
taken
|
42
57
|
|
43
|
-
Each method returns an OpenSRSResponse object which you can
|
44
|
-
|
45
|
-
|
46
|
-
|
58
|
+
Each method returns an `OpenSRSResponse` object which you can use to determine
|
59
|
+
if the call was successful and retrieve the response code and/or error
|
60
|
+
message. The result variable is a hash that contains all of the relevant data
|
61
|
+
returned by the call.
|
47
62
|
|
48
63
|
Note on Patches/Pull Requests
|
49
|
-
|
64
|
+
-----------------------------
|
50
65
|
|
51
66
|
* Fork the project.
|
52
67
|
* Make your feature addition or bug fix.
|
@@ -58,6 +73,6 @@ Note on Patches/Pull Requests
|
|
58
73
|
* Send me a pull request. Bonus points for topic branches.
|
59
74
|
|
60
75
|
Copyright
|
61
|
-
|
76
|
+
---------
|
62
77
|
|
63
78
|
Copyright (c) 2011 Site5 LLC. See LICENSE for details.
|
data/lib/moo_moo/opensrs/args.rb
CHANGED
@@ -1,108 +1,108 @@
|
|
1
1
|
module MooMoo
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
2
|
+
module OpenSRS
|
3
|
+
class Args
|
4
|
+
attr_reader :required_params, :boolean_params, :optional_params, :one_of_params
|
5
|
+
attr_reader :options
|
6
|
+
# Check the included hash for the included parameters.
|
7
|
+
# Raises MooMooArgumentError when it's mising the proper params
|
8
|
+
#
|
9
|
+
# ==== Example
|
10
|
+
#
|
11
|
+
# Args.new(options) do |c|
|
12
|
+
# c.requries :user, :pass
|
13
|
+
# c.booleans :name
|
14
|
+
# c.optionals :whatever
|
15
|
+
# end
|
16
|
+
def initialize(options)
|
17
|
+
@required_params ||= []
|
18
|
+
@boolean_params ||= []
|
19
|
+
@optional_params ||= []
|
20
|
+
@one_of_params ||= []
|
21
|
+
@options = options
|
22
|
+
|
23
|
+
yield self
|
24
|
+
|
25
|
+
requires!
|
26
|
+
booleans!
|
27
|
+
one_ofs!
|
28
|
+
valid_options!
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
# Specifies the required arguments
|
32
|
+
def requires(*values)
|
33
|
+
@optional_params.concat(values)
|
34
|
+
@required_params = values
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
# Specifies which arguments are boolean
|
38
|
+
def booleans(*values)
|
39
|
+
@optional_params.concat(values)
|
40
|
+
@boolean_params = values
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
# Specifies which arguments are optional
|
44
|
+
def optionals(*values)
|
45
|
+
@optional_params.concat(values)
|
46
|
+
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
# Specifies which arguments take one of a set of arguments
|
49
|
+
def one_of(*values)
|
50
|
+
@optional_params.concat(values)
|
51
|
+
@one_of_params = values
|
52
|
+
end
|
54
53
|
|
55
|
-
|
54
|
+
protected
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
# Verifies that all required arguments are present
|
57
|
+
def requires!
|
58
|
+
@required_params.each do |param|
|
59
|
+
key = (param.is_a?(Array) ? param.first : param)
|
60
|
+
verify_required_param(key)
|
61
|
+
end
|
62
62
|
end
|
63
|
-
end
|
64
63
|
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
# Checks to see if supplied params (which are booleans) contain
|
66
|
+
# either a 1 ("Yes") or 0 ("No") value.
|
67
|
+
def booleans!
|
68
|
+
@boolean_params.each do |param|
|
69
|
+
key = (param.is_a?(Array) ? param.first : param)
|
70
|
+
verify_boolean_param(key)
|
71
|
+
end
|
72
72
|
end
|
73
|
-
end
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
# Verifies that only valid arguments were set
|
75
|
+
def valid_options!
|
76
|
+
@options.keys.uniq.each do |key|
|
77
|
+
raise MooMoo::MooMooArgumentError.new("Not a valid parameter: #{key}") unless @optional_params.include?(key)
|
78
|
+
end
|
79
79
|
end
|
80
|
-
end
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
# Verifies that the one_of arguments were used correctly
|
82
|
+
def one_ofs!
|
83
|
+
if @one_of_params.size > 1
|
84
|
+
specified = @options.keys.select { |key| @one_of_params.include?(key) }.uniq
|
85
|
+
if specified.size > 1 || specified.size == 0
|
86
|
+
raise MooMoo::MooMooArgumentError.new("The parameters may include only one of '#{@one_of_params.join(', ')}'")
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise MooMoo::MooMooArgumentError.new("One of requires two or more items") unless @one_of_params.empty?
|
88
90
|
end
|
89
|
-
else
|
90
|
-
raise MooMoo::MooMooArgumentError.new("One of requires two or more items") unless @one_of_params.empty?
|
91
91
|
end
|
92
|
-
end
|
93
92
|
|
94
|
-
|
93
|
+
private
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
# Internal method for verifiying required arguments
|
96
|
+
def verify_required_param(param)
|
97
|
+
raise MooMoo::MooMooArgumentError.new("Missing required parameter: #{param}") unless @options.has_key?(param)
|
98
|
+
raise MooMoo::MooMooArgumentError.new("Required parameter cannot be blank: #{param}") if (@options[param].nil? || (@options[param].respond_to?(:empty?) && @options[param].empty?))
|
99
|
+
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
# Internal method for verifying boolean arguments
|
102
|
+
def verify_boolean_param(param)
|
103
|
+
if @options.include?(param) && ![true, false].include?(@options[param])
|
104
|
+
raise MooMoo::MooMooArgumentError.new("Boolean parameter must be \"true\" or \"false\": #{param}")
|
105
|
+
end
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
data/lib/moo_moo/opensrs/base.rb
CHANGED
@@ -1,21 +1,11 @@
|
|
1
1
|
module MooMoo
|
2
2
|
module OpenSRS
|
3
|
-
autoload :OpenSRSException, 'moo_moo/opensrs/opensrsexception'
|
4
|
-
autoload :Command, 'moo_moo/opensrs/command'
|
5
|
-
autoload :Utils, 'moo_moo/opensrs/utils'
|
6
|
-
autoload :LookupCommands, 'moo_moo/opensrs/lookup_commands'
|
7
|
-
autoload :ProvisioningCommands, 'moo_moo/opensrs/provisioning_commands'
|
8
|
-
autoload :TransferCommands, 'moo_moo/opensrs/transfer_commands'
|
9
|
-
autoload :NameserverCommands, 'moo_moo/opensrs/nameserver_commands'
|
10
|
-
autoload :CookieCommands, 'moo_moo/opensrs/cookie_commands'
|
11
|
-
|
12
3
|
class Base
|
13
4
|
include LookupCommands
|
14
5
|
include ProvisioningCommands
|
15
6
|
include TransferCommands
|
16
7
|
include NameserverCommands
|
17
8
|
include CookieCommands
|
18
|
-
include Utils
|
19
9
|
|
20
10
|
attr_reader :host, :key, :user, :pass, :port
|
21
11
|
|
@@ -31,7 +21,7 @@ module MooMoo
|
|
31
21
|
# * <tt>:port</tt> - port to connect on
|
32
22
|
def initialize(host = nil, key = nil, user = nil, pass = nil, port = 55443)
|
33
23
|
@host = host || MooMoo.config.host
|
34
|
-
@key
|
24
|
+
@key = key || MooMoo.config.key
|
35
25
|
@user = user || MooMoo.config.user
|
36
26
|
@pass = pass || MooMoo.config.pass
|
37
27
|
@port = port || MooMoo.config.port
|
@@ -70,6 +60,14 @@ module MooMoo
|
|
70
60
|
|
71
61
|
arr_indexed
|
72
62
|
end
|
63
|
+
|
64
|
+
def try_opensrs
|
65
|
+
begin
|
66
|
+
yield
|
67
|
+
rescue Exception => e
|
68
|
+
raise OpenSRSException, e.message
|
69
|
+
end
|
70
|
+
end
|
73
71
|
end
|
74
72
|
end
|
75
73
|
end
|
data/lib/moo_moo/opensrs.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module MooMoo
|
2
|
-
autoload :Args, 'moo_moo/opensrs/args'
|
3
|
-
|
4
2
|
module OpenSRS
|
5
|
-
autoload :
|
6
|
-
autoload :
|
3
|
+
autoload :Args, 'moo_moo/opensrs/args'
|
4
|
+
autoload :Base, 'moo_moo/opensrs/base'
|
5
|
+
autoload :Command, 'moo_moo/opensrs/command'
|
6
|
+
autoload :LookupCommands, 'moo_moo/opensrs/lookup_commands'
|
7
|
+
autoload :ProvisioningCommands, 'moo_moo/opensrs/provisioning_commands'
|
8
|
+
autoload :TransferCommands, 'moo_moo/opensrs/transfer_commands'
|
9
|
+
autoload :NameserverCommands, 'moo_moo/opensrs/nameserver_commands'
|
10
|
+
autoload :CookieCommands, 'moo_moo/opensrs/cookie_commands'
|
11
|
+
autoload :Response, 'moo_moo/opensrs/response'
|
7
12
|
end
|
8
13
|
end
|
data/lib/moo_moo/version.rb
CHANGED
data/lib/moo_moo.rb
CHANGED
data/moo_moo.gemspec
CHANGED
@@ -15,14 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "opensrs"
|
16
16
|
|
17
17
|
s.add_runtime_dependency('jruby-openssl', '~> 0.7.3') if RUBY_PLATFORM == 'java'
|
18
|
-
s.add_development_dependency 'rake', '~> 0.
|
19
|
-
s.add_development_dependency 'rspec', '~> 2.
|
18
|
+
s.add_development_dependency 'rake', '~> 0.9.2.2'
|
19
|
+
s.add_development_dependency 'rspec', '~> 2.8.0'
|
20
20
|
s.add_development_dependency 'fakeweb', '~> 1.3.0'
|
21
|
-
s.add_development_dependency 'vcr', '~> 1.
|
22
|
-
if !defined?(RUBY_ENGINE) || RUBY_ENGINE != 'rbx'
|
23
|
-
s.add_development_dependency 'rcov', '>= 0.9.9'
|
24
|
-
s.add_development_dependency 'metric_fu', '>= 2.1.1'
|
25
|
-
end
|
21
|
+
s.add_development_dependency 'vcr', '~> 1.11.3'
|
26
22
|
|
27
23
|
s.add_dependency 'extlib'
|
28
24
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::Config do
|
4
|
+
before :each do
|
5
|
+
@config = MooMoo::Config.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it { @config.should have_attr_accessor :host }
|
9
|
+
it { @config.should have_attr_accessor :key }
|
10
|
+
it { @config.should have_attr_accessor :user }
|
11
|
+
it { @config.should have_attr_accessor :pass }
|
12
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::OpenSRS::Args do
|
4
|
+
context "#required_parms" do
|
5
|
+
it "raises an error when missing" do
|
6
|
+
options = {:arg1 => true}
|
7
|
+
args = lambda {
|
8
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
9
|
+
c.requires :arg2
|
10
|
+
end
|
11
|
+
}
|
12
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /Missing required parameter: arg2/)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "does not raise an error with valid params" do
|
16
|
+
options = {:arg1 => true}
|
17
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
18
|
+
c.requires :arg1
|
19
|
+
}
|
20
|
+
|
21
|
+
args.required_params.should have(1).value
|
22
|
+
args.required_params.should include(:arg1)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "sets optional_params" do
|
26
|
+
options = {:arg1 => true, :arg2 => 2}
|
27
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
28
|
+
c.requires :arg1, :arg2
|
29
|
+
}
|
30
|
+
|
31
|
+
args.optional_params.should have(2).values
|
32
|
+
args.required_params.should have(2).values
|
33
|
+
|
34
|
+
args.optional_params.should include(*args.required_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not set boolean_params" do
|
38
|
+
options = {:arg1 => true, :arg2 => 2}
|
39
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
40
|
+
c.requires :arg1, :arg2
|
41
|
+
}
|
42
|
+
|
43
|
+
args.boolean_params.should be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "#boolean_params" do
|
48
|
+
it "raises an error when the param is not boolean" do
|
49
|
+
options = {:arg1 => 'string'}
|
50
|
+
args = lambda {
|
51
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
52
|
+
c.booleans :arg1
|
53
|
+
end
|
54
|
+
}
|
55
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /Boolean parameter must be.*: arg1/)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises an error with boolean params" do
|
59
|
+
options = {:arg1 => true}
|
60
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
61
|
+
c.booleans :arg1
|
62
|
+
}
|
63
|
+
|
64
|
+
args.boolean_params.should have(1).value
|
65
|
+
args.boolean_params.should include(:arg1)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "sets optional_params" do
|
69
|
+
options = {:arg1 => true, :arg2 => false}
|
70
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
71
|
+
c.booleans :arg1, :arg2
|
72
|
+
}
|
73
|
+
|
74
|
+
args.optional_params.should have(2).values
|
75
|
+
args.boolean_params.should have(2).values
|
76
|
+
|
77
|
+
args.optional_params.should include(:arg1, :arg2)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "sets required_params" do
|
81
|
+
options = {:arg1 => true, :arg2 => false}
|
82
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
83
|
+
c.booleans :arg1, :arg2
|
84
|
+
}
|
85
|
+
|
86
|
+
args.required_params.should be_empty
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "#optional_params" do
|
91
|
+
it "raises an error with unknown params" do
|
92
|
+
options = {:arg1 => true}
|
93
|
+
args = lambda {
|
94
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
95
|
+
c.optionals :arg2
|
96
|
+
end
|
97
|
+
}
|
98
|
+
|
99
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /Not a valid parameter: arg1/)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "does not raise an error with known params" do
|
103
|
+
options = {:arg1 => true, :arg2 => 2}
|
104
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
105
|
+
c.optionals :arg1, :arg2
|
106
|
+
}
|
107
|
+
|
108
|
+
args.optional_params.should have(2).values
|
109
|
+
args.optional_params.should include(:arg1, :arg2)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "does not set required_params" do
|
113
|
+
options = {:arg1 => true, :arg2 => 2}
|
114
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
115
|
+
c.optionals :arg1, :arg2
|
116
|
+
}
|
117
|
+
|
118
|
+
args.required_params.should be_empty
|
119
|
+
end
|
120
|
+
|
121
|
+
it "does not set boolean_params" do
|
122
|
+
options = {:arg1 => true, :arg2 => 2}
|
123
|
+
args = MooMoo::OpenSRS::Args.new(options) { |c|
|
124
|
+
c.optionals :arg1, :arg2
|
125
|
+
}
|
126
|
+
|
127
|
+
args.boolean_params.should be_empty
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "#one_of" do
|
132
|
+
it "allows one arg" do
|
133
|
+
options = {:arg1 => true}
|
134
|
+
args = lambda {
|
135
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
136
|
+
c.one_of :arg1
|
137
|
+
end
|
138
|
+
}
|
139
|
+
|
140
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /One of requires two or more items/)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "allows two or more args" do
|
144
|
+
options = {:arg1 => true}
|
145
|
+
|
146
|
+
args = MooMoo::OpenSRS::Args.new(options) do |c|
|
147
|
+
c.one_of :arg1, :arg2
|
148
|
+
end
|
149
|
+
|
150
|
+
args.one_of_params.should have(2).values
|
151
|
+
args.one_of_params.should include(:arg1, :arg2)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "does not allow 0 params" do
|
155
|
+
options = {}
|
156
|
+
args = lambda {
|
157
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
158
|
+
c.one_of :arg1, :arg2
|
159
|
+
end
|
160
|
+
}
|
161
|
+
|
162
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "does not allow both args" do
|
166
|
+
options = {:arg1 => true, :arg2 => 2}
|
167
|
+
args = lambda {
|
168
|
+
MooMoo::OpenSRS::Args.new(options) do |c|
|
169
|
+
c.one_of :arg1, :arg2
|
170
|
+
end
|
171
|
+
}
|
172
|
+
|
173
|
+
expect { args.call }.to raise_error(MooMoo::MooMooArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::OpenSRS::Base do
|
4
|
+
describe "included modules" do
|
5
|
+
subject { MooMoo::OpenSRS::Base }
|
6
|
+
it { should include MooMoo::OpenSRS::CookieCommands }
|
7
|
+
it { should include MooMoo::OpenSRS::LookupCommands }
|
8
|
+
it { should include MooMoo::OpenSRS::NameserverCommands }
|
9
|
+
it { should include MooMoo::OpenSRS::ProvisioningCommands }
|
10
|
+
it { should include MooMoo::OpenSRS::TransferCommands }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#try_opensrs" do
|
14
|
+
it "raises an OpenSRSException" do
|
15
|
+
expect do
|
16
|
+
MooMoo::OpenSRS::Base.new.instance_eval do
|
17
|
+
try_opensrs { raise "Exception message" }
|
18
|
+
end
|
19
|
+
end.to raise_error MooMoo::OpenSRSException
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MooMoo::OpenSRS::CookieCommands do
|
4
|
+
before(:each) do
|
5
|
+
@opensrs = MooMoo::OpenSRS::Base.new
|
6
|
+
@registered_domain = "domainthatsnottaken1302209138.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#set_cookie" do
|
10
|
+
it "sets the cookie" do
|
11
|
+
VCR.use_cassette("cookie/set_cookie") do
|
12
|
+
res = @opensrs.set_cookie(
|
13
|
+
:username => MooMoo.config.user,
|
14
|
+
:password => MooMoo.config.pass,
|
15
|
+
:domain => @registered_domain
|
16
|
+
)
|
17
|
+
res.success?.should be_true
|
18
|
+
res.result['cookie'].should == "0000000000000000:000000:00000"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "fails to set the cookie" do
|
23
|
+
VCR.use_cassette("cookie/set_cookie_fail") do
|
24
|
+
res = @opensrs.set_cookie(
|
25
|
+
:username => MooMoo.config.user,
|
26
|
+
:password => 'password',
|
27
|
+
:domain => 'example.com'
|
28
|
+
)
|
29
|
+
res.success?.should be_false
|
30
|
+
res.error_code.should == 415
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#delete_cookie" do
|
36
|
+
use_vcr_cassette "cookie/delete_cookie"
|
37
|
+
|
38
|
+
it "destroys the cookie" do
|
39
|
+
res = @opensrs.set_cookie(
|
40
|
+
:username => MooMoo.config.user,
|
41
|
+
:password => MooMoo.config.pass,
|
42
|
+
:domain => @registered_domain
|
43
|
+
)
|
44
|
+
res = @opensrs.delete_cookie(res.result['cookie'])
|
45
|
+
res.success?.should be_true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#update_cookie" do
|
50
|
+
use_vcr_cassette "cookie/update_cookie"
|
51
|
+
|
52
|
+
it "updates the cookie's domain" do
|
53
|
+
res = @opensrs.set_cookie(
|
54
|
+
:username => MooMoo.config.user,
|
55
|
+
:password => MooMoo.config.pass,
|
56
|
+
:domain => @registered_domain
|
57
|
+
)
|
58
|
+
res = @opensrs.update_cookie(
|
59
|
+
:old_domain => @registered_domain,
|
60
|
+
:new_domain => @registered_domain,
|
61
|
+
:cookie => res.result['cookie']
|
62
|
+
)
|
63
|
+
res.success?.should be_true
|
64
|
+
res.result['domain_count'].to_i.should == 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#quit_session" do
|
69
|
+
use_vcr_cassette "cookie/quit_session"
|
70
|
+
|
71
|
+
it "quits the session" do
|
72
|
+
res = @opensrs.quit_session
|
73
|
+
res.success?.should be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|