htty 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/htty/cli/commands/help.rb +2 -1
- data/lib/htty/cli/commands/ssl_verification.rb +57 -0
- data/lib/htty/cli/commands/ssl_verification_off.rb +42 -0
- data/lib/htty/cli/commands/ssl_verification_on.rb +43 -0
- data/lib/htty/preferences.rb +26 -0
- data/lib/htty/request.rb +2 -1
- data/lib/htty/requests_util.rb +9 -1
- data/spec/system/scenarios_spec.rb +2 -1
- data/spec/unit/htty/cli/commands/query_set_spec.rb +4 -3
- data/spec/unit/htty/preferences_spec.rb +8 -0
- metadata +15 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
@@ -52,6 +52,7 @@ private
|
|
52
52
|
'Building Requests',
|
53
53
|
'Issuing Requests',
|
54
54
|
'Inspecting Responses',
|
55
|
+
'Preferences',
|
55
56
|
nil]
|
56
57
|
HTTY::CLI::Commands.select do |c|
|
57
58
|
# Filter out commands not yet implemented.
|
@@ -60,7 +61,7 @@ private
|
|
60
61
|
c.alias_for.instance_methods.collect(&:to_sym).include?(:perform))
|
61
62
|
end.group_by(&:category).sort_by do |category, commands|
|
62
63
|
# Group commands by category and give the categories a custom order.
|
63
|
-
categories_in_order.index
|
64
|
+
categories_in_order.index(category) || 0
|
64
65
|
end.each do |category, commands|
|
65
66
|
category ||= 'Miscellaneous'
|
66
67
|
puts
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path("#{File.dirname __FILE__}/../../preferences")
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../command")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/../display")
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification_off")
|
5
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification_on")
|
6
|
+
|
7
|
+
module HTTY; end
|
8
|
+
|
9
|
+
class HTTY::CLI; end
|
10
|
+
|
11
|
+
module HTTY::CLI::Commands; end
|
12
|
+
|
13
|
+
# Encapsulates the _ssl-verification_ command.
|
14
|
+
class HTTY::CLI::Commands::SslVerification < HTTY::CLI::Command
|
15
|
+
|
16
|
+
include HTTY::CLI::Display
|
17
|
+
|
18
|
+
# Returns the name of a category under which help for the _ssl-verification_
|
19
|
+
# command should appear.
|
20
|
+
def self.category
|
21
|
+
'Preferences'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the help text for the _ssl-verification_ command.
|
25
|
+
def self.help
|
26
|
+
'Displays the preference for SSL certificate verification'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the extended help text for the _ssl-verification_ command.
|
30
|
+
def self.help_extended
|
31
|
+
'Displays the preference for SSL certificate verification. Does not ' +
|
32
|
+
"communicate with the host.\n" +
|
33
|
+
"\n" +
|
34
|
+
'When issuing HTTP Secure requests, server certificates will be ' +
|
35
|
+
'verified. You can disable and reenable this behavior.'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns related command classes for the _ssl-verification_ command.
|
39
|
+
def self.see_also_commands
|
40
|
+
[HTTY::CLI::Commands::SslVerificationOff,
|
41
|
+
HTTY::CLI::Commands::SslVerificationOn]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Performs the _ssl-verification_ command.
|
45
|
+
def perform
|
46
|
+
unless arguments.empty?
|
47
|
+
raise ArgumentError,
|
48
|
+
"wrong number of arguments (#{arguments.length} for 0)"
|
49
|
+
end
|
50
|
+
|
51
|
+
will_or_not = HTTY::Preferences.current.verify_certificates? ?
|
52
|
+
'will' :
|
53
|
+
'will not'
|
54
|
+
puts notice("SSL certificates #{will_or_not} be verified")
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path("#{File.dirname __FILE__}/../../preferences")
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../command")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification")
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification_on")
|
5
|
+
|
6
|
+
module HTTY; end
|
7
|
+
|
8
|
+
class HTTY::CLI; end
|
9
|
+
|
10
|
+
module HTTY::CLI::Commands; end
|
11
|
+
|
12
|
+
# Encapsulates the _ssl-verification-off_ command.
|
13
|
+
class HTTY::CLI::Commands::SslVerificationOff < HTTY::CLI::Command
|
14
|
+
|
15
|
+
# Returns the name of a category under which help for the
|
16
|
+
# _ssl-verification-off_ command should appear.
|
17
|
+
def self.category
|
18
|
+
'Preferences'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the help text for the _ssl-verification-off_ command.
|
22
|
+
def self.help
|
23
|
+
'Disables SSL certificate verification'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the extended help text for the _ssl-verification-off_ command.
|
27
|
+
def self.help_extended
|
28
|
+
'Disables SSL certificate verification. Does not communicate with the host.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns related command classes for the _ssl-verification-off_ command.
|
32
|
+
def self.see_also_commands
|
33
|
+
[HTTY::CLI::Commands::SslVerificationOn,
|
34
|
+
HTTY::CLI::Commands::SslVerification]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Performs the _ssl-verification-off_ command.
|
38
|
+
def perform
|
39
|
+
HTTY::Preferences.current.verify_certificates = false
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path("#{File.dirname __FILE__}/../../preferences")
|
2
|
+
require File.expand_path("#{File.dirname __FILE__}/../command")
|
3
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification")
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/ssl_verification_off")
|
5
|
+
|
6
|
+
module HTTY; end
|
7
|
+
|
8
|
+
class HTTY::CLI; end
|
9
|
+
|
10
|
+
module HTTY::CLI::Commands; end
|
11
|
+
|
12
|
+
# Encapsulates the _ssl-verification-on_ command.
|
13
|
+
class HTTY::CLI::Commands::SslVerificationOn < HTTY::CLI::Command
|
14
|
+
|
15
|
+
# Returns the name of a category under which help for the
|
16
|
+
# _ssl-verification-on_ command should appear.
|
17
|
+
def self.category
|
18
|
+
'Preferences'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the help text for the _ssl-verification-on_ command.
|
22
|
+
def self.help
|
23
|
+
'Reenables SSL certificate verification'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the extended help text for the _ssl-verification-on_ command.
|
27
|
+
def self.help_extended
|
28
|
+
'Reenables SSL certificate verification. Does not communicate with the ' +
|
29
|
+
'host.'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns related command classes for the _ssl-verification-on_ command.
|
33
|
+
def self.see_also_commands
|
34
|
+
[HTTY::CLI::Commands::SslVerificationOff,
|
35
|
+
HTTY::CLI::Commands::SslVerification]
|
36
|
+
end
|
37
|
+
|
38
|
+
# Performs the _ssl-verification-on_ command.
|
39
|
+
def perform
|
40
|
+
HTTY::Preferences.current.verify_certificates = true
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HTTY; end
|
2
|
+
|
3
|
+
# Encapsulates _htty_ user preferences.
|
4
|
+
class HTTY::Preferences
|
5
|
+
|
6
|
+
# Returns the instance of HTTY::Preferences holding current preferences.
|
7
|
+
def self.current
|
8
|
+
@current ||= new
|
9
|
+
end
|
10
|
+
|
11
|
+
# Sets the boolean preference for whether server certificates are verified
|
12
|
+
# during HTTP Secure requests.
|
13
|
+
attr_writer :verify_certificates
|
14
|
+
|
15
|
+
# Initializes a new HTTY::Preferences object.
|
16
|
+
def initialize
|
17
|
+
@verify_certificates = true
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns +true+ if server certificates are verified during HTTP Secure
|
21
|
+
# requests.
|
22
|
+
def verify_certificates?
|
23
|
+
@verify_certificates
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/htty/request.rb
CHANGED
data/lib/htty/requests_util.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'net/https'
|
3
3
|
require 'uri'
|
4
|
+
require File.expand_path("#{File.dirname __FILE__}/preferences")
|
4
5
|
require File.expand_path("#{File.dirname __FILE__}/response")
|
5
6
|
|
6
7
|
module HTTY; end
|
@@ -73,7 +74,14 @@ private
|
|
73
74
|
|
74
75
|
def self.request(request)
|
75
76
|
http = Net::HTTP.new(request.uri.host, request.uri.port)
|
76
|
-
|
77
|
+
|
78
|
+
if request.uri.kind_of?(URI::HTTPS)
|
79
|
+
http.use_ssl = true
|
80
|
+
http.verify_mode = HTTY::Preferences.current.verify_certificates? ?
|
81
|
+
OpenSSL::SSL::VERIFY_PEER :
|
82
|
+
OpenSSL::SSL::VERIFY_NONE
|
83
|
+
end
|
84
|
+
|
77
85
|
http.start do |host|
|
78
86
|
http_response = yield(host)
|
79
87
|
headers = []
|
@@ -14,7 +14,8 @@ Dir.glob "#{all_dir}/**/*/" do |this_dir|
|
|
14
14
|
content
|
15
15
|
end
|
16
16
|
|
17
|
-
define_method :run_and_capture do |
|
17
|
+
define_method :run_and_capture do |*args|
|
18
|
+
options = args.first || {}
|
18
19
|
stdin_filename = "#{this_dir}/stdin"
|
19
20
|
htty_filename = "#{File.dirname __FILE__}/../../bin/htty"
|
20
21
|
stderr_target = options[:combine_stdout_and_stderr] ?
|
@@ -54,9 +54,10 @@ describe HTTY::CLI::Commands::QuerySet do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should play nice with nested fields' do
|
57
|
-
@session.requests.last.uri.query = 'test[my][]=
|
58
|
-
query_set = create_query_set_and_perform('test[my][]', '
|
59
|
-
query_set
|
57
|
+
@session.requests.last.uri.query = 'test[my][]=1'
|
58
|
+
query_set = create_query_set_and_perform('test[my][]', '2')
|
59
|
+
query_set = create_query_set_and_perform('test', '3')
|
60
|
+
query_set.session.requests.last.uri.query.should == 'test[my][]=2&test=3'
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
9
|
+
- 5
|
10
|
+
version: 1.1.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nils Jonsson
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-20 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
28
30
|
segments:
|
29
31
|
- 2
|
30
32
|
- 0
|
@@ -40,6 +42,7 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - ">="
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 49
|
43
46
|
segments:
|
44
47
|
- 0
|
45
48
|
- 8
|
@@ -55,6 +58,7 @@ dependencies:
|
|
55
58
|
requirements:
|
56
59
|
- - ">="
|
57
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 27
|
58
62
|
segments:
|
59
63
|
- 1
|
60
64
|
- 3
|
@@ -70,6 +74,7 @@ dependencies:
|
|
70
74
|
requirements:
|
71
75
|
- - ">="
|
72
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 5
|
73
78
|
segments:
|
74
79
|
- 0
|
75
80
|
- 6
|
@@ -148,6 +153,9 @@ files:
|
|
148
153
|
- lib/htty/cli/commands/quit.rb
|
149
154
|
- lib/htty/cli/commands/reuse.rb
|
150
155
|
- lib/htty/cli/commands/scheme_set.rb
|
156
|
+
- lib/htty/cli/commands/ssl_verification.rb
|
157
|
+
- lib/htty/cli/commands/ssl_verification_off.rb
|
158
|
+
- lib/htty/cli/commands/ssl_verification_on.rb
|
151
159
|
- lib/htty/cli/commands/status.rb
|
152
160
|
- lib/htty/cli/commands/undo.rb
|
153
161
|
- lib/htty/cli/commands/userinfo_clear.rb
|
@@ -164,6 +172,7 @@ files:
|
|
164
172
|
- lib/htty/no_set_cookie_header_error.rb
|
165
173
|
- lib/htty/ordered_hash.rb
|
166
174
|
- lib/htty/payload.rb
|
175
|
+
- lib/htty/preferences.rb
|
167
176
|
- lib/htty/request.rb
|
168
177
|
- lib/htty/requests_util.rb
|
169
178
|
- lib/htty/response.rb
|
@@ -181,6 +190,7 @@ files:
|
|
181
190
|
- spec/unit/htty/cli/commands/query_set_spec.rb
|
182
191
|
- spec/unit/htty/cli_spec.rb
|
183
192
|
- spec/unit/htty/ordered_hash_spec.rb
|
193
|
+
- spec/unit/htty/preferences_spec.rb
|
184
194
|
- spec/unit/htty/request_spec.rb
|
185
195
|
- spec/unit/htty/response_spec.rb
|
186
196
|
- spec/unit/htty/session_spec.rb
|
@@ -200,6 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
210
|
requirements:
|
201
211
|
- - ">="
|
202
212
|
- !ruby/object:Gem::Version
|
213
|
+
hash: 3
|
203
214
|
segments:
|
204
215
|
- 0
|
205
216
|
version: "0"
|
@@ -208,6 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
219
|
requirements:
|
209
220
|
- - ">="
|
210
221
|
- !ruby/object:Gem::Version
|
222
|
+
hash: 3
|
211
223
|
segments:
|
212
224
|
- 0
|
213
225
|
version: "0"
|