From Fedora Project Wiki

m (Added "-v" parameter in 5. step of testing for restorecon.)
 
(8 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
|setup=Ensure that {{package|policycoreutils}} package is installed.
 
|setup=Ensure that {{package|policycoreutils}} package is installed.
 
|actions=
 
|actions=
#Create test file {{command|touch /tmp/test}}
+
<ol>
#Check test file context {{command|ls -Z /tmp/test}}. Result should be  <pre>unconfined_u:object_r:user_tmp_t:s0 /tmp/test
+
<li>Create test file: <pre>#touch /tmp/test</pre> </li>
</pre>
+
<li>Check test file context: <pre>#ls -Z /tmp/test
#Add new context for the test file {{command|semanage fcontext -a -t user_home_t "/tmp/test"}}
+
unconfined_u:object_r:user_tmp_t:s0 /tmp/test</pre> </li>
#List local customisations {{command|semanage fcontext -l -C}} <pre>/tmp/test    all files    system_u:object_r:user_home_t:s0
+
<li>Add new context for the test file: <pre>#semanage fcontext -a -t user_home_t "/tmp/test"</pre></li>
</pre>
+
<li>List local customisations: <pre>#semanage fcontext -l -C
 
+
/tmp/test    all files    system_u:object_r:user_home_t:s0</pre></li>
#Apply new context {{command|restorecon /tmp/test}}
+
<li>Apply new context: <pre>#restorecon -v /tmp/test</pre></li>
#Check that the context has changed {{command|ls -Z /tmp/test}} <pre>unconfined_u:object_r:user_home_t:s0 /tmp/test
+
<li>Check that the context has changed: <pre>#ls -Z /tmp/test
</pre>
+
unconfined_u:object_r:user_home_t:s0 /tmp/test</pre> </li>
+
<li>Remove custom context (revert to default): <pre>#semanage fcontext -d -t user_home_t "/tmp/test"
#Remove custom context (revert to default) {{command|semanage fcontext -d -t user_home_t "/tmp/test"}}
+
restorecon:  Warning no default label for /tmp/test </pre></li>
#Last action should result in the following warning:
+
<li>Remove test file <pre>#rm -rf /tmp/test</pre></li>
<pre>restorecon:  Warning no default label for /tmp/test
+
</ol>
</pre>
 
#Remove test file {{command|rm -rf /tmp/test}}
 
 
 
 
|results=
 
|results=
 
 
# All commands are executed successfully  
 
# All commands are executed successfully  
 
# Context of the test file matches prescribed values
 
# Context of the test file matches prescribed values
 
}}
 
}}
 
[[Category:Package_policycoreutils_test_cases]]
 
[[Category:Package_policycoreutils_test_cases]]

Latest revision as of 09:45, 18 December 2017

Description

This test case tests semanage basic functionalities (context addition/removal, listing).

Setup

Ensure that Package-x-generic-16.pngpolicycoreutils package is installed.

How to test

  1. Create test file:
    #touch /tmp/test
  2. Check test file context:
    #ls -Z /tmp/test
    unconfined_u:object_r:user_tmp_t:s0 /tmp/test
  3. Add new context for the test file:
    #semanage fcontext -a -t user_home_t "/tmp/test"
  4. List local customisations:
    #semanage fcontext -l -C
    /tmp/test    all files    system_u:object_r:user_home_t:s0
  5. Apply new context:
    #restorecon -v /tmp/test
  6. Check that the context has changed:
    #ls -Z /tmp/test
    unconfined_u:object_r:user_home_t:s0 /tmp/test
  7. Remove custom context (revert to default):
    #semanage fcontext -d -t user_home_t "/tmp/test"
    restorecon:  Warning no default label for /tmp/test 
  8. Remove test file
    #rm -rf /tmp/test

Expected Results

  1. All commands are executed successfully
  2. Context of the test file matches prescribed values