oddb2xml 3.0.22 → 3.0.24
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/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/History.txt +7 -0
- data/lib/oddb2xml/downloader.rb +7 -1
- data/lib/oddb2xml/proxy_check.rb +73 -17
- data/lib/oddb2xml/version.rb +1 -1
- data/scripts/run_oddb2xml.sh +99 -0
- data/scripts/transfer.sh +45 -0
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +2092 -2092
- data/spec/proxy_check_spec.rb +74 -0
- metadata +5 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "oddb2xml/proxy_check"
|
|
5
|
+
|
|
6
|
+
RSpec.describe Oddb2xml::ProxyCheck do
|
|
7
|
+
describe ".check_host" do
|
|
8
|
+
it "returns :ok with no :via for a plain 200" do
|
|
9
|
+
stub_request(:head, "https://files.refdata.ch/x").to_return(status: 200)
|
|
10
|
+
expect(described_class.check_host("files.refdata.ch", nil, "/x")).to eq(result: :ok, via: nil)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "flags a proxy 407 as :blocked" do
|
|
14
|
+
stub_request(:head, "https://files.refdata.ch/x").to_return(status: 407)
|
|
15
|
+
expect(described_class.check_host("files.refdata.ch", nil, "/x")[:result]).to eq :blocked
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "follows the cross-host redirect chain and names the final host in :via" do
|
|
19
|
+
stub_request(:head, "https://id.gs1.ch/01/07612345000961")
|
|
20
|
+
.to_return(status: 301, headers: {"Location" => "https://id.gs1.org/01/07612345000961"})
|
|
21
|
+
stub_request(:head, "https://id.gs1.org/01/07612345000961")
|
|
22
|
+
.to_return(status: 307, headers: {"Location" => "https://apitools.gs1.ch/api/v2/x?format=csv"})
|
|
23
|
+
stub_request(:head, "https://apitools.gs1.ch/api/v2/x?format=csv").to_return(status: 405)
|
|
24
|
+
|
|
25
|
+
expect(described_class.check_host("id.gs1.ch", nil, "/01/07612345000961"))
|
|
26
|
+
.to eq(result: :ok, via: "apitools.gs1.ch")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "reports a blocked redirect target as :blocked, naming it in :via" do
|
|
30
|
+
stub_request(:head, "https://id.gs1.ch/01/x")
|
|
31
|
+
.to_return(status: 301, headers: {"Location" => "https://id.gs1.org/01/x"})
|
|
32
|
+
stub_request(:head, "https://id.gs1.org/01/x").to_return(status: 407)
|
|
33
|
+
|
|
34
|
+
expect(described_class.check_host("id.gs1.ch", nil, "/01/x"))
|
|
35
|
+
.to eq(result: :blocked, via: "id.gs1.org")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "does not set :via for a same-host redirect" do
|
|
39
|
+
stub_request(:head, "https://files.refdata.ch/a")
|
|
40
|
+
.to_return(status: 301, headers: {"Location" => "https://files.refdata.ch/b"})
|
|
41
|
+
# same-host redirect is not followed; the host is already reachable
|
|
42
|
+
expect(described_class.check_host("files.refdata.ch", nil, "/a")).to eq(result: :ok, via: nil)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe ".all_hosts" do
|
|
47
|
+
it "includes the GS1 forwarder target id.gs1.org" do
|
|
48
|
+
expect(described_class.all_hosts).to have_key("id.gs1.org")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe ".hosts_for" do
|
|
53
|
+
it "probes id.gs1.org alongside id.gs1.ch when firstbase is requested" do
|
|
54
|
+
hosts = described_class.hosts_for(firstbase: true)
|
|
55
|
+
expect(hosts).to include("id.gs1.ch", "id.gs1.org")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "omits the GS1 hosts without firstbase" do
|
|
59
|
+
hosts = described_class.hosts_for({})
|
|
60
|
+
expect(hosts).not_to have_key("id.gs1.ch")
|
|
61
|
+
expect(hosts).not_to have_key("id.gs1.org")
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe ".probe_path" do
|
|
66
|
+
it "maps a known host to its real download resource" do
|
|
67
|
+
expect(described_class.probe_path("id.gs1.ch")).to eq "/01/07612345000961"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "falls back to / for an unknown host" do
|
|
71
|
+
expect(described_class.probe_path("example.com")).to eq "/"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oddb2xml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
|
|
@@ -496,6 +496,8 @@ files:
|
|
|
496
496
|
- oddb2xml.gemspec
|
|
497
497
|
- oddb2xml.xsd
|
|
498
498
|
- oddb_calc.xsd
|
|
499
|
+
- scripts/run_oddb2xml.sh
|
|
500
|
+
- scripts/transfer.sh
|
|
499
501
|
- spec/artikelstamm_spec.rb
|
|
500
502
|
- spec/builder_spec.rb
|
|
501
503
|
- spec/calc_spec.rb
|
|
@@ -570,6 +572,7 @@ files:
|
|
|
570
572
|
- spec/galenic_spec.rb
|
|
571
573
|
- spec/options_spec.rb
|
|
572
574
|
- spec/parslet_spec.rb
|
|
575
|
+
- spec/proxy_check_spec.rb
|
|
573
576
|
- spec/refdata_cleanup_spec.rb
|
|
574
577
|
- spec/spec_helper.rb
|
|
575
578
|
- spec/weleda_sl_spec.rb
|
|
@@ -674,6 +677,7 @@ test_files:
|
|
|
674
677
|
- spec/galenic_spec.rb
|
|
675
678
|
- spec/options_spec.rb
|
|
676
679
|
- spec/parslet_spec.rb
|
|
680
|
+
- spec/proxy_check_spec.rb
|
|
677
681
|
- spec/refdata_cleanup_spec.rb
|
|
678
682
|
- spec/spec_helper.rb
|
|
679
683
|
- spec/weleda_sl_spec.rb
|