ruby/example_code/s3/tests/test_s3_get_csaes_decrypt_item.rb
# Given data from stub_put, stub a getter for the same object.
# During the get operation, get_object is called twice: once to
#   get the full body, and once again with a range to get just the
#   auth_tag.
Given data from stub_put, stub a getter for the same object.
During the get operation, get_object is called twice: once to
get the full body, and once again with a range to get just the
auth_tag.
Given data from stub_put stub a getter for the same object . During the get operation get_object is called twice : once to get the full body and once again with a range to get just the auth_tag .
def stub_get(s3_client, data, stub_auth_tag)
    resp_headers = Hash[*data[:metadata].map { |k, v| ["x-amz-meta-#{k.to_s}", v] }.flatten(1)]
    resp_headers['content-length'] = data[:enc_body].length
    if stub_auth_tag
      auth_tag = data[:enc_body].unpack('C*')[-16, 16].pack('C*')
    else
      auth_tag = nil
    end
    s3_client.stub_responses(
      :get_object,
      {
        status_code: 200,
        body: data[:enc_body],
        headers: resp_headers
      },
      {
        body: auth_tag
      }
    )
  end
def stub_get ( s3_client , data , stub_auth_tag ) resp_headers = Hash [ * data [ :metadata ] . map { | k , v | [ "x-amz-meta-#{k.to_s}" , v ] } . flatten ( 1 ) ] resp_headers [ 'content-length' ] = data [ :enc_body ] . length if stub_auth_tag auth_tag = data [ :enc_body ] . unpack ( 'C*' ) [ - 16 , 16 ] . pack ( 'C*' ) else auth_tag = nil end s3_client . stub_responses ( :get_object , { status_code : 200 , body : data [ :enc_body ] , headers : resp_headers } , { body : auth_tag } ) end
Given data from stub_put, stub a getter for the same object.
Given data from stub_put stub a getter for the same object .
s3_client
data
stub_auth_tag