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,71 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactCreateCommand < Test::Unit::TestCase
4
+ context 'EPP::Contact::Create' do
5
+ setup do
6
+ @contact_create = EPP::Contact::Create.new('UK-4398495',
7
+ :voice => "+44.1234567890",
8
+ :email => "enoch.root@test.host",
9
+ :postal_info => {
10
+ :org => "Epiphyte",
11
+ :name => "Enoch Root",
12
+ :addr => {
13
+ :street => "Test Suite\n1 Test Avenue",
14
+ :city => "Testington",
15
+ :sp => "Testshire",
16
+ :pc => "TE57 1NG",
17
+ :cc => "GB" } },
18
+ :auth_info => {:pw => '2381728348'},
19
+ :disclose => {"0" => %w(voice email)})
20
+
21
+ @create = EPP::Commands::Create.new(@contact_create)
22
+ @command = EPP::Requests::Command.new('ABC-123', @create)
23
+ @request = EPP::Request.new(@command)
24
+ @xml = @request.to_xml
25
+
26
+ namespaces_from_request
27
+ end
28
+
29
+ should 'validate against schema' do
30
+ assert @xml.validate_schema(schema)
31
+ end
32
+
33
+ should 'set clTRID' do
34
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
35
+ end
36
+
37
+ should 'set id' do
38
+ assert_equal 'UK-4398495', xpath_find('//contact:id')
39
+ end
40
+
41
+ should 'set voice' do
42
+ assert_equal "+44.1234567890", xpath_find('//contact:voice')
43
+ end
44
+ should 'set email' do
45
+ assert_equal "enoch.root@test.host", xpath_find('//contact:email')
46
+ end
47
+ should 'set organisation' do
48
+ assert_equal "Epiphyte", xpath_find('//contact:postalInfo[@type="loc"]/contact:org')
49
+ end
50
+ should 'set name' do
51
+ assert_equal "Enoch Root", xpath_find('//contact:postalInfo[@type="loc"]/contact:name')
52
+ end
53
+ should 'set address' do
54
+ assert_equal "Test Suite", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:street[1]')
55
+ assert_equal "1 Test Avenue", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:street[2]')
56
+ assert_equal "Testington", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:city')
57
+ assert_equal "Testshire", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:sp')
58
+ assert_equal "TE57 1NG", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:pc')
59
+ assert_equal "GB", xpath_find('//contact:postalInfo[@type="loc"]/contact:addr/contact:cc')
60
+ end
61
+
62
+ should 'set authInfo' do
63
+ assert_equal '2381728348', xpath_find('//contact:authInfo/contact:pw')
64
+ end
65
+
66
+ should 'set disclose' do
67
+ assert xpath_exists?('//contact:disclose[@flag="0"]/contact:email'), "should disallow disclose of email"
68
+ assert xpath_exists?('//contact:disclose[@flag="0"]/contact:voice'), "should disallow disclose of voice"
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactCreateResponse < Test::Unit::TestCase
4
+ context 'EPP::Contact::CreateResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('contact/create'))
7
+ @create_response = EPP::Contact::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 id sh8013' do
24
+ assert_equal 'sh8013', @create_response.id
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 TestEppContactDeleteCommand < Test::Unit::TestCase
4
+ context 'EPP::Contact::Delete' do
5
+ setup do
6
+ @contact_delete = EPP::Contact::Delete.new('UK-39246923864')
7
+
8
+ @delete = EPP::Commands::Delete.new(@contact_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 'UK-39246923864', xpath_find('//contact:id')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactDeleteResponse < Test::Unit::TestCase
4
+ context 'EPP::Contact::DeleteResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('contact/delete'))
7
+ @delete_response = EPP::Contact::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 TestEppContactInfoCommand < Test::Unit::TestCase
4
+ context 'EPP::Contact::Info' do
5
+ setup do
6
+ @contact_info = EPP::Contact::Info.new('UK-39246923864')
7
+
8
+ @info = EPP::Commands::Info.new(@contact_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 UK-39246923864 as id' do
25
+ assert_equal 'UK-39246923864', xpath_find('//contact:id')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,100 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactInfoResponse < Test::Unit::TestCase
4
+ context 'EPP::Contact::InfoResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('contact/info'))
7
+ @info_response = EPP::Contact::InfoResponse.new(@response)
8
+ end
9
+
10
+ should 'proxy methods to @response' do
11
+ assert_equal @response.message, @info_response.message
12
+ end
13
+
14
+ should 'be successful' do
15
+ assert @info_response.success?
16
+ assert_equal 1000, @info_response.code
17
+ end
18
+
19
+ should 'have message' do
20
+ assert_equal 'Command completed successfully', @info_response.message
21
+ end
22
+
23
+ should 'have id' do
24
+ assert_equal 'sh8013', @info_response.id
25
+ end
26
+
27
+ should 'have roid' do
28
+ assert_equal 'SH8013-REP', @info_response.roid
29
+ end
30
+
31
+ should 'have status' do
32
+ expected = %w(linked clientDeleteProhibited)
33
+ assert_equal expected, @info_response.status
34
+ end
35
+
36
+ should 'have postal_info' do
37
+ expected = { :name => "John Doe",
38
+ :org => "Example Inc.",
39
+ :addr => {
40
+ :street => "123 Example Dr.\nSuite 100",
41
+ :city => "Dulles",
42
+ :sp => "VA",
43
+ :pc => "20166-6503",
44
+ :cc => "US" }}
45
+ assert_equal expected, @info_response.postal_info
46
+ end
47
+
48
+ should 'have email' do
49
+ assert_equal 'jdoe@example.com', @info_response.email
50
+ end
51
+
52
+ should 'have voice' do
53
+ assert_equal '+1.7035555555.1234', @info_response.voice
54
+ end
55
+
56
+ should 'have fax' do
57
+ assert_equal '+1.7035555556', @info_response.fax
58
+ end
59
+
60
+ should 'have client_id' do
61
+ assert_equal 'ClientY', @info_response.client_id
62
+ end
63
+
64
+ should 'have creator_id' do
65
+ assert_equal 'ClientX', @info_response.creator_id
66
+ end
67
+
68
+ should 'have created_date' do
69
+ # 1999-04-03T22:00:00.0Z
70
+ expected = Time.gm(1999,4,3,22,00,00)
71
+ assert_equal expected, @info_response.created_date
72
+ end
73
+
74
+ should 'have updator_id' do
75
+ assert_equal 'ClientX', @info_response.updator_id
76
+ end
77
+
78
+ should 'have updated_date' do
79
+ # 1999-12-03T09:00:00.0Z
80
+ expected = Time.gm(1999,12,3,9,00,00)
81
+ assert_equal expected, @info_response.updated_date
82
+ end
83
+
84
+ should 'have transfer_date' do
85
+ # 2000-04-08T09:00:00.0Z
86
+ expected = Time.gm(2000,4,8,9,00,00)
87
+ assert_equal expected, @info_response.transfer_date
88
+ end
89
+
90
+ should 'have authInfo' do
91
+ expected = { 'pw' => '2fooBAR' }
92
+ assert_equal expected, @info_response.auth_info
93
+ end
94
+
95
+ should 'have disclose' do
96
+ expected = { "0" => %w(voice email) }
97
+ assert_equal expected, @info_response.disclose
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactTransferCommand < Test::Unit::TestCase
4
+ context 'EPP::Contact::Transfer' do
5
+ setup do
6
+ @contact_transfer = EPP::Contact::Transfer.new('UK-39246923864')
7
+
8
+ @transfer = EPP::Commands::Transfer.new('query', @contact_transfer)
9
+ @command = EPP::Requests::Command.new('ABC-123', @transfer)
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 UK-39246923864 as id' do
25
+ assert_equal 'UK-39246923864', xpath_find('//contact:id')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,100 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactTransferResponse < Test::Unit::TestCase
4
+ context 'EPP::Contact::TransferResponse' do
5
+ context 'query' do
6
+ setup do
7
+ @response = EPP::Response.new(load_xml('contact/transfer-query'))
8
+ @transfer_response = EPP::Contact::TransferResponse.new(@response)
9
+ end
10
+
11
+ should 'proxy methods to @response' do
12
+ assert_equal @response.message, @transfer_response.message
13
+ end
14
+
15
+ should 'be successful' do
16
+ assert @transfer_response.success?
17
+ assert_equal 1000, @transfer_response.code
18
+ end
19
+
20
+ should 'have message' do
21
+ assert_equal 'Command completed successfully', @transfer_response.message
22
+ end
23
+
24
+ should 'have contact id' do
25
+ assert_equal 'sh8013', @transfer_response.id
26
+ end
27
+
28
+ should 'have transfer status' do
29
+ assert_equal 'pending', @transfer_response.status
30
+ end
31
+
32
+ should 'have request ID' do
33
+ assert_equal 'ClientX', @transfer_response.requested_id
34
+ end
35
+
36
+ should 'have request date' do
37
+ # 2000-06-06T22:00:00.0Z
38
+ expected = Time.gm(2000,6,6,22,00,00)
39
+ assert_equal expected, @transfer_response.requested_date
40
+ end
41
+
42
+ should 'have action id' do
43
+ assert_equal 'ClientY', @transfer_response.action_id
44
+ end
45
+
46
+ should 'have action date' do
47
+ # 2000-06-11T22:00:00.0Z
48
+ expected = Time.gm(2000,6,11,22,00,00)
49
+ assert_equal expected, @transfer_response.action_date
50
+ end
51
+ end
52
+ context 'request' do
53
+ setup do
54
+ @response = EPP::Response.new(load_xml('contact/transfer-request'))
55
+ @transfer_response = EPP::Contact::TransferResponse.new(@response)
56
+ end
57
+
58
+ should 'proxy methods to @response' do
59
+ assert_equal @response.message, @transfer_response.message
60
+ end
61
+
62
+ should 'be pending' do
63
+ assert @transfer_response.pending?
64
+ assert_equal 1001, @transfer_response.code
65
+ end
66
+
67
+ should 'have message' do
68
+ assert_equal 'Command completed successfully; action pending', @transfer_response.message
69
+ end
70
+
71
+ should 'have contact id' do
72
+ assert_equal 'sh8013', @transfer_response.id
73
+ end
74
+
75
+ should 'have transfer status' do
76
+ assert_equal 'pending', @transfer_response.status
77
+ end
78
+
79
+ should 'have request ID' do
80
+ assert_equal 'ClientX', @transfer_response.requested_id
81
+ end
82
+
83
+ should 'have request date' do
84
+ # 2000-06-06T22:00:00.0Z
85
+ expected = Time.gm(2000,6,8,22,00,00)
86
+ assert_equal expected, @transfer_response.requested_date
87
+ end
88
+
89
+ should 'have action id' do
90
+ assert_equal 'ClientY', @transfer_response.action_id
91
+ end
92
+
93
+ should 'have action date' do
94
+ # 2000-06-13T22:00:00.0Z
95
+ expected = Time.gm(2000,6,13,22,00,00)
96
+ assert_equal expected, @transfer_response.action_date
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,84 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactUpdateCommand < Test::Unit::TestCase
4
+ context 'EPP::Contact::Update' do
5
+ setup do
6
+ @contact_update = EPP::Contact::Update.new('UK-4398495',
7
+ :add => {:status => {:ok => "Okie Dokie"}},
8
+ :rem => {:status => {:ok => ["Okie Dokie", "en"]}},
9
+ :chg => {
10
+ :voice => "+44.1234567890",
11
+ :email => "enoch.root@test.host",
12
+ :postal_info => {
13
+ :org => "Epiphyte",
14
+ :name => "Enoch Root",
15
+ :addr => {
16
+ :street => "Test Suite\n1 Test Avenue",
17
+ :city => "Testington",
18
+ :sp => "Testshire",
19
+ :pc => "TE57 1NG",
20
+ :cc => "GB" } },
21
+ :auth_info => {:pw => '2381728348'},
22
+ :disclose => {"0" => %w(name)}
23
+ })
24
+
25
+ @update = EPP::Commands::Update.new(@contact_update)
26
+ @command = EPP::Requests::Command.new('ABC-123', @update)
27
+ @request = EPP::Request.new(@command)
28
+ @xml = @request.to_xml
29
+
30
+ namespaces_from_request
31
+ end
32
+
33
+ should 'validate against schema' do
34
+ assert @xml.validate_schema(schema)
35
+ end
36
+
37
+ should 'set clTRID' do
38
+ assert_equal 'ABC-123', xpath_find('//epp:clTRID')
39
+ end
40
+
41
+ should 'set UK-4398495 as id' do
42
+ assert_equal 'UK-4398495', xpath_find('//contact:id')
43
+ end
44
+ should 'add status' do
45
+ assert_equal "Okie Dokie", xpath_find('//contact:add/contact:status')
46
+ assert_equal "ok", xpath_find('//contact:add/contact:status/@s')
47
+ end
48
+
49
+ should 'remove status' do
50
+ assert_equal "Okie Dokie", xpath_find('//contact:rem/contact:status')
51
+ assert_equal "en", xpath_find('//contact:rem/contact:status/@lang')
52
+ assert_equal "ok", xpath_find('//contact:rem/contact:status/@s')
53
+ end
54
+
55
+ should 'set voice for change' do
56
+ assert_equal "+44.1234567890", xpath_find('//contact:chg/contact:voice')
57
+ end
58
+ should 'set email for change' do
59
+ assert_equal "enoch.root@test.host", xpath_find('//contact:chg/contact:email')
60
+ end
61
+ should 'set organisation for change' do
62
+ assert_equal "Epiphyte", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:org')
63
+ end
64
+ should 'set name for change' do
65
+ assert_equal "Enoch Root", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:name')
66
+ end
67
+ should 'set address for change' do
68
+ assert_equal "Test Suite", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:street[1]')
69
+ assert_equal "1 Test Avenue", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:street[2]')
70
+ assert_equal "Testington", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:city')
71
+ assert_equal "Testshire", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:sp')
72
+ assert_equal "TE57 1NG", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:pc')
73
+ assert_equal "GB", xpath_find('//contact:chg/contact:postalInfo[@type="loc"]/contact:addr/contact:cc')
74
+ end
75
+
76
+ should 'set authInfo for change' do
77
+ assert_equal '2381728348', xpath_find('//contact:chg/contact:authInfo/contact:pw')
78
+ end
79
+
80
+ should 'set disclose for change' do
81
+ assert xpath_exists?('//contact:chg/contact:disclose[@flag="0"]/contact:name'), "should disallow disclose of name"
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestEppContactUpdateResponse < Test::Unit::TestCase
4
+ context 'EPP::Contact::UpdateResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('contact/update'))
7
+ @update_response = EPP::Contact::UpdateResponse.new(@response)
8
+ end
9
+
10
+ should 'proxy methods to @response' do
11
+ assert_equal @response.message, @update_response.message
12
+ end
13
+
14
+ should 'be successful' do
15
+ assert @update_response.success?
16
+ assert_equal 1000, @update_response.code
17
+ end
18
+
19
+ should 'have message' do
20
+ assert_equal 'Command completed successfully', @update_response.message
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ class TestEppDomainCheckCommand < Test::Unit::TestCase
4
+ context 'EPP::Domain::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,88 @@
1
+ require 'helper'
2
+
3
+ class TestEppDomainCheckResponse < Test::Unit::TestCase
4
+ context 'EPP::Domain::CheckResponse' do
5
+ setup do
6
+ @response = EPP::Response.new(load_xml('domain/check'))
7
+ @check_response = EPP::Domain::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 = ['example.com', 'example.net', 'example.org'].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 example.com as available' do
33
+ assert @check_response.available?('example.com')
34
+ assert !@check_response.unavailable?('example.com')
35
+ end
36
+
37
+ should 'list example.net as unavailable' do
38
+ assert @check_response.unavailable?('example.net')
39
+ assert !@check_response.available?('example.net')
40
+ end
41
+
42
+ should 'list example.org as available' do
43
+ assert @check_response.available?('example.org')
44
+ assert !@check_response.unavailable?('example.org')
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::Domain::CheckResponse Single Query' do
61
+ setup do
62
+ @response = EPP::Response.new(load_xml('domain/check-single'))
63
+ @check_response = EPP::Domain::CheckResponse.new(@response)
64
+ end
65
+
66
+ should 'have names' do
67
+ assert_equal ['example.com'], @check_response.names
68
+ end
69
+
70
+ should 'have name' do
71
+ assert_equal '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 example.com as available' do
79
+ assert @check_response.available?('example.com')
80
+ assert !@check_response.unavailable?('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