diff options
| author | Mike Frysinger <vapier@google.com> | 2021-03-10 23:35:44 -0500 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2021-03-12 16:31:14 +0000 |
| commit | 0458faa502e9992a4305bfbb282fbee344d505bf (patch) | |
| tree | a91a10bd124b06c55c3a8ca522143d810070d1a6 /tests/test_manifest_xml.py | |
| parent | 68d5d4dfe5375be53f935c8b72060a56801dda24 (diff) | |
| download | git-repo-0458faa502e9992a4305bfbb282fbee344d505bf.tar.gz | |
manifest: allow toplevel project checkoutsv2.13.5
Re-allow checking out projects to the top of the repo client checkout.
We add checks to prevent checking out files under .repo/ as that path
is only managed by us, and projects cannot inject content or settings
into it.
Bug: https://crbug.com/gerrit/14156
Bug: https://crbug.com/gerrit/14200
Change-Id: Id6bf9e882f5be748442b2c35bbeaee3549410b25
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299623
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
| -rw-r--r-- | tests/test_manifest_xml.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 9060ef3d..eda06968 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
| @@ -32,6 +32,7 @@ INVALID_FS_PATHS = ( | |||
| 32 | '..', | 32 | '..', |
| 33 | '../', | 33 | '../', |
| 34 | './', | 34 | './', |
| 35 | './/', | ||
| 35 | 'foo/', | 36 | 'foo/', |
| 36 | './foo', | 37 | './foo', |
| 37 | '../foo', | 38 | '../foo', |
| @@ -427,6 +428,28 @@ class ProjectElementTests(ManifestParseTestCase): | |||
| 427 | self.assertEqual(manifest.projects[0].objdir, | 428 | self.assertEqual(manifest.projects[0].objdir, |
| 428 | os.path.join(self.tempdir, '.repo/project-objects/a/path.git')) | 429 | os.path.join(self.tempdir, '.repo/project-objects/a/path.git')) |
| 429 | 430 | ||
| 431 | manifest = parse('a/path', 'foo//////') | ||
| 432 | self.assertEqual(manifest.projects[0].gitdir, | ||
| 433 | os.path.join(self.tempdir, '.repo/projects/foo.git')) | ||
| 434 | self.assertEqual(manifest.projects[0].objdir, | ||
| 435 | os.path.join(self.tempdir, '.repo/project-objects/a/path.git')) | ||
| 436 | |||
| 437 | def test_toplevel_path(self): | ||
| 438 | """Check handling of path=. specially.""" | ||
| 439 | def parse(name, path): | ||
| 440 | return self.getXmlManifest(f""" | ||
| 441 | <manifest> | ||
| 442 | <remote name="default-remote" fetch="http://localhost" /> | ||
| 443 | <default remote="default-remote" revision="refs/heads/main" /> | ||
| 444 | <project name="{name}" path="{path}" /> | ||
| 445 | </manifest> | ||
| 446 | """) | ||
| 447 | |||
| 448 | for path in ('.', './', './/', './//'): | ||
| 449 | manifest = parse('server/path', path) | ||
| 450 | self.assertEqual(manifest.projects[0].gitdir, | ||
| 451 | os.path.join(self.tempdir, '.repo/projects/..git')) | ||
| 452 | |||
| 430 | def test_bad_path_name_checks(self): | 453 | def test_bad_path_name_checks(self): |
| 431 | """Check handling of bad path & name attributes.""" | 454 | """Check handling of bad path & name attributes.""" |
| 432 | def parse(name, path): | 455 | def parse(name, path): |
| @@ -454,8 +477,11 @@ class ProjectElementTests(ManifestParseTestCase): | |||
| 454 | 477 | ||
| 455 | with self.assertRaises(error.ManifestInvalidPathError): | 478 | with self.assertRaises(error.ManifestInvalidPathError): |
| 456 | parse(path, 'ok') | 479 | parse(path, 'ok') |
| 457 | with self.assertRaises(error.ManifestInvalidPathError): | 480 | |
| 458 | parse('ok', path) | 481 | # We have a dedicated test for path=".". |
| 482 | if path not in {'.'}: | ||
| 483 | with self.assertRaises(error.ManifestInvalidPathError): | ||
| 484 | parse('ok', path) | ||
| 459 | 485 | ||
| 460 | 486 | ||
| 461 | class SuperProjectElementTests(ManifestParseTestCase): | 487 | class SuperProjectElementTests(ManifestParseTestCase): |
