epp-client 0.0.3 → 1.0.0

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.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.simplecov +16 -0
  4. data/.travis.yml +11 -0
  5. data/.yardopts +4 -0
  6. data/Gemfile +20 -0
  7. data/Gemfile.lock +51 -0
  8. data/LICENSE +1 -1
  9. data/README.md +75 -0
  10. data/Rakefile +2 -37
  11. data/epp-client.gemspec +15 -58
  12. data/gemfiles/Gemfile.ruby18 +13 -0
  13. data/lib/epp-client.rb +94 -7
  14. data/lib/epp-client/client.rb +117 -20
  15. data/lib/epp-client/commands/check.rb +11 -0
  16. data/lib/epp-client/commands/command.rb +24 -0
  17. data/lib/epp-client/commands/create.rb +11 -0
  18. data/lib/epp-client/commands/delete.rb +11 -0
  19. data/lib/epp-client/commands/info.rb +11 -0
  20. data/lib/epp-client/commands/login.rb +40 -0
  21. data/lib/epp-client/commands/logout.rb +11 -0
  22. data/lib/epp-client/commands/poll.rb +28 -0
  23. data/lib/epp-client/commands/read_write_command.rb +18 -0
  24. data/lib/epp-client/commands/renew.rb +11 -0
  25. data/lib/epp-client/commands/transfer.rb +25 -0
  26. data/lib/epp-client/commands/update.rb +11 -0
  27. data/lib/epp-client/contact/check.rb +23 -0
  28. data/lib/epp-client/contact/check_response.rb +22 -0
  29. data/lib/epp-client/contact/command.rb +87 -0
  30. data/lib/epp-client/contact/create.rb +34 -0
  31. data/lib/epp-client/contact/create_response.rb +14 -0
  32. data/lib/epp-client/contact/delete.rb +21 -0
  33. data/lib/epp-client/contact/delete_response.rb +9 -0
  34. data/lib/epp-client/contact/info.rb +21 -0
  35. data/lib/epp-client/contact/info_response.rb +74 -0
  36. data/lib/epp-client/contact/response.rb +34 -0
  37. data/lib/epp-client/contact/transfer.rb +21 -0
  38. data/lib/epp-client/contact/transfer_response.rb +26 -0
  39. data/lib/epp-client/contact/update.rb +80 -0
  40. data/lib/epp-client/contact/update_response.rb +9 -0
  41. data/lib/epp-client/domain/check.rb +23 -0
  42. data/lib/epp-client/domain/check_response.rb +22 -0
  43. data/lib/epp-client/domain/command.rb +92 -0
  44. data/lib/epp-client/domain/create.rb +49 -0
  45. data/lib/epp-client/domain/create_response.rb +17 -0
  46. data/lib/epp-client/domain/delete.rb +21 -0
  47. data/lib/epp-client/domain/delete_response.rb +9 -0
  48. data/lib/epp-client/domain/info.rb +21 -0
  49. data/lib/epp-client/domain/info_response.rb +66 -0
  50. data/lib/epp-client/domain/renew.rb +34 -0
  51. data/lib/epp-client/domain/renew_response.rb +14 -0
  52. data/lib/epp-client/domain/response.rb +34 -0
  53. data/lib/epp-client/domain/transfer.rb +27 -0
  54. data/lib/epp-client/domain/transfer_response.rb +29 -0
  55. data/lib/epp-client/domain/update.rb +81 -0
  56. data/lib/epp-client/domain/update_response.rb +9 -0
  57. data/lib/epp-client/host/check.rb +23 -0
  58. data/lib/epp-client/host/check_response.rb +22 -0
  59. data/lib/epp-client/host/command.rb +47 -0
  60. data/lib/epp-client/host/create.rb +24 -0
  61. data/lib/epp-client/host/create_response.rb +14 -0
  62. data/lib/epp-client/host/delete.rb +21 -0
  63. data/lib/epp-client/host/delete_response.rb +9 -0
  64. data/lib/epp-client/host/info.rb +21 -0
  65. data/lib/epp-client/host/info_response.rb +42 -0
  66. data/lib/epp-client/host/response.rb +34 -0
  67. data/lib/epp-client/host/update.rb +76 -0
  68. data/lib/epp-client/host/update_response.rb +9 -0
  69. data/lib/epp-client/request.rb +29 -74
  70. data/lib/epp-client/requests/abstract.rb +30 -0
  71. data/lib/epp-client/requests/command.rb +28 -0
  72. data/lib/epp-client/requests/extension.rb +28 -0
  73. data/lib/epp-client/requests/hello.rb +12 -0
  74. data/lib/epp-client/response.rb +45 -8
  75. data/lib/epp-client/response_helper.rb +25 -0
  76. data/lib/epp-client/server.rb +167 -63
  77. data/lib/epp-client/testing.rb +59 -0
  78. data/lib/epp-client/version.rb +3 -0
  79. data/lib/epp-client/xml_helper.rb +71 -0
  80. data/test/commands/test_check_command.rb +33 -0
  81. data/test/commands/test_create_command.rb +53 -0
  82. data/test/commands/test_delete_command.rb +28 -0
  83. data/test/commands/test_info_command.rb +28 -0
  84. data/test/commands/test_login_command.rb +56 -0
  85. data/test/commands/test_logout_command.rb +22 -0
  86. data/test/commands/test_poll_command.rb +54 -0
  87. data/test/commands/test_renew_command.rb +39 -0
  88. data/test/commands/test_transfer_command.rb +37 -0
  89. data/test/commands/test_update_command.rb +60 -0
  90. data/test/contact/test_contact_check.rb +33 -0
  91. data/test/contact/test_contact_check_response.rb +38 -0
  92. data/test/contact/test_contact_create.rb +70 -0
  93. data/test/contact/test_contact_create_response.rb +33 -0
  94. data/test/contact/test_contact_delete.rb +28 -0
  95. data/test/contact/test_contact_delete_response.rb +23 -0
  96. data/test/contact/test_contact_info.rb +28 -0
  97. data/test/contact/test_contact_info_response.rb +100 -0
  98. data/test/contact/test_contact_transfer.rb +28 -0
  99. data/test/contact/test_contact_transfer_response.rb +100 -0
  100. data/test/contact/test_contact_update.rb +83 -0
  101. data/test/contact/test_contact_update_response.rb +23 -0
  102. data/test/domain/test_domain_check.rb +33 -0
  103. data/test/domain/test_domain_check_response.rb +38 -0
  104. data/test/domain/test_domain_create.rb +53 -0
  105. data/test/domain/test_domain_create_response.rb +39 -0
  106. data/test/domain/test_domain_delete.rb +28 -0
  107. data/test/domain/test_domain_delete_response.rb +23 -0
  108. data/test/domain/test_domain_info.rb +28 -0
  109. data/test/domain/test_domain_info_response.rb +107 -0
  110. data/test/domain/test_domain_renew.rb +39 -0
  111. data/test/domain/test_domain_renew_response.rb +32 -0
  112. data/test/domain/test_domain_transfer.rb +37 -0
  113. data/test/domain/test_domain_transfer_response.rb +112 -0
  114. data/test/domain/test_domain_update.rb +73 -0
  115. data/test/domain/test_domain_update_response.rb +23 -0
  116. data/test/fixtures/responses/contact/check.xml +27 -0
  117. data/test/fixtures/responses/contact/create.xml +19 -0
  118. data/test/fixtures/responses/contact/delete.xml +12 -0
  119. data/test/fixtures/responses/contact/info.xml +49 -0
  120. data/test/fixtures/responses/contact/transfer-query.xml +23 -0
  121. data/test/fixtures/responses/contact/transfer-request.xml +23 -0
  122. data/test/fixtures/responses/contact/update.xml +12 -0
  123. data/test/fixtures/responses/domain/check.xml +27 -0
  124. data/test/fixtures/responses/domain/create.xml +20 -0
  125. data/test/fixtures/responses/domain/delete.xml +12 -0
  126. data/test/fixtures/responses/domain/info-no-exDate.xml +38 -0
  127. data/test/fixtures/responses/domain/info.xml +39 -0
  128. data/test/fixtures/responses/domain/renew.xml +19 -0
  129. data/test/fixtures/responses/domain/transfer-query.xml +24 -0
  130. data/test/fixtures/responses/domain/transfer-request.xml +24 -0
  131. data/test/fixtures/responses/domain/update.xml +12 -0
  132. data/test/fixtures/responses/greeting.xml +25 -0
  133. data/test/fixtures/responses/host/check.xml +27 -0
  134. data/test/fixtures/responses/host/create.xml +19 -0
  135. data/test/fixtures/responses/host/delete.xml +12 -0
  136. data/test/fixtures/responses/host/info.xml +30 -0
  137. data/test/fixtures/responses/host/update.xml +12 -0
  138. data/test/helper.rb +89 -0
  139. data/test/host/test_host_check.rb +33 -0
  140. data/test/host/test_host_check_response.rb +38 -0
  141. data/test/host/test_host_create.rb +37 -0
  142. data/test/host/test_host_create_response.rb +33 -0
  143. data/test/host/test_host_delete.rb +28 -0
  144. data/test/host/test_host_delete_response.rb +23 -0
  145. data/test/host/test_host_info.rb +28 -0
  146. data/test/host/test_host_info_response.rb +72 -0
  147. data/test/host/test_host_update.rb +68 -0
  148. data/test/host/test_host_update_response.rb +23 -0
  149. data/test/requests/test_command_request.rb +16 -0
  150. data/test/requests/test_extension_request.rb +55 -0
  151. data/test/requests/test_hello_request.rb +15 -0
  152. data/test/support/schemas/all.xsd +21 -0
  153. data/test/support/schemas/contact-1.0.xsd +387 -0
  154. data/test/support/schemas/domain-1.0.xsd +432 -0
  155. data/test/support/schemas/epp-1.0.xsd +403 -0
  156. data/test/support/schemas/eppcom-1.0.xsd +93 -0
  157. data/test/support/schemas/host-1.0.xsd +240 -0
  158. data/test/test_client.rb +54 -0
  159. data/test/test_request.rb +15 -0
  160. data/test/test_server.rb +57 -0
  161. metadata +270 -91
  162. data/.document +0 -5
  163. data/README.rdoc +0 -17
  164. data/VERSION +0 -1
  165. data/lib/epp-client/hello_request.rb +0 -9
  166. data/test/test_epp-client.rb +0 -7
@@ -0,0 +1,59 @@
1
+ require 'epp-client'
2
+
3
+ module EPP
4
+ class Client
5
+ # Request Preparation Methods
6
+ def check_prepare(payload, extension = nil)
7
+ check = EPP::Commands::Check.new(payload)
8
+ prepare_request(check, extension)
9
+ end
10
+
11
+ def create_prepare(payload, extension = nil)
12
+ create = EPP::Commands::Create.new(payload)
13
+ prepare_request(create, extension)
14
+ end
15
+
16
+ def delete_prepare(payload, extension = nil)
17
+ delete = EPP::Commands::Delete.new(payload)
18
+ prepare_request(delete, extension)
19
+ end
20
+
21
+ def info_prepare(payload, extension = nil)
22
+ info = EPP::Commands::Info.new(payload)
23
+ prepare_request(info, extension)
24
+ end
25
+
26
+ def renew_prepare(payload, extension = nil)
27
+ renew = EPP::Commands::Renew.new(payload)
28
+ prepare_request(renew, extension)
29
+ end
30
+
31
+ def transfer_prepare(op, payload, extension = nil)
32
+ transfer = EPP::Commands::Transfer.new(op, payload)
33
+ prepare_request(transfer, extension)
34
+ end
35
+
36
+ def update_prepare(payload, extension = nil)
37
+ update = EPP::Commands::Update.new(payload)
38
+ prepare_request(update, extension)
39
+ end
40
+
41
+ def poll_prepare
42
+ poll = EPP::Commands::Poll.new
43
+ prepare_request(poll)
44
+ end
45
+ def ack_prepare(msgID)
46
+ ack = EPP::Commands::Poll.new(msgID)
47
+ prepare_request(ack)
48
+ end
49
+
50
+ def prepare_request(cmd, extension = nil)
51
+ @conn.prepare_request(cmd, extension)
52
+ end
53
+
54
+ # Response Preparation Methods
55
+ def load_response(xml_data)
56
+ EPP::Response.new(xml_data)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module EPP
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,71 @@
1
+ module EPP
2
+ module XMLHelpers
3
+ # Creates and returns an instance of the EPP 1.0 namespace
4
+ #
5
+ # @param [XML::Node] node to create the namespace on
6
+ # @param [String, nil] Name to give the namespace
7
+ # @return [XML::Namespace] EPP 1.0 namespace
8
+ def epp_namespace(node, name = nil, namespaces = {})
9
+ return namespaces['epp'] if namespaces.has_key?('epp')
10
+ xml_namespace(node, name, 'urn:ietf:params:xml:ns:epp-1.0')
11
+ end
12
+
13
+ # Creates and returns a new node in the EPP 1.0 namespace
14
+ #
15
+ # @param [String] name of the node to create
16
+ # @param [String,XML::Node,nil] value of the node
17
+ # @return [XML::Node]
18
+ def epp_node(name, value = nil, namespaces = {})
19
+ value, namespaces = nil, value if value.kind_of?(Hash)
20
+
21
+ node = xml_node(name, value)
22
+ node.namespaces.namespace = epp_namespace(node, nil, namespaces)
23
+ node
24
+ end
25
+
26
+ # Creates and returns a new XML node
27
+ #
28
+ # @param [String] name of the node to create
29
+ # @param [String,XML::Node,nil] value of the node
30
+ # @return [XML::Node]
31
+ def xml_node(name, value = nil)
32
+ XML::Node.new(name, value)
33
+ end
34
+
35
+ # Creates and returns a new XML namespace
36
+ #
37
+ # @param [XML::Node] node XML node to add the namespace to
38
+ # @param [String] name Name of the namespace to create
39
+ # @param [String] uri URI of the namespace to create
40
+ # @return [XML::Namespace]
41
+ def xml_namespace(node, name, uri, namespaces = {})
42
+ XML::Namespace.new(node, name, uri)
43
+ end
44
+
45
+ # Creates and returns a new XML document
46
+ #
47
+ # @param [XML::Document,String] obj Object to create the document with
48
+ # @return [XML::Document]
49
+ def xml_document(obj)
50
+ case obj
51
+ when XML::Document
52
+ XML::Document.document(obj)
53
+ else
54
+ XML::Document.new('1.0')
55
+ end
56
+ end
57
+
58
+ def as_xml(obj)
59
+ return obj.to_xml if obj.respond_to?(:to_xml)
60
+
61
+ case obj
62
+ when String
63
+ XML::Document.string(obj).root
64
+ when XML::Node
65
+ obj
66
+ when XML::Document
67
+ obj.root
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestEppCheckCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Check' do
5
+ setup do
6
+ @domain_check = EPP::Domain::Check.new('example.com', 'example.net')
7
+
8
+ @check = EPP::Commands::Check.new(@domain_check)
9
+ @command = EPP::Requests::Command.new('ABC-123', @check)
10
+ @request = EPP::Request.new(@command)
11
+ @xml = @request.to_xml
12
+
13
+ namespaces_from_request
14
+ end
15
+
16
+ should 'validate against schema' do
17
+ assert @xml.validate_schema(schema)
18
+ end
19
+
20
+ should 'set clTRID' do
21
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
22
+ end
23
+
24
+ should 'set names' do
25
+ names = []
26
+ xpath_each('//domain:name') do |node|
27
+ names << node.content.strip
28
+ end
29
+
30
+ assert_equal %w(example.com example.net), names
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ class TestEppCreateCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Create' do
5
+ setup do
6
+ @domain_create = EPP::Domain::Create.new('example.com',
7
+ :period => '2y', :registrant => 'UK-2349723',
8
+ :nameservers => %w(ns1.test.host ns2.test.host),
9
+ :auth_info => {:pw => '2381728348'})
10
+
11
+ @create = EPP::Commands::Create.new(@domain_create)
12
+ @command = EPP::Requests::Command.new('ABC-123', @create)
13
+ @request = EPP::Request.new(@command)
14
+ @xml = @request.to_xml
15
+
16
+ namespaces_from_request
17
+ end
18
+
19
+ should 'validate against schema' do
20
+ assert @xml.validate_schema(schema)
21
+ end
22
+
23
+ should 'set clTRID' do
24
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
25
+ end
26
+
27
+ should 'set example.com as name' do
28
+ assert_equal 'example.com', xpath_find('//domain:name')
29
+ end
30
+
31
+ should 'set period' do
32
+ assert_equal '2', xpath_find('//domain:period')
33
+ assert_equal 'y', xpath_find('//domain:period/@unit')
34
+ end
35
+
36
+ should 'set registrant' do
37
+ assert_equal 'UK-2349723', xpath_find('//domain:registrant')
38
+ end
39
+
40
+ should 'set nameservers' do
41
+ nameservers = []
42
+ xpath_each('//domain:ns/domain:hostObj') do |node|
43
+ nameservers << node.content.strip
44
+ end
45
+
46
+ assert_equal %w(ns1.test.host ns2.test.host), nameservers
47
+ end
48
+
49
+ should 'set authInfo' do
50
+ assert_equal '2381728348', xpath_find('//domain:authInfo/domain:pw')
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestEppDeleteCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Delete' do
5
+ setup do
6
+ @domain_delete = EPP::Domain::Delete.new('example.com')
7
+
8
+ @delete = EPP::Commands::Delete.new(@domain_delete)
9
+ @command = EPP::Requests::Command.new('ABC-123', @delete)
10
+ @request = EPP::Request.new(@command)
11
+ @xml = @request.to_xml
12
+
13
+ namespaces_from_request
14
+ end
15
+
16
+ should 'validate against schema' do
17
+ assert @xml.validate_schema(schema)
18
+ end
19
+
20
+ should 'set clTRID' do
21
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
22
+ end
23
+
24
+ should 'set example.com as name' do
25
+ assert_equal 'example.com', xpath_find('//domain:name')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestEppInfoCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Info' do
5
+ setup do
6
+ @domain_info = EPP::Domain::Info.new('example.com')
7
+
8
+ @info = EPP::Commands::Info.new(@domain_info)
9
+ @command = EPP::Requests::Command.new('ABC-123', @info)
10
+ @request = EPP::Request.new(@command)
11
+ @xml = @request.to_xml
12
+
13
+ namespaces_from_request
14
+ end
15
+
16
+ should 'validate against schema' do
17
+ assert @xml.validate_schema(schema)
18
+ end
19
+
20
+ should 'set clTRID' do
21
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
22
+ end
23
+
24
+ should 'set example.com as name' do
25
+ assert_equal 'example.com', xpath_find('//domain:name')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,56 @@
1
+ require 'helper'
2
+
3
+ class TestEppLoginCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Login' do
5
+ setup do
6
+ @options = {:lang => 'en', :version => '1.0',
7
+ :services => EPP::Client::DEFAULT_SERVICES,
8
+ :extensions => ['http://www.nominet.org.uk/epp/xml/domain-nom-ext-1.2']}
9
+
10
+ @login = EPP::Commands::Login.new('TEST', 'testing', @options)
11
+ @command = EPP::Requests::Command.new('ABC-123', @login)
12
+ @request = EPP::Request.new(@command)
13
+
14
+ @xml = @request.to_xml
15
+
16
+ namespaces_from_request
17
+ end
18
+
19
+ should 'validate against schema' do
20
+ assert @xml.validate_schema(schema)
21
+ end
22
+
23
+ should 'set clTRID' do
24
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
25
+ end
26
+
27
+ should 'set TEST as clID' do
28
+ assert_equal 'TEST', xpath_find('//epp:clID')
29
+ end
30
+ should 'set testing as pw' do
31
+ assert_equal 'testing', xpath_find('//epp:pw')
32
+ end
33
+ should 'set 1.0 as version' do
34
+ assert_equal '1.0', xpath_find('//epp:version')
35
+ end
36
+ should 'set en as lang' do
37
+ assert_equal 'en', xpath_find('//epp:lang')
38
+ end
39
+ should 'set services' do
40
+ services = []
41
+ xpath_each('//epp:svcs/epp:objURI') do |node|
42
+ services << node.content
43
+ end
44
+
45
+ assert_equal services, @options[:services]
46
+ end
47
+ should 'set service extensions' do
48
+ extensions = []
49
+ xpath_each('//epp:svcs/epp:svcExtension/epp:extURI') do |node|
50
+ extensions << node.content
51
+ end
52
+
53
+ assert_equal extensions, @options[:extensions]
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ class TestEppLogoutCommand < Test::Unit::TestCase
4
+ context 'EPP::LogoutCommand' do
5
+ setup do
6
+ @logout = EPP::Commands::Logout.new
7
+ @command = EPP::Requests::Command.new('ABC-123', @logout)
8
+ @request = EPP::Request.new(@command)
9
+ @xml = @request.to_xml
10
+
11
+ namespaces_from_request
12
+ end
13
+
14
+ should 'validate against schema' do
15
+ assert @xml.validate_schema(schema)
16
+ end
17
+
18
+ should 'set clTRID' do
19
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ require 'helper'
2
+
3
+ class TestEppPollCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Poll' do
5
+ context 'poll' do
6
+ setup do
7
+ @poll = EPP::Commands::Poll.new
8
+ @command = EPP::Requests::Command.new('ABC-123', @poll)
9
+ @request = EPP::Request.new(@command)
10
+ @xml = @request.to_xml
11
+
12
+ namespaces_from_request
13
+ end
14
+
15
+ should 'validate against schema' do
16
+ assert @xml.validate_schema(schema)
17
+ end
18
+
19
+ should 'set clTRID' do
20
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
21
+ end
22
+
23
+ should 'set op mode req' do
24
+ assert_equal 'req', xpath_find('//epp:poll/@op')
25
+ end
26
+ end
27
+ context 'ack' do
28
+ setup do
29
+ @poll = EPP::Commands::Poll.new('234629834')
30
+ @command = EPP::Requests::Command.new('ABC-123', @poll)
31
+ @request = EPP::Request.new(@command)
32
+ @xml = @request.to_xml
33
+
34
+ namespaces_from_request
35
+ end
36
+
37
+ should 'validate against schema' do
38
+ assert @xml.validate_schema(schema)
39
+ end
40
+
41
+ should 'set clTRID' do
42
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
43
+ end
44
+
45
+ should 'set op mode ack' do
46
+ assert_equal 'ack', xpath_find('//epp:poll/@op')
47
+ end
48
+
49
+ should 'set msgID' do
50
+ assert_equal '234629834', xpath_find('//epp:poll/@msgID')
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+
3
+ class TestEppRenewCommand < Test::Unit::TestCase
4
+ context 'EPP::Commands::Renew' do
5
+ setup do
6
+ @time = Time.now
7
+ @domain_renew = EPP::Domain::Renew.new('example.com', @time, '12m')
8
+
9
+ @renew = EPP::Commands::Renew.new(@domain_renew)
10
+ @command = EPP::Requests::Command.new('ABC-123', @renew)
11
+ @request = EPP::Request.new(@command)
12
+ @xml = @request.to_xml
13
+
14
+ namespaces_from_request
15
+ end
16
+
17
+ should 'validate against schema' do
18
+ assert @xml.validate_schema(schema)
19
+ end
20
+
21
+ should 'set clTRID' do
22
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
23
+ end
24
+
25
+ should 'set example.com as name' do
26
+ assert_equal 'example.com', xpath_find('//domain:name')
27
+ end
28
+
29
+ should 'set date as curExpDate' do
30
+ date = @time.strftime('%Y-%m-%d')
31
+ assert_equal date, xpath_find('//domain:curExpDate')
32
+ end
33
+
34
+ should 'set period' do
35
+ assert_equal '12', xpath_find('//domain:period')
36
+ assert_equal 'm', xpath_find('//domain:period/@unit')
37
+ end
38
+ end
39
+ end