Merge remote branch 'joshuanapoli/simpledb'

This commit is contained in:
geemus 2011-04-11 16:54:52 -07:00
commit d4118662c6
4 changed files with 14 additions and 7 deletions

View File

@ -124,8 +124,8 @@ module Fog
item_index = 0
for item_key in items.keys
encoded_attributes["Item.#{item_index}.ItemName"] = item_key.to_s
attribute_index = 0
for attribute_key in items[item_key].keys
attribute_index = 0
for value in Array(items[item_key][attribute_key])
encoded_attributes["Item.#{item_index}.Attribute.#{attribute_index}.Name"] = attribute_key.to_s
if replace_attributes[item_key].include?(attribute_key)
@ -134,8 +134,8 @@ module Fog
encoded_attributes["Item.#{item_index}.Attribute.#{attribute_index}.Value"] = sdb_encode(value)
attribute_index += 1
end
item_index += 1
end
item_index += 1
end
end
encoded_attributes

View File

@ -41,6 +41,10 @@ module Fog
params
end
def self.escape(string)
string.gsub( /([^-a-zA-Z0-9_.~]+)/n ) { |match| '%' + match.unpack( 'H2' * match.size ).join( '%' ).upcase }
end
def self.signed_params(params, options = {})
params.merge!({
'AWSAccessKeyId' => options[:aws_access_key_id],
@ -53,7 +57,7 @@ module Fog
body = ''
for key in params.keys.sort
unless (value = params[key]).nil?
body << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
body << "#{key}=#{escape(value.to_s)}&"
end
end
string_to_sign = "POST\n#{options[:host]}:#{options[:port]}\n#{options[:path]}\n" << body.chop

View File

@ -6,11 +6,11 @@ Shindo.tests('AWS::SimpleDB | attributes requests', ['aws']) do
tests('success') do
tests("#batch_put_attributes('#{@domain_name}', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } }).body").formats(AWS::SimpleDB::Formats::BASIC) do
AWS[:sdb].batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } }).body
tests("#batch_put_attributes('#{@domain_name}', { 'a' => { 'b' => 'c', 'd' => 'e' }, 'x' => { 'y' => 'z' } }).body").formats(AWS::SimpleDB::Formats::BASIC) do
AWS[:sdb].batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c', 'd' => 'e' }, 'x' => { 'y' => 'z' } }).body
end
tests("#get_attributes('#{@domain_name}', 'a').body['Attributes']").returns({'b' => ['c']}) do
tests("#get_attributes('#{@domain_name}', 'a').body['Attributes']").returns({'b' => ['c'], 'd' => ['e']}) do
attributes = {}
Fog.wait_for {
attributes = AWS[:sdb].get_attributes(@domain_name, 'a').body['Attributes']
@ -23,7 +23,7 @@ Shindo.tests('AWS::SimpleDB | attributes requests', ['aws']) do
AWS[:sdb].get_attributes(@domain_name, 'notanattribute')
end
tests("#select('select * from #{@domain_name}').body['Items']").returns({ 'a' => { 'b' => ['c'] }, 'x' => { 'y' => ['z'] } }) do
tests("#select('select * from #{@domain_name}').body['Items']").returns({'a' => { 'b' => ['c'], 'd' => ['e']}, 'x' => { 'y' => ['z'] } }) do
pending if Fog.mocking?
AWS[:sdb].select("select * from #{@domain_name}").body['Items']
end

View File

@ -0,0 +1,3 @@
Shindo.tests('AWS | signed_params', ['aws']) do
returns( Fog::AWS.escape( "'Stop!' said Fred_-~." ) ) { "%27Stop%21%27%20said%20Fred_-~." }
end