Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3796984
D2125.id5361.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D2125.id5361.diff
View Options
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,37 @@
+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
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 08:45 (21 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2270864
Default Alt Text
D2125.id5361.diff (1 KB)
Attached To
Mode
D2125: Detect invalid or missing properties for shellusers
Attached
Detach File
Event Timeline
Log In to Comment