[Fuego] [PATCH] Add test cases for commands of ACL.

Wang Mingyu wangmy at cn.fujitsu.com
Tue Nov 6 13:56:24 UTC 2018


ACLs are a second level of discretionary permissions, that may override the standard ugo/rwx ones.
When used correctly they can grant you a better granularity in setting access to a file or a directory.
This is a simple test to check the commands of ACL.

Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.acl/acl_test.sh           |  4 +++
 engine/tests/Functional.acl/fuego_test.sh         | 21 +++++++++++++++
 engine/tests/Functional.acl/parser.py             | 22 ++++++++++++++++
 engine/tests/Functional.acl/spec.json             |  7 +++++
 engine/tests/Functional.acl/test.yaml             | 32 +++++++++++++++++++++++
 engine/tests/Functional.acl/tests/acl_chacl.sh    | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_getfacl1.sh |  9 +++++++
 engine/tests/Functional.acl/tests/acl_getfacl2.sh | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_getfacl3.sh | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_setfacl1.sh |  9 +++++++
 engine/tests/Functional.acl/tests/acl_setfacl2.sh | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_setfacl3.sh | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_setfacl4.sh | 18 +++++++++++++
 engine/tests/Functional.acl/tests/acl_setfacl5.sh | 18 +++++++++++++
 14 files changed, 230 insertions(+)
 create mode 100755 engine/tests/Functional.acl/acl_test.sh
 create mode 100644 engine/tests/Functional.acl/fuego_test.sh
 create mode 100644 engine/tests/Functional.acl/parser.py
 create mode 100644 engine/tests/Functional.acl/spec.json
 create mode 100644 engine/tests/Functional.acl/test.yaml
 create mode 100644 engine/tests/Functional.acl/tests/acl_chacl.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_getfacl1.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_getfacl2.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_getfacl3.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_setfacl1.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_setfacl2.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_setfacl3.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_setfacl4.sh
 create mode 100644 engine/tests/Functional.acl/tests/acl_setfacl5.sh

diff --git a/engine/tests/Functional.acl/acl_test.sh b/engine/tests/Functional.acl/acl_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.acl/acl_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.acl/fuego_test.sh b/engine/tests/Functional.acl/fuego_test.sh
new file mode 100644
index 0000000..a65e39c
--- /dev/null
+++ b/engine/tests/Functional.acl/fuego_test.sh
@@ -0,0 +1,21 @@
+function test_pre_check {
+    assert_has_program chacl
+    assert_has_program setfacl
+    assert_has_program getfacl
+}
+
+function test_deploy {
+    put $TEST_HOME/acl_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export tst_acl_ram=$DISK_DEV;\
+    export tst_acl_media=$DISK_MEDIA;\
+    ./acl_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.acl/parser.py b/engine/tests/Functional.acl/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.acl/parser.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/engine/tests/Functional.acl/spec.json b/engine/tests/Functional.acl/spec.json
new file mode 100644
index 0000000..6fcca9b
--- /dev/null
+++ b/engine/tests/Functional.acl/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.acl",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.acl/test.yaml b/engine/tests/Functional.acl/test.yaml
new file mode 100644
index 0000000..9959fb3
--- /dev/null
+++ b/engine/tests/Functional.acl/test.yaml
@@ -0,0 +1,32 @@
+fuego_package_version: 1
+name: Functional.acl
+description: |
+      ACLs are a second level of discretionary permissions, that may override the standard ugo/rwx ones.
+      When used correctly they can grant you a better granularity in setting access to a file or a directory.
+      This is a simple test to check the commands of ACL.
+license: Unknown
+author: Wang Mingyu <wangmy at cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird at sony.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['vlan']
+params:
+      DISK_DEV="the device file in your target board" Defined in board file
+      DISK_MEDIA="the mount point of device in your target board" Defined in board file
+data_files:
+ - acl_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
+    acl_chacl.sh
+    acl_getfacl1.sh
+    acl_getfacl2.sh
+    acl_getfacl3.sh
+    acl_setfacl1.sh
+    acl_setfacl2.sh
+    acl_setfacl3.sh
+    acl_setfacl4.sh
+    acl_setfacl5.sh
diff --git a/engine/tests/Functional.acl/tests/acl_chacl.sh b/engine/tests/Functional.acl/tests/acl_chacl.sh
new file mode 100644
index 0000000..f89dc9f
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_chacl.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="chacl"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+chacl u::rwx,g::r-x,o::r-- $tst_acl_media/testfile
+if getfacl $tst_acl_media/testfile | grep "user::rwx"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/engine/tests/Functional.acl/tests/acl_getfacl1.sh b/engine/tests/Functional.acl/tests/acl_getfacl1.sh
new file mode 100644
index 0000000..063c50b
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_getfacl1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+test="getfacl"
+
+if getfacl --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.acl/tests/acl_getfacl2.sh b/engine/tests/Functional.acl/tests/acl_getfacl2.sh
new file mode 100644
index 0000000..e570fd3
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_getfacl2.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="getfacl2"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+setfacl -m u:ftp:rw $tst_acl_media/testfile
+if getfacl $tst_acl_media/testfile | grep "user:ftp"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/engine/tests/Functional.acl/tests/acl_getfacl3.sh b/engine/tests/Functional.acl/tests/acl_getfacl3.sh
new file mode 100644
index 0000000..1875ae4
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_getfacl3.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="getfacl3"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+setfacl -b /media/ram/testfile
+if getfacl /media/ram/testfile | grep "user::"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
diff --git a/engine/tests/Functional.acl/tests/acl_setfacl1.sh b/engine/tests/Functional.acl/tests/acl_setfacl1.sh
new file mode 100644
index 0000000..92ce0a1
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_setfacl1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+test="setfacl1"
+
+if setfacl --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.acl/tests/acl_setfacl2.sh b/engine/tests/Functional.acl/tests/acl_setfacl2.sh
new file mode 100644
index 0000000..427dfb8
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_setfacl2.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="setfacl2"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+setfacl -m u:ftp:rw $tst_acl_media/testfile
+if [ `echo $?` == 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f $tst_acl_media/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/engine/tests/Functional.acl/tests/acl_setfacl3.sh b/engine/tests/Functional.acl/tests/acl_setfacl3.sh
new file mode 100644
index 0000000..79fd0db
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_setfacl3.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="setfacl3"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+setfacl -x u:ftp /media/ram/testfile
+if [ `echo $?` == 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
diff --git a/engine/tests/Functional.acl/tests/acl_setfacl4.sh b/engine/tests/Functional.acl/tests/acl_setfacl4.sh
new file mode 100644
index 0000000..9e7696c
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_setfacl4.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="setfacl4"
+
+modprobe brd
+yes | mke2fs -j $tst_acl_ram
+mkdir $tst_acl_media
+mount -t ext3 -o acl $tst_acl_ram $tst_acl_media
+touch $tst_acl_media/testfile
+setfacl -m g:ftp:r $tst_acl_media/testfile
+if [ `echo $?` == 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f /meida/ram/testfile
+umount $tst_acl_media
+rm -rf $tst_acl_media
diff --git a/engine/tests/Functional.acl/tests/acl_setfacl5.sh b/engine/tests/Functional.acl/tests/acl_setfacl5.sh
new file mode 100644
index 0000000..29a301e
--- /dev/null
+++ b/engine/tests/Functional.acl/tests/acl_setfacl5.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+test="setfacl5"
+
+yes | mke2fs -j /dev/ram
+mkdir /media/ram
+mount -t ext3 -o acl /dev/ram /media/ram
+touch /media/ram/testfile
+setfacl -m u:ftp:rw /media/ram/testfile
+setfacl -b /media/ram/testfile
+if [ `echo $?` == 0 ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+rm -f /media/ram/testfile
+umount /media/ram
+rm -rf /media/ram
-- 
1.8.3.1





More information about the Fuego mailing list