tdi 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c99171625c1a80a506de4317c2f21c5ac73945f5
4
- data.tar.gz: 91a4ae1345e634e9cff30d911feba6e091835f67
3
+ metadata.gz: 4f886ba994177c0f77b060ac037649df1bb770d8
4
+ data.tar.gz: 3a9d33dca864eab56f7d2a8f4ca87753c696c0ac
5
5
  SHA512:
6
- metadata.gz: a473114f8aee6572f22e137f200a215f3c4eae236c41123ffd6711386da692ed727ad4c83ae45143c7825ace8ff50d2e88d2dabf87fc6144950efead5a8c58c7
7
- data.tar.gz: 8fc290f11de2d3398524c951920fab206dc2d3638f07619765f8eae589e0577449698eb7c761ad3aee5f67ca93f45ce14438e5ac6f64da16f048d6c1202951a8
6
+ metadata.gz: 83fe06b4f51a77b5352432261848afe4da6383bf5ba54fa1c5336b8a0f5745780329c3476b759fef9ee6871b22a4f44866ce229abb93115a493bd6e2fe6eb6c6
7
+ data.tar.gz: 5abb8268952a0251358153fc043b6ff9e30437830b58b4ee365e0635b925b69167027f58985d55958eb9f6a9badba43956030cc3e2a32ea2b9cbdac87fddb350
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tdi (0.2.0)
4
+ tdi (0.2.1)
5
5
  awesome_print
6
6
  colorize
7
7
  etc
@@ -32,6 +32,12 @@
32
32
 
33
33
  "http://g1.globo.com/index.html": {
34
34
  "match": "<html"
35
+ },
36
+
37
+ "186.192.90.5": {
38
+ "send_header": "Host: globo.com",
39
+ "code": 301,
40
+ "expect_header": "Location: http://www.globo.com/"
35
41
  }
36
42
  }
37
43
  }
@@ -103,7 +103,7 @@ class TDIPlan < TDI
103
103
 
104
104
  # Verdict.
105
105
  res_msg = "FILE (#{user}): #{path} => #{perm} #{type} #{location}"
106
- res_dict = case_content
106
+ res_dict = {:path => case_name}.merge(case_content)
107
107
  if @flag_success
108
108
  success role_name, plan_name, res_msg, res_dict
109
109
  else
@@ -41,6 +41,7 @@ class TDIPlan < TDI
41
41
  # Params.
42
42
  code = params['code'].nil? ? 200 : params['code'].to_i
43
43
  match = params['match']
44
+ send_header = params['send_header']
44
45
  expect_header = params['expect_header']
45
46
  timeout_limit = params['timeout'].nil? ? 2 : params['timeout'].to_i
46
47
 
@@ -57,7 +58,7 @@ class TDIPlan < TDI
57
58
  end
58
59
  end
59
60
 
60
- return host, port, path, proxy, proxy_port, code, match, expect_header_key, expect_header_value, ssl, timeout_limit
61
+ return host, port, path, proxy, proxy_port, send_header, code, match, expect_header_key, expect_header_value, ssl, timeout_limit
61
62
  end
62
63
 
63
64
  def http(role_name, plan_name, plan_content)
@@ -65,7 +66,7 @@ class TDIPlan < TDI
65
66
  val.is_a?(Hash)
66
67
  }.each_pair do |case_name, case_content|
67
68
  # Parse params.
68
- host, port, path, proxy, proxy_port, code, match, expect_header_key, expect_header_value, ssl, timeout_limit = _parse(case_name, case_content)
69
+ host, port, path, proxy, proxy_port, send_header, code, match, expect_header_key, expect_header_value, ssl, timeout_limit = _parse(case_name, case_content)
69
70
 
70
71
  # User.
71
72
  user = Etc.getpwuid(Process.euid).name
@@ -76,8 +77,14 @@ class TDIPlan < TDI
76
77
  res_str = case_name
77
78
  res_dict = {url: case_name, net: origin_network(host)}
78
79
  res_dict[:proxy] = "#{proxy}:#{proxy_port}" unless proxy.nil?
80
+ headers = nil
79
81
  response = nil
80
82
 
83
+ if not send_header.nil?
84
+ hdr, val = send_header.split(': ')
85
+ headers = Hash[hdr, val]
86
+ end
87
+
81
88
  begin
82
89
  addr = getaddress(host).to_s
83
90
 
@@ -87,7 +94,7 @@ class TDIPlan < TDI
87
94
  Timeout::timeout(timeout_limit) do
88
95
  begin
89
96
  http.start(host, port, use_ssl: ssl, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
90
- response = http.get(path)
97
+ response = http.get(path, headers)
91
98
  }
92
99
  rescue Errno::ECONNREFUSED, Errno::ECONNRESET => e
93
100
  res_msg = "HTTP (#{user}): #{res_str} (#{e.message})"
@@ -104,7 +111,7 @@ class TDIPlan < TDI
104
111
  Timeout::timeout(timeout_limit) do
105
112
  begin
106
113
  http.start() { |http|
107
- response = http.get(path)
114
+ response = http.get(path, headers)
108
115
  }
109
116
  rescue Errno::ECONNREFUSED, Errno::ECONNRESET => e
110
117
  res_msg = "HTTP (#{user}): #{res_str} (#{e.message})"
@@ -18,5 +18,5 @@
18
18
  # along with TDI. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module Tdi
21
- VERSION = '0.2.0'
21
+ VERSION = '0.2.1'
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rogério Carvalho Schneider
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-18 00:00:00.000000000 Z
13
+ date: 2016-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler