bucky-core 0.10.6 → 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/bucky/test_equipment/verifications/status_checker.rb +22 -11
- data/lib/bucky/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba4cfdfb0d88340a326b8bb17c55517e8f4e9838
|
4
|
+
data.tar.gz: d52796926a4bdd0bce45326f73aeb4b0bddd62f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30e29812db9cf2b91c771e5565d4d477dd0c2f59675878a3a17c24891c2d3aea99cf650609ea60ee5b6c2665cf40d8c22a098d12773782bf211f2245659daa4
|
7
|
+
data.tar.gz: c8018498f6471c2744e8142c883853b2a9575e96b21aa2f27bdd7e1cf33a0e596de9334348201d6a089922c164343cbed4fffea7f20678d785983af8759617a2
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -34,7 +34,11 @@ module Bucky
|
|
34
34
|
# If number of requests is over redirect limit
|
35
35
|
return { error_message: "\n[Redirect Error] #{url} is redirected more than #{REDIRECT_LIMIT}" } if redirect_count > REDIRECT_LIMIT
|
36
36
|
|
37
|
-
|
37
|
+
begin
|
38
|
+
check_result = check_log_and_get_response(url, device, link_check_max_times, url_log)
|
39
|
+
rescue Net::ReadTimeout => e
|
40
|
+
return { error_message: "#{e.message} Please check this url: #{url}" }
|
41
|
+
end
|
38
42
|
# If result include response continue to check, else return result
|
39
43
|
!check_result.key?(:response) ? (return check_result) : response = check_result[:response]
|
40
44
|
|
@@ -46,13 +50,8 @@ module Bucky
|
|
46
50
|
puts " #{url} ... [#{response.code}:OK]"
|
47
51
|
{ entity: response.entity }
|
48
52
|
when /3[0-9]{2}/
|
49
|
-
|
50
|
-
|
51
|
-
# Add fqdn if location doesn't include fqdn
|
52
|
-
redirect_url = fqdn << redirect_url unless redirect_url.include?('http')
|
53
|
-
puts " #{url} ... redirect to #{redirect_url} [#{response.code}:RD]"
|
54
|
-
http_status_check_args = { url: redirect_url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: redirect_count + 1, redirect_url_list: redirect_url_list }
|
55
|
-
http_status_check(http_status_check_args)
|
53
|
+
http_status_check_args = { url: url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: redirect_count + 1, redirect_url_list: redirect_url_list }
|
54
|
+
redirect_and_http_status_check(response, http_status_check_args)
|
56
55
|
when /(4|5)[0-9]{2}/
|
57
56
|
url_log[url][:error_message] = "[Status Error] http status returned #{response.code}.\ncheck this url: #{redirect_url_list.join(' -> ')}"
|
58
57
|
puts " #{url} ... [#{response.code}:NG]"
|
@@ -82,12 +81,12 @@ module Bucky
|
|
82
81
|
# Check base url
|
83
82
|
http_status_check_args = { url: url, device: device, link_check_max_times: link_check_max_times, url_log: url_log, redirect_count: 0, redirect_url_list: [] }
|
84
83
|
base_response = http_status_check(http_status_check_args)
|
85
|
-
|
84
|
+
raise Test::Unit::AssertionFailedError, "Response of base URL is incorrect.\n#{base_response[:error_message]}" unless base_response[:error_message].nil?
|
86
85
|
|
87
86
|
# Collect links
|
88
87
|
links_args = { base_url: base_url, base_fqdn: base_fqdn, url_reg: url_reg, only_same_fqdn: only_same_fqdn, entity: base_response[:entity] }
|
89
88
|
links = make_target_links(links_args)
|
90
|
-
links = exclude(links, exclude_urls)
|
89
|
+
links = exclude(links, exclude_urls)
|
91
90
|
|
92
91
|
errors = []
|
93
92
|
Parallel.each(links.uniq, in_threads: Bucky::Utils::Config.instance[:linkstatus_thread_num]) do |link|
|
@@ -96,7 +95,7 @@ module Bucky
|
|
96
95
|
link_response = http_status_check(http_status_check_args)
|
97
96
|
errors << link_response[:error_message] if link_response[:error_message]
|
98
97
|
end
|
99
|
-
|
98
|
+
raise Test::Unit::AssertionFailedError, errors.join("\n") unless errors.empty?
|
100
99
|
end
|
101
100
|
|
102
101
|
def make_target_links(args)
|
@@ -128,6 +127,8 @@ module Bucky
|
|
128
127
|
|
129
128
|
# Exclude non test target url
|
130
129
|
def exclude(links, exclude_urls)
|
130
|
+
return links if exclude_urls.nil?
|
131
|
+
|
131
132
|
excluded_links = links - exclude_urls
|
132
133
|
|
133
134
|
# Exclude url if it has "*" in the last of it
|
@@ -178,6 +179,16 @@ module Bucky
|
|
178
179
|
href.insert(0, '/') unless href.match(%r{^/|^#})
|
179
180
|
base_url + href
|
180
181
|
end
|
182
|
+
|
183
|
+
def redirect_and_http_status_check(response, http_status_check_args)
|
184
|
+
fqdn = http_status_check_args[:url][%r{^(https?:\/\/([a-zA-Z0-9\-_.]+))}]
|
185
|
+
redirect_url = response['location']
|
186
|
+
# Add fqdn if location doesn't include fqdn
|
187
|
+
redirect_url = fqdn << redirect_url unless redirect_url.include?('http')
|
188
|
+
puts " #{http_status_check_args[:url]} ... redirect to #{redirect_url} [#{response.code}:RD]"
|
189
|
+
http_status_check_args[:url] = redirect_url
|
190
|
+
http_status_check(http_status_check_args)
|
191
|
+
end
|
181
192
|
end
|
182
193
|
end
|
183
194
|
end
|
data/lib/bucky/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucky-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NaotoKishino
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: exe
|
15
15
|
cert_chain: []
|
16
|
-
date: 2020-
|
16
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|