webmock 1.8.4 → 1.8.5

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.
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.5
4
+
5
+ * WebMock::RackResponse supports basic auth
6
+
7
+ Thanks to [jugyo](https://github.com/jugyo)
8
+
3
9
  ## 1.8.4
4
10
 
5
11
  * Warning message is printed when an unsupported version of a http library is loaded.
data/README.md CHANGED
@@ -702,6 +702,7 @@ People who submitted patches and new features or suggested improvements. Many th
702
702
  * Jordan Elver
703
703
  * Joe Karayusuf
704
704
  * Paul Cortens
705
+ * jugyo
705
706
 
706
707
  For a full list of contributors you can visit the
707
708
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -38,6 +38,8 @@ module WebMock
38
38
  'SERVER_NAME' => uri.host
39
39
  }
40
40
 
41
+ env['HTTP_AUTHORIZATION'] = 'Basic ' + [uri.userinfo].pack('m').delete("\r\n") if uri.userinfo
42
+
41
43
  # Rack-specific variables
42
44
  env['rack.input'] = StringIO.new(body)
43
45
  env['rack.version'] = Rack::VERSION
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '1.8.4' unless defined?(::WebMock::VERSION)
2
+ VERSION = '1.8.5' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  describe WebMock::RackResponse do
4
4
  before :each do
5
5
  @rack_response = WebMock::RackResponse.new(MyRackApp)
6
- @locked_rack_response = WebMock::RackResponse.new(MyLockedRackApp)
7
6
  end
8
7
 
9
8
  it "should hook up to a rack appliance" do
@@ -23,6 +22,7 @@ describe WebMock::RackResponse do
23
22
  end
24
23
 
25
24
  it "should shouldn't blow up when hitting a locked resource twice" do
25
+ @locked_rack_response = WebMock::RackResponse.new(MyLockedRackApp)
26
26
  request = WebMock::RequestSignature.new(:get, 'www.example.com/locked')
27
27
  response = @locked_rack_response.evaluate(request)
28
28
  response2 = @locked_rack_response.evaluate(request)
@@ -48,4 +48,27 @@ describe WebMock::RackResponse do
48
48
  response = @rack_response.evaluate(request)
49
49
  response.body.should include('Good to meet you, Jimmy!')
50
50
  end
51
+
52
+ describe 'basic auth request' do
53
+ before :each do
54
+ @rack_response_with_basic_auth = WebMock::RackResponse.new(
55
+ Rack::Auth::Basic.new(MyRackApp) do |username, password|
56
+ username == 'username' && password == 'password'
57
+ end
58
+ )
59
+ end
60
+ it 'should be failure when wrong credentials' do
61
+ request = WebMock::RequestSignature.new(:get, 'foo:bar@www.example.com')
62
+ response = @rack_response_with_basic_auth.evaluate(request)
63
+ response.status.first.should == 401
64
+ response.body.should_not include('This is my root!')
65
+ end
66
+
67
+ it 'should be success when valid credentials' do
68
+ request = WebMock::RequestSignature.new(:get, 'username:password@www.example.com')
69
+ response = @rack_response_with_basic_auth.evaluate(request)
70
+ response.status.first.should == 200
71
+ response.body.should include('This is my root!')
72
+ end
73
+ end
51
74
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 8
9
- - 4
10
- version: 1.8.4
9
+ - 5
10
+ version: 1.8.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bartosz Blimke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-19 00:00:00 Z
18
+ date: 2012-03-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: addressable