From dfe343ed51d92961aae6badb5dcbb6b51157d767 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Mon, 20 Nov 2023 15:58:22 +0100 Subject: [PATCH] Adds test to verify that bad YAML indentation does not cause a panic. --- cloud/clouds_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cloud/clouds_test.go b/cloud/clouds_test.go index b8e686f1159..0d3e19960e2 100644 --- a/cloud/clouds_test.go +++ b/cloud/clouds_test.go @@ -276,6 +276,19 @@ clouds: s.assertCompareClouds(c, metadata, false) } +func (s *cloudSuite) TestMalformedYAMLNoPanic(_ *gc.C) { + // Note the bad indentation. This case was reported under LP:2039322. + metadata := ` +clouds: +manual-cloud: + type: manual + endpoint: ubuntu@some-host-fqdn +`[1:] + + // We don't care about the result, just that there is no panic. + _, _ = cloud.ParseCloudMetadata([]byte(metadata)) +} + func (s *cloudSuite) TestRegionNames(c *gc.C) { regions := []cloud.Region{ {Name: "mars"},