diff options
author | Daniel Watkins <daniel.watkins@canonical.com> | 2015-10-09 14:01:11 +0100 |
---|---|---|
committer | Daniel Watkins <daniel.watkins@canonical.com> | 2015-10-09 14:01:11 +0100 |
commit | 41900b72f31a1bd0eebe2f58a8598bfab25f0003 (patch) | |
tree | a01c7f1e87910ec834db335f6e8c8b6efe2def12 /tests | |
parent | e9e86164198993aca13148872afdeebaae751c2c (diff) | |
download | vyos-cloud-init-41900b72f31a1bd0eebe2f58a8598bfab25f0003.tar.gz vyos-cloud-init-41900b72f31a1bd0eebe2f58a8598bfab25f0003.zip |
Handle escaped quotes in WALinuxAgentShim.find_endpoint.
This fixes bug 1488891.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_azure_helper.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/unittests/test_datasource/test_azure_helper.py b/tests/unittests/test_datasource/test_azure_helper.py index a5228870..68af31cd 100644 --- a/tests/unittests/test_datasource/test_azure_helper.py +++ b/tests/unittests/test_datasource/test_azure_helper.py @@ -97,7 +97,8 @@ class TestFindEndpoint(TestCase): if not use_hex: ip_address_repr = struct.pack( '>L', int(ip_address_repr.replace(':', ''), 16)) - ip_address_repr = '"{0}"'.format(ip_address_repr.decode('utf-8')) + ip_address_repr = '"{0}"'.format( + ip_address_repr.decode('utf-8').replace('"', '\\"')) return '\n'.join([ 'lease {', ' interface "eth0";', @@ -125,6 +126,13 @@ class TestFindEndpoint(TestCase): self.assertEqual(ip_address, azure_helper.WALinuxAgentShim.find_endpoint()) + def test_packed_string_with_escaped_quote(self): + ip_address = '100.72.34.108' + file_content = self._build_lease_content(ip_address, use_hex=False) + self.load_file.return_value = file_content + self.assertEqual(ip_address, + azure_helper.WALinuxAgentShim.find_endpoint()) + def test_latest_lease_used(self): ip_addresses = ['4.3.2.1', '98.76.54.32'] file_content = '\n'.join([self._build_lease_content(ip_address) |