epp 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- = EPP v1.3.0 (by {Ultraspeed}[http://ultraspeed.co.uk])
1
+ = EPP v1.3.1 (by {Ultraspeed}[http://ultraspeed.co.uk])
2
2
 
3
3
  The EPP gem provides basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers. It has been fully tested against the RFC 5730 & 5734 specification.
4
4
 
@@ -42,7 +42,7 @@ You would then make an XML request to the server.
42
42
  xml = "<?xml ... </epp>"
43
43
  response = server.request(xml)
44
44
 
45
- You can build this however you'd like. The process is as follows:
45
+ You can build this however you'd like, although we prefer Hpricot. The process is as follows:
46
46
 
47
47
  * Connect to EPP server and receive the <greeting> frame
48
48
  * Send a standard <login> request
data/Rakefile CHANGED
@@ -15,7 +15,6 @@ begin
15
15
  # Dependencies
16
16
  gem.add_development_dependency "shoulda"
17
17
  gem.add_development_dependency "mocha"
18
- gem.add_dependency "activesupport"
19
18
  gem.add_dependency "hpricot"
20
19
  end
21
20
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epp}
8
- s.version = "1.3.1"
8
+ s.version = "1.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Delsman"]
12
- s.date = %q{2010-07-07}
12
+ s.date = %q{2010-07-14}
13
13
  s.description = %q{Basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers}
14
14
  s.email = %q{jdelsman@ultraspeed.com}
15
15
  s.extra_rdoc_files = [
@@ -56,18 +56,15 @@ Gem::Specification.new do |s|
56
56
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
57
  s.add_development_dependency(%q<shoulda>, [">= 0"])
58
58
  s.add_development_dependency(%q<mocha>, [">= 0"])
59
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
60
59
  s.add_runtime_dependency(%q<hpricot>, [">= 0"])
61
60
  else
62
61
  s.add_dependency(%q<shoulda>, [">= 0"])
63
62
  s.add_dependency(%q<mocha>, [">= 0"])
64
- s.add_dependency(%q<activesupport>, [">= 0"])
65
63
  s.add_dependency(%q<hpricot>, [">= 0"])
66
64
  end
67
65
  else
68
66
  s.add_dependency(%q<shoulda>, [">= 0"])
69
67
  s.add_dependency(%q<mocha>, [">= 0"])
70
- s.add_dependency(%q<activesupport>, [">= 0"])
71
68
  s.add_dependency(%q<hpricot>, [">= 0"])
72
69
  end
73
70
  end
data/lib/epp.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  # Gem and other dependencies
2
2
  require 'rubygems'
3
3
  require 'openssl'
4
- require 'socket'
5
- require 'active_support'
6
4
  require 'rexml/document'
7
5
  require 'hpricot'
6
+ require 'uuidtools'
8
7
 
9
8
  # Package files
10
9
  require File.dirname(__FILE__) + '/require_parameters.rb'
@@ -3,7 +3,7 @@ module Epp #:nodoc:
3
3
  include REXML
4
4
  include RequiresParameters
5
5
 
6
- attr_accessor :tag, :password, :server, :port, :services, :lang, :extensions, :version
6
+ attr_accessor :tag, :password, :server, :port, :lang, :services, :extensions, :version
7
7
 
8
8
  # ==== Required Attrbiutes
9
9
  #
@@ -14,7 +14,6 @@ module Epp #:nodoc:
14
14
  # ==== Optional Attributes
15
15
  #
16
16
  # * <tt>:port</tt> - The EPP standard port is 700. However, you can choose a different port to use.
17
- # * <tt>:clTRID</tt> - The client transaction identifier is an element that EPP specifies MAY be used to uniquely identify the command to the server. You are responsible for maintaining your own transaction identifier space to ensure uniqueness. Defaults to "ABC-12345"
18
17
  # * <tt>:lang</tt> - Set custom language attribute. Default is 'en'.
19
18
  # * <tt>:services</tt> - Use custom EPP services in the <login> frame. The defaults use the EPP standard domain, contact and host 1.0 services.
20
19
  # * <tt>:extensions</tt> - URLs to custom extensions to standard EPP. Use these to extend the standard EPP (e.g., Nominet uses extensions). Defaults to none.
@@ -35,7 +34,7 @@ module Epp #:nodoc:
35
34
  end
36
35
 
37
36
  def new_epp_request
38
- xml = Document.new
37
+ xml = Document.new
39
38
  xml << XMLDecl.new("1.0", "UTF-8", "no")
40
39
 
41
40
  xml.add_element("epp", {
@@ -59,10 +58,8 @@ module Epp #:nodoc:
59
58
  begin
60
59
  @response = send_request(xml)
61
60
  ensure
62
- if @logged_in
63
- @logged_in = false if logout
64
- end
65
-
61
+ @logged_in = false if @logged_in && logout
62
+
66
63
  close_connection
67
64
  end
68
65
 
@@ -92,8 +89,9 @@ module Epp #:nodoc:
92
89
 
93
90
  # Closes the connection to the EPP server.
94
91
  def close_connection
95
- @socket.close if @socket and not @socket.closed?
92
+ @socket.close if @socket and not @socket.closed?
96
93
  @connection.close if @connection and not @connection.closed?
94
+
97
95
  @socket = @connection = nil
98
96
 
99
97
  return true
@@ -107,14 +105,14 @@ module Epp #:nodoc:
107
105
  raise SocketError.new("Connection closed by remote server") if !@socket or @socket.eof?
108
106
 
109
107
  header = @socket.read(4)
110
-
108
+
111
109
  raise SocketError.new("Error reading frame from remote server") if header.nil?
112
-
110
+
113
111
  length = header_size(header)
114
-
112
+
115
113
  raise SocketError.new("Got bad frame header length of #{length} bytes from the server") if length < 5
116
-
117
- response = @socket.read(length - 4)
114
+
115
+ return @socket.read(length - 4)
118
116
  end
119
117
 
120
118
  # Send an XML frame to the server. Should return the total byte
@@ -131,8 +129,7 @@ module Epp #:nodoc:
131
129
 
132
130
  # Returns size of header of response from the EPP server.
133
131
  def header_size(header)
134
- unpacked_header = header.unpack("N")
135
- unpacked_header[0]
132
+ header.unpack("N").first
136
133
  end
137
134
 
138
135
  private
@@ -164,37 +161,37 @@ module Epp #:nodoc:
164
161
  extensions_container.add_element("extURI").text = uri
165
162
  end
166
163
 
167
- command.add_element("clTRID").text = "ABC-12345"
164
+ command.add_element("clTRID").text = UUIDTools::UUID.timestamp_create.to_s
168
165
 
169
166
  response = Hpricot.XML(send_request(xml.to_s))
170
167
 
171
- result_message = (response/"epp"/"response"/"result"/"msg").text.strip
172
- result_code = (response/"epp"/"response"/"result").attr("code").to_i
173
-
174
- if result_code == 1000
175
- return true
176
- else
177
- raise EppErrorResponse.new(:xml => response, :code => result_code, :message => result_message)
178
- end
168
+ handle_response(response)
179
169
  end
180
170
 
181
171
  # Sends a standard logout request to the EPP server.
182
- def logout
172
+ def logout
183
173
  raise SocketError, "Socket must be opened before logging out" if !@socket or @socket.closed?
184
174
 
185
175
  xml = new_epp_request
186
176
 
187
177
  command = xml.root.add_element("command")
188
- login = command.add_element("logout")
178
+
179
+ command.add_element("logout")
180
+ command.add_element("clTRID").text = UUIDTools::UUID.timestamp_create.to_s
189
181
 
190
182
  response = Hpricot.XML(send_request(xml.to_s))
191
183
 
192
- result_message = (response/"epp"/"response"/"result"/"msg").text.strip
193
- result_code = (response/"epp"/"response"/"result").attr("code").to_i
184
+ handle_response(response, 1500)
185
+ end
186
+
187
+ def handle_response(response, acceptable_response = 1000)
188
+ result_code = (response/"epp"/"response"/"result").attr("code").to_i
194
189
 
195
- if result_code == 1500
190
+ if result_code == acceptable_response
196
191
  return true
197
192
  else
193
+ result_message = (response/"epp"/"response"/"result"/"msg").text.strip
194
+
198
195
  raise EppErrorResponse.new(:xml => response, :code => result_code, :message => result_message)
199
196
  end
200
197
  end
@@ -211,7 +211,7 @@ class EppTest < Test::Unit::TestCase
211
211
  private
212
212
 
213
213
  def prepare_socket!
214
- @response = xml_file("test_request.xml")
214
+ @response = xml_file("test_response.xml")
215
215
 
216
216
  TCPSocket.expects(:new).returns(@tcp_sock)
217
217
  OpenSSL::SSL::SSLSocket.expects(:new).returns(@ssl_sock)
@@ -221,7 +221,6 @@ class EppTest < Test::Unit::TestCase
221
221
  @ssl_sock.expects(:read).with(4).returns("\000\000\003\r")
222
222
  @ssl_sock.expects(:read).with(777).returns(@response)
223
223
  @ssl_sock.stubs(:eof?)
224
-
225
224
  end
226
225
 
227
226
  def check_socket!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 1
10
- version: 1.3.1
9
+ - 2
10
+ version: 1.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Delsman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-07 00:00:00 -04:00
18
+ date: 2010-07-14 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :development
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: activesupport
50
+ name: hpricot
51
51
  prerelease: false
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -60,20 +60,6 @@ dependencies:
60
60
  version: "0"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: hpricot
65
- prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- type: :runtime
76
- version_requirements: *id004
77
63
  description: Basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers
78
64
  email: jdelsman@ultraspeed.com
79
65
  executables: []