Exemplo n.º 1
0
 def test_dest_block_symlink(self):
     """Do not allow writing to a symlink."""
     src = os.path.join(self.worktree, 'foo.txt')
     self.touch(src)
     platform_utils.symlink('dest', os.path.join(self.topdir, 'sym'))
     cf = self.CopyFile('foo.txt', 'sym')
     self.assertRaises(error.ManifestInvalidPathError, cf._Copy)
Exemplo n.º 2
0
 def test_dest_block_symlink_traversal(self):
     """Do not allow writing through a symlink dir."""
     src = os.path.join(self.worktree, 'foo.txt')
     self.touch(src)
     platform_utils.symlink(tempfile.gettempdir(),
                            os.path.join(self.topdir, 'sym'))
     cf = self.CopyFile('foo.txt', 'sym/foo.txt')
     self.assertRaises(error.ManifestInvalidPathError, cf._Copy)
Exemplo n.º 3
0
 def test_src_block_symlink(self):
     """Do not allow reading from a symlinked path."""
     src = os.path.join(self.worktree, 'foo.txt')
     sym = os.path.join(self.worktree, 'sym')
     self.touch(src)
     platform_utils.symlink('foo.txt', sym)
     self.assertExists(sym)
     cf = self.CopyFile('sym', 'foo')
     self.assertRaises(error.ManifestInvalidPathError, cf._Copy)
Exemplo n.º 4
0
 def test_src_block_symlink_traversal(self):
   """Do not allow reading through a symlink dir."""
   realfile = os.path.join(self.tempdir, 'file.txt')
   self.touch(realfile)
   src = os.path.join(self.worktree, 'bar', 'file.txt')
   platform_utils.symlink(self.tempdir, os.path.join(self.worktree, 'bar'))
   self.assertExists(src)
   cf = self.CopyFile('bar/file.txt', 'foo')
   self.assertRaises(error.ManifestInvalidPathError, cf._Copy)
Exemplo n.º 5
0
  def test_update(self):
    """Make sure changed targets get updated."""
    dest = os.path.join(self.topdir, 'sym')

    src = os.path.join(self.worktree, 'foo.txt')
    self.touch(src)
    lf = self.LinkFile('foo.txt', 'sym')
    lf._Link()
    self.assertEqual(os.path.join('git-project', 'foo.txt'), os.readlink(dest))

    # Point the symlink somewhere else.
    os.unlink(dest)
    platform_utils.symlink(self.tempdir, dest)
    lf._Link()
    self.assertEqual(os.path.join('git-project', 'foo.txt'), os.readlink(dest))