kono_epp_client 0.1.0 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/Makefile +13 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/kono_epp_client.gemspec +42 -0
- data/lib/kono_epp_client/VERSION +1 -0
- data/lib/kono_epp_client/commands/check_contacts.rb +19 -0
- data/lib/{epp/epp_command/kono_epp_check_domains.rb → kono_epp_client/commands/check_domains.rb} +3 -1
- data/lib/kono_epp_client/commands/command.rb +15 -0
- data/lib/kono_epp_client/commands/create_contact.rb +89 -0
- data/lib/kono_epp_client/commands/create_domain.rb +56 -0
- data/lib/kono_epp_client/commands/delete_contact.rb +17 -0
- data/lib/kono_epp_client/commands/delete_domain.rb +16 -0
- data/lib/kono_epp_client/commands/hello.rb +15 -0
- data/lib/kono_epp_client/commands/info_contact.rb +17 -0
- data/lib/kono_epp_client/commands/info_domain.rb +16 -0
- data/lib/kono_epp_client/commands/login.rb +84 -0
- data/lib/kono_epp_client/commands/logout.rb +12 -0
- data/lib/kono_epp_client/commands/poll.rb +18 -0
- data/lib/kono_epp_client/commands/transfer_domain.rb +38 -0
- data/lib/kono_epp_client/commands/update_contact.rb +116 -0
- data/lib/kono_epp_client/commands/update_domain.rb +117 -0
- data/lib/kono_epp_client/dns_sec/add.rb +13 -0
- data/lib/kono_epp_client/dns_sec/ds_data.rb +65 -0
- data/lib/kono_epp_client/dns_sec/rem.rb +14 -0
- data/lib/kono_epp_client/dns_sec/rem_all.rb +10 -0
- data/lib/kono_epp_client/exceptions/error_response.rb +19 -0
- data/lib/kono_epp_client/exceptions.rb +15 -0
- data/lib/kono_epp_client/requires_parameters.rb +16 -0
- data/lib/kono_epp_client/server.rb +311 -0
- data/lib/kono_epp_client/version.rb +3 -0
- data/lib/kono_epp_client.rb +4 -16
- data/spec/eager_load_spec.rb +6 -0
- data/spec/factories/ds_data.rb +12 -0
- data/spec/fixtures/dns_sec/add.xml +14 -0
- data/spec/fixtures/dns_sec/ds_data.xml +6 -0
- data/spec/fixtures/dns_sec/rem.xml +14 -0
- data/spec/fixtures/dns_sec/rem_all.xml +3 -0
- data/spec/fixtures/login_response.xml +23 -0
- data/spec/fixtures/login_response_for_dnssec.xml +25 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/create_domain/_create_with_ds_data_build_extensions.xml.snap +39 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_login.xml.snap +7 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_extensions_with_value_xml.xml.snap +14 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_lang_with_value_xml.xml.snap +11 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_new_password_with_value_xml.xml.snap +9 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_services_with_value_xml.xml.snap +12 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_tags_version_with_value_xml.xml.snap +11 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/login/_with_id_and_password_login.xml.snap +10 -0
- data/spec/fixtures/snapshots/kono_epp_client/commands/update_domain/_update_DnsSec_build_extensions.xml.snap +30 -0
- data/spec/{epp/epp_command/kono_epp_check_contacts_spec.rb → lib/commands/check_contacts_spec.rb} +1 -1
- data/spec/{epp/epp_command/kono_epp_check_domains_spec.rb → lib/commands/check_domains_spec.rb} +1 -1
- data/spec/{epp/kono_epp_command_spec.rb → lib/commands/command_spec.rb} +2 -2
- data/spec/lib/commands/create_domain_spec.rb +50 -0
- data/spec/lib/commands/login_spec.rb +87 -0
- data/spec/{epp/epp_command/kono_epp_transfer_domain_spec.rb → lib/commands/transfer_domain_spec.rb} +1 -1
- data/spec/{epp/epp_command/kono_epp_update_domain_spec.rb → lib/commands/update_domain_spec.rb} +20 -4
- data/spec/lib/dns_sec/add_spec.rb +14 -0
- data/spec/lib/dns_sec/ds_data_spec.rb +43 -0
- data/spec/lib/dns_sec/rem_all_spec.rb +11 -0
- data/spec/lib/dns_sec/rem_spec.rb +14 -0
- data/spec/lib/server_spec.rb +304 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/support/context.rb +1 -1
- data/spec/support/factory_bot.rb +8 -0
- data/spec/support/fixtures.rb +16 -0
- data/spec/support/matchers.rb +14 -0
- data/spec/support/parametric.rb +1 -0
- data/spec/support/snapshot.rb +13 -3
- data/spec/support/superdiff.rb +1 -0
- metadata +178 -58
- data/lib/epp/epp_command/check_contacts.rb +0 -17
- data/lib/epp/epp_command/create_contact.rb +0 -87
- data/lib/epp/epp_command/create_domain.rb +0 -44
- data/lib/epp/epp_command/delete_contact.rb +0 -15
- data/lib/epp/epp_command/delete_domain.rb +0 -14
- data/lib/epp/epp_command/hello.rb +0 -13
- data/lib/epp/epp_command/info_contact.rb +0 -15
- data/lib/epp/epp_command/info_domain.rb +0 -14
- data/lib/epp/epp_command/login.rb +0 -79
- data/lib/epp/epp_command/logout.rb +0 -10
- data/lib/epp/epp_command/poll.rb +0 -16
- data/lib/epp/epp_command/transfer_domain.rb +0 -36
- data/lib/epp/epp_command/update_contact.rb +0 -115
- data/lib/epp/epp_command/update_domain.rb +0 -104
- data/lib/epp/epp_command.rb +0 -15
- data/lib/epp/exceptions.rb +0 -28
- data/lib/epp/server.rb +0 -295
- data/lib/epp/transport/tcp.rb +0 -93
- data/lib/require_parameters.rb +0 -14
- data/spec/epp/epp_command/kono_epp_create_domain_spec.rb +0 -37
- /data/lib/{epp/transport/http.rb → kono_epp_client/transport/http_transport.rb} +0 -0
- /data/lib/{epp → kono_epp_client}/transport.rb +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_check_contacts → kono_epp_client/commands/check_contacts}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_check_domains → kono_epp_client/commands/check_domains}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_create_domain → kono_epp_client/commands/create_domain}/_create.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_transfer_domain → kono_epp_client/commands/transfer_domain}/_con_extension_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_transfer_domain → kono_epp_client/commands/transfer_domain}/_construct.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_restore_esiste_l'estensione_di_restore.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_auth_info_cambia_AUTH_INFO.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_auth_info_con_nuovo_registrant_cambia_REGISTRANT.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_contacts_cambia_ADMIN_TECH.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_nameservers_aggiunge_e_rimuove_ns.xml.snap +0 -0
- /data/spec/fixtures/snapshots/{kono_epp_update_domain → kono_epp_client/commands/update_domain}/_update_status_cambia_status.xml.snap +0 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppClient::Commands::CreateDomain do
|
4
|
+
include_context "like epp command"
|
5
|
+
|
6
|
+
let(:opts) {
|
7
|
+
{
|
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
|
+
let(:instance) { KonoEppClient::Commands::CreateDomain.new(opts) }
|
23
|
+
|
24
|
+
it "create", snapshot: "xml" do
|
25
|
+
expect(rendered.to_s).to have_tag("ns")
|
26
|
+
expect(rendered.to_s.downcase).to have_tag("hostattr")
|
27
|
+
expect(rendered.to_s.downcase).to have_tag("ns hostattr") do
|
28
|
+
with_tag("hostname", text: "ns2.test.it")
|
29
|
+
with_tag("hostaddr", text: "192.168.100.20", with: {ip: "v4"})
|
30
|
+
end
|
31
|
+
expect(rendered.to_s.downcase).to have_tag("ns hostattr") do
|
32
|
+
with_tag("hostname", text: "ns.test.it")
|
33
|
+
with_tag("hostaddr", text: "192.168.100.10", with: {ip: "v4"})
|
34
|
+
end
|
35
|
+
expect(rendered.to_s.downcase).not_to have_tag("ns hostaddr", with: {ip: 'v4'}, text: "")
|
36
|
+
end
|
37
|
+
|
38
|
+
context "create with ds_data" do
|
39
|
+
|
40
|
+
let(:opts) {
|
41
|
+
super().merge(dns_sec_data: [create(:ds_data, key_tag: 9657)])
|
42
|
+
}
|
43
|
+
|
44
|
+
it "build extensions", snapshot: "xml" do
|
45
|
+
expect(rendered.to_s).to have_tag("extension>create>dsdata>keytag", text: 9657)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe KonoEppClient::Commands::Login do
|
4
|
+
include_context "like epp command"
|
5
|
+
|
6
|
+
let(:args) { [] }
|
7
|
+
|
8
|
+
let(:instance) {
|
9
|
+
KonoEppClient::Commands::Login.new(*args)
|
10
|
+
}
|
11
|
+
subject(:xml) { rendered.to_s }
|
12
|
+
|
13
|
+
it "login", snapshot: "xml" do
|
14
|
+
is_expected.to have_tag("command") do
|
15
|
+
with_tag(:login)
|
16
|
+
with_tag("cltrid", text: "ABC-12345")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with id and password" do
|
21
|
+
let(:args) { ["12", "password"] }
|
22
|
+
it "login", snapshot: "xml" do
|
23
|
+
is_expected.to have_tag("command") do
|
24
|
+
with_tag(:login) do
|
25
|
+
with_tag("clid", text: "12")
|
26
|
+
with_tag("pw", text: "password")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "tags" do
|
33
|
+
where(:case_name, :method, :tag_matcher, :value, :no_value, :getter) do
|
34
|
+
[
|
35
|
+
[:lang, :lang, have_tag("command>login>options>lang", text: "en"), "en", nil, true],
|
36
|
+
[:version, :version, have_tag("command>login>options>version", text: "1.0"), "1.0", nil, true],
|
37
|
+
[:new_password, :new_password, have_tag("command>login>newpw", text: "password"), "password", nil, false],
|
38
|
+
|
39
|
+
[:services, :services,
|
40
|
+
lazy {
|
41
|
+
have_tag("command>login>svcs") do
|
42
|
+
with_tag("objuri", count: 2)
|
43
|
+
with_tag("objuri", text: "valore1")
|
44
|
+
end
|
45
|
+
}, ["valore1", "valore2"], [], true],
|
46
|
+
|
47
|
+
[
|
48
|
+
:extensions, :extensions,
|
49
|
+
lazy {
|
50
|
+
have_tag("command>login>svcs>svcextension") do
|
51
|
+
with_tag("exturi", count: 2)
|
52
|
+
with_tag("exturi", text: "http://uri1.com/valore1")
|
53
|
+
end
|
54
|
+
}, ["http://uri1.com/valore1", "http://uri2.com/valore2"],
|
55
|
+
[],
|
56
|
+
true
|
57
|
+
]
|
58
|
+
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
with_them do
|
63
|
+
|
64
|
+
subject { instance.send(method) }
|
65
|
+
it "getter" do
|
66
|
+
if getter
|
67
|
+
is_expected.to eq no_value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with value" do
|
72
|
+
let(:instance) {
|
73
|
+
super().tap { |e| e.send("#{method}=", value) }
|
74
|
+
}
|
75
|
+
it "getter" do
|
76
|
+
if getter
|
77
|
+
is_expected.to be == value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
it "xml", snapshot: "xml" do
|
81
|
+
expect(xml).to tag_matcher
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/spec/{epp/epp_command/kono_epp_update_domain_spec.rb → lib/commands/update_domain_spec.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe
|
3
|
+
RSpec.describe KonoEppClient::Commands::UpdateDomain do
|
4
4
|
|
5
5
|
let(:options) do
|
6
6
|
{
|
@@ -19,7 +19,7 @@ RSpec.describe KonoEppUpdateDomain do
|
|
19
19
|
include_context "like epp command"
|
20
20
|
|
21
21
|
let(:instance) {
|
22
|
-
|
22
|
+
KonoEppClient::Commands::UpdateDomain.new(options)
|
23
23
|
}
|
24
24
|
|
25
25
|
it "contiene il nome del dominio" do
|
@@ -46,7 +46,7 @@ RSpec.describe KonoEppUpdateDomain do
|
|
46
46
|
expect(rendered.to_s.downcase).to have_tag("update>add>ns") do
|
47
47
|
with_tag("hostattr") do
|
48
48
|
with_tag("hostname", text: 'ns3.example.com')
|
49
|
-
without_tag("hostaddr",text:"")
|
49
|
+
without_tag("hostaddr", text: "")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
expect(rendered.to_s.downcase).to have_tag("update>rem>ns") do
|
@@ -92,7 +92,7 @@ RSpec.describe KonoEppUpdateDomain do
|
|
92
92
|
restore: true
|
93
93
|
})
|
94
94
|
}
|
95
|
-
it "esiste l'estensione di restore",snapshot: 'xml' do
|
95
|
+
it "esiste l'estensione di restore", snapshot: 'xml' do
|
96
96
|
expect(rendered.to_s.downcase).to have_tag("extension>update>restore", with: {op: "request"})
|
97
97
|
end
|
98
98
|
end
|
@@ -122,4 +122,20 @@ RSpec.describe KonoEppUpdateDomain do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
describe "update DnsSec" do
|
126
|
+
let(:options) {
|
127
|
+
super().merge(dns_sec_data: [
|
128
|
+
KonoEppClient::DnsSec::Add.new(create(:ds_data, key_tag: 9657)),
|
129
|
+
KonoEppClient::DnsSec::Rem.new(create(:ds_data, key_tag: 1685))
|
130
|
+
])
|
131
|
+
}
|
132
|
+
|
133
|
+
it "build extensions", snapshot: "xml" do
|
134
|
+
expect(rendered.to_s).to have_tag("extension>update>add>dsdata>keytag", text: 9657)
|
135
|
+
expect(rendered.to_s).to have_tag("extension>update>rem>dsdata>keytag", text: 1685)
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
end
|
140
|
+
|
125
141
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe KonoEppClient::DnsSec::DsData do
|
2
|
+
|
3
|
+
let(:instance) {
|
4
|
+
KonoEppClient::DnsSec::Add.new(
|
5
|
+
create(:ds_data,key_tag:"1234"),
|
6
|
+
create(:ds_data,key_tag:"4321"),
|
7
|
+
)
|
8
|
+
}
|
9
|
+
|
10
|
+
it "#to_s" do
|
11
|
+
expect(instance.to_s).to match(xml_fixture("dns_sec/add.xml"))
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
RSpec.describe KonoEppClient::DnsSec::DsData do
|
2
|
+
|
3
|
+
let(:instance) {
|
4
|
+
KonoEppClient::DnsSec::DsData.new(123, :dsa_sha_1, :sha_1, "digest")
|
5
|
+
}
|
6
|
+
|
7
|
+
it "valid instance" do
|
8
|
+
expect(instance).to have_attributes(key_tag: 123, alg: 3, digest_type: 1, digest: "digest")
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "instantiate" do
|
12
|
+
where(:case_name, :values, :expectation) do
|
13
|
+
[
|
14
|
+
[
|
15
|
+
:key_tag_to_low,
|
16
|
+
[-1, :dsa_sha_1, :sha_1, "digest"],
|
17
|
+
"Invalid key tag -1, should be 0<=key_tag<=65535"
|
18
|
+
], [
|
19
|
+
:key_tag_to_hight,
|
20
|
+
[1_000_000, :dsa_sha_1, :sha_1, "digest"],
|
21
|
+
"Invalid key tag 1000000, should be 0<=key_tag<=65535"
|
22
|
+
], [
|
23
|
+
:digest_type,
|
24
|
+
[123, :dsa_sha_1, :non_presente, "digest"],
|
25
|
+
"Invalid digest type non_presente"
|
26
|
+
], [
|
27
|
+
:alg,
|
28
|
+
[1_000_000, :non_presente, :sha_1, "digest"],
|
29
|
+
"Invalid alg non_presente"
|
30
|
+
],
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
with_them do
|
35
|
+
it { expect { KonoEppClient::DnsSec::DsData.new(*values) }.to raise_error(expectation) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "#to_s" do
|
40
|
+
expect(instance.to_s).to match(xml_fixture("dns_sec/ds_data.xml"))
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe KonoEppClient::DnsSec::DsData do
|
2
|
+
|
3
|
+
let(:instance) {
|
4
|
+
KonoEppClient::DnsSec::Rem.new(
|
5
|
+
create(:ds_data, key_tag: "1234"),
|
6
|
+
create(:ds_data, key_tag: "4321"),
|
7
|
+
)
|
8
|
+
}
|
9
|
+
|
10
|
+
it "#to_s" do
|
11
|
+
expect(instance.to_s).to match(xml_fixture("dns_sec/rem.xml"))
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,304 @@
|
|
1
|
+
RSpec.describe KonoEppClient::Server do
|
2
|
+
|
3
|
+
let(:params) {
|
4
|
+
{
|
5
|
+
tag: "abc",
|
6
|
+
password: "123123",
|
7
|
+
server: "epp.pubtest.nic.it"
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:instance) { described_class.new(params) }
|
12
|
+
|
13
|
+
##
|
14
|
+
# Impostazione per eseguire inviare comandi di login con estensione DNSSEC
|
15
|
+
shared_context "dnssec activation" do
|
16
|
+
let(:params) {
|
17
|
+
super().merge(enable_dns_sec: true)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Forza l'istanza come se avessi avuto conferma di connessione tramite DNSSEC
|
23
|
+
shared_context "dnssec activated" do
|
24
|
+
let(:instance) {
|
25
|
+
super().tap { |c| c.instance_variable_set(:@dns_sec_enabled, true) }
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "initialization" do
|
30
|
+
|
31
|
+
it "base" do
|
32
|
+
expect(instance).to have_attributes(
|
33
|
+
**params,
|
34
|
+
port: 700,
|
35
|
+
lang: "en",
|
36
|
+
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"],
|
37
|
+
extensions: [],
|
38
|
+
version: "1.0",
|
39
|
+
transport: :http,
|
40
|
+
transport_options: {},
|
41
|
+
timeout: 30,
|
42
|
+
ssl_version: :TLSv1
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
it_behaves_like "dnssec activation" do
|
47
|
+
|
48
|
+
it { expect(instance).to have_attributes(
|
49
|
+
extensions: include("urn:ietf:params:xml:ns:secDNS-1.1",
|
50
|
+
"http://www.nic.it/ITNIC-EPP/extsecDNS-1.0"),
|
51
|
+
dns_sec_enabled: false # questo viene abilitato rispetto alla risposta del NIC
|
52
|
+
)
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#open_connection" do
|
61
|
+
|
62
|
+
let(:params) {
|
63
|
+
super().merge(
|
64
|
+
transport: :http,
|
65
|
+
)
|
66
|
+
}
|
67
|
+
|
68
|
+
it "default transport" do
|
69
|
+
|
70
|
+
double = instance_double(KonoEppClient::Transport::HttpTransport)
|
71
|
+
|
72
|
+
expect(KonoEppClient::Transport::HttpTransport).to receive(:new).with(
|
73
|
+
params[:server],
|
74
|
+
700, ssl_version: :TLSv1, cookie_file: "abc.cookies.pstore").and_return(double)
|
75
|
+
|
76
|
+
expect { instance.open_connection }.to change { instance.instance_variable_get(:@connection) }.
|
77
|
+
to(double)
|
78
|
+
end
|
79
|
+
|
80
|
+
context "transport http" do
|
81
|
+
|
82
|
+
let(:params) {
|
83
|
+
super().merge(
|
84
|
+
transport_options: {cookie_file: "file_to_coockies"},
|
85
|
+
)
|
86
|
+
}
|
87
|
+
|
88
|
+
it "use http transport" do
|
89
|
+
double = instance_double(KonoEppClient::Transport::HttpTransport)
|
90
|
+
|
91
|
+
expect(KonoEppClient::Transport::HttpTransport).to receive(:new).with(
|
92
|
+
params[:server],
|
93
|
+
700, ssl_version: :TLSv1, cookie_file: "file_to_coockies").and_return(double)
|
94
|
+
|
95
|
+
expect { instance.open_connection }.to change { instance.instance_variable_get(:@connection) }.
|
96
|
+
to(double)
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#login" do
|
105
|
+
|
106
|
+
it {
|
107
|
+
expect(instance).to receive(:send_command) do |command|
|
108
|
+
expect(command.to_s).to have_tag("command>login") do
|
109
|
+
with_tag("options>version", text: "1.0")
|
110
|
+
with_tag("options>lang", text: "en")
|
111
|
+
instance.services.each do |srv|
|
112
|
+
with_tag("svcs>objuri", text: srv)
|
113
|
+
end
|
114
|
+
without_tag("svcs>svcextension")
|
115
|
+
end
|
116
|
+
Nokogiri::XML(file_fixture("login_response.xml").read) # Si aspetta un XML di risposta
|
117
|
+
end
|
118
|
+
|
119
|
+
instance.login
|
120
|
+
}
|
121
|
+
|
122
|
+
context "with extensions" do
|
123
|
+
let(:params) {
|
124
|
+
super().merge(extensions: ["https://nome.estensione", "altra:estensione"])
|
125
|
+
}
|
126
|
+
|
127
|
+
it {
|
128
|
+
expect(instance).to receive(:send_command) do |command|
|
129
|
+
expect(command.to_s).to have_tag("command>login>svcs>svcextension") do
|
130
|
+
with_tag("exturi", text: "https://nome.estensione")
|
131
|
+
with_tag("exturi", text: "altra:estensione")
|
132
|
+
end
|
133
|
+
Nokogiri::XML(file_fixture("login_response.xml").read) # Si aspetta un XML di risposta
|
134
|
+
end
|
135
|
+
|
136
|
+
instance.login
|
137
|
+
|
138
|
+
}
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
it_behaves_like "dnssec activation" do
|
143
|
+
|
144
|
+
it "requested" do
|
145
|
+
expect(instance).to receive(:send_command) do |command|
|
146
|
+
expect(command.to_s).to have_tag("command>login>svcs>svcextension") do
|
147
|
+
with_tag("exturi", text: "http://www.nic.it/ITNIC-EPP/extsecDNS-1.0")
|
148
|
+
with_tag("exturi", text: "urn:ietf:params:xml:ns:secDNS-1.1")
|
149
|
+
end
|
150
|
+
Nokogiri::XML(file_fixture("login_response_for_dnssec.xml").read) # Si aspetta un XML di risposta
|
151
|
+
end
|
152
|
+
|
153
|
+
instance.login
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
it "with response" do
|
158
|
+
allow(instance).to receive(:send_request)
|
159
|
+
.and_return(file_fixture("login_response_for_dnssec.xml").read)
|
160
|
+
|
161
|
+
expect {
|
162
|
+
instance.login
|
163
|
+
expect(instance).to be_dns_sec_enabled
|
164
|
+
}.to change(instance, :dns_sec_enabled).to(true)
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
it "response for Registrar not accredited" do
|
169
|
+
allow(instance).to receive(:send_request)
|
170
|
+
.and_return(file_fixture("login_response.xml").read)
|
171
|
+
|
172
|
+
expect {
|
173
|
+
instance.login
|
174
|
+
expect(instance).not_to be_dns_sec_enabled
|
175
|
+
}.not_to change(instance, :dns_sec_enabled)
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "#create_domain" do
|
183
|
+
|
184
|
+
let(:ds_data) {
|
185
|
+
create(:ds_data)
|
186
|
+
}
|
187
|
+
|
188
|
+
it {
|
189
|
+
expect(instance).to receive(:send_command) do |command|
|
190
|
+
expect(command.to_s).to have_xpath("//domain:create//domain:name[text()='architest.it']", {"domain" => "urn:ietf:params:xml:ns:domain-1.0"})
|
191
|
+
expect(command.to_s).not_to have_xpath("//extension//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
192
|
+
end
|
193
|
+
|
194
|
+
instance.create_domain(name: 'architest.it', nameservers: [])
|
195
|
+
|
196
|
+
}
|
197
|
+
|
198
|
+
it "impostando i dati del dnssec ma senza aver avuto conferma da NIC di poterlo usare" do
|
199
|
+
expect(instance).to receive(:send_command) do |command|
|
200
|
+
expect(command.to_s).not_to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
201
|
+
end
|
202
|
+
|
203
|
+
instance.create_domain(name: 'architest.it', nameservers: [], dns_sec_data: [ds_data])
|
204
|
+
end
|
205
|
+
|
206
|
+
it_behaves_like "dnssec activated" do
|
207
|
+
|
208
|
+
it "senza assegnare dnssec data non succede nulla" do
|
209
|
+
expect(instance).to receive(:send_command) do |command|
|
210
|
+
expect(command.to_s).not_to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
211
|
+
end
|
212
|
+
|
213
|
+
instance.create_domain(name: 'architest.it', nameservers: [])
|
214
|
+
end
|
215
|
+
|
216
|
+
it "assegnando dei valori" do
|
217
|
+
expect(instance).to receive(:send_command) do |command|
|
218
|
+
expect(command.to_s).to have_xpath("//secDNS:create", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
219
|
+
expect(command.to_s).to have_xpath(
|
220
|
+
"//secDNS:keyTag[text()='123']",
|
221
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
222
|
+
)
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
instance.create_domain(name: 'architest.it', nameservers: [], dns_sec_data: [ds_data])
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#update_domain" do
|
234
|
+
|
235
|
+
let(:ds_data_a) { create(:ds_data) }
|
236
|
+
let(:ds_data_b) { create(:ds_data) }
|
237
|
+
|
238
|
+
it {
|
239
|
+
expect(instance).to receive(:send_command) do |command|
|
240
|
+
expect(command.to_s).to have_xpath("//domain:update//domain:name[text()='architest.it']", {"xmlns:domain" => "urn:ietf:params:xml:ns:domain-1.0"})
|
241
|
+
expect(command.to_s).not_to have_xpath("//extension//secDNS:update", {"xmlns:secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
242
|
+
end
|
243
|
+
|
244
|
+
instance.update_domain(name: 'architest.it')
|
245
|
+
}
|
246
|
+
|
247
|
+
it "impostando i dati del dnssec ma senza aver avuto conferma da NIC di poterlo usare" do
|
248
|
+
expect(instance).to receive(:send_command) do |command|
|
249
|
+
expect(command.to_s).not_to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
250
|
+
end
|
251
|
+
|
252
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [KonoEppClient::DnsSec::Add.new(ds_data_a)])
|
253
|
+
end
|
254
|
+
|
255
|
+
it_behaves_like "dnssec activated" do
|
256
|
+
|
257
|
+
it "senza assegnare dnssec data non succede nulla" do
|
258
|
+
expect(instance).to receive(:send_command) do |command|
|
259
|
+
expect(command.to_s).not_to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
260
|
+
end
|
261
|
+
|
262
|
+
instance.update_domain(name: 'architest.it')
|
263
|
+
end
|
264
|
+
|
265
|
+
it "assegnando dei valori" do
|
266
|
+
expect(instance).to receive(:send_command) do |command|
|
267
|
+
expect(command.to_s).to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
268
|
+
|
269
|
+
expect(command.to_s).to have_xpath(
|
270
|
+
"//secDNS:update//secDNS:add//secDNS:dsData//secDNS:keyTag[text()='#{ds_data_a.key_tag}']",
|
271
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
272
|
+
)
|
273
|
+
expect(command.to_s).to have_xpath(
|
274
|
+
"//secDNS:update//secDNS:rem//secDNS:dsData//secDNS:keyTag[text()='#{ds_data_b.key_tag}']",
|
275
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
279
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [
|
280
|
+
KonoEppClient::DnsSec::Add.new(ds_data_a),
|
281
|
+
KonoEppClient::DnsSec::Rem.new(ds_data_b)
|
282
|
+
])
|
283
|
+
end
|
284
|
+
|
285
|
+
it "cancello tutti i ds_data" do
|
286
|
+
expect(instance).to receive(:send_command) do |command|
|
287
|
+
expect(command.to_s).to have_xpath("//secDNS:update", {"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"})
|
288
|
+
|
289
|
+
expect(command.to_s).to have_xpath(
|
290
|
+
"//secDNS:update//secDNS:rem//secDNS:all[text()='true']",
|
291
|
+
{"secDNS" => "urn:ietf:params:xml:ns:secDNS-1.1"}
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
instance.update_domain(name: 'architest.it', dns_sec_data: [
|
296
|
+
KonoEppClient::DnsSec::RemAll.new
|
297
|
+
])
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,13 @@ Bundler.setup
|
|
3
3
|
|
4
4
|
require 'simplecov'
|
5
5
|
SimpleCov.start do
|
6
|
-
|
7
|
-
|
6
|
+
enable_coverage :branch
|
7
|
+
enable_coverage_for_eval
|
8
|
+
add_group "Commands","lib/kono_epp_client/commands"
|
9
|
+
add_filter "spec"
|
8
10
|
|
11
|
+
end
|
12
|
+
require 'debug'
|
9
13
|
require 'kono_epp_client' # and any other gems you need
|
10
14
|
|
11
15
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
data/spec/support/context.rb
CHANGED
@@ -9,7 +9,7 @@ RSpec.shared_context "like epp command" do
|
|
9
9
|
}
|
10
10
|
let(:rendered) {
|
11
11
|
x = Nokogiri::XML(raw_rendered_content)
|
12
|
-
x.remove_namespaces! #
|
12
|
+
x.remove_namespaces! # La ricerca con namespace deve essere fatta con have_xpath e il passaggio di namespace
|
13
13
|
x
|
14
14
|
}
|
15
15
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module FixturesReader
|
2
|
+
def file_fixture(filename)
|
3
|
+
fixuture_path = File.expand_path('../fixtures', File.dirname(__FILE__))
|
4
|
+
File.open("#{fixuture_path}/#{filename}", 'r')
|
5
|
+
end
|
6
|
+
|
7
|
+
##
|
8
|
+
# Stessa cosa del file_fixture ma elimina tutti gli spazi dal file xml
|
9
|
+
def xml_fixture(filename)
|
10
|
+
file_fixture(filename).read.gsub(/[[:space:]]/, '')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include FixturesReader
|
16
|
+
end
|
data/spec/support/matchers.rb
CHANGED
@@ -3,4 +3,18 @@ require 'rspec-html-matchers'
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
|
5
5
|
config.include RSpecHtmlMatchers
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec::Matchers.define :have_xpath do |xpath, *opts|
|
9
|
+
match do |str|
|
10
|
+
Nokogiri::XML(str).xpath(xpath, *opts).any?
|
11
|
+
end
|
12
|
+
|
13
|
+
failure_message do |str|
|
14
|
+
"Expected xpath #{xpath.inspect} to match in:\n" + Nokogiri::XML(str).to_xml(indent: 2)
|
15
|
+
end
|
16
|
+
|
17
|
+
failure_message_when_negated do |str|
|
18
|
+
"Expected xpath #{xpath.inspect} not to match in:\n" + Nokogiri::XML(str).to_xml(indent: 2)
|
19
|
+
end
|
6
20
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec-parameterized'
|