diff --git a/lib/fog/aws/requests/dns/list_hosted_zones.rb b/lib/fog/aws/requests/dns/list_hosted_zones.rb index df6f87860..f8deee3bc 100644 --- a/lib/fog/aws/requests/dns/list_hosted_zones.rb +++ b/lib/fog/aws/requests/dns/list_hosted_zones.rb @@ -49,6 +49,49 @@ module Fog end end + + class Mock + + def list_hosted_zones(options = {}) + if options[:max_items].nil? + maxitems = 100 + else + maxitems = options[:max_items] + end + + if options[:marker].nil? + start = 0 + else + start = self.data[:zones].find_index {|z| z[:zone_id] == options[:marker]} + end + + zones = self.data[:zones].values[start, maxitems] + next_zone = self.data[:zones].values[start + maxitems] + truncated = !next_zone.nil? + + response = Excon::Response.new + response.body = { + 'HostedZones' => zones.map do |z| + { + 'Id' => z[:zone_id], + 'Name' => z[:name], + 'CallerReference' => z[:reference], + 'Comment' => z[:comment], + } + end, + 'Marker' => options[:marker].to_s, + 'MaxItems' => options[:max_items].to_s, + 'IsTruncated' => truncated.to_s + } + + if truncated + response.body['NextMarker'] = next_zone[:zone_id] + end + + response + end + + end end end end