kono_epp_client 0.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +17 -0
- data/README.md +16 -0
- data/Rakefile +6 -0
- data/kono_epp_client.gemspec +39 -0
- data/lib/epp/epp_command/check_contacts.rb +17 -0
- data/lib/epp/epp_command/create_domain.rb +4 -2
- data/lib/epp/epp_command/kono_epp_check_domains.rb +18 -0
- data/lib/epp/epp_command/transfer_domain.rb +22 -5
- data/lib/epp/epp_command/update_domain.rb +60 -44
- data/lib/epp/exceptions.rb +10 -0
- data/lib/epp/server.rb +116 -84
- data/lib/epp/transport/http.rb +10 -5
- data/lib/kono_epp_client/VERSION +1 -0
- data/lib/kono_epp_client/version.rb +3 -0
- data/lib/kono_epp_client.rb +5 -14
- data/spec/epp/epp_command/kono_epp_check_contacts_spec.rb +25 -0
- data/spec/epp/epp_command/kono_epp_check_domains_spec.rb +16 -0
- data/spec/epp/epp_command/kono_epp_create_domain_spec.rb +37 -0
- data/spec/epp/epp_command/kono_epp_transfer_domain_spec.rb +33 -0
- data/spec/epp/epp_command/kono_epp_update_domain_spec.rb +125 -0
- data/spec/epp/kono_epp_command_spec.rb +16 -0
- data/spec/epp/server_spec.rb +69 -0
- data/spec/fixtures/snapshots/kono_epp_check_contacts/_construct.xml.snap +13 -0
- data/spec/fixtures/snapshots/kono_epp_check_domains/_construct.xml.snap +11 -0
- data/spec/fixtures/snapshots/kono_epp_create_domain/_create.xml.snap +29 -0
- data/spec/fixtures/snapshots/kono_epp_transfer_domain/_con_extension_construct.xml.snap +23 -0
- data/spec/fixtures/snapshots/kono_epp_transfer_domain/_construct.xml.snap +13 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_restore_esiste_l'estensione_di_restore.xml.snap +15 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_update_auth_info_cambia_AUTH_INFO.xml.snap +15 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_update_auth_info_con_nuovo_registrant_cambia_REGISTRANT.xml.snap +16 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_update_contacts_cambia_ADMIN_TECH.xml.snap +18 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_update_nameservers_aggiunge_e_rimuove_ns.xml.snap +28 -0
- data/spec/fixtures/snapshots/kono_epp_update_domain/_update_status_cambia_status.xml.snap +16 -0
- data/spec/spec_helper.rb +111 -0
- data/spec/support/context.rb +15 -0
- data/spec/support/matchers.rb +6 -0
- data/spec/support/snapshot.rb +20 -0
- data/spec/support/superdiff.rb +1 -0
- metadata +159 -6
data/lib/epp/server.rb
CHANGED
@@ -5,7 +5,9 @@ module KonoEppClient #:nodoc:
|
|
5
5
|
|
6
6
|
require 'nokogiri'
|
7
7
|
|
8
|
-
attr_accessor :tag, :password, :server, :port, :
|
8
|
+
attr_accessor :tag, :password, :server, :port, :ssl_version, :old_server,
|
9
|
+
:services, :lang, :extensions, :version, :credit, :timeout,
|
10
|
+
:transport, :transport_options
|
9
11
|
|
10
12
|
# ==== Required Attrbiutes
|
11
13
|
#
|
@@ -22,22 +24,30 @@ module KonoEppClient #:nodoc:
|
|
22
24
|
# * <tt>:services</tt> - Use custom EPP services in the <login> frame. The defaults use the EPP standard domain, contact and host 1.0 services.
|
23
25
|
# * <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.
|
24
26
|
# * <tt>:version</tt> - Set the EPP version. Defaults to "1.0".
|
27
|
+
# * <tt>:transport</tt> - Type of connection (http or tcp). Default to "tcp"
|
28
|
+
# * <tt>:transport_options</tt> - Overrides for transport configurations. Default to {}
|
29
|
+
# * <tt>:timeout</tt> - Timeou for connections in seconds. Default to "30"
|
30
|
+
# * <tt>:ssl_version</tt> - Version of the ssl protocol versione. Default to TLSv1
|
31
|
+
# * <tt>:ssl_version</tt> - Version of the ssl protocol versione. Default to TLSv1
|
32
|
+
#
|
25
33
|
def initialize(attributes = {})
|
26
34
|
requires!(attributes, :tag, :password, :server)
|
27
35
|
|
28
|
-
@tag
|
29
|
-
@password
|
30
|
-
@server
|
31
|
-
@port
|
36
|
+
@tag = attributes[:tag]
|
37
|
+
@password = attributes[:password]
|
38
|
+
@server = attributes[:server]
|
39
|
+
@port = attributes[:port] || 700
|
32
40
|
@old_server = attributes[:old_server] || false
|
33
|
-
@lang
|
34
|
-
@services
|
41
|
+
@lang = attributes[:lang] || "en"
|
42
|
+
@services = attributes[:services] || ["urn:ietf:params:xml:ns:domain-1.0", "urn:ietf:params:xml:ns:contact-1.0", "urn:ietf:params:xml:ns:host-1.0"]
|
35
43
|
@extensions = attributes[:extensions] || []
|
36
|
-
@version
|
37
|
-
@transport
|
38
|
-
@
|
44
|
+
@version = attributes[:version] || "1.0"
|
45
|
+
@transport = attributes[:transport] || :tcp
|
46
|
+
@transport_options = attributes[:transport_options] || {}
|
47
|
+
@timeout = attributes[:timeout] || 30
|
48
|
+
@ssl_version = attributes[:ssl_version] || :TLSv1
|
39
49
|
|
40
|
-
@logged_in
|
50
|
+
@logged_in = false
|
41
51
|
end
|
42
52
|
|
43
53
|
def connect_and_hello
|
@@ -55,13 +65,13 @@ module KonoEppClient #:nodoc:
|
|
55
65
|
# <tt><login></tt> and <tt><logout></tt> requests are also wrapped
|
56
66
|
# around the request, so we can close the socket immediately after
|
57
67
|
# the request is made.
|
58
|
-
def request(
|
68
|
+
def request(xml)
|
59
69
|
# open_connection
|
60
70
|
|
61
71
|
# @logged_in = true if login
|
62
72
|
|
63
73
|
begin
|
64
|
-
@response = send_request(
|
74
|
+
@response = send_request(xml)
|
65
75
|
ensure
|
66
76
|
if @logged_in && !old_server
|
67
77
|
@logged_in = false if logout
|
@@ -73,7 +83,7 @@ module KonoEppClient #:nodoc:
|
|
73
83
|
|
74
84
|
# Sends a standard login request to the EPP server.
|
75
85
|
def login
|
76
|
-
login = KonoEppLogin.new(
|
86
|
+
login = KonoEppLogin.new(tag, password)
|
77
87
|
|
78
88
|
# FIXME: Order matters
|
79
89
|
login.version = version
|
@@ -82,11 +92,11 @@ module KonoEppClient #:nodoc:
|
|
82
92
|
login.services = services
|
83
93
|
login.extensions = extensions
|
84
94
|
|
85
|
-
send_command(
|
95
|
+
send_command(login)
|
86
96
|
end
|
87
97
|
|
88
|
-
def change_password(
|
89
|
-
login = KonoEppLogin.new(
|
98
|
+
def change_password(new_password)
|
99
|
+
login = KonoEppLogin.new(tag, password)
|
90
100
|
|
91
101
|
# FIXME: Order matters
|
92
102
|
login.new_password = new_password
|
@@ -97,7 +107,7 @@ module KonoEppClient #:nodoc:
|
|
97
107
|
login.services = services
|
98
108
|
login.extensions = extensions
|
99
109
|
|
100
|
-
send_command(
|
110
|
+
send_command(login)
|
101
111
|
end
|
102
112
|
|
103
113
|
def logged_in?
|
@@ -112,144 +122,166 @@ module KonoEppClient #:nodoc:
|
|
112
122
|
|
113
123
|
# FIXME: Remove command wrappers?
|
114
124
|
def hello
|
115
|
-
|
125
|
+
send_request(KonoEppHello.new.to_s)
|
116
126
|
end
|
117
127
|
|
118
|
-
def poll(
|
119
|
-
poll = KonoEppPoll.new(
|
128
|
+
def poll(id = nil)
|
129
|
+
poll = KonoEppPoll.new(id ? :ack : :req)
|
120
130
|
|
121
131
|
poll.ack_id = id if id
|
122
132
|
|
123
|
-
send_command(
|
133
|
+
send_command(poll)
|
124
134
|
end
|
125
135
|
|
126
|
-
def create_contact(
|
136
|
+
def create_contact(options)
|
127
137
|
contact = KonoEppCreateContact.new options
|
128
|
-
send_command(
|
138
|
+
send_command(contact)
|
139
|
+
end
|
140
|
+
|
141
|
+
def check_contacts(ids)
|
142
|
+
send_command(KonoEppCheckContacts.new(ids))
|
129
143
|
end
|
130
144
|
|
131
|
-
def delete_contact(
|
145
|
+
def delete_contact(id)
|
132
146
|
contact = KonoEppDeleteContact.new id
|
133
|
-
send_command(
|
147
|
+
send_command(contact)
|
134
148
|
end
|
135
149
|
|
136
|
-
def update_contact(
|
150
|
+
def update_contact(options)
|
137
151
|
contact = KonoEppUpdateContact.new options
|
138
|
-
send_command(
|
152
|
+
send_command(contact)
|
139
153
|
end
|
140
154
|
|
141
|
-
def create_domain(
|
155
|
+
def create_domain(options)
|
142
156
|
domain = KonoEppCreateDomain.new options
|
143
|
-
send_command(
|
157
|
+
send_command(domain)
|
144
158
|
end
|
145
159
|
|
146
|
-
def
|
160
|
+
def check_domains(*domains)
|
161
|
+
send_command(KonoEppCheckDomains.new *domains)
|
162
|
+
end
|
163
|
+
|
164
|
+
def update_domain(options)
|
147
165
|
domain = KonoEppUpdateDomain.new options
|
148
|
-
send_command(
|
166
|
+
send_command(domain)
|
149
167
|
end
|
150
168
|
|
151
|
-
def delete_domain(
|
169
|
+
def delete_domain(name)
|
152
170
|
domain = KonoEppDeleteDomain.new name
|
153
|
-
send_command(
|
171
|
+
send_command(domain)
|
154
172
|
end
|
155
173
|
|
156
|
-
def info_contact(
|
174
|
+
def info_contact(id)
|
157
175
|
contact = KonoEppInfoContact.new id
|
158
|
-
send_command(
|
176
|
+
send_command(contact)
|
159
177
|
end
|
160
178
|
|
161
|
-
def info_domain(
|
179
|
+
def info_domain(name)
|
162
180
|
info = KonoEppInfoDomain.new name
|
163
|
-
send_command(
|
181
|
+
send_command(info)
|
164
182
|
end
|
165
183
|
|
166
|
-
def transfer_domain(
|
167
|
-
|
168
|
-
send_command( transfer )
|
184
|
+
def transfer_domain(name, authinfo, op, extension: nil)
|
185
|
+
send_command(KonoEppTransferDomain.new(name, authinfo, op, extension: extension))
|
169
186
|
end
|
170
187
|
|
171
188
|
# Sends a standard logout request to the EPP server.
|
172
189
|
def logout
|
173
|
-
send_command(
|
190
|
+
send_command(KonoEppLogout.new, 1500)
|
174
191
|
end
|
175
192
|
|
176
|
-
# private
|
193
|
+
# private
|
177
194
|
# Wrapper which sends XML to the server, and receives
|
178
195
|
# the response in return.
|
179
|
-
def send_request(
|
180
|
-
write(
|
196
|
+
def send_request(xml)
|
197
|
+
write(xml)
|
181
198
|
read
|
182
199
|
end
|
183
200
|
|
184
|
-
def send_command(
|
185
|
-
namespaces = {
|
186
|
-
|
201
|
+
def send_command(command, expected_result = 1000..1999)
|
202
|
+
namespaces = {'extepp' => 'http://www.nic.it/ITNIC-EPP/extepp-2.0',
|
203
|
+
'xmlns' => "urn:ietf:params:xml:ns:epp-1.0"}
|
187
204
|
|
188
|
-
xml = Nokogiri.XML(
|
205
|
+
xml = Nokogiri.XML(send_request(command.to_s))
|
189
206
|
|
190
207
|
# TODO: multiple <response> RFC 3730 §2.6
|
191
|
-
result = xml.at_xpath(
|
192
|
-
|
193
|
-
raise KonoEppErrorResponse.new(
|
208
|
+
result = xml.at_xpath("/xmlns:epp/xmlns:response[1]/xmlns:result",
|
209
|
+
namespaces)
|
210
|
+
raise KonoEppErrorResponse.new(:message => 'Malformed response') if result.nil?
|
194
211
|
|
195
|
-
xmlns_code = result.at_xpath(
|
196
|
-
raise KonoEppErrorResponse.new(
|
212
|
+
xmlns_code = result.at_xpath("@code")
|
213
|
+
raise KonoEppErrorResponse.new(:message => 'Malformed response') if xmlns_code.nil?
|
197
214
|
|
198
215
|
response_code = xmlns_code.value.to_i
|
199
216
|
|
200
|
-
xmlns_msg = result.xpath(
|
201
|
-
|
202
|
-
raise KonoEppErrorResponse.new(
|
217
|
+
xmlns_msg = result.xpath("xmlns:msg/text ()",
|
218
|
+
namespaces)
|
219
|
+
raise KonoEppErrorResponse.new(:message => 'Malformed response') if xmlns_msg.empty?
|
203
220
|
|
204
221
|
result_message = xmlns_msg.text.strip
|
205
222
|
|
206
223
|
# TODO: value
|
207
224
|
|
208
|
-
xmlns_ext_reason = result.xpath(
|
209
|
-
|
225
|
+
xmlns_ext_reason = result.xpath("xmlns:extValue/xmlns:reason",
|
226
|
+
namespaces)
|
210
227
|
result_message += ": #{xmlns_ext_reason.text.strip}" unless xmlns_ext_reason.empty?
|
211
228
|
|
212
|
-
xmlns_reason_code = result.xpath(
|
213
|
-
|
229
|
+
xmlns_reason_code = result.xpath("xmlns:extValue/xmlns:value/extepp:reasonCode",
|
230
|
+
namespaces)
|
214
231
|
reason_code = xmlns_reason_code.text.strip.to_i unless xmlns_reason_code.empty?
|
215
232
|
|
216
|
-
credit_msg = xml.xpath(
|
217
|
-
|
233
|
+
credit_msg = xml.xpath("//extepp:credit/text ()",
|
234
|
+
namespaces)
|
218
235
|
@credit = credit_msg.text.to_f unless credit_msg.empty?
|
219
236
|
|
220
237
|
if expected_result === response_code
|
221
238
|
return xml
|
222
239
|
end
|
223
240
|
|
224
|
-
args = {
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
case [
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
241
|
+
args = {:xml => xml,
|
242
|
+
:response_code => response_code,
|
243
|
+
:reason_code => reason_code,
|
244
|
+
:message => result_message}
|
245
|
+
|
246
|
+
case [response_code, reason_code]
|
247
|
+
when [2200, 6004]
|
248
|
+
raise KonoEppAuthenticationPasswordExpired.new(args)
|
249
|
+
when [2002, 4015]
|
250
|
+
raise KonoEppLoginNeeded.new(args)
|
251
|
+
when [2304, 9022]
|
252
|
+
raise KonoEppDomainHasStatusCliTransProhibited.new(args)
|
253
|
+
when [2304, 9026]
|
254
|
+
raise KonoEppDomainHasStatusClientUpdateProhibited.new(args)
|
255
|
+
else
|
256
|
+
raise KonoEppErrorResponse.new(args)
|
236
257
|
end
|
237
258
|
end
|
238
259
|
|
239
260
|
# Establishes the connection to the server. If the connection is
|
240
|
-
|
241
|
-
|
242
|
-
|
261
|
+
# established, then this method will call read and return
|
262
|
+
# the EPP <tt><greeting></tt> which is sent by the
|
263
|
+
# server upon connection.
|
243
264
|
def open_connection
|
265
|
+
# FIXME il timeout serve solamente nella versione tcp
|
266
|
+
# FIXME perchè utilizzare un'istanza di classe? non sarebbe meglio avere un metodo che genera il transport
|
267
|
+
# e successivamente viene utilizzato sempre quello?
|
244
268
|
Timeout.timeout @timeout do
|
245
|
-
|
246
|
-
|
247
|
-
|
269
|
+
case @transport
|
270
|
+
when :tcp
|
271
|
+
@connection = KonoEppClient::Transport::TcpTransport.new(server, port)
|
272
|
+
when :http
|
273
|
+
|
274
|
+
options = {
|
275
|
+
ssl_version: ssl_version,
|
276
|
+
cookie_file: "#{@tag.downcase}.cookies.pstore"
|
277
|
+
}.merge(@transport_options)
|
278
|
+
|
279
|
+
@connection = KonoEppClient::Transport::HttpTransport.new(server, port, **options)
|
280
|
+
|
248
281
|
end
|
249
282
|
end
|
250
283
|
end
|
251
284
|
|
252
|
-
|
253
285
|
# Receive an EPP response from the server. Since the connection is blocking,
|
254
286
|
# this method will wait until the connection becomes available for use. If
|
255
287
|
# the connection is broken, a SocketError will be raised. Otherwise,
|
@@ -262,9 +294,9 @@ module KonoEppClient #:nodoc:
|
|
262
294
|
|
263
295
|
# Send XML to the server. If the socket returns EOF,
|
264
296
|
# the connection has closed and a SocketError is raised.
|
265
|
-
def write(
|
297
|
+
def write(xml)
|
266
298
|
Timeout.timeout @timeout do
|
267
|
-
@connection.write(
|
299
|
+
@connection.write(xml)
|
268
300
|
end
|
269
301
|
end
|
270
302
|
end
|
data/lib/epp/transport/http.rb
CHANGED
@@ -6,20 +6,24 @@ module KonoEppClient::Transport
|
|
6
6
|
|
7
7
|
require 'pstore'
|
8
8
|
|
9
|
-
|
9
|
+
# @param [String] server
|
10
|
+
# @param [Integer] port
|
11
|
+
# @param [Symbol] ssl_version -> Versione ssl
|
12
|
+
# @param [String] cookie_file -> identifica il nome del file del cookie-store
|
13
|
+
def initialize(server, port, ssl_version: :TLSv1, cookie_file: "cookies.pstore")
|
10
14
|
@net_http = Net::HTTP.new( server, port )
|
11
15
|
|
12
16
|
@net_http.use_ssl = true
|
13
|
-
@net_http.ssl_version =
|
17
|
+
@net_http.ssl_version = ssl_version
|
14
18
|
@net_http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
15
|
-
|
19
|
+
|
16
20
|
#FIXME: Commented because not work on MacOS (dev machine), is necessary for Linux machine?
|
17
21
|
#@net_http.ca_path = '/etc/ssl/certs'
|
18
|
-
|
22
|
+
|
19
23
|
# @net_http.set_debug_output $stderr
|
20
24
|
#@net_http.set_debug_output File.open( "/tmp/net.log", "a")
|
21
25
|
|
22
|
-
@store = PStore.new(
|
26
|
+
@store = PStore.new( cookie_file )
|
23
27
|
end
|
24
28
|
|
25
29
|
def read
|
@@ -43,6 +47,7 @@ module KonoEppClient::Transport
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def close
|
50
|
+
FileUtils.rm_rf(@store.path)
|
46
51
|
end
|
47
52
|
|
48
53
|
private
|
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/lib/kono_epp_client.rb
CHANGED
@@ -4,7 +4,6 @@ require 'openssl'
|
|
4
4
|
require 'socket'
|
5
5
|
require 'active_support'
|
6
6
|
require 'rexml/document'
|
7
|
-
require 'hpricot'
|
8
7
|
|
9
8
|
# Package files
|
10
9
|
require File.dirname(__FILE__) + '/require_parameters.rb'
|
@@ -16,19 +15,11 @@ require File.dirname(__FILE__) + '/epp/transport/tcp.rb'
|
|
16
15
|
require File.dirname(__FILE__) + '/epp/transport/http.rb'
|
17
16
|
|
18
17
|
require File.dirname(__FILE__) + '/epp/epp_command.rb'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
require
|
23
|
-
|
24
|
-
require File.dirname(__FILE__) + '/epp/epp_command/create_domain.rb'
|
25
|
-
require File.dirname(__FILE__) + '/epp/epp_command/info_contact.rb'
|
26
|
-
require File.dirname(__FILE__) + '/epp/epp_command/info_domain.rb'
|
27
|
-
require File.dirname(__FILE__) + '/epp/epp_command/delete_contact.rb'
|
28
|
-
require File.dirname(__FILE__) + '/epp/epp_command/delete_domain.rb'
|
29
|
-
require File.dirname(__FILE__) + '/epp/epp_command/transfer_domain.rb'
|
30
|
-
require File.dirname(__FILE__) + '/epp/epp_command/update_contact.rb'
|
31
|
-
require File.dirname(__FILE__) + '/epp/epp_command/update_domain.rb'
|
18
|
+
|
19
|
+
# load di tutti i comandi presenti in epp_command
|
20
|
+
Dir.glob(File.dirname(__FILE__) + '/epp/epp_command/*.rb').each do |f|
|
21
|
+
require f
|
22
|
+
end
|
32
23
|
|
33
24
|
module KonoEppClient #:nodoc:
|
34
25
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.describe KonoEppCheckContacts do
|
3
|
+
|
4
|
+
let(:ids){
|
5
|
+
["mm001",
|
6
|
+
"mb001",
|
7
|
+
"cl001",
|
8
|
+
"bb001"]
|
9
|
+
}
|
10
|
+
|
11
|
+
include_context "like epp command"
|
12
|
+
|
13
|
+
let(:instance) {
|
14
|
+
described_class.new(ids)
|
15
|
+
}
|
16
|
+
|
17
|
+
it "construct", snapshot: 'xml' do
|
18
|
+
expect(rendered.to_s).to have_tag("epp>command>check>check") do
|
19
|
+
ids.each do |t|
|
20
|
+
with_tag("id", text: t)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppCheckDomains do
|
4
|
+
include_context "like epp command"
|
5
|
+
|
6
|
+
let(:instance) do
|
7
|
+
described_class.new("test.it","wow.it")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "construct", snapshot: "xml" do
|
11
|
+
expect(rendered.to_s).to have_tag("epp>command>check>check") do
|
12
|
+
with_tag("name", text: "test.it")
|
13
|
+
with_tag("name", text: "wow.it")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppCreateDomain do
|
4
|
+
include_context "like epp command"
|
5
|
+
|
6
|
+
let(:instance) {
|
7
|
+
KonoEppCreateDomain.new(
|
8
|
+
{name: 'architest.it',
|
9
|
+
period: 1,
|
10
|
+
nameservers:
|
11
|
+
[["ns.test.it", "192.168.100.10"],
|
12
|
+
["ns2.test.it", "192.168.100.20"],
|
13
|
+
["ns3.foo.com"]],
|
14
|
+
# contacts
|
15
|
+
registrant: "RRR12",
|
16
|
+
admin: "AAAA12",
|
17
|
+
tech: "TTT12",
|
18
|
+
authinfo: "WWW-test-it"
|
19
|
+
}
|
20
|
+
)
|
21
|
+
}
|
22
|
+
|
23
|
+
it "create", snapshot: "xml" do
|
24
|
+
expect(rendered.to_s).to have_tag("ns")
|
25
|
+
expect(rendered.to_s.downcase).to have_tag("hostattr")
|
26
|
+
expect(rendered.to_s.downcase).to have_tag("ns hostattr" ) do
|
27
|
+
with_tag("hostname",text:"ns2.test.it")
|
28
|
+
with_tag("hostaddr",text:"192.168.100.20",with:{ip:"v4"})
|
29
|
+
end
|
30
|
+
expect(rendered.to_s.downcase).to have_tag("ns hostattr" ) do
|
31
|
+
with_tag("hostname",text:"ns.test.it")
|
32
|
+
with_tag("hostaddr",text:"192.168.100.10",with:{ip:"v4"})
|
33
|
+
end
|
34
|
+
expect(rendered.to_s.downcase).not_to have_tag("ns hostaddr", with: {ip: 'v4'},text:"" )
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppTransferDomain do
|
4
|
+
|
5
|
+
include_context "like epp command"
|
6
|
+
|
7
|
+
let(:instance) do
|
8
|
+
described_class.new("test.it", "wee-12-sd", 'request')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "construct", snapshot: 'xml' do
|
12
|
+
expect(rendered.to_s).to have_tag("epp>command>transfer", with: {op: "request"}, count: 1) do
|
13
|
+
with_tag("transfer>name", text: "test.it")
|
14
|
+
with_tag("transfer>authinfo>pw", text: "wee-12-sd")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "con extension" do
|
19
|
+
|
20
|
+
let(:instance) do
|
21
|
+
described_class.new("test.it", "wee-12-sd", 'request',
|
22
|
+
extension: {new_registrant: "xx123fd", new_auth_info: "abc-sd934-sd"})
|
23
|
+
end
|
24
|
+
|
25
|
+
it "construct", snapshot: 'xml' do
|
26
|
+
expect(rendered.to_s).to have_tag("epp>command>extension>trade>transfertrade") do
|
27
|
+
with_tag("newregistrant", text: "xx123fd")
|
28
|
+
with_tag("newauthinfo>pw", text: "abc-sd934-sd")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppUpdateDomain do
|
4
|
+
|
5
|
+
let(:options) do
|
6
|
+
{
|
7
|
+
name: 'example.com',
|
8
|
+
# add_nameservers: [['ns1.example.com', '192.168.1.1']],
|
9
|
+
# add_admin: 'admin_contact',
|
10
|
+
# add_tech: 'tech_contact',
|
11
|
+
# remove_nameservers: ['ns2.example.com'],
|
12
|
+
# remove_admin: 'admin_contact_to_remove',
|
13
|
+
# remove_tech: 'tech_contact_to_remove',
|
14
|
+
# auth_info: 'my_auth_info',
|
15
|
+
# registrant: 'new_registrant'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
include_context "like epp command"
|
20
|
+
|
21
|
+
let(:instance) {
|
22
|
+
KonoEppUpdateDomain.new(options)
|
23
|
+
}
|
24
|
+
|
25
|
+
it "contiene il nome del dominio" do
|
26
|
+
expect(rendered.to_s).to have_tag("update>name", text: options[:name])
|
27
|
+
end
|
28
|
+
|
29
|
+
context "update nameservers" do
|
30
|
+
let(:options) {
|
31
|
+
super().merge({
|
32
|
+
add_nameservers: [
|
33
|
+
['ns1.example.com', '192.168.1.1'],
|
34
|
+
['ns3.example.com']
|
35
|
+
],
|
36
|
+
remove_nameservers: ['ns2.example.com'],
|
37
|
+
})
|
38
|
+
}
|
39
|
+
it "aggiunge e rimuove ns", snapshot: 'xml' do
|
40
|
+
expect(rendered.to_s.downcase).to have_tag("update>add>ns") do
|
41
|
+
with_tag("hostattr") do
|
42
|
+
with_tag("hostname", text: 'ns1.example.com')
|
43
|
+
with_tag("hostaddr", text: '192.168.1.1')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
expect(rendered.to_s.downcase).to have_tag("update>add>ns") do
|
47
|
+
with_tag("hostattr") do
|
48
|
+
with_tag("hostname", text: 'ns3.example.com')
|
49
|
+
without_tag("hostaddr",text:"")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
expect(rendered.to_s.downcase).to have_tag("update>rem>ns") do
|
53
|
+
with_tag("hostattr") do
|
54
|
+
with_tag("hostname", text: 'ns2.example.com')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "update contacts", snapshot: 'xml' do
|
61
|
+
let(:options) {
|
62
|
+
super().merge({
|
63
|
+
add_admin: "AAA1",
|
64
|
+
add_tech: "TTT1",
|
65
|
+
remove_admin: "AAA2",
|
66
|
+
remove_tech: "TTT2"
|
67
|
+
})
|
68
|
+
}
|
69
|
+
it "cambia ADMIN_TECH", snapshot: 'xml' do
|
70
|
+
expect(rendered.to_s.downcase).to have_tag("update>add>contact", with: {type: "admin"}, text: options[:add_admin].downcase)
|
71
|
+
expect(rendered.to_s.downcase).to have_tag("update>rem>contact", with: {type: "admin"}, text: options[:remove_admin].downcase)
|
72
|
+
expect(rendered.to_s.downcase).to have_tag("update>add>contact", with: {type: "tech"}, text: options[:add_tech].downcase)
|
73
|
+
expect(rendered.to_s.downcase).to have_tag("update>rem>contact", with: {type: "tech"}, text: options[:remove_tech].downcase)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
context "update status" do
|
77
|
+
let(:options) {
|
78
|
+
super().merge({
|
79
|
+
add_status: "clientTransferProhibited",
|
80
|
+
remove_status: "clientHold",
|
81
|
+
})
|
82
|
+
}
|
83
|
+
it "cambia status", snapshot: 'xml' do
|
84
|
+
expect(rendered.to_s.downcase).to have_tag("update>add>status", with: {s: options[:add_status].downcase})
|
85
|
+
expect(rendered.to_s.downcase).to have_tag("update>rem>status", with: {s: options[:remove_status].downcase})
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "restore" do
|
90
|
+
let(:options) {
|
91
|
+
super().merge({
|
92
|
+
restore: true
|
93
|
+
})
|
94
|
+
}
|
95
|
+
it "esiste l'estensione di restore",snapshot: 'xml' do
|
96
|
+
expect(rendered.to_s.downcase).to have_tag("extension>update>restore", with: {op: "request"})
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "update auth_info" do
|
101
|
+
let(:options) {
|
102
|
+
super().merge({
|
103
|
+
auth_info: "AUTH12-!DSRTG"
|
104
|
+
})
|
105
|
+
}
|
106
|
+
it "cambia AUTH_INFO", snapshot: "xml" do
|
107
|
+
expect(rendered.to_s.downcase).to have_tag("update>chg") do
|
108
|
+
with_tag("authinfo>pw", text: options[:auth_info].downcase)
|
109
|
+
without_tag("registrant")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "con nuovo registrant" do
|
114
|
+
let(:options) {
|
115
|
+
super().merge({
|
116
|
+
registrant: "R0001"
|
117
|
+
})
|
118
|
+
}
|
119
|
+
it "cambia REGISTRANT", snapshot: "xml" do
|
120
|
+
expect(rendered.to_s.downcase).to have_tag("update>chg>registrant", text: options[:registrant].downcase)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|