Skip to content

Commit

Permalink
Add a test for sqlite permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
ppolewicz committed Feb 23, 2022
1 parent 8257c60 commit 325d7f1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/unit/account_info/test_account_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import os
import platform
import shutil
import stat
import tempfile

import pytest
Expand Down Expand Up @@ -322,12 +323,22 @@ def setUp(self, request):
self.test_home = tempfile.mkdtemp()

yield
for cleanup_method in [lambda: os.unlink(self.db_path), lambda: shutil.rmtree(self.test_home)]:
for cleanup_method in [
lambda: os.unlink(self.db_path), lambda: shutil.rmtree(self.test_home)
]:
try:
cleanup_method()
except OSError:
pass

def test_permissions(self):
"""
Test that a new database won't be readable by just any user
"""
s = SqliteAccountInfo(file_name=self.db_path,)
mode = os.stat(self.db_path).st_mode
assert stat.filemode(mode) == '-rw-------'

def test_corrupted(self):
"""
Test that a corrupted file will be replaced with a blank file.
Expand Down

0 comments on commit 325d7f1

Please sign in to comment.