Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13142151
test_users.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_users.py
View Options
#!/usr/bin/env python3
import
unittest
import
yaml
PILLAR_FILE
=
"../pillar/core/users.sls"
USER_PROPERTIES_MANDATORY
=
set
([
"fullname"
,
"ssh_keys"
,
"uid"
])
USER_PROPERTIES_OPTIONAL
=
set
([
"class"
,
"shell"
,
"yubico_keys"
,
"devserver_tasks"
])
class
Testinstance
(
unittest
.
TestCase
):
def
setUp
(
self
):
with
open
(
PILLAR_FILE
,
"r"
)
as
fd
:
self
.
pillar
=
yaml
.
safe_load
(
fd
)
# users must have a 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
))
if
__name__
==
"__main__"
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Nov 21, 16:10 (8 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3179313
Default Alt Text
test_users.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment