1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 01:22:19 +03:00

Read-Only obtain_lock() test commented and cleaned up.

* Comment added about what you'd see if you could check tmpdir
  properties whilst it's set !Write.
* Deleted all the testing print()s.
This commit is contained in:
Athanasius 2021-03-19 18:48:37 +00:00
parent ec230a9c05
commit 70bdc5e0e9

@ -59,7 +59,6 @@ class TestJournalLock:
def get_str(key: str, *, default: str = None) -> str:
"""Mock config.*Config get_str to provide fake journaldir."""
if key == 'journaldir':
print(f'journaldir: using tmpdir: {tmpdir}')
return tmpdir
print('Other key, calling up ...')
@ -135,6 +134,10 @@ class TestJournalLock:
dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = win32security.ACL()
# Add Write to Denied list
# con.FILE_WRITE_DATA results in a 'Special permissions' being
# listed on Properties > Security for the user in the 'Deny' column.
# Clicking through to 'Advanced' shows a 'Deny' for
# 'Create files / write data'.
dacl.AddAccessDeniedAce(win32security.ACL_REVISION, con.FILE_WRITE_DATA, winuser)
# Apply that change.
sd.SetSecurityDescriptorDacl(1, dacl, 0) # may not be necessary
@ -159,14 +162,12 @@ class TestJournalLock:
i = 0
ace = dacl.GetAce(i)
while ace:
print(f'After {ace=}')
if ace[0] == (con.ACCESS_DENIED_ACE_TYPE, 0) and ace[1] == con.FILE_WRITE_DATA:
# Delete the Ace that we added
dacl.DeleteAce(i)
# Apply that change.
sd.SetSecurityDescriptorDacl(1, dacl, 0) # may not be necessary
win32security.SetFileSecurity(str(tmpdir), win32security.DACL_SECURITY_INFORMATION, sd)
print('Found the Ace we added, removing...')
break
i += 1
@ -180,5 +181,4 @@ class TestJournalLock:
else:
os.chmod(tmpdir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
print(f'{locked=}')
assert locked == JournalLockResult.JOURNALDIR_READONLY