summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-12-11 18:30:37 +0100
committerRonny Chevalier <chevalier.ronny@gmail.com>2014-12-11 18:32:57 +0100
commit015df1f78f443f91b354e0c4b4cb76de86c838eb (patch)
tree79b97803c3c56a785a72a6f717958df12200fb8c /src/test
parente74aa253e977ffd768a6d3af3535ea5b31e350a7 (diff)
test-condition: add more test cases
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-condition.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/test/test-condition.c b/src/test/test-condition.c
index 349c6470c3..88147c8e0a 100644
--- a/src/test/test-condition.c
+++ b/src/test/test-condition.c
@@ -23,8 +23,13 @@
#include "log.h"
#include "architecture.h"
#include "sd-id128.h"
+#include "selinux-util.h"
+#include "audit.h"
+#include "ima-util.h"
+#include "apparmor-util.h"
+#include "smack-util.h"
-static void test_condition_test_path_exists(void) {
+static void test_condition_test_path(void) {
Condition *condition;
condition = condition_new(CONDITION_PATH_EXISTS, "/bin/sh", false, false);
@@ -82,6 +87,14 @@ static void test_condition_test_path_exists(void) {
condition = condition_new(CONDITION_PATH_IS_MOUNT_POINT, "/bin", false, false);
assert_se(!condition_test(condition));
condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_READ_WRITE, "/tmp", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_PATH_IS_SYMBOLIC_LINK, "/dev/stdout", false, false);
+ assert_se(condition_test(condition));
+ condition_free(condition);
}
static void test_condition_test_ac_power(void) {
@@ -179,16 +192,46 @@ static void test_condition_test_null(void) {
condition_free(condition);
}
+static void test_condition_test_security(void) {
+ Condition *condition;
+
+ condition = condition_new(CONDITION_SECURITY, "garbage oifdsjfoidsjoj", false, false);
+ assert_se(!condition_test(condition));
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_SECURITY, "selinux", false, true);
+ assert_se(condition_test(condition) != mac_selinux_use());
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_SECURITY, "ima", false, false);
+ assert_se(condition_test(condition) == use_ima());
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_SECURITY, "apparmor", false, false);
+ assert_se(condition_test(condition) == mac_apparmor_use());
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_SECURITY, "smack", false, false);
+ assert_se(condition_test(condition) == mac_smack_use());
+ condition_free(condition);
+
+ condition = condition_new(CONDITION_SECURITY, "audit", false, false);
+ assert_se(condition_test(condition) == use_audit());
+ condition_free(condition);
+}
+
+
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
- test_condition_test_path_exists();
+ test_condition_test_path();
test_condition_test_ac_power();
test_condition_test_host();
test_condition_test_architecture();
test_condition_test_kernel_command_line();
test_condition_test_null();
+ test_condition_test_security();
return 0;
}