diff --git a/lib/fog/aws/requests/compute/describe_internet_gateways.rb b/lib/fog/aws/requests/compute/describe_internet_gateways.rb index 2842c43f8..987a599da 100644 --- a/lib/fog/aws/requests/compute/describe_internet_gateways.rb +++ b/lib/fog/aws/requests/compute/describe_internet_gateways.rb @@ -37,16 +37,22 @@ module Fog }.merge!(params)) end end - + class Mock def describe_internet_gateways(filters = {}) - Excon::Response.new.tap do |response| - response.status = 200 - response.body = { - 'requestId' => Fog::AWS::Mock.request_id, - 'internetGatewaySet' => self.data[:internet_gateways] - } + internet_gateways = self.data[:internet_gateways] + + if filters['internet-gateway-id'] + internet_gateways = internet_gateways.reject {|internet_gateway| internet_gateway['internetGatewayId'] != filters['internet-gateway-id']} end + + Excon::Response.new( + :status => 200, + :body => { + 'requestId' => Fog::AWS::Mock.request_id, + 'internetGatewaySet' => internet_gateways + } + ) end end end diff --git a/lib/fog/aws/requests/compute/describe_subnets.rb b/lib/fog/aws/requests/compute/describe_subnets.rb index 42f25d216..5272bc0bc 100644 --- a/lib/fog/aws/requests/compute/describe_subnets.rb +++ b/lib/fog/aws/requests/compute/describe_subnets.rb @@ -41,16 +41,22 @@ module Fog }.merge!(params)) end end - + class Mock def describe_subnets(filters = {}) - Excon::Response.new.tap do |response| - response.status = 200 - response.body = { - 'requestId' => Fog::AWS::Mock.request_id, - 'subnetSet' => self.data[:subnets] - } + subnets = self.data[:subnets] + + if filters['subnet-id'] + subnets = subnets.reject {|subnet| subnet['subnetId'] != filters['subnet-id']} end + + Excon::Response.new( + :status => 200, + :body => { + 'requestId' => Fog::AWS::Mock.request_id, + 'subnetSet' => subnets + } + ) end end end diff --git a/lib/fog/aws/requests/compute/describe_vpcs.rb b/lib/fog/aws/requests/compute/describe_vpcs.rb index 545952cdd..10e2c9e8e 100644 --- a/lib/fog/aws/requests/compute/describe_vpcs.rb +++ b/lib/fog/aws/requests/compute/describe_vpcs.rb @@ -38,16 +38,22 @@ module Fog }.merge!(params)) end end - + class Mock def describe_vpcs(filters = {}) - Excon::Response.new.tap do |response| - response.status = 200 - response.body = { - 'requestId' => Fog::AWS::Mock.request_id, - 'vpcSet' => self.data[:vpcs] - } + vpcs = self.data[:vpcs] + + if filters['vpc-id'] + vpcs = vpcs.reject {|vpc| vpc['vpcId'] != filters['vpc-id']} end + + Excon::Response.new( + :status => 200, + :body => { + 'requestId' => Fog::AWS::Mock.request_id, + 'vpcSet' => vpcs + } + ) end end end