Skip to content

Commit

Permalink
Test acceptance of x-shellscript as cloud-config.
Browse files Browse the repository at this point in the history
Test case from Ryan Harper in discussion of PR#234
(canonical#234).
This should demonstrate that cloud-init (without the subsequent
patches) will fail to accept multipart user-data documents
with the cloud-config piece (mis)declared as text/x-shellscript.

This happens on old heat on OpenTelekomCloud.

Let's watch this fail the CI and then add the fix ...

Signed-off-by: Kurt Garloff <kurt@garloff.de>
  • Loading branch information
garloff committed Mar 30, 2020
1 parent 2566fdb commit 2745b82
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/unittests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,40 @@ def gzip_text(text):
f.close()
return contents.getvalue()

def test_cloud_config_as_x_shell_script(self):
blob_cc = '''
#cloud-config
a: b
c: d
'''
message_cc = MIMEBase("text", "x-shellscript")
message_cc.set_payload(blob_cc)

blob_jp = '''
#cloud-config-jsonp
[
{ "op": "replace", "path": "/a", "value": "c" },
{ "op": "remove", "path": "/c" }
]
'''

message_jp = MIMEBase('text', "cloud-config-jsonp")
message_jp.set_payload(blob_jp)

message = MIMEMultipart()
message.attach(message_cc)
message.attach(message_jp)

self.reRoot()
ci = stages.Init()
ci.datasource = FakeDataSource(str(message))
ci.fetch()
ci.consume_data()
cc_contents = util.load_file(ci.paths.get_ipath("cloud_config"))
cc = util.load_yaml(cc_contents)
self.assertEqual(1, len(cc))
self.assertEqual('c', cc['a'])


# FIXME: these tests shouldn't be checking log output??
# Weirddddd...
Expand Down

0 comments on commit 2745b82

Please sign in to comment.