Skip to content

Commit 1e826ff

Browse files
authored
Fix jruby test failures (#2384)
1 parent 47179a6 commit 1e826ff

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

aws-sdk-resources/lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module S3
77
module Encryption
88
# @api private
99
class DecryptHandler < Seahorse::Client::Handler
10+
@@warned_response_target_proc = false
1011

1112
V1_ENVELOPE_KEYS = %w(
1213
x-amz-key
@@ -45,6 +46,16 @@ class DecryptHandler < Seahorse::Client::Handler
4546
def call(context)
4647
attach_http_event_listeners(context)
4748
apply_cse_user_agent(context)
49+
50+
if context[:response_target].is_a?(Proc) && !@@warned_response_target_proc
51+
@@warned_response_target_proc = true
52+
warn(':response_target is a Proc, or a block was provided. ' \
53+
'Read the entire object to the ' \
54+
'end before you start using the decrypted data. This is to ' \
55+
'verify that the object has not been modified since it ' \
56+
'was encrypted.')
57+
end
58+
4859
@handler.call(context)
4960
end
5061

@@ -75,11 +86,11 @@ def attach_http_event_listeners(context)
7586
end
7687

7788
def decryption_cipher(context)
78-
if envelope = get_encryption_envelope(context)
89+
if (envelope = get_encryption_envelope(context))
7990
cipher = context[:encryption][:cipher_provider]
8091
.decryption_cipher(
8192
envelope,
82-
kms_encryption_context: context[:encryption][:kms_encryption_context]
93+
context[:encryption]
8394
)
8495
[cipher, envelope]
8596
else

aws-sdk-resources/lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@ class IODecrypter
99
# @param [OpenSSL::Cipher] cipher
1010
# @param [IO#write] io An IO-like object that responds to `#write`.
1111
def initialize(cipher, io)
12-
@cipher = cipher.clone
12+
@cipher = cipher
1313
# Ensure that IO is reset between retries
1414
@io = io.tap { |io| io.truncate(0) if io.respond_to?(:truncate) }
15+
@cipher_buffer = String.new
1516
end
1617

1718
# @return [#write]
1819
attr_reader :io
1920

2021
def write(chunk)
2122
# decrypt and write
22-
@io.write(@cipher.update(chunk))
23+
if @cipher.method(:update).arity == 1
24+
@io.write(@cipher.update(chunk))
25+
else
26+
@io.write(@cipher.update(chunk, @cipher_buffer))
27+
end
2328
end
2429

2530
def finalize
2631
@io.write(@cipher.final)
2732
end
2833

29-
def size
30-
@io.size
31-
end
32-
3334
end
3435
end
3536
end

aws-sdk-resources/lib/aws-sdk-resources/services/s3/encryptionV2/client.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ module S3
7171
# ## Required Configuration
7272
#
7373
# You must configure all of the following:
74+
#
7475
# * a key or key provider - See the Keys section below. The key provided determines
7576
# the key wrapping schema(s) supported for both encryption and decryption.
7677
# * `key_wrap_schema` - The key wrapping schema. It must match the type of key configured.
@@ -234,6 +235,7 @@ class Client
234235
def_delegators :@client, :config, :delete_object, :head_object, :build_request
235236

236237
# Creates a new encryption client. You must configure all of the following:
238+
#
237239
# * a key or key provider - The key provided also determines the key wrapping
238240
# schema(s) supported for both encryption and decryption.
239241
# * `key_wrap_schema` - The key wrapping schema. It must match the type of key configured.
@@ -387,7 +389,7 @@ def put_object(params = {})
387389
# @option (see S3::Client#get_object)
388390
# @return (see S3::Client#get_object)
389391
# @see S3::Client#get_object
390-
# @note The `:range` request parameter is not yet supported.
392+
# @note The `:range` request parameter is not supported.
391393
def get_object(params = {}, &block)
392394
if params[:range]
393395
raise NotImplementedError, '#get_object with :range not supported'

aws-sdk-resources/spec/services/s3/encryption/client_spec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,8 @@ def stub_encrypted_get_with_instruction_file(sfx = '.instruction')
608608
"\x8E\x0E\xC0\xD5\x1A\x88\xAF2\xB1\xEEg#\x15"
609609
end
610610

611-
if !ENV['TRAVIS'] && RUBY_VERSION > '1.9.3'
611+
if !ENV['TRAVIS'] && RUBY_VERSION > '1.9.3' && OpenSSL::Cipher.ciphers.include?('aes-256-gcm')
612612
it 'supports decryption via KMS w/ GCM' do
613-
unless OpenSSL::Cipher.ciphers.include?('aes-256-gcm')
614-
pending('aes-256-gcm not supported')
615-
end
616613
kms_client.stub_responses(
617614
:decrypt, plaintext: plaintext_object_key
618615
)

0 commit comments

Comments
 (0)