Page MenuHomeDevCentral

D2125.id5358.diff
No OneTemporary

D2125.id5358.diff

diff --git a/_tests/pillar/core/__init__.py b/_tests/pillar/core/__init__.py
new file mode 100644
diff --git a/_tests/pillar/core/test_users.py b/_tests/pillar/core/test_users.py
new file mode 100644
--- /dev/null
+++ b/_tests/pillar/core/test_users.py
@@ -0,0 +1,36 @@
+import unittest
+import yaml
+
+
+PILLAR_FILE = '../pillar/core/users.sls'
+
+USER_PROPERTIES_MANDATORY = set(["fullname", "ssh_keys", "uid"])
+USER_PROPERTIES_OPTIONAL = set([
+ "shell",
+ "yubico_keys",
+ "deploy_dotfiles_to_devserver"
+])
+
+class Testinstance(unittest.TestCase):
+
+ def setUp(self):
+ with open(PILLAR_FILE, 'r') as fd:
+ self.pillar = yaml.safe_load(fd)
+
+ # users must have an username, an UID and SSH keys
+ def test_users_properties(self):
+ is_valid = True
+ errors = []
+
+ for user, properties in self.pillar["shellusers"].items():
+ missing_properties = USER_PROPERTIES_MANDATORY - set(properties)
+ if missing_properties:
+ errors.append(f" Missing properties for {user}: {missing_properties}")
+ is_valid = False
+
+ invalid_properties = set(properties) - USER_PROPERTIES_MANDATORY - USER_PROPERTIES_OPTIONAL
+ if invalid_properties:
+ errors.append(f" Invalid properties for {user}: {invalid_properties}")
+ is_valid = False
+
+ self.assertTrue(is_valid, "\n" + "\n".join(errors))

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 12:32 (5 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2268934
Default Alt Text
D2125.id5358.diff (1 KB)

Event Timeline