diff options
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r-- | tests/test_manifest_xml.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index f69e9cf8..6977b417 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -298,8 +298,8 @@ class IncludeElementTests(ManifestParseTestCase): | |||
298 | # Check level2 proj group not removed. | 298 | # Check level2 proj group not removed. |
299 | self.assertIn('l2g1', proj.groups) | 299 | self.assertIn('l2g1', proj.groups) |
300 | 300 | ||
301 | def test_bad_name_checks(self): | 301 | def test_allow_bad_name_from_user(self): |
302 | """Check handling of bad name attribute.""" | 302 | """Check handling of bad name attribute from the user's input.""" |
303 | def parse(name): | 303 | def parse(name): |
304 | manifest = self.getXmlManifest(f""" | 304 | manifest = self.getXmlManifest(f""" |
305 | <manifest> | 305 | <manifest> |
@@ -311,6 +311,34 @@ class IncludeElementTests(ManifestParseTestCase): | |||
311 | # Force the manifest to be parsed. | 311 | # Force the manifest to be parsed. |
312 | manifest.ToXml() | 312 | manifest.ToXml() |
313 | 313 | ||
314 | # Setup target of the include. | ||
315 | target = os.path.join(self.tempdir, 'target.xml') | ||
316 | with open(target, 'w') as fp: | ||
317 | fp.write('<manifest></manifest>') | ||
318 | |||
319 | # Include with absolute path. | ||
320 | parse(os.path.abspath(target)) | ||
321 | |||
322 | # Include with relative path. | ||
323 | parse(os.path.relpath(target, self.manifest_dir)) | ||
324 | |||
325 | def test_bad_name_checks(self): | ||
326 | """Check handling of bad name attribute.""" | ||
327 | def parse(name): | ||
328 | # Setup target of the include. | ||
329 | with open(os.path.join(self.manifest_dir, 'target.xml'), 'w') as fp: | ||
330 | fp.write(f'<manifest><include name="{name}"/></manifest>') | ||
331 | |||
332 | manifest = self.getXmlManifest(""" | ||
333 | <manifest> | ||
334 | <remote name="default-remote" fetch="http://localhost" /> | ||
335 | <default remote="default-remote" revision="refs/heads/main" /> | ||
336 | <include name="target.xml" /> | ||
337 | </manifest> | ||
338 | """) | ||
339 | # Force the manifest to be parsed. | ||
340 | manifest.ToXml() | ||
341 | |||
314 | # Handle empty name explicitly because a different codepath rejects it. | 342 | # Handle empty name explicitly because a different codepath rejects it. |
315 | with self.assertRaises(error.ManifestParseError): | 343 | with self.assertRaises(error.ManifestParseError): |
316 | parse('') | 344 | parse('') |