Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
d7c133c2
Commit
d7c133c2
authored
Jul 18, 2013
by
Mukund Sivaraman
Browse files
[3056] Skip some more tests when run as the root user
parent
949a2522
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/memmgr/tests/memmgr_test.py
View file @
d7c133c2
...
...
@@ -137,9 +137,24 @@ class TestMemmgr(unittest.TestCase):
self
.
assertEqual
(
1
,
answer
[
0
])
self
.
assertIsNotNone
(
re
.
search
(
'not a directory'
,
answer
[
1
]))
# Bad update: directory exists but is not readable.
os
.
mkdir
(
self
.
__test_mapped_file_dir
,
0o500
)
# drop writable bit
@
unittest
.
skipIf
(
os
.
getuid
()
==
0
,
'test cannot be run as root user'
)
def
test_configure_bad_permissions
(
self
):
self
.
__mgr
.
_setup_ccsession
()
# Pretend specified directories exist and writable
os
.
path
.
isdir
=
lambda
x
:
True
os
.
access
=
lambda
x
,
y
:
True
# Initial configuration.
self
.
assertEqual
((
0
,
None
),
parse_answer
(
self
.
__mgr
.
_config_handler
({})))
os
.
path
.
isdir
=
self
.
__orig_isdir
os
.
access
=
self
.
__orig_os_access
# Bad update: directory exists but is not writable.
os
.
mkdir
(
self
.
__test_mapped_file_dir
,
0o500
)
# drop writable bit
user_cfg
=
{
'mapped_file_dir'
:
self
.
__test_mapped_file_dir
}
answer
=
parse_answer
(
self
.
__mgr
.
_config_handler
(
user_cfg
))
self
.
assertEqual
(
1
,
answer
[
0
])
...
...
src/bin/usermgr/tests/b10-cmdctl-usermgr_test.py
View file @
d7c133c2
...
...
@@ -399,6 +399,19 @@ Options:
'add'
,
'user1'
,
'pass1'
])
@
unittest
.
skipIf
(
os
.
getuid
()
==
0
,
'test cannot be run as root user'
)
def
test_bad_file_permissions
(
self
):
"""
Check for graceful handling of bad file argument
"""
# Create the test file
self
.
run_check
(
0
,
None
,
None
,
[
self
.
TOOL
,
'-f'
,
self
.
OUTPUT_FILE
,
'add'
,
'user1'
,
'pass1'
])
# Make it non-writable (don't worry about cleanup, the
# file should be deleted after each test anyway
os
.
chmod
(
self
.
OUTPUT_FILE
,
stat
.
S_IRUSR
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment