Skip to content

Commit

Permalink
Check whether D-Bus and metadata agree about encryption
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Jul 15, 2024
1 parent 5fb6ec8 commit 99fddd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ def pool_uuid(pool_path):

return iface.Get(StratisDbus._POOL_IFACE, "Uuid", timeout=StratisDbus._TIMEOUT)

@staticmethod
def pool_encrypted(pool_path):
"""
Find a pool Encrypted value given an object path.
"""
iface = dbus.Interface(
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, pool_path),
dbus.PROPERTIES_IFACE,
)

return iface.Get(
StratisDbus._POOL_IFACE, "Encrypted", timeout=StratisDbus._TIMEOUT
)

@staticmethod
def pool_create(
pool_name,
Expand Down
12 changes: 12 additions & 0 deletions testlib/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ def _check_thin_meta_allocations(self, metadata):
"total size of thin meta spare device.",
)

def _check_encryption_information_consistency(self, pool_object_path, metadata):
"""
Check whether D-Bus and metadata agree about encryption state of pool.
"""
encrypted = bool(StratisDbus.pool_encrypted(pool_object_path))

if encrypted:
self.assertIn("encrypted", metadata["features"])
else:
self.assertNotIn("encrypted", metadata["features"])

def run_check(self, stop_time):
"""
Run the check.
Expand Down Expand Up @@ -270,6 +281,7 @@ def run_check(self, stop_time):

self._check_thin_meta_allocations(written)

self._check_encryption_information_consistency(object_path, written)
else:
current_message = (
"" if current_return_code == _OK else current_message
Expand Down

0 comments on commit 99fddd6

Please sign in to comment.