From 325d7f1b8871f4397c1c2959e113c6d0d961c2b3 Mon Sep 17 00:00:00 2001
From: Pawel Polewicz
Date: Sun, 6 Feb 2022 16:39:48 +0100
Subject: [PATCH] Add a test for sqlite permissions
---
test/unit/account_info/test_account_info.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/test/unit/account_info/test_account_info.py b/test/unit/account_info/test_account_info.py
index 2f367305e..bc131b70a 100644
--- a/test/unit/account_info/test_account_info.py
+++ b/test/unit/account_info/test_account_info.py
@@ -14,6 +14,7 @@
import os
import platform
import shutil
+import stat
import tempfile
import pytest
@@ -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.