epp-client 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.simplecov +16 -0
- data/.travis.yml +11 -0
- data/.yardopts +4 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +1 -1
- data/README.md +75 -0
- data/Rakefile +2 -37
- data/epp-client.gemspec +15 -58
- data/gemfiles/Gemfile.ruby18 +13 -0
- data/lib/epp-client.rb +94 -7
- data/lib/epp-client/client.rb +117 -20
- data/lib/epp-client/commands/check.rb +11 -0
- data/lib/epp-client/commands/command.rb +24 -0
- data/lib/epp-client/commands/create.rb +11 -0
- data/lib/epp-client/commands/delete.rb +11 -0
- data/lib/epp-client/commands/info.rb +11 -0
- data/lib/epp-client/commands/login.rb +40 -0
- data/lib/epp-client/commands/logout.rb +11 -0
- data/lib/epp-client/commands/poll.rb +28 -0
- data/lib/epp-client/commands/read_write_command.rb +18 -0
- data/lib/epp-client/commands/renew.rb +11 -0
- data/lib/epp-client/commands/transfer.rb +25 -0
- data/lib/epp-client/commands/update.rb +11 -0
- data/lib/epp-client/contact/check.rb +23 -0
- data/lib/epp-client/contact/check_response.rb +22 -0
- data/lib/epp-client/contact/command.rb +87 -0
- data/lib/epp-client/contact/create.rb +34 -0
- data/lib/epp-client/contact/create_response.rb +14 -0
- data/lib/epp-client/contact/delete.rb +21 -0
- data/lib/epp-client/contact/delete_response.rb +9 -0
- data/lib/epp-client/contact/info.rb +21 -0
- data/lib/epp-client/contact/info_response.rb +74 -0
- data/lib/epp-client/contact/response.rb +34 -0
- data/lib/epp-client/contact/transfer.rb +21 -0
- data/lib/epp-client/contact/transfer_response.rb +26 -0
- data/lib/epp-client/contact/update.rb +80 -0
- data/lib/epp-client/contact/update_response.rb +9 -0
- data/lib/epp-client/domain/check.rb +23 -0
- data/lib/epp-client/domain/check_response.rb +22 -0
- data/lib/epp-client/domain/command.rb +92 -0
- data/lib/epp-client/domain/create.rb +49 -0
- data/lib/epp-client/domain/create_response.rb +17 -0
- data/lib/epp-client/domain/delete.rb +21 -0
- data/lib/epp-client/domain/delete_response.rb +9 -0
- data/lib/epp-client/domain/info.rb +21 -0
- data/lib/epp-client/domain/info_response.rb +66 -0
- data/lib/epp-client/domain/renew.rb +34 -0
- data/lib/epp-client/domain/renew_response.rb +14 -0
- data/lib/epp-client/domain/response.rb +34 -0
- data/lib/epp-client/domain/transfer.rb +27 -0
- data/lib/epp-client/domain/transfer_response.rb +29 -0
- data/lib/epp-client/domain/update.rb +81 -0
- data/lib/epp-client/domain/update_response.rb +9 -0
- data/lib/epp-client/host/check.rb +23 -0
- data/lib/epp-client/host/check_response.rb +22 -0
- data/lib/epp-client/host/command.rb +47 -0
- data/lib/epp-client/host/create.rb +24 -0
- data/lib/epp-client/host/create_response.rb +14 -0
- data/lib/epp-client/host/delete.rb +21 -0
- data/lib/epp-client/host/delete_response.rb +9 -0
- data/lib/epp-client/host/info.rb +21 -0
- data/lib/epp-client/host/info_response.rb +42 -0
- data/lib/epp-client/host/response.rb +34 -0
- data/lib/epp-client/host/update.rb +76 -0
- data/lib/epp-client/host/update_response.rb +9 -0
- data/lib/epp-client/request.rb +29 -74
- data/lib/epp-client/requests/abstract.rb +30 -0
- data/lib/epp-client/requests/command.rb +28 -0
- data/lib/epp-client/requests/extension.rb +28 -0
- data/lib/epp-client/requests/hello.rb +12 -0
- data/lib/epp-client/response.rb +45 -8
- data/lib/epp-client/response_helper.rb +25 -0
- data/lib/epp-client/server.rb +167 -63
- data/lib/epp-client/testing.rb +59 -0
- data/lib/epp-client/version.rb +3 -0
- data/lib/epp-client/xml_helper.rb +71 -0
- data/test/commands/test_check_command.rb +33 -0
- data/test/commands/test_create_command.rb +53 -0
- data/test/commands/test_delete_command.rb +28 -0
- data/test/commands/test_info_command.rb +28 -0
- data/test/commands/test_login_command.rb +56 -0
- data/test/commands/test_logout_command.rb +22 -0
- data/test/commands/test_poll_command.rb +54 -0
- data/test/commands/test_renew_command.rb +39 -0
- data/test/commands/test_transfer_command.rb +37 -0
- data/test/commands/test_update_command.rb +60 -0
- data/test/contact/test_contact_check.rb +33 -0
- data/test/contact/test_contact_check_response.rb +38 -0
- data/test/contact/test_contact_create.rb +70 -0
- data/test/contact/test_contact_create_response.rb +33 -0
- data/test/contact/test_contact_delete.rb +28 -0
- data/test/contact/test_contact_delete_response.rb +23 -0
- data/test/contact/test_contact_info.rb +28 -0
- data/test/contact/test_contact_info_response.rb +100 -0
- data/test/contact/test_contact_transfer.rb +28 -0
- data/test/contact/test_contact_transfer_response.rb +100 -0
- data/test/contact/test_contact_update.rb +83 -0
- data/test/contact/test_contact_update_response.rb +23 -0
- data/test/domain/test_domain_check.rb +33 -0
- data/test/domain/test_domain_check_response.rb +38 -0
- data/test/domain/test_domain_create.rb +53 -0
- data/test/domain/test_domain_create_response.rb +39 -0
- data/test/domain/test_domain_delete.rb +28 -0
- data/test/domain/test_domain_delete_response.rb +23 -0
- data/test/domain/test_domain_info.rb +28 -0
- data/test/domain/test_domain_info_response.rb +107 -0
- data/test/domain/test_domain_renew.rb +39 -0
- data/test/domain/test_domain_renew_response.rb +32 -0
- data/test/domain/test_domain_transfer.rb +37 -0
- data/test/domain/test_domain_transfer_response.rb +112 -0
- data/test/domain/test_domain_update.rb +73 -0
- data/test/domain/test_domain_update_response.rb +23 -0
- data/test/fixtures/responses/contact/check.xml +27 -0
- data/test/fixtures/responses/contact/create.xml +19 -0
- data/test/fixtures/responses/contact/delete.xml +12 -0
- data/test/fixtures/responses/contact/info.xml +49 -0
- data/test/fixtures/responses/contact/transfer-query.xml +23 -0
- data/test/fixtures/responses/contact/transfer-request.xml +23 -0
- data/test/fixtures/responses/contact/update.xml +12 -0
- data/test/fixtures/responses/domain/check.xml +27 -0
- data/test/fixtures/responses/domain/create.xml +20 -0
- data/test/fixtures/responses/domain/delete.xml +12 -0
- data/test/fixtures/responses/domain/info-no-exDate.xml +38 -0
- data/test/fixtures/responses/domain/info.xml +39 -0
- data/test/fixtures/responses/domain/renew.xml +19 -0
- data/test/fixtures/responses/domain/transfer-query.xml +24 -0
- data/test/fixtures/responses/domain/transfer-request.xml +24 -0
- data/test/fixtures/responses/domain/update.xml +12 -0
- data/test/fixtures/responses/greeting.xml +25 -0
- data/test/fixtures/responses/host/check.xml +27 -0
- data/test/fixtures/responses/host/create.xml +19 -0
- data/test/fixtures/responses/host/delete.xml +12 -0
- data/test/fixtures/responses/host/info.xml +30 -0
- data/test/fixtures/responses/host/update.xml +12 -0
- data/test/helper.rb +89 -0
- data/test/host/test_host_check.rb +33 -0
- data/test/host/test_host_check_response.rb +38 -0
- data/test/host/test_host_create.rb +37 -0
- data/test/host/test_host_create_response.rb +33 -0
- data/test/host/test_host_delete.rb +28 -0
- data/test/host/test_host_delete_response.rb +23 -0
- data/test/host/test_host_info.rb +28 -0
- data/test/host/test_host_info_response.rb +72 -0
- data/test/host/test_host_update.rb +68 -0
- data/test/host/test_host_update_response.rb +23 -0
- data/test/requests/test_command_request.rb +16 -0
- data/test/requests/test_extension_request.rb +55 -0
- data/test/requests/test_hello_request.rb +15 -0
- data/test/support/schemas/all.xsd +21 -0
- data/test/support/schemas/contact-1.0.xsd +387 -0
- data/test/support/schemas/domain-1.0.xsd +432 -0
- data/test/support/schemas/epp-1.0.xsd +403 -0
- data/test/support/schemas/eppcom-1.0.xsd +93 -0
- data/test/support/schemas/host-1.0.xsd +240 -0
- data/test/test_client.rb +54 -0
- data/test/test_request.rb +15 -0
- data/test/test_server.rb +57 -0
- metadata +270 -91
- data/.document +0 -5
- data/README.rdoc +0 -17
- data/VERSION +0 -1
- data/lib/epp-client/hello_request.rb +0 -9
- data/test/test_epp-client.rb +0 -7
data/lib/epp-client/client.rb
CHANGED
@@ -4,14 +4,33 @@ module EPP
|
|
4
4
|
# Establishes a connection to an EPP server and allows for sending commands
|
5
5
|
# to that EPP server.
|
6
6
|
class Client
|
7
|
+
# Default Service URNs
|
8
|
+
#
|
9
|
+
# Provided to make it easier for clients to add additional services to
|
10
|
+
# the default list.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# services = DEFAULT_SERVICES + %w(urn:ietf:params:xml:ns:secDNS-1.1)
|
14
|
+
# EPP::Client.new('username','password','epp.example.com', :services => services)
|
15
|
+
DEFAULT_SERVICES = [ Domain::NAMESPACE, Contact::NAMESPACE, Host::NAMESPACE ]
|
16
|
+
|
7
17
|
# Create new instance of EPP::Client.
|
8
18
|
#
|
9
19
|
# @param [String] tag EPP Tag
|
10
20
|
# @param [String] passwd EPP Tag password
|
11
21
|
# @param [String] host EPP Host address
|
12
22
|
# @param [Hash] options Options
|
13
|
-
# @option options [
|
23
|
+
# @option options [Integer] :port EPP Port number, default 700
|
24
|
+
# @option options [Boolean] :compatibility Compatibility mode, default false
|
25
|
+
# @option options [String] :lang EPP Language code, default 'en'
|
26
|
+
# @option options [String] :version EPP protocol version, default '1.0'
|
27
|
+
# @option options [Array<String>] :extensions EPP Extension URNs
|
28
|
+
# @option options [Array<String>] :services EPP Service URNs
|
29
|
+
# @option options [String] :address_family 'AF_INET' or 'AF_INET6' or either of the
|
30
|
+
# appropriate socket constants. Will cause connections to be
|
31
|
+
# limited to this address family. Default try all addresses.
|
14
32
|
def initialize(tag, passwd, host, options = {})
|
33
|
+
@tag, @passwd, @host, @options = tag, passwd, host, options
|
15
34
|
@conn = if options.delete(:compatibility) == true
|
16
35
|
OldServer.new(tag, passwd, host, options)
|
17
36
|
else
|
@@ -19,20 +38,64 @@ module EPP
|
|
19
38
|
end
|
20
39
|
end
|
21
40
|
|
41
|
+
attr_reader :tag, :passwd, :host, :options
|
42
|
+
|
43
|
+
def compatibility?
|
44
|
+
@conn.is_a?(OldServer)
|
45
|
+
end
|
46
|
+
|
22
47
|
# Returns the last request sent to the EPP server
|
23
48
|
#
|
24
49
|
# @return [Request] last request sent to the EPP server
|
25
|
-
def
|
50
|
+
def last_request
|
26
51
|
@conn.last_request
|
27
52
|
end
|
28
53
|
|
54
|
+
# Returns the last request sent to the EPP server
|
55
|
+
#
|
56
|
+
# @deprecated
|
57
|
+
# @return [Request] last request sent to the EPP server
|
58
|
+
def _last_request
|
59
|
+
warn "The #{self.class}#_last_request method is deprecated, please call #last_request"
|
60
|
+
last_request
|
61
|
+
end
|
62
|
+
|
29
63
|
# Returns the last response received from the EPP server
|
30
64
|
#
|
31
|
-
# @return [
|
32
|
-
def
|
65
|
+
# @return [Response] last response received from the EPP server
|
66
|
+
def last_response
|
33
67
|
@conn.last_response
|
34
68
|
end
|
35
69
|
|
70
|
+
# Returns the last response received from the EPP server
|
71
|
+
#
|
72
|
+
# @deprecated
|
73
|
+
# @return [Response] last response received from the EPP server
|
74
|
+
def _last_response
|
75
|
+
warn "The #{self.class}#_last_response method is deprecated, please call #last_response"
|
76
|
+
last_response
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns the last error received from a login or logout request
|
80
|
+
#
|
81
|
+
# @return [ResponseError] last error received from login/logout request
|
82
|
+
def last_error
|
83
|
+
@conn.last_error
|
84
|
+
end
|
85
|
+
|
86
|
+
# Returns the last error received from a login or logout request
|
87
|
+
#
|
88
|
+
# @deprecated
|
89
|
+
# @return [ResponseError] last error received from login/logout request
|
90
|
+
def _last_error
|
91
|
+
warn "The #{self.class}#_last_error method is deprecated, please call #last_error"
|
92
|
+
last_error
|
93
|
+
end
|
94
|
+
|
95
|
+
def greeting
|
96
|
+
@conn.greeting
|
97
|
+
end
|
98
|
+
|
36
99
|
# Send hello command
|
37
100
|
def hello
|
38
101
|
@conn.connection do
|
@@ -40,23 +103,57 @@ module EPP
|
|
40
103
|
end
|
41
104
|
end
|
42
105
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
106
|
+
def check(payload, extension = nil)
|
107
|
+
check = EPP::Commands::Check.new(payload)
|
108
|
+
command(check, extension)
|
109
|
+
end
|
110
|
+
|
111
|
+
def create(payload, extension = nil)
|
112
|
+
create = EPP::Commands::Create.new(payload)
|
113
|
+
command(create, extension)
|
114
|
+
end
|
115
|
+
|
116
|
+
def delete(payload, extension = nil)
|
117
|
+
delete = EPP::Commands::Delete.new(payload)
|
118
|
+
command(delete, extension)
|
119
|
+
end
|
120
|
+
|
121
|
+
def info(payload, extension = nil)
|
122
|
+
info = EPP::Commands::Info.new(payload)
|
123
|
+
command(info, extension)
|
124
|
+
end
|
125
|
+
|
126
|
+
def renew(payload, extension = nil)
|
127
|
+
renew = EPP::Commands::Renew.new(payload)
|
128
|
+
command(renew, extension)
|
129
|
+
end
|
130
|
+
|
131
|
+
def transfer(op, payload, extension = nil)
|
132
|
+
transfer = EPP::Commands::Transfer.new(op, payload)
|
133
|
+
command(transfer, extension)
|
134
|
+
end
|
135
|
+
|
136
|
+
def update(payload, extension = nil)
|
137
|
+
update = EPP::Commands::Update.new(payload)
|
138
|
+
command(update, extension)
|
139
|
+
end
|
140
|
+
|
141
|
+
def poll
|
142
|
+
poll = EPP::Commands::Poll.new
|
143
|
+
command(poll)
|
144
|
+
end
|
145
|
+
def ack(msgID)
|
146
|
+
ack = EPP::Commands::Poll.new(msgID)
|
147
|
+
command(ack)
|
148
|
+
end
|
149
|
+
|
150
|
+
protected
|
151
|
+
def command(cmd, extension = nil)
|
152
|
+
@conn.connection do
|
153
|
+
@conn.with_login do
|
154
|
+
@conn.request(cmd, extension)
|
155
|
+
end
|
58
156
|
end
|
59
157
|
end
|
60
|
-
end
|
61
158
|
end
|
62
159
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module EPP
|
2
|
+
module Commands
|
3
|
+
class Command
|
4
|
+
include XMLHelpers
|
5
|
+
|
6
|
+
def set_namespaces(namespaces)
|
7
|
+
@namespaces = namespaces
|
8
|
+
end
|
9
|
+
|
10
|
+
# Receiver in XML form
|
11
|
+
# @return [XML::Document] XML of the receiver
|
12
|
+
def to_xml
|
13
|
+
epp_node(name, @namespaces || {})
|
14
|
+
end
|
15
|
+
|
16
|
+
# Convert the receiver to a string
|
17
|
+
#
|
18
|
+
# @param [Hash] opts Formatting options, passed to the XML::Document
|
19
|
+
def to_s(opts = {})
|
20
|
+
to_xml.to_s({:indent => false}.merge(opts))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Commands
|
5
|
+
class Login < Command
|
6
|
+
def initialize(tag, passwd, config)
|
7
|
+
@tag, @passwd, @config = tag, passwd, config
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
'login'
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_xml
|
15
|
+
node = super
|
16
|
+
node << epp_node('clID', @tag, @namespaces || {})
|
17
|
+
node << epp_node('pw', @passwd, @namespaces || {})
|
18
|
+
|
19
|
+
options = epp_node('options', @namespaces || {})
|
20
|
+
options << epp_node('version', @config[:version], @namespaces || {})
|
21
|
+
options << epp_node('lang', @config[:lang], @namespaces || {})
|
22
|
+
node << options
|
23
|
+
|
24
|
+
svcs = epp_node('svcs', @namespaces || {})
|
25
|
+
@config[:services].each { |uri| svcs << epp_node('objURI', uri, @namespaces || {}) }
|
26
|
+
node << svcs
|
27
|
+
|
28
|
+
unless @config[:extensions].empty?
|
29
|
+
ext = epp_node('svcExtension', @namespaces || {})
|
30
|
+
@config[:extensions].each do |uri|
|
31
|
+
ext << epp_node('extURI', uri, @namespaces || {})
|
32
|
+
end
|
33
|
+
svcs << ext
|
34
|
+
end
|
35
|
+
|
36
|
+
node
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Commands
|
5
|
+
class Poll < Command
|
6
|
+
def initialize(msgID = nil)
|
7
|
+
@msgID = msgID
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
'poll'
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_xml
|
15
|
+
node = super
|
16
|
+
|
17
|
+
if @msgID
|
18
|
+
node['op'] = 'ack'
|
19
|
+
node['msgID'] = @msgID
|
20
|
+
else
|
21
|
+
node['op'] = 'req'
|
22
|
+
end
|
23
|
+
|
24
|
+
node
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Commands
|
5
|
+
class ReadWriteCommand < Command
|
6
|
+
def initialize(command)
|
7
|
+
@command = command
|
8
|
+
end
|
9
|
+
def to_xml
|
10
|
+
node = super
|
11
|
+
|
12
|
+
@command.set_namespaces(@namespaces) if @command.respond_to?(:set_namespaces)
|
13
|
+
node << as_xml(@command)
|
14
|
+
node
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../read_write_command', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Commands
|
5
|
+
class Transfer < ReadWriteCommand
|
6
|
+
OPERATIONS = %w(approve cancel query reject request)
|
7
|
+
|
8
|
+
def initialize(op, command)
|
9
|
+
raise ArgumentError, "op must be one of #{OPERATIONS.join(', ')}" unless OPERATIONS.include?(op)
|
10
|
+
|
11
|
+
super command
|
12
|
+
@op = op
|
13
|
+
end
|
14
|
+
def name
|
15
|
+
'transfer'
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_xml
|
19
|
+
node = super
|
20
|
+
node['op'] = @op
|
21
|
+
node
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Contact
|
5
|
+
class Check < Command
|
6
|
+
def initialize(*ids)
|
7
|
+
@ids = ids.flatten
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
'check'
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_xml
|
15
|
+
node = super
|
16
|
+
@ids.each do |id|
|
17
|
+
node << contact_node('id', id)
|
18
|
+
end
|
19
|
+
node
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
2
|
+
|
3
|
+
module EPP
|
4
|
+
module Contact
|
5
|
+
class CheckResponse < Response
|
6
|
+
def available?(id)
|
7
|
+
availability[id]
|
8
|
+
end
|
9
|
+
def unavailable?(id)
|
10
|
+
!available?(id)
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def availability
|
15
|
+
@availability ||= nodes_for_xpath('//contact:id').inject({}) do |hash, node|
|
16
|
+
hash[node.content.strip] = node['avail'] == '1'
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|