(self)
| 2631 | class LimitsTest(unittest.TestCase): |
| 2632 | |
| 2633 | def test_ustar_limits(self): |
| 2634 | # 100 char name |
| 2635 | tarinfo = tarfile.TarInfo("0123456789" * 10) |
| 2636 | tarinfo.tobuf(tarfile.USTAR_FORMAT) |
| 2637 | |
| 2638 | # 101 char name that cannot be stored |
| 2639 | tarinfo = tarfile.TarInfo("0123456789" * 10 + "0") |
| 2640 | self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) |
| 2641 | |
| 2642 | # 256 char name with a slash at pos 156 |
| 2643 | tarinfo = tarfile.TarInfo("123/" * 62 + "longname") |
| 2644 | tarinfo.tobuf(tarfile.USTAR_FORMAT) |
| 2645 | |
| 2646 | # 256 char name that cannot be stored |
| 2647 | tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname") |
| 2648 | self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) |
| 2649 | |
| 2650 | # 512 char name |
| 2651 | tarinfo = tarfile.TarInfo("123/" * 126 + "longname") |
| 2652 | self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) |
| 2653 | |
| 2654 | # 512 char linkname |
| 2655 | tarinfo = tarfile.TarInfo("longlink") |
| 2656 | tarinfo.linkname = "123/" * 126 + "longname" |
| 2657 | self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) |
| 2658 | |
| 2659 | # uid > 8 digits |
| 2660 | tarinfo = tarfile.TarInfo("name") |
| 2661 | tarinfo.uid = 0o10000000 |
| 2662 | self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT) |
| 2663 | |
| 2664 | def test_gnu_limits(self): |
| 2665 | tarinfo = tarfile.TarInfo("123/" * 126 + "longname") |
nothing calls this directly
no test coverage detected