epp-ruby 3.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 (178) 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/CHANGELOG.md +31 -0
  7. data/Gemfile +20 -0
  8. data/Gemfile.lock +51 -0
  9. data/LICENSE +21 -0
  10. data/README.md +95 -0
  11. data/Rakefile +20 -0
  12. data/epp-ruby.gemspec +22 -0
  13. data/examples/contact_create.rb +28 -0
  14. data/examples/domain_check.rb +11 -0
  15. data/examples/domain_create.rb +19 -0
  16. data/examples/domain_info.rb +9 -0
  17. data/examples/host_create.rb +14 -0
  18. data/gemfiles/Gemfile.ruby18 +14 -0
  19. data/lib/epp-client/client.rb +172 -0
  20. data/lib/epp-client/commands/check.rb +11 -0
  21. data/lib/epp-client/commands/command.rb +24 -0
  22. data/lib/epp-client/commands/create.rb +11 -0
  23. data/lib/epp-client/commands/delete.rb +11 -0
  24. data/lib/epp-client/commands/info.rb +11 -0
  25. data/lib/epp-client/commands/login.rb +40 -0
  26. data/lib/epp-client/commands/logout.rb +11 -0
  27. data/lib/epp-client/commands/poll.rb +28 -0
  28. data/lib/epp-client/commands/read_write_command.rb +18 -0
  29. data/lib/epp-client/commands/renew.rb +11 -0
  30. data/lib/epp-client/commands/transfer.rb +25 -0
  31. data/lib/epp-client/commands/transfer_handshake.rb +43 -0
  32. data/lib/epp-client/commands/update.rb +11 -0
  33. data/lib/epp-client/contact/check.rb +23 -0
  34. data/lib/epp-client/contact/check_response.rb +41 -0
  35. data/lib/epp-client/contact/command.rb +106 -0
  36. data/lib/epp-client/contact/create.rb +34 -0
  37. data/lib/epp-client/contact/create_response.rb +14 -0
  38. data/lib/epp-client/contact/delete.rb +21 -0
  39. data/lib/epp-client/contact/delete_response.rb +9 -0
  40. data/lib/epp-client/contact/info.rb +21 -0
  41. data/lib/epp-client/contact/info_response.rb +74 -0
  42. data/lib/epp-client/contact/response.rb +34 -0
  43. data/lib/epp-client/contact/transfer.rb +21 -0
  44. data/lib/epp-client/contact/transfer_response.rb +26 -0
  45. data/lib/epp-client/contact/update.rb +80 -0
  46. data/lib/epp-client/contact/update_response.rb +9 -0
  47. data/lib/epp-client/domain/check.rb +23 -0
  48. data/lib/epp-client/domain/check_response.rb +41 -0
  49. data/lib/epp-client/domain/command.rb +92 -0
  50. data/lib/epp-client/domain/create.rb +75 -0
  51. data/lib/epp-client/domain/create_response.rb +29 -0
  52. data/lib/epp-client/domain/delete.rb +21 -0
  53. data/lib/epp-client/domain/delete_response.rb +9 -0
  54. data/lib/epp-client/domain/info.rb +21 -0
  55. data/lib/epp-client/domain/info_response.rb +72 -0
  56. data/lib/epp-client/domain/list.rb +36 -0
  57. data/lib/epp-client/domain/renew.rb +38 -0
  58. data/lib/epp-client/domain/renew_response.rb +14 -0
  59. data/lib/epp-client/domain/response.rb +34 -0
  60. data/lib/epp-client/domain/transfer.rb +37 -0
  61. data/lib/epp-client/domain/transfer_response.rb +29 -0
  62. data/lib/epp-client/domain/update.rb +81 -0
  63. data/lib/epp-client/domain/update_response.rb +9 -0
  64. data/lib/epp-client/host/check.rb +23 -0
  65. data/lib/epp-client/host/check_response.rb +41 -0
  66. data/lib/epp-client/host/command.rb +47 -0
  67. data/lib/epp-client/host/create.rb +24 -0
  68. data/lib/epp-client/host/create_response.rb +14 -0
  69. data/lib/epp-client/host/delete.rb +21 -0
  70. data/lib/epp-client/host/delete_response.rb +9 -0
  71. data/lib/epp-client/host/info.rb +21 -0
  72. data/lib/epp-client/host/info_response.rb +42 -0
  73. data/lib/epp-client/host/response.rb +34 -0
  74. data/lib/epp-client/host/update.rb +76 -0
  75. data/lib/epp-client/host/update_response.rb +9 -0
  76. data/lib/epp-client/old_server.rb +25 -0
  77. data/lib/epp-client/request.rb +51 -0
  78. data/lib/epp-client/requests/abstract.rb +30 -0
  79. data/lib/epp-client/requests/command.rb +28 -0
  80. data/lib/epp-client/requests/extension.rb +28 -0
  81. data/lib/epp-client/requests/hello.rb +12 -0
  82. data/lib/epp-client/response.rb +100 -0
  83. data/lib/epp-client/response_error.rb +15 -0
  84. data/lib/epp-client/response_helper.rb +25 -0
  85. data/lib/epp-client/server.rb +330 -0
  86. data/lib/epp-client/testing.rb +59 -0
  87. data/lib/epp-client/version.rb +3 -0
  88. data/lib/epp-client/xml_helper.rb +71 -0
  89. data/lib/epp-client.rb +103 -0
  90. data/lib/epp-ruby.rb +1 -0
  91. data/test/commands/test_check_command.rb +33 -0
  92. data/test/commands/test_create_command.rb +53 -0
  93. data/test/commands/test_delete_command.rb +28 -0
  94. data/test/commands/test_info_command.rb +28 -0
  95. data/test/commands/test_login_command.rb +56 -0
  96. data/test/commands/test_logout_command.rb +22 -0
  97. data/test/commands/test_poll_command.rb +54 -0
  98. data/test/commands/test_renew_command.rb +39 -0
  99. data/test/commands/test_transfer_command.rb +37 -0
  100. data/test/commands/test_update_command.rb +60 -0
  101. data/test/contact/test_contact_check.rb +33 -0
  102. data/test/contact/test_contact_check_response.rb +88 -0
  103. data/test/contact/test_contact_create.rb +71 -0
  104. data/test/contact/test_contact_create_response.rb +33 -0
  105. data/test/contact/test_contact_delete.rb +28 -0
  106. data/test/contact/test_contact_delete_response.rb +23 -0
  107. data/test/contact/test_contact_info.rb +28 -0
  108. data/test/contact/test_contact_info_response.rb +100 -0
  109. data/test/contact/test_contact_transfer.rb +28 -0
  110. data/test/contact/test_contact_transfer_response.rb +100 -0
  111. data/test/contact/test_contact_update.rb +84 -0
  112. data/test/contact/test_contact_update_response.rb +23 -0
  113. data/test/domain/test_domain_check.rb +33 -0
  114. data/test/domain/test_domain_check_response.rb +88 -0
  115. data/test/domain/test_domain_create.rb +108 -0
  116. data/test/domain/test_domain_create_response.rb +70 -0
  117. data/test/domain/test_domain_delete.rb +28 -0
  118. data/test/domain/test_domain_delete_response.rb +23 -0
  119. data/test/domain/test_domain_info.rb +28 -0
  120. data/test/domain/test_domain_info_response.rb +146 -0
  121. data/test/domain/test_domain_renew.rb +91 -0
  122. data/test/domain/test_domain_renew_response.rb +32 -0
  123. data/test/domain/test_domain_transfer.rb +89 -0
  124. data/test/domain/test_domain_transfer_response.rb +112 -0
  125. data/test/domain/test_domain_update.rb +73 -0
  126. data/test/domain/test_domain_update_response.rb +23 -0
  127. data/test/fixtures/responses/contact/check-single.xml +20 -0
  128. data/test/fixtures/responses/contact/check.xml +27 -0
  129. data/test/fixtures/responses/contact/create.xml +19 -0
  130. data/test/fixtures/responses/contact/delete.xml +12 -0
  131. data/test/fixtures/responses/contact/info.xml +49 -0
  132. data/test/fixtures/responses/contact/transfer-query.xml +23 -0
  133. data/test/fixtures/responses/contact/transfer-request.xml +23 -0
  134. data/test/fixtures/responses/contact/update.xml +12 -0
  135. data/test/fixtures/responses/domain/check-single.xml +20 -0
  136. data/test/fixtures/responses/domain/check.xml +27 -0
  137. data/test/fixtures/responses/domain/create-pending.xml +12 -0
  138. data/test/fixtures/responses/domain/create.xml +20 -0
  139. data/test/fixtures/responses/domain/delete.xml +12 -0
  140. data/test/fixtures/responses/domain/info-no-exDate.xml +38 -0
  141. data/test/fixtures/responses/domain/info-ns-hostAttr-name-only.xml +34 -0
  142. data/test/fixtures/responses/domain/info-ns-hostAttr.xml +38 -0
  143. data/test/fixtures/responses/domain/info.xml +40 -0
  144. data/test/fixtures/responses/domain/renew.xml +19 -0
  145. data/test/fixtures/responses/domain/transfer-query.xml +24 -0
  146. data/test/fixtures/responses/domain/transfer-request.xml +24 -0
  147. data/test/fixtures/responses/domain/update.xml +12 -0
  148. data/test/fixtures/responses/greeting.xml +25 -0
  149. data/test/fixtures/responses/host/check-single.xml +20 -0
  150. data/test/fixtures/responses/host/check.xml +27 -0
  151. data/test/fixtures/responses/host/create.xml +19 -0
  152. data/test/fixtures/responses/host/delete.xml +12 -0
  153. data/test/fixtures/responses/host/info.xml +30 -0
  154. data/test/fixtures/responses/host/update.xml +12 -0
  155. data/test/helper.rb +100 -0
  156. data/test/host/test_host_check.rb +33 -0
  157. data/test/host/test_host_check_response.rb +88 -0
  158. data/test/host/test_host_create.rb +37 -0
  159. data/test/host/test_host_create_response.rb +33 -0
  160. data/test/host/test_host_delete.rb +28 -0
  161. data/test/host/test_host_delete_response.rb +23 -0
  162. data/test/host/test_host_info.rb +28 -0
  163. data/test/host/test_host_info_response.rb +72 -0
  164. data/test/host/test_host_update.rb +68 -0
  165. data/test/host/test_host_update_response.rb +23 -0
  166. data/test/requests/test_command_request.rb +16 -0
  167. data/test/requests/test_extension_request.rb +55 -0
  168. data/test/requests/test_hello_request.rb +15 -0
  169. data/test/support/schemas/all.xsd +21 -0
  170. data/test/support/schemas/contact-1.0.xsd +387 -0
  171. data/test/support/schemas/domain-1.0.xsd +432 -0
  172. data/test/support/schemas/epp-1.0.xsd +403 -0
  173. data/test/support/schemas/eppcom-1.0.xsd +93 -0
  174. data/test/support/schemas/host-1.0.xsd +240 -0
  175. data/test/test_client.rb +64 -0
  176. data/test/test_request.rb +15 -0
  177. data/test/test_server.rb +67 -0
  178. metadata +322 -0
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <domain:renData
9
+ xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
10
+ <domain:name>example.com</domain:name>
11
+ <domain:exDate>2005-04-03T22:00:00.0Z</domain:exDate>
12
+ </domain:renData>
13
+ </resData>
14
+ <trID>
15
+ <clTRID>ABC-12345</clTRID>
16
+ <svTRID>54322-XYZ</svTRID>
17
+ </trID>
18
+ </response>
19
+ </epp>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <domain:trnData
9
+ xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
10
+ <domain:name>example.com</domain:name>
11
+ <domain:trStatus>pending</domain:trStatus>
12
+ <domain:reID>ClientX</domain:reID>
13
+ <domain:reDate>2000-06-06T22:00:00.0Z</domain:reDate>
14
+ <domain:acID>ClientY</domain:acID>
15
+ <domain:acDate>2000-06-11T22:00:00.0Z</domain:acDate>
16
+ <domain:exDate>2002-09-08T22:00:00.0Z</domain:exDate>
17
+ </domain:trnData>
18
+ </resData>
19
+ <trID>
20
+ <clTRID>ABC-12345</clTRID>
21
+ <svTRID>54322-XYZ</svTRID>
22
+ </trID>
23
+ </response>
24
+ </epp>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1001">
5
+ <msg>Command completed successfully; action pending</msg>
6
+ </result>
7
+ <resData>
8
+ <domain:trnData
9
+ xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
10
+ <domain:name>example.com</domain:name>
11
+ <domain:trStatus>pending</domain:trStatus>
12
+ <domain:reID>ClientX</domain:reID>
13
+ <domain:reDate>2000-06-08T22:00:00.0Z</domain:reDate>
14
+ <domain:acID>ClientY</domain:acID>
15
+ <domain:acDate>2000-06-13T22:00:00.0Z</domain:acDate>
16
+ <domain:exDate>2002-09-08T22:00:00.0Z</domain:exDate>
17
+ </domain:trnData>
18
+ </resData>
19
+ <trID>
20
+ <clTRID>ABC-12345</clTRID>
21
+ <svTRID>54322-XYZ</svTRID>
22
+ </trID>
23
+ </response>
24
+ </epp>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <trID>
8
+ <clTRID>ABC-12345</clTRID>
9
+ <svTRID>54321-XYZ</svTRID>
10
+ </trID>
11
+ </response>
12
+ </epp>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <greeting>
4
+ <svID>EPP Test Server</svID>
5
+ <svDate>2013-04-16T07:19:39Z</svDate>
6
+ <svcMenu>
7
+ <version>1.0</version>
8
+ <lang>en</lang>
9
+ <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
10
+ <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
11
+ <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
12
+ <svcExtension>
13
+ <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
14
+ </svcExtension>
15
+ </svcMenu>
16
+ <dcp>
17
+ <access><all/></access>
18
+ <statement>
19
+ <purpose><admin/><prov/></purpose>
20
+ <recipient><ours/></recipient>
21
+ <retention><indefinite/></retention>
22
+ </statement>
23
+ </dcp>
24
+ </greeting>
25
+ </epp>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <host:chkData
9
+ xmlns:host="urn:ietf:params:xml:ns:host-1.0">
10
+ <host:cd>
11
+ <host:name avail="1">ns1.example.com</host:name>
12
+ </host:cd>
13
+ </host:chkData>
14
+ </resData>
15
+ <trID>
16
+ <clTRID>ABC-12345</clTRID>
17
+ <svTRID>54322-XYZ</svTRID>
18
+ </trID>
19
+ </response>
20
+ </epp>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <host:chkData
9
+ xmlns:host="urn:ietf:params:xml:ns:host-1.0">
10
+ <host:cd>
11
+ <host:name avail="1">ns1.example.com</host:name>
12
+ </host:cd>
13
+ <host:cd>
14
+ <host:name avail="0">ns2.example2.com</host:name>
15
+ <host:reason>In use</host:reason>
16
+ </host:cd>
17
+ <host:cd>
18
+ <host:name avail="1">ns3.example3.com</host:name>
19
+ </host:cd>
20
+ </host:chkData>
21
+ </resData>
22
+ <trID>
23
+ <clTRID>ABC-12345</clTRID>
24
+ <svTRID>54322-XYZ</svTRID>
25
+ </trID>
26
+ </response>
27
+ </epp>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <host:creData
9
+ xmlns:host="urn:ietf:params:xml:ns:host-1.0">
10
+ <host:name>ns1.example.com</host:name>
11
+ <host:crDate>1999-04-03T22:00:00.0Z</host:crDate>
12
+ </host:creData>
13
+ </resData>
14
+ <trID>
15
+ <clTRID>ABC-12345</clTRID>
16
+ <svTRID>54322-XYZ</svTRID>
17
+ </trID>
18
+ </response>
19
+ </epp>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <trID>
8
+ <clTRID>ABC-12345</clTRID>
9
+ <svTRID>54321-XYZ</svTRID>
10
+ </trID>
11
+ </response>
12
+ </epp>
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <resData>
8
+ <host:infData
9
+ xmlns:host="urn:ietf:params:xml:ns:host-1.0">
10
+ <host:name>ns1.example.com</host:name>
11
+ <host:roid>NS1_EXAMPLE1-REP</host:roid>
12
+ <host:status s="linked"/>
13
+ <host:status s="clientUpdateProhibited"/>
14
+ <host:addr ip="v4">192.0.2.2</host:addr>
15
+ <host:addr ip="v4">192.0.2.29</host:addr>
16
+ <host:addr ip="v6">1080:0:0:0:8:800:200C:417A</host:addr>
17
+ <host:clID>ClientY</host:clID>
18
+ <host:crID>ClientX</host:crID>
19
+ <host:crDate>1999-04-03T22:00:00.0Z</host:crDate>
20
+ <host:upID>ClientX</host:upID>
21
+ <host:upDate>1999-12-03T09:00:00.0Z</host:upDate>
22
+ <host:trDate>2000-04-08T09:00:00.0Z</host:trDate>
23
+ </host:infData>
24
+ </resData>
25
+ <trID>
26
+ <clTRID>ABC-12345</clTRID>
27
+ <svTRID>54322-XYZ</svTRID>
28
+ </trID>
29
+ </response>
30
+ </epp>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
3
+ <response>
4
+ <result code="1000">
5
+ <msg>Command completed successfully</msg>
6
+ </result>
7
+ <trID>
8
+ <clTRID>ABC-12345</clTRID>
9
+ <svTRID>54321-XYZ</svTRID>
10
+ </trID>
11
+ </response>
12
+ </epp>
data/test/helper.rb ADDED
@@ -0,0 +1,100 @@
1
+ require 'rubygems'
2
+
3
+ if RUBY_VERSION >= '1.9'
4
+ begin
5
+ require 'simplecov'
6
+ rescue LoadError
7
+ puts "Coverage results will not be available during this build"
8
+ end
9
+ end
10
+
11
+ require 'test/unit'
12
+ require 'shoulda'
13
+ require 'mocha/setup'
14
+
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
17
+ require 'epp-client'
18
+
19
+ # Load EVERYTHING so SimpleCov works
20
+ EPP::constants.each do |constant|
21
+ konstant = EPP::const_get(constant)
22
+ case konstant
23
+ when Class, Module
24
+ konstant::constants.each do |k2|
25
+ konstant::const_get(k2)
26
+ end
27
+ end
28
+ end
29
+
30
+ class Test::Unit::TestCase
31
+ def stub_getaddrinfo!(host = 'epp.test.host', port = 700)
32
+ host ||= 'epp.test.host'
33
+ port ||= 700
34
+
35
+ addrinfo = [["AF_INET", port, "198.51.100.53", "198.51.100.53", 2, 1, 6]]
36
+ Socket.expects(:getaddrinfo).with(host, port, nil, Socket::SOCK_STREAM).returns(addrinfo).at_least_once
37
+ end
38
+ def load_xml(name)
39
+ xml_path = File.expand_path("../fixtures/responses/#{name}.xml", __FILE__)
40
+ File.read(xml_path)
41
+ end
42
+ def load_schema(name)
43
+ xsd_path = File.expand_path("../support/schemas/#{name}.xsd", __FILE__)
44
+ xsd_doc = XML::Document.file(xsd_path)
45
+ XML::Schema.document(xsd_doc)
46
+ end
47
+ def schema
48
+ @schema ||= load_schema('all')
49
+ end
50
+ def xpath_find(query)
51
+ n = @xml.find(query, @namespaces).first
52
+ case n
53
+ when XML::Node
54
+ n.content.strip
55
+ when XML::Attr
56
+ n.value.strip
57
+ end
58
+ end
59
+ def xpath_each(query)
60
+ @xml.find(query, @namespaces).each do |node|
61
+ yield node
62
+ end
63
+ end
64
+ def xpath_exists?(query)
65
+ !@xml.find(query, @namespaces).empty?
66
+ end
67
+ def namespaces_from_request(request = @request)
68
+ @namespaces = Hash[*request.namespaces.map { |k,ns| [k, ns.href] }.flatten]
69
+ end
70
+
71
+ unless RUBY_VERSION >= "1.9"
72
+ def assert_output stdout = nil, stderr = nil
73
+ out, err = capture_io do
74
+ yield
75
+ end
76
+
77
+ stdout_matcher = stdout.is_a?(Regexp) ? method(:assert_match) : method(:assert_equal)
78
+ stderr_matcher = stderr.is_a?(Regexp) ? method(:assert_match) : method(:assert_equal)
79
+
80
+ x = stdout_matcher.call(stdout, out, "In stdout") if stdout
81
+ y = stderr_matcher.call(stderr, err, "In stderr") if stderr
82
+
83
+ (!stdout || x) && (!stderr || y)
84
+ end
85
+ def capture_io
86
+ require 'stringio'
87
+
88
+ orig_stdout, orig_stderr = $stdout, $stderr
89
+ captured_stdout, captured_stderr = StringIO.new, StringIO.new
90
+ $stdout, $stderr = captured_stdout, captured_stderr
91
+
92
+ yield
93
+
94
+ return captured_stdout.string, captured_stderr.string
95
+ ensure
96
+ $stdout = orig_stdout
97
+ $stderr = orig_stderr
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostCheckCommand < Test::Unit::TestCase
4
+ context 'EPP::Host::Check' do
5
+ setup do
6
+ @host_check = EPP::Host::Check.new('ns1.example.com', 'ns2.example.com')
7
+
8
+ @check = EPP::Commands::Check.new(@host_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('//host:name') do |node|
27
+ names << node.content.strip
28
+ end
29
+
30
+ assert_equal %w(ns1.example.com ns2.example.com), names
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,88 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostCheckResponse < Test::Unit::TestCase
4
+ context 'EPP::Host::CheckResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('host/check'))
7
+ @check_response = EPP::Host::CheckResponse.new(@response)
8
+ end
9
+
10
+ should 'proxy methods to @response' do
11
+ assert_equal @response.message, @check_response.message
12
+ end
13
+
14
+ should 'be successful' do
15
+ assert @check_response.success?
16
+ assert_equal 1000, @check_response.code
17
+ end
18
+
19
+ should 'have message' do
20
+ assert_equal 'Command completed successfully', @check_response.message
21
+ end
22
+
23
+ should 'have names' do
24
+ expected = ['ns1.example.com', 'ns2.example2.com', 'ns3.example3.com'].sort
25
+ assert_equal expected, @check_response.names.sort
26
+ end
27
+
28
+ should 'have count' do
29
+ assert_equal 3, @check_response.count
30
+ end
31
+
32
+ should 'list ns1.example.com as available' do
33
+ assert @check_response.available?('ns1.example.com')
34
+ assert !@check_response.unavailable?('ns1.example.com')
35
+ end
36
+
37
+ should 'list ns2.exampl2.com as unavailable' do
38
+ assert @check_response.unavailable?('ns2.example2.com')
39
+ assert !@check_response.available?('ns2.example2.com')
40
+ end
41
+
42
+ should 'list ns3.example3.com as available' do
43
+ assert @check_response.available?('ns3.example3.com')
44
+ assert !@check_response.unavailable?('ns3.example3.com')
45
+ end
46
+
47
+ should 'raise ArgumentError if available with no argument for count > 1' do
48
+ assert_raise ArgumentError do
49
+ @check_response.available?
50
+ end
51
+ end
52
+
53
+ should 'raise RuntimeError if name called with count > 1' do
54
+ assert_raise RuntimeError do
55
+ @check_response.name
56
+ end
57
+ end
58
+ end
59
+
60
+ context 'EPP::Host::CheckResponse Single Query' do
61
+ setup do
62
+ @response = EPP::Response.new(load_xml('host/check-single'))
63
+ @check_response = EPP::Host::CheckResponse.new(@response)
64
+ end
65
+
66
+ should 'have names' do
67
+ assert_equal ['ns1.example.com'], @check_response.names
68
+ end
69
+
70
+ should 'have name' do
71
+ assert_equal 'ns1.example.com', @check_response.name
72
+ end
73
+
74
+ should 'have count' do
75
+ assert_equal 1, @check_response.count
76
+ end
77
+
78
+ should 'list ns1.example.com as available' do
79
+ assert @check_response.available?('ns1.example.com')
80
+ assert !@check_response.unavailable?('ns1.example.com')
81
+ end
82
+
83
+ should 'be available? with no argument' do
84
+ assert @check_response.available?
85
+ assert !@check_response.unavailable?
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostCreateCommand < Test::Unit::TestCase
4
+ context 'EPP::Host::Create' do
5
+ setup do
6
+ @host_create = EPP::Host::Create.new('ns1.example.com',
7
+ :ipv4 => "198.51.100.53", :ipv6 => "2001:db8::53:1")
8
+
9
+ @create = EPP::Commands::Create.new(@host_create)
10
+ @command = EPP::Requests::Command.new('ABC-123', @create)
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 ns1.example.com as name' do
26
+ assert_equal 'ns1.example.com', xpath_find('//host:name')
27
+ end
28
+
29
+ should 'set IPv4 address' do
30
+ assert_equal "198.51.100.53", xpath_find('//host:addr[@ip="v4"]')
31
+ end
32
+
33
+ should 'set IPv6 address' do
34
+ assert_equal "2001:db8::53:1", xpath_find('//host:addr[@ip="v6"]')
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostCreateResponse < Test::Unit::TestCase
4
+ context 'EPP::Host::CreateResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('host/create'))
7
+ @create_response = EPP::Host::CreateResponse.new(@response)
8
+ end
9
+
10
+ should 'proxy methods to @response' do
11
+ assert_equal @response.message, @create_response.message
12
+ end
13
+
14
+ should 'be successful' do
15
+ assert @create_response.success?
16
+ assert_equal 1000, @create_response.code
17
+ end
18
+
19
+ should 'have message' do
20
+ assert_equal 'Command completed successfully', @create_response.message
21
+ end
22
+
23
+ should 'have name ns1.example.com' do
24
+ assert_equal 'ns1.example.com', @create_response.name
25
+ end
26
+
27
+ should 'have new creation date' do
28
+ # 1999-04-03T22:00:00.0Z
29
+ expected = Time.gm(1999,04,03,22,00,00)
30
+ assert_equal expected, @create_response.creation_date
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostDeleteCommand < Test::Unit::TestCase
4
+ context 'EPP::Host::Delete' do
5
+ setup do
6
+ @host_info = EPP::Host::Delete.new('ns1.example.com')
7
+
8
+ @info = EPP::Commands::Delete.new(@host_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 ns1.example.com as name' do
25
+ assert_equal 'ns1.example.com', xpath_find('//host:name')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostDeleteResponse < Test::Unit::TestCase
4
+ context 'EPP::Host::DeleteResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('host/delete'))
7
+ @delete_response = EPP::Host::DeleteResponse.new(@response)
8
+ end
9
+
10
+ should 'proxy methods to @response' do
11
+ assert_equal @response.message, @delete_response.message
12
+ end
13
+
14
+ should 'be successful' do
15
+ assert @delete_response.success?
16
+ assert_equal 1000, @delete_response.code
17
+ end
18
+
19
+ should 'have message' do
20
+ assert_equal 'Command completed successfully', @delete_response.message
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestEppHostInfoCommand < Test::Unit::TestCase
4
+ context 'EPP::Host::Info' do
5
+ setup do
6
+ @host_info = EPP::Host::Info.new('ns1.example.com')
7
+
8
+ @info = EPP::Commands::Info.new(@host_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 ns1.example.com as name' do
25
+ assert_equal 'ns1.example.com', xpath_find('//host:name')
26
+ end
27
+ end
28
+ end