Commit 2f9a04d6 authored by Christian Kellner's avatar Christian Kellner
Browse files

test/integration: cleanup stale domains check

Simulate stale domains by creating a store with four domains, one
of which has a bootacl journal with entries. Since the store does
not have a 'version' file, an upgrade will be performed which will
lead to the cleanup of stale domains. All domains, except the one
with the non-empty bootacl journal should be cleaned up.
parent 9e859394
......@@ -1440,6 +1440,32 @@ class BoltTest(dbusmock.DBusTestCase):
path = os.path.join(self.dbpath, 'domains', uid)
return os.path.exists(path)
def store_create_domain(self, *, uid=None, acl=None):
if not uid:
uid = str(uuid.uuid4())
if acl:
bootacl = ",".join(acl)
else:
bootacl = ""
entry = (
"[domain]\n"
f"bootacl={bootacl}\n"
)
path = os.path.join(self.dbpath, 'domains', uid)
with open(path, 'w') as f:
f.write(entry)
return uid
def store_create_journal(self, name, uid, entries):
ts = 123456
data = ["%s %s %016iX" % (e["uid"], e["op"], ts) for e in entries]
journal = os.path.join(self.dbpath, name)
os.makedirs(journal, exist_ok=True)
path = os.path.join(journal, uid)
with open(path, 'w') as f:
f.write("\n".join(data))
# the actual tests
def test_basic(self):
def make_events(name, devices):
......@@ -1743,6 +1769,29 @@ class BoltTest(dbusmock.DBusTestCase):
self.daemon_stop()
def test_domain_cleanup_stale(self):
stale = []
for _ in range(4):
uid = self.store_create_domain()
stale += [uid]
uid = self.store_create_domain()
acls = [{"uid": str(uuid.uuid4), "op": "+"}]
self.store_create_journal("bootacl", uid, acls)
self.daemon_start()
client = self.client
domains = client.list_domains()
have = []
for domain in domains:
self.assertNotIn(domain.uid, stale)
have += [domain.uid]
self.assertIn(uid, have)
self.daemon_stop()
def test_signals_on_start(self):
# Check that we get DeviceAdded signals for un-authorized
# devices that are not in the database
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment