Renamed vault migration script and some minor test fixes

This commit is contained in:
Nuwan Goonasekera
2021-12-02 00:36:35 +05:30
parent d9f2c0bf91
commit 7328ca0da9
3 changed files with 8 additions and 7 deletions
+5 -5
View File
@@ -23,11 +23,11 @@ class VaultTestBase(ABC):
self.assertEqual(self.vault.read_secret("my/new/secret"), "hello overwritten") # type: ignore
def test_valid_paths(self):
with self.assertRaises(InvalidVaultKeyException):
with self.assertRaises(InvalidVaultKeyException): # type: ignore
self.vault.write_secret("", "hello world")
with self.assertRaises(InvalidVaultKeyException):
with self.assertRaises(InvalidVaultKeyException): # type: ignore
self.vault.write_secret("my//new/secret", "hello world")
with self.assertRaises(InvalidVaultKeyException):
with self.assertRaises(InvalidVaultKeyException): # type: ignore
self.vault.write_secret("my/ /new/secret", "hello world")
# leading and trailing slashes should be ignored
self.vault.write_secret("/my/new/secret with space/", "hello overwritten")
@@ -76,7 +76,7 @@ class TestDatabaseVault(VaultTestBase, unittest.TestCase):
vault.write_secret("my/rotated/secret", "hello rotated")
# should succeed after rotation
app.config.vault_config_file = VAULT_CONF_DATABASE_ROTATED
app.config.vault_config_file = VAULT_CONF_DATABASE_ROTATED # type: ignore
vault = VaultFactory.from_app(app)
self.assertEqual(vault.read_secret("my/rotated/secret"), "hello rotated")
@@ -87,7 +87,7 @@ class TestDatabaseVault(VaultTestBase, unittest.TestCase):
vault.write_secret("my/incorrect/secret", "hello incorrect")
# should fail because decryption keys are the wrong
app.config.vault_config_file = VAULT_CONF_DATABASE_INVALID
app.config.vault_config_file = VAULT_CONF_DATABASE_INVALID # type: ignore
vault = VaultFactory.from_app(app)
with self.assertRaises(InvalidToken):
vault.read_secret("my/incorrect/secret")