(self)
| 815 | |
| 816 | @unittest.skipUnless(os.name == "nt", "Only on Windows.") |
| 817 | def test_mode_win32(self): |
| 818 | # Use icacls.exe to extract the users with some level of access |
| 819 | # Main thing we are testing is that the BUILTIN\Users group has |
| 820 | # no access. The exact ACL is going to vary based on which user |
| 821 | # is running the test. |
| 822 | dir = self.do_create() |
| 823 | try: |
| 824 | out = subprocess.check_output(["icacls.exe", dir], encoding="oem").casefold() |
| 825 | finally: |
| 826 | os.rmdir(dir) |
| 827 | |
| 828 | dir = dir.casefold() |
| 829 | users = set() |
| 830 | found_user = False |
| 831 | for line in out.strip().splitlines(): |
| 832 | acl = None |
| 833 | # First line of result includes our directory |
| 834 | if line.startswith(dir): |
| 835 | acl = line.removeprefix(dir).strip() |
| 836 | elif line and line[:1].isspace(): |
| 837 | acl = line.strip() |
| 838 | if acl: |
| 839 | users.add(acl.partition(":")[0]) |
| 840 | |
| 841 | self.assertNotIn(r"BUILTIN\Users".casefold(), users) |
| 842 | |
| 843 | def test_collision_with_existing_file(self): |
| 844 | # mkdtemp tries another name when a file with |
nothing calls this directly
no test coverage detected