httpi 0.9.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ ## 1.0.0 (2012-06-07)
2
+
3
+ * Feature: [#48](https://github.com/rubiii/httpi/pull/48) @jheiss added support
4
+ for HTTP Negotiate/SPNEGO authentication (curb-specific).
5
+
6
+ * Fix: [#53](https://github.com/rubiii/httpi/issues/53) fixed an issue where
7
+ `HTTPI.log_level` did not do anything at all.
8
+
1
9
  ## 0.9.7 (2012-04-26)
2
10
 
3
11
  * Fix: Merged [pull request 49](https://github.com/rubiii/httpi/pull/49) so that cert
data/README.md CHANGED
@@ -167,13 +167,16 @@ request.read_timeout = 30 # sec
167
167
  HTTPI::Auth
168
168
  -----------
169
169
 
170
- `HTTPI::Auth` supports HTTP basic and digest authentication.
170
+ `HTTPI::Auth` supports HTTP basic, digest and Negotiate/SPNEGO authentication.
171
171
 
172
172
  ``` ruby
173
173
  request.auth.basic("username", "password") # HTTP basic auth credentials
174
174
  request.auth.digest("username", "password") # HTTP digest auth credentials
175
+ request.auth.gssnegotiate # HTTP Negotiate/SPNEGO (aka Kerberos)
175
176
  ```
176
177
 
178
+ HTTP Negotiate only works when using Curb.
179
+
177
180
  For experimental NTLM authentication, please use the [httpi-ntlm](rubygems.org/gems/httpi-ntml)
178
181
  gem and provide feedback.
179
182
 
@@ -162,10 +162,9 @@ module HTTPI
162
162
  @log_level ||= DEFAULT_LOG_LEVEL
163
163
  end
164
164
 
165
- # Logs given +messages+.
166
- def log(*messages)
167
- level = Symbol === messages.first ? messages.shift : log_level
168
- logger.send level, messages.join(" ") if log?
165
+ # Logs a given +message+.
166
+ def log(message)
167
+ logger.send(log_level, message) if log?
169
168
  end
170
169
 
171
170
  # Reset the default config.
@@ -190,7 +189,7 @@ module HTTPI
190
189
  def with_adapter(method, request, adapter)
191
190
  adapter, adapter_class = Adapter.load adapter
192
191
 
193
- log :debug, "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter"
192
+ log "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter"
194
193
  yield adapter_class.new(request)
195
194
  end
196
195
 
@@ -58,6 +58,7 @@ module HTTPI
58
58
  def setup_client(request)
59
59
  basic_setup request
60
60
  setup_http_auth request if request.auth.http?
61
+ setup_gssnegotiate_auth request if request.auth.gssnegotiate?
61
62
  setup_ssl_auth request.auth.ssl if request.auth.ssl?
62
63
  end
63
64
 
@@ -75,6 +76,14 @@ module HTTPI
75
76
  client.username, client.password = *request.auth.credentials
76
77
  end
77
78
 
79
+ def setup_gssnegotiate_auth(request)
80
+ client.http_auth_types = request.auth.type
81
+ # The curl man page (http://curl.haxx.se/docs/manpage.html) says that
82
+ # you have to specify a fake username when using Negotiate auth, and
83
+ # they use ':' in their example.
84
+ client.username = ':'
85
+ end
86
+
78
87
  def setup_ssl_auth(ssl)
79
88
  client.cert_key = ssl.cert_key_file
80
89
  client.cert = ssl.cert_file
@@ -5,12 +5,12 @@ module HTTPI
5
5
 
6
6
  # = HTTPI::Auth::Config
7
7
  #
8
- # Manages HTTP and SSL auth configuration. Currently supports HTTP basic/digest
9
- # and SSL client authentication.
8
+ # Manages HTTP and SSL auth configuration. Currently supports HTTP basic/digest,
9
+ # Negotiate/SPNEGO, and SSL client authentication.
10
10
  class Config
11
11
 
12
12
  # Supported authentication types.
13
- TYPES = [:basic, :digest, :ssl]
13
+ TYPES = [:basic, :digest, :gssnegotiate, :ssl]
14
14
 
15
15
  # Accessor for the HTTP basic auth credentials.
16
16
  def basic(*args)
@@ -38,6 +38,16 @@ module HTTPI
38
38
  type == :digest
39
39
  end
40
40
 
41
+ # Enable HTTP Negotiate/SPNEGO authentication.
42
+ def gssnegotiate
43
+ self.type = :gssnegotiate
44
+ end
45
+
46
+ # Returns whether to use HTTP Negotiate/SPNEGO auth.
47
+ def gssnegotiate?
48
+ type == :gssnegotiate
49
+ end
50
+
41
51
  # Returns whether to use HTTP basic or dihest auth.
42
52
  def http?
43
53
  type == :basic || type == :digest
@@ -1,5 +1,5 @@
1
1
  module HTTPI
2
2
 
3
- VERSION = "0.9.7"
3
+ VERSION = "1.0.0"
4
4
 
5
5
  end
@@ -169,6 +169,13 @@ unless RUBY_PLATFORM =~ /java/
169
169
  curb.expects(:http_auth_types=).with(:digest)
170
170
  adapter.get(request)
171
171
  end
172
+
173
+ it "is set to :gssnegotiate for HTTP Negotiate auth" do
174
+ request = basic_request { |request| request.auth.gssnegotiate }
175
+
176
+ curb.expects(:http_auth_types=).with(:gssnegotiate)
177
+ adapter.get(request)
178
+ end
172
179
  end
173
180
 
174
181
  describe "username and password" do
@@ -60,6 +60,24 @@ describe HTTPI::Auth::Config do
60
60
  end
61
61
  end
62
62
 
63
+ describe "#gssnegotiate" do
64
+ it "sets the authentication type to :gssnegotiate" do
65
+ auth.gssnegotiate
66
+ auth.type.should == :gssnegotiate
67
+ end
68
+ end
69
+
70
+ describe "#gssnegotiate?" do
71
+ it "defaults to return false" do
72
+ auth.should_not be_gssnegotiate
73
+ end
74
+
75
+ it "returns true for HTTP Negotiate auth" do
76
+ auth.gssnegotiate
77
+ auth.should be_gssnegotiate
78
+ end
79
+ end
80
+
63
81
  describe "#http?" do
64
82
  it "defaults to return false" do
65
83
  auth.should_not be_http
@@ -233,7 +233,7 @@ describe HTTPI do
233
233
  before { opts[:class].any_instance.expects(method) }
234
234
 
235
235
  it "logs that we're executing a request" do
236
- HTTPI.expects(:log).with(:debug, "HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter")
236
+ HTTPI.expects(:log).with("HTTPI executes HTTP #{method.to_s.upcase} using the #{adapter} adapter")
237
237
  client.request method, request, adapter
238
238
  end
239
239
 
@@ -274,9 +274,9 @@ describe HTTPI do
274
274
 
275
275
  describe ".log" do
276
276
  it "logs the given messages" do
277
- HTTPI.log_level = :debug
278
- HTTPI.logger.expects(:debug).with("Log this")
279
- HTTPI.log "Log", "this"
277
+ HTTPI.log_level = :info
278
+ HTTPI.logger.expects(:info).with("Log this")
279
+ HTTPI.log "Log this"
280
280
  end
281
281
  end
282
282
  end
metadata CHANGED
@@ -1,135 +1,139 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: httpi
3
- version: !ruby/object:Gem::Version
4
- version: 0.9.7
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Daniel Harrington
9
14
  - Martin Tepper
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2012-04-26 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rack
17
- requirement: !ruby/object:Gem::Requirement
18
+
19
+ date: 2012-06-07 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
18
23
  none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ name: rack
23
32
  type: :runtime
24
33
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
31
- - !ruby/object:Gem::Dependency
32
- name: rake
33
- requirement: !ruby/object:Gem::Requirement
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
34
37
  none: false
35
- requirements:
38
+ requirements:
36
39
  - - ~>
37
- - !ruby/object:Gem::Version
40
+ - !ruby/object:Gem::Version
41
+ hash: 49
42
+ segments:
43
+ - 0
44
+ - 8
45
+ - 7
38
46
  version: 0.8.7
47
+ name: rake
39
48
  type: :development
40
49
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
42
53
  none: false
43
- requirements:
54
+ requirements:
44
55
  - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 0.8.7
47
- - !ruby/object:Gem::Dependency
56
+ - !ruby/object:Gem::Version
57
+ hash: 13
58
+ segments:
59
+ - 2
60
+ - 7
61
+ version: "2.7"
48
62
  name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '2.7'
55
63
  type: :development
56
64
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: '2.7'
63
- - !ruby/object:Gem::Dependency
64
- name: mocha
65
- requirement: !ruby/object:Gem::Requirement
65
+ requirement: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
68
  none: false
67
- requirements:
69
+ requirements:
68
70
  - - ~>
69
- - !ruby/object:Gem::Version
71
+ - !ruby/object:Gem::Version
72
+ hash: 41
73
+ segments:
74
+ - 0
75
+ - 9
76
+ - 9
70
77
  version: 0.9.9
78
+ name: mocha
71
79
  type: :development
72
80
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
81
+ requirement: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ version_requirements: &id005 !ruby/object:Gem::Requirement
74
84
  none: false
75
- requirements:
85
+ requirements:
76
86
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 0.9.9
79
- - !ruby/object:Gem::Dependency
80
- name: webmock
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ~>
85
- - !ruby/object:Gem::Version
87
+ - !ruby/object:Gem::Version
88
+ hash: 7
89
+ segments:
90
+ - 1
91
+ - 4
92
+ - 0
86
93
  version: 1.4.0
94
+ name: webmock
87
95
  type: :development
88
96
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
97
+ requirement: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ version_requirements: &id006 !ruby/object:Gem::Requirement
90
100
  none: false
91
- requirements:
92
- - - ~>
93
- - !ruby/object:Gem::Version
94
- version: 1.4.0
95
- - !ruby/object:Gem::Dependency
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
96
108
  name: autotest
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
109
  type: :development
104
110
  prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: ZenTest
113
- requirement: !ruby/object:Gem::Requirement
111
+ requirement: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ version_requirements: &id007 !ruby/object:Gem::Requirement
114
114
  none: false
115
- requirements:
116
- - - '='
117
- - !ruby/object:Gem::Version
115
+ requirements:
116
+ - - "="
117
+ - !ruby/object:Gem::Version
118
+ hash: 43
119
+ segments:
120
+ - 4
121
+ - 5
122
+ - 0
118
123
  version: 4.5.0
124
+ name: ZenTest
119
125
  type: :development
120
126
  prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - '='
125
- - !ruby/object:Gem::Version
126
- version: 4.5.0
127
+ requirement: *id007
127
128
  description: HTTPI provides a common interface for Ruby HTTP libraries.
128
129
  email: me@rubiii.com
129
130
  executables: []
131
+
130
132
  extensions: []
133
+
131
134
  extra_rdoc_files: []
132
- files:
135
+
136
+ files:
133
137
  - .gitignore
134
138
  - .rspec
135
139
  - .travis.yml
@@ -173,26 +177,36 @@ files:
173
177
  - spec/support/matchers.rb
174
178
  homepage: http://github.com/rubiii/httpi
175
179
  licenses: []
180
+
176
181
  post_install_message:
177
182
  rdoc_options: []
178
- require_paths:
183
+
184
+ require_paths:
179
185
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
186
+ required_ruby_version: !ruby/object:Gem::Requirement
181
187
  none: false
182
- requirements:
183
- - - ! '>='
184
- - !ruby/object:Gem::Version
185
- version: '0'
186
- required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ hash: 3
192
+ segments:
193
+ - 0
194
+ version: "0"
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
196
  none: false
188
- requirements:
189
- - - ! '>='
190
- - !ruby/object:Gem::Version
191
- version: '0'
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ hash: 3
201
+ segments:
202
+ - 0
203
+ version: "0"
192
204
  requirements: []
205
+
193
206
  rubyforge_project: httpi
194
- rubygems_version: 1.8.20
207
+ rubygems_version: 1.8.21
195
208
  signing_key:
196
209
  specification_version: 3
197
210
  summary: Interface for Ruby HTTP libraries
198
211
  test_files: []
212
+