Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Sep 17, 2024
1 parent a2f4dd4 commit b247b04
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def setUp(self):
except:
self.skipTest("Encryption not supported on this ZFS version.")

def load_key(self, key, path):

shelltest("rm /tmp/zfstest.key 2>/dev/null;true")
shelltest("echo {} > /tmp/zfstest.key".format(key))
shelltest("zfs load-key {}".format(path))

def prepare_encrypted_dataset(self, key, path, unload_key=False):

# create encrypted source dataset
Expand Down Expand Up @@ -269,6 +275,8 @@ def test_resume_encrypt_with_no_key(self):



#NOTE: this leaves 2 weird sub-datasets that should'nt be there (its a zfs thing i think)

r = shelltest("zfs get -r -t all encryptionroot test_target1")
self.assertEqual(r, """
NAME PROPERTY VALUE SOURCE
Expand All @@ -282,8 +290,24 @@ def test_resume_encrypt_with_no_key(self):
test_target1/encryptedtarget/test_source1/fs1/encryptedsource@test-20101111000001 encryptionroot test_target1/encryptedtarget/test_source1/fs1/encryptedsource -
test_target1/encryptedtarget/test_source1/fs1/sub encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source1/fs1/sub@test-20101111000000 encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source1/fs1/sub/sub encryptionroot - -
test_target1/encryptedtarget/test_source1/fs1/sub/sub@test-20101111000001 encryptionroot - -
test_target1/encryptedtarget/test_source2 encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source2/fs2 encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source2/fs2/sub encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source2/fs2/sub@test-20101111000000 encryptionroot test_target1/encryptedtarget -
test_target1/encryptedtarget/test_source2/fs2/sub/sub encryptionroot - -
test_target1/encryptedtarget/test_source2/fs2/sub/sub@test-20101111000001 encryptionroot - -
""")



#reload key and resume correctly.
self.load_key("22222222", "test_target1/encryptedtarget")

# resume
with mocktime("20101111000001"):
self.assertEqual(ZfsAutobackup(
"test test_target1/encryptedtarget --verbose --no-progress --encrypt --exclude-received --allow-empty --no-snapshot --clear-mountpoint".split(
" ")).run(),0)

0 comments on commit b247b04

Please sign in to comment.