api-auth 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b4f04ff0b0fdfdc276177e1a225239af93aff34
4
- data.tar.gz: 490677e918c7928517f8cb1bb476c5c81a9ac176
3
+ metadata.gz: a70b97184e4a7a11031e6c7bf62f26227da7e1cd
4
+ data.tar.gz: d6471c1d3d487b5b24106765d7eedde455e7c534
5
5
  SHA512:
6
- metadata.gz: cd94a12c5eaaf7b76390fead34de8b6a60644656343b3a3aedbfff4fc1b5eea64777c258b20136a6d1ff3aa2bf0c071c007914c4ad958d2db5684f48cce23e08
7
- data.tar.gz: 4ac0b39723cb446470b716d4cd8b06bc111bc88fd85fabf0c9e72a1300b6765c460463f038d9ed59f1d0c838bdcb5d103421e80cc833fba5e673bf43ffdea127
6
+ metadata.gz: c4d9d1eb76a1c1de3c65640dc9f44e877bdc62a7faad7773009527cf48034d58dadc304712bd54d70d3c3b934d240f0ce1d0951064183987e1f340066349a8a7
7
+ data.tar.gz: 13356a10470f99e4d2ab9104ca073cc92cb7f60f9f3696194013a13824b15e060a05ce1a102ca236bd4101a8e6e4523b9043849977a65a6d63f98eaf3a1f10d9
@@ -1,3 +1,7 @@
1
+ # 1.4.1 (2016-01-04)
2
+ - Fixed an issue where getters wouldn't immdiately have the correct value after
3
+ setting a date or content md5 in some of the request drivers (#91)
4
+
1
5
  # 1.4 (2015-12-16)
2
6
 
3
7
  ## IMPORTANT SECURITY FIX (with backwards compatible fallback)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.4.0)
4
+ api-auth (1.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,13 +8,13 @@ module ApiAuth
8
8
 
9
9
  def initialize(request)
10
10
  @request = request
11
- @headers = fetch_headers
11
+ fetch_headers
12
12
  true
13
13
  end
14
14
 
15
15
  def set_auth_header(header)
16
16
  @request.env["Authorization"] = header
17
- @headers = fetch_headers
17
+ fetch_headers
18
18
  @request
19
19
  end
20
20
 
@@ -26,6 +26,7 @@ module ApiAuth
26
26
  def populate_content_md5
27
27
  if @request.put? || @request.post?
28
28
  @request.env["Content-MD5"] = calculated_md5
29
+ fetch_headers
29
30
  end
30
31
  end
31
32
 
@@ -38,7 +39,7 @@ module ApiAuth
38
39
  end
39
40
 
40
41
  def fetch_headers
41
- capitalize_keys @request.env
42
+ @headers = capitalize_keys @request.env
42
43
  end
43
44
 
44
45
  def http_method
@@ -61,6 +62,7 @@ module ApiAuth
61
62
 
62
63
  def set_date
63
64
  @request.env['HTTP_DATE'] = Time.now.utc.httpdate
65
+ fetch_headers
64
66
  end
65
67
 
66
68
  def timestamp
@@ -8,13 +8,13 @@ module ApiAuth
8
8
 
9
9
  def initialize(request)
10
10
  @request = request
11
- @headers = fetch_headers
11
+ fetch_headers
12
12
  true
13
13
  end
14
14
 
15
15
  def set_auth_header(header)
16
16
  @request.headers.merge!({ "Authorization" => header })
17
- @headers = fetch_headers
17
+ fetch_headers
18
18
  @request
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ module ApiAuth
27
27
  end
28
28
 
29
29
  def fetch_headers
30
- capitalize_keys @request.headers
30
+ @headers = capitalize_keys @request.headers
31
31
  end
32
32
 
33
33
  def http_method
@@ -50,6 +50,7 @@ module ApiAuth
50
50
 
51
51
  def set_date
52
52
  @request.headers.merge!({ "DATE" => Time.now.utc.httpdate })
53
+ fetch_headers
53
54
  end
54
55
 
55
56
  def timestamp
@@ -8,13 +8,13 @@ module ApiAuth
8
8
 
9
9
  def initialize(request)
10
10
  @request = request
11
- @headers = fetch_headers
11
+ fetch_headers
12
12
  true
13
13
  end
14
14
 
15
15
  def set_auth_header(header)
16
16
  @request.headers.merge!({ "Authorization" => header })
17
- @headers = fetch_headers
17
+ fetch_headers
18
18
  @request
19
19
  end
20
20
 
@@ -30,6 +30,7 @@ module ApiAuth
30
30
  def populate_content_md5
31
31
  if ['POST', 'PUT'].include?(@request.method.to_s.upcase)
32
32
  @request.headers["Content-MD5"] = calculated_md5
33
+ fetch_headers
33
34
  end
34
35
  end
35
36
 
@@ -42,7 +43,7 @@ module ApiAuth
42
43
  end
43
44
 
44
45
  def fetch_headers
45
- capitalize_keys @request.headers
46
+ @headers = capitalize_keys @request.headers
46
47
  end
47
48
 
48
49
  def http_method
@@ -68,6 +69,7 @@ module ApiAuth
68
69
 
69
70
  def set_date
70
71
  @request.headers.merge!({ "DATE" => Time.now.utc.httpdate })
72
+ fetch_headers
71
73
  end
72
74
 
73
75
  def timestamp
@@ -8,13 +8,13 @@ module ApiAuth
8
8
 
9
9
  def initialize(request)
10
10
  @request = request
11
- @headers = fetch_headers
11
+ fetch_headers
12
12
  true
13
13
  end
14
14
 
15
15
  def set_auth_header(header)
16
16
  @request.headers["Authorization"] = header
17
- @headers = fetch_headers
17
+ fetch_headers
18
18
  @request
19
19
  end
20
20
 
@@ -25,6 +25,7 @@ module ApiAuth
25
25
  def populate_content_md5
26
26
  if @request.body
27
27
  @request.headers["Content-MD5"] = calculated_md5
28
+ fetch_headers
28
29
  end
29
30
  end
30
31
 
@@ -37,7 +38,7 @@ module ApiAuth
37
38
  end
38
39
 
39
40
  def fetch_headers
40
- capitalize_keys @request.headers
41
+ @headers = capitalize_keys @request.headers
41
42
  end
42
43
 
43
44
  def http_method
@@ -60,6 +61,7 @@ module ApiAuth
60
61
 
61
62
  def set_date
62
63
  @request.headers["DATE"] = Time.now.utc.httpdate
64
+ fetch_headers
63
65
  end
64
66
 
65
67
  def timestamp
@@ -8,13 +8,13 @@ module ApiAuth
8
8
 
9
9
  def initialize(request)
10
10
  @request = request
11
- @headers = fetch_headers
11
+ fetch_headers
12
12
  true
13
13
  end
14
14
 
15
15
  def set_auth_header(header)
16
16
  @request.env.merge!({ "Authorization" => header })
17
- @headers = fetch_headers
17
+ fetch_headers
18
18
  @request
19
19
  end
20
20
 
@@ -31,6 +31,7 @@ module ApiAuth
31
31
  def populate_content_md5
32
32
  if ['POST', 'PUT'].include?(@request.request_method)
33
33
  @request.env["Content-MD5"] = calculated_md5
34
+ fetch_headers
34
35
  end
35
36
  end
36
37
 
@@ -43,7 +44,7 @@ module ApiAuth
43
44
  end
44
45
 
45
46
  def fetch_headers
46
- capitalize_keys @request.env
47
+ @headers = capitalize_keys @request.env
47
48
  end
48
49
 
49
50
  def http_method
@@ -66,6 +67,7 @@ module ApiAuth
66
67
 
67
68
  def set_date
68
69
  @request.env.merge!({ "DATE" => Time.now.utc.httpdate })
70
+ fetch_headers
69
71
  end
70
72
 
71
73
  def timestamp
@@ -105,6 +105,11 @@ if defined?(ActionController::Request)
105
105
  driven_request.populate_content_md5
106
106
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
107
107
  end
108
+
109
+ it "refreshes the cached headers" do
110
+ driven_request.populate_content_md5
111
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
112
+ end
108
113
  end
109
114
 
110
115
  context "when putting" do
@@ -113,6 +118,11 @@ if defined?(ActionController::Request)
113
118
  driven_request.populate_content_md5
114
119
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
115
120
  end
121
+
122
+ it "refreshes the cached headers" do
123
+ driven_request.populate_content_md5
124
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
125
+ end
116
126
  end
117
127
 
118
128
  context "when deleting" do
@@ -126,11 +136,19 @@ if defined?(ActionController::Request)
126
136
  end
127
137
 
128
138
  describe "#set_date" do
129
- it "sets the date" do
139
+ before do
130
140
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
141
+ end
142
+
143
+ it "sets the date header of the request" do
131
144
  driven_request.set_date
132
145
  expect(request.env['HTTP_DATE']).to eq(timestamp)
133
146
  end
147
+
148
+ it "refreshes the cached headers" do
149
+ driven_request.set_date
150
+ expect(driven_request.timestamp).to eq(timestamp)
151
+ end
134
152
  end
135
153
 
136
154
  describe "#set_auth_header" do
@@ -106,6 +106,11 @@ if defined?(ActionDispatch::Request)
106
106
  driven_request.populate_content_md5
107
107
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
108
108
  end
109
+
110
+ it "refreshes the cached headers" do
111
+ driven_request.populate_content_md5
112
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
113
+ end
109
114
  end
110
115
 
111
116
  context "when putting" do
@@ -114,6 +119,11 @@ if defined?(ActionDispatch::Request)
114
119
  driven_request.populate_content_md5
115
120
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
116
121
  end
122
+
123
+ it "refreshes the cached headers" do
124
+ driven_request.populate_content_md5
125
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
126
+ end
117
127
  end
118
128
 
119
129
  context "when deleting" do
@@ -127,11 +137,19 @@ if defined?(ActionDispatch::Request)
127
137
  end
128
138
 
129
139
  describe "#set_date" do
130
- it "sets the date" do
140
+ before do
131
141
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
142
+ end
143
+
144
+ it "sets the date header of the request" do
132
145
  driven_request.set_date
133
146
  expect(request.env['HTTP_DATE']).to eq(timestamp)
134
147
  end
148
+
149
+ it "refreshes the cached headers" do
150
+ driven_request.set_date
151
+ expect(driven_request.timestamp).to eq(timestamp)
152
+ end
135
153
  end
136
154
 
137
155
  describe "#set_auth_header" do
@@ -66,11 +66,19 @@ describe ApiAuth::RequestDrivers::CurbRequest do
66
66
  end
67
67
 
68
68
  describe "#set_date" do
69
- it "sets the date" do
69
+ before do
70
70
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
71
+ end
72
+
73
+ it "sets the date header of the request" do
71
74
  driven_request.set_date
72
75
  expect(request.headers['DATE']).to eq(timestamp)
73
76
  end
77
+
78
+ it "refreshes the cached headers" do
79
+ driven_request.set_date
80
+ expect(driven_request.timestamp).to eq(timestamp)
81
+ end
74
82
  end
75
83
 
76
84
  describe "#set_auth_header" do
@@ -131,6 +131,11 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
131
131
  driven_request.populate_content_md5
132
132
  expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
133
133
  end
134
+
135
+ it "refreshes the cached headers" do
136
+ driven_request.populate_content_md5
137
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
138
+ end
134
139
  end
135
140
 
136
141
  context "when putting" do
@@ -139,6 +144,11 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
139
144
  driven_request.populate_content_md5
140
145
  expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
141
146
  end
147
+
148
+ it "refreshes the cached headers" do
149
+ driven_request.populate_content_md5
150
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
151
+ end
142
152
  end
143
153
 
144
154
  context "when deleting" do
@@ -152,11 +162,19 @@ describe ApiAuth::RequestDrivers::FaradayRequest do
152
162
  end
153
163
 
154
164
  describe "#set_date" do
155
- it "sets the date" do
165
+ before do
156
166
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
167
+ end
168
+
169
+ it "sets the date header of the request" do
157
170
  driven_request.set_date
158
171
  expect(request.headers['DATE']).to eq(timestamp)
159
172
  end
173
+
174
+ it "refreshes the cached headers" do
175
+ driven_request.set_date
176
+ expect(driven_request.timestamp).to eq(timestamp)
177
+ end
160
178
  end
161
179
 
162
180
  describe "#set_auth_header" do
@@ -87,15 +87,28 @@ describe ApiAuth::RequestDrivers::HttpiRequest do
87
87
  driven_request.populate_content_md5
88
88
  expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
89
89
  end
90
+
91
+ it "refreshes the cached headers" do
92
+ driven_request.populate_content_md5
93
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
94
+ end
90
95
  end
91
96
  end
92
97
 
93
98
  describe "#set_date" do
94
- it "sets the date" do
99
+ before do
95
100
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
101
+ end
102
+
103
+ it "sets the date header of the request" do
96
104
  driven_request.set_date
97
105
  expect(request.headers['DATE']).to eq(timestamp)
98
106
  end
107
+
108
+ it "refreshes the cached headers" do
109
+ driven_request.set_date
110
+ expect(driven_request.timestamp).to eq(timestamp)
111
+ end
99
112
  end
100
113
 
101
114
  describe "#set_auth_header" do
@@ -123,15 +123,28 @@ describe ApiAuth::RequestDrivers::NetHttpRequest do
123
123
  driven_request.populate_content_md5
124
124
  expect(request["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
125
125
  end
126
+
127
+ it "refreshes the cached headers" do
128
+ driven_request.populate_content_md5
129
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
130
+ end
126
131
  end
127
132
  end
128
133
 
129
134
  describe "#set_date" do
130
- it "sets the date" do
135
+ before do
131
136
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
137
+ end
138
+
139
+ it "sets the date header of the request" do
132
140
  driven_request.set_date
133
141
  expect(request['DATE']).to eq(timestamp)
134
142
  end
143
+
144
+ it "refreshes the cached headers" do
145
+ driven_request.set_date
146
+ expect(driven_request.timestamp).to eq(timestamp)
147
+ end
135
148
  end
136
149
 
137
150
  describe "#set_auth_header" do
@@ -137,6 +137,11 @@ describe ApiAuth::RequestDrivers::RackRequest do
137
137
  driven_request.populate_content_md5
138
138
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
139
139
  end
140
+
141
+ it "refreshes the cached headers" do
142
+ driven_request.populate_content_md5
143
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
144
+ end
140
145
  end
141
146
 
142
147
  context "when putting" do
@@ -154,6 +159,11 @@ describe ApiAuth::RequestDrivers::RackRequest do
154
159
  driven_request.populate_content_md5
155
160
  expect(request.env["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
156
161
  end
162
+
163
+ it "refreshes the cached headers" do
164
+ driven_request.populate_content_md5
165
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
166
+ end
157
167
  end
158
168
 
159
169
  context "when deleting" do
@@ -175,11 +185,19 @@ describe ApiAuth::RequestDrivers::RackRequest do
175
185
  end
176
186
 
177
187
  describe "#set_date" do
178
- it "sets the date" do
188
+ before do
179
189
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
190
+ end
191
+
192
+ it "sets the date header of the request" do
180
193
  driven_request.set_date
181
194
  expect(request.env['DATE']).to eq(timestamp)
182
195
  end
196
+
197
+ it "refreshes the cached headers" do
198
+ driven_request.set_date
199
+ expect(driven_request.timestamp).to eq(timestamp)
200
+ end
183
201
  end
184
202
 
185
203
  describe "#set_auth_header" do
@@ -131,6 +131,11 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
131
131
  driven_request.populate_content_md5
132
132
  expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
133
133
  end
134
+
135
+ it "refreshes the cached headers" do
136
+ driven_request.populate_content_md5
137
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
138
+ end
134
139
  end
135
140
 
136
141
  context "when putting" do
@@ -147,6 +152,11 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
147
152
  driven_request.populate_content_md5
148
153
  expect(request.headers["Content-MD5"]).to eq('kZXQvrKoieG+Be1rsZVINw==')
149
154
  end
155
+
156
+ it "refreshes the cached headers" do
157
+ driven_request.populate_content_md5
158
+ expect(driven_request.content_md5).to eq('kZXQvrKoieG+Be1rsZVINw==')
159
+ end
150
160
  end
151
161
 
152
162
  context "when deleting" do
@@ -167,11 +177,20 @@ describe ApiAuth::RequestDrivers::RestClientRequest do
167
177
  end
168
178
 
169
179
  describe "#set_date" do
170
- it "sets the date" do
180
+ before do
181
+ allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
182
+ end
183
+
184
+ it "sets the date header of the request" do
171
185
  allow(Time).to receive_message_chain(:now, :utc, :httpdate).and_return(timestamp)
172
186
  driven_request.set_date
173
187
  expect(request.headers['DATE']).to eq(timestamp)
174
188
  end
189
+
190
+ it "refreshes the cached headers" do
191
+ driven_request.set_date
192
+ expect(driven_request.timestamp).to eq(timestamp)
193
+ end
175
194
  end
176
195
 
177
196
  describe "#set_auth_header" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal