mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
66187d73fb
Calling #all fails with the error: `Excon::Error::Socket: 25:28: FATAL: Document is empty (Nokogiri::XML::SyntaxError)`. This was because of the parser not handling nil creationDate values: ``` when 'creationDate' @image[name] = Time.parse(value) ``` This commit ensures nil `creationDate` fields are not parsed.
33 lines
1.3 KiB
Ruby
33 lines
1.3 KiB
Ruby
require 'fog/xml'
|
|
require 'fog/aws/parsers/compute/describe_images'
|
|
|
|
DESCRIBE_IMAGES_RESULT = <<-EOF
|
|
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
<requestId>180a8433-ade0-4a6c-b35b-107897579572</requestId>
|
|
<imagesSet>
|
|
<item>
|
|
<imageId>aki-02486376</imageId>
|
|
<imageLocation>ec2-public-images-eu/vmlinuz-2.6.21-2.fc8xen-ec2-v1.0.i386.aki.manifest.xml</imageLocation>
|
|
<imageState>available</imageState>
|
|
<imageOwnerId>206029621532</imageOwnerId>
|
|
<creationDate/>
|
|
<isPublic>true</isPublic>
|
|
<architecture>i386</architecture>
|
|
<imageType>kernel</imageType>
|
|
<imageOwnerAlias>amazon</imageOwnerAlias>
|
|
<rootDeviceType>instance-store</rootDeviceType>
|
|
<blockDeviceMapping/>
|
|
<virtualizationType>paravirtual</virtualizationType>
|
|
<hypervisor>xen</hypervisor>
|
|
</item>
|
|
</imagesSet>
|
|
</DescribeImagesResponse>
|
|
EOF
|
|
|
|
Shindo.tests('Compute::AWS | parsers | describe_images', ['compute', 'aws', 'parser']) do
|
|
tests('parses the xml').formats(AWS::Compute::Formats::DESCRIBE_IMAGES) do
|
|
parser = Nokogiri::XML::SAX::Parser.new(Fog::Parsers::Compute::AWS::DescribeImages.new)
|
|
parser.parse(DESCRIBE_IMAGES_RESULT)
|
|
parser.document.response
|
|
end
|
|
end
|