Skip to content

Commit 929856d

Browse files
jterapinmullermp
andauthored
Fix Checksum algo spec to pass JRuby CI (#2858)
* Update `checksum_algorithm` plugin to use IO.copy_stream for JRuby --------- Co-authored-by: Juli Tera <[email protected]> Co-authored-by: Matt Muller <[email protected]>
1 parent f0140bd commit 929856d

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

gems/aws-sdk-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Updated `checksum_algorithm` plugin to use IO.copy_stream for JRuby.
5+
46
3.173.0 (2023-05-18)
57
------------------
68

gems/aws-sdk-core/lib/aws-sdk-core/plugins/checksum_algorithm.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def rewind
314314
@io.rewind
315315
end
316316

317-
def read(length, buf)
317+
def read(length, buf = nil)
318318
# account for possible leftover bytes at the end, if we have trailer bytes, send them
319319
if @trailer_io
320320
return @trailer_io.read(length, buf)

gems/aws-sdk-core/spec/aws/plugins/checksum_algorithm_spec.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,8 @@ module Plugins
181181
expect(headers['x-amz-decoded-content-length']).to eq('11')
182182
# capture the body by reading it into a new IO object
183183
body = StringIO.new
184-
if (defined?(JRUBY_VERSION))
185-
body << context.http_request.body.read(1000, String.new) + context.http_request.body.read(1000, String.new)
186-
else
187-
# IO.copy_stream is the same method used by Net::Http to write our body to the socket
188-
IO.copy_stream(context.http_request.body, body)
189-
end
184+
# IO.copy_stream is the same method used by Net::Http to write our body to the socket
185+
IO.copy_stream(context.http_request.body, body)
190186
body.rewind
191187
expect(body.read).to eq "b\r\nHello World\r\n0\r\nx-amz-checksum-sha256:pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=\r\n\r\n"
192188
end)
@@ -195,11 +191,11 @@ module Plugins
195191
end
196192

197193
it 'handles header-based auth with checksum in header' do
198-
client.stub_responses(:some_operation, -> (context) do
199-
expect(context.http_request.headers['x-amz-checksum-sha256']).to eq('pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=')
200-
expect(context.http_request.body.read).to eq('Hello World')
201-
end)
202-
client.some_operation(checksum_algorithm: 'sha256', body: 'Hello World')
194+
client.stub_responses(:some_operation, -> (context) do
195+
expect(context.http_request.headers['x-amz-checksum-sha256']).to eq('pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=')
196+
expect(context.http_request.body.read).to eq('Hello World')
197+
end)
198+
client.some_operation(checksum_algorithm: 'sha256', body: 'Hello World')
203199
end
204200

205201
it 'handles sigv4-streaming auth with checksum in trailer' do

0 commit comments

Comments
 (0)