diff --git a/lib/fog/compute/requests/aws/describe_images.rb b/lib/fog/compute/requests/aws/describe_images.rb index a18398d8b..862490bc7 100644 --- a/lib/fog/compute/requests/aws/describe_images.rb +++ b/lib/fog/compute/requests/aws/describe_images.rb @@ -69,6 +69,14 @@ module Fog Fog::Mock.not_implemented end + if owner = filters.delete('Owner') + if owner == 'self' + filters['owner-id'] = self.data[:owner_id] + else + filters['owner-alias'] = owner + end + end + response = Excon::Response.new aliases = { diff --git a/lib/fog/compute/requests/aws/register_image.rb b/lib/fog/compute/requests/aws/register_image.rb index a3902b956..debf49bfd 100644 --- a/lib/fog/compute/requests/aws/register_image.rb +++ b/lib/fog/compute/requests/aws/register_image.rb @@ -79,7 +79,7 @@ module Fog 'ramdiskId' => Fog::AWS::Mock.ramdisk_id, 'platform' => 'Linux', 'stateReason' => {}, - 'imageOwnerAlias' => 'self', + 'imageOwnerAlias' => self.data[:owner_id], 'name' => name, 'description' => description, 'rootDeviceType' => '', diff --git a/tests/compute/requests/aws/image_tests.rb b/tests/compute/requests/aws/image_tests.rb index 4fd7ac5f3..73e67d0ad 100644 --- a/tests/compute/requests/aws/image_tests.rb +++ b/tests/compute/requests/aws/image_tests.rb @@ -44,10 +44,20 @@ Shindo.tests('Fog::Compute[:aws] | image requests', ['aws']) do end @image_id = @image['imageId'] + + tests("#describe_images('Owner' => 'self')").formats(@describe_images_format) do + Fog::Compute[:aws].describe_images('Owner' => 'self').body + end end tests("#describe_images('image-id' => '#{@image_id}')").formats(@describe_images_format) do - Fog::Compute[:aws].describe_images('image-id' => @image_id).body + @other_image = Fog::Compute[:aws].describe_images('image-id' => @image_id).body + end + + unless Fog.mocking? + tests("#describe_images('Owner' => '#{@other_image['imageOwnerAlias']}', 'image-id' => '#{@image_id}')").formats(@describe_images_format) do + Fog::Compute[:aws].describe_images('Owner' => @other_image['imageOwnerAlias'], 'image-id' => @image_id).body + end end end end