check in current project state

This commit is contained in:
2025-04-01 18:35:11 +02:00
parent 8eeb98801d
commit 30692614e5
30 changed files with 2412 additions and 72 deletions

View File

@ -96,6 +96,30 @@ class TestFileTableBackend(unittest.TestCase):
webserver_file = testdir / "webserver.json"
self.assertFalse(webserver_file.exists())
def test_lookup_by_secret(self) -> None:
"""Test lookup of secrets."""
dataset = [
TestClientSpec("webserver", {"SECRET_TOKEN": "mysecrettoken"}),
TestClientSpec("webserver2", {"SECRET_TOKEN": "mysecrettoken"}),
TestClientSpec("webserver3", {"SECRET_TOKEN": "mysecrettoken"}),
TestClientSpec("dbserver", {"DB_ROOT_PASSWORD": "mysecretpassword"}),
TestClientSpec("dbserver2", {"DB_ROOT_PASSWORD": "mysecretpassword"}),
TestClientSpec("appserver", {"DB_ROOT_PASSWORD": "mysecretpassword", "SECRET_TOKEN": "mysecrettoken"}),
]
with test_context(dataset) as testdir:
backend = FileTableBackend(testdir)
token_mapping = backend.lookup_by_secret("SECRET_TOKEN")
self.assertEqual(len(token_mapping), 4)
token_mapping_names = [client.name for client in token_mapping]
self.assertIn("webserver2", token_mapping_names)
self.assertIn("appserver", token_mapping_names)
db_mapping = backend.lookup_by_secret("DB_ROOT_PASSWORD")
db_mapping_names = [client.name for client in db_mapping]
self.assertEqual(len(db_mapping), 3)
self.assertNotIn("webserver", db_mapping_names)
if __name__ == "__main__":
unittest.main()