1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update tests for VaultEditor API changes

This commit is contained in:
Abhijit Menon-Sen 2015-08-26 19:52:20 +05:30
parent 20fd9224bb
commit c4b2540ecc

View file

@ -81,7 +81,7 @@ class TestVaultEditor(unittest.TestCase):
pass pass
def test_methods_exist(self): def test_methods_exist(self):
v = VaultEditor(None, None, None) v = VaultEditor(None)
slots = ['create_file', slots = ['create_file',
'decrypt_file', 'decrypt_file',
'edit_file', 'edit_file',
@ -103,8 +103,8 @@ class TestVaultEditor(unittest.TestCase):
tmp_file = tempfile.NamedTemporaryFile() tmp_file = tempfile.NamedTemporaryFile()
os.unlink(tmp_file.name) os.unlink(tmp_file.name)
ve = VaultEditor(None, "ansible", tmp_file.name) ve = VaultEditor("ansible")
ve.create_file() ve.create_file(tmp_file.name)
self.assertTrue(os.path.exists(tmp_file.name)) self.assertTrue(os.path.exists(tmp_file.name))
@ -120,12 +120,12 @@ class TestVaultEditor(unittest.TestCase):
with v10_file as f: with v10_file as f:
f.write(to_bytes(v10_data)) f.write(to_bytes(v10_data))
ve = VaultEditor(None, "ansible", v10_file.name) ve = VaultEditor("ansible")
# make sure the password functions for the cipher # make sure the password functions for the cipher
error_hit = False error_hit = False
try: try:
ve.decrypt_file() ve.decrypt_file(v10_file.name)
except errors.AnsibleError as e: except errors.AnsibleError as e:
error_hit = True error_hit = True
@ -148,12 +148,12 @@ class TestVaultEditor(unittest.TestCase):
with v11_file as f: with v11_file as f:
f.write(to_bytes(v11_data)) f.write(to_bytes(v11_data))
ve = VaultEditor(None, "ansible", v11_file.name) ve = VaultEditor("ansible")
# make sure the password functions for the cipher # make sure the password functions for the cipher
error_hit = False error_hit = False
try: try:
ve.decrypt_file() ve.decrypt_file(v11_file.name)
except errors.AnsibleError as e: except errors.AnsibleError as e:
error_hit = True error_hit = True
@ -180,12 +180,12 @@ class TestVaultEditor(unittest.TestCase):
with v10_file as f: with v10_file as f:
f.write(to_bytes(v10_data)) f.write(to_bytes(v10_data))
ve = VaultEditor(None, "ansible", v10_file.name) ve = VaultEditor("ansible")
# make sure the password functions for the cipher # make sure the password functions for the cipher
error_hit = False error_hit = False
try: try:
ve.rekey_file('ansible2') ve.rekey_file('ansible2', v10_file.name)
except errors.AnsibleError as e: except errors.AnsibleError as e:
error_hit = True error_hit = True