Skip to content

Commit 13802bc

Browse files
committed
Added acceptance tests for immutable bit
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <[email protected]>
1 parent 93b5bb7 commit 13802bc

File tree

6 files changed

+266
-0
lines changed

6 files changed

+266
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
##############################################################################
2+
#
3+
# Test that immutable file CANNOT be edited by agent without specifying
4+
# fsattrs immutable constraint.
5+
#
6+
##############################################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
version => "1.0";
13+
}
14+
15+
body fsattrs set_immutable
16+
{
17+
immutable => "true";
18+
}
19+
20+
body fsattrs set_mutable
21+
{
22+
immutable => "false";
23+
}
24+
25+
bundle agent init
26+
{
27+
files:
28+
"/tmp/00_immutable.txt"
29+
content => "I'm immutable",
30+
fsattrs => set_immutable;
31+
}
32+
33+
bundle agent test
34+
{
35+
meta:
36+
"description" -> { "CFE-1840", "ENT-10961" }
37+
string => "Test that immutable file cannot be edited by agent without specifying fsattrs immutable constraint";
38+
39+
"test_soft_fail"
40+
string => "hpux|aix|windows",
41+
meta => { "CFE-1840", "ENT-10961" };
42+
43+
commands:
44+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
45+
}
46+
47+
bundle agent check
48+
{
49+
vars:
50+
"expected"
51+
string => "I'm immutable";
52+
"actual"
53+
string => readfile("/tmp/00_immutable.txt");
54+
55+
classes:
56+
"ok"
57+
expression => strcmp("$(actual)", "$(expected)");
58+
59+
methods:
60+
"any"
61+
usebundle => dcs_passif("ok", "$(this.promise_filename)"),
62+
inherit => "true";
63+
64+
reports:
65+
"Expected: '$(expected)', actual: '$(actual)'";
66+
}
67+
68+
bundle agent destroy
69+
{
70+
files:
71+
# Make sure immutable bit is not set
72+
"/tmp/00_immutable.txt"
73+
fsattrs => set_mutable,
74+
delete => tidy;
75+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
body fsattrs set_immutable
2+
{
3+
# Nothing here
4+
}
5+
6+
bundle agent main
7+
{
8+
files:
9+
"/tmp/00_immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
##############################################################################
2+
#
3+
# Test that immutable file CAN be edited by agent with fsattrs immutable
4+
# constraint set to true.
5+
#
6+
##############################################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
version => "1.0";
13+
}
14+
15+
body fsattrs set_immutable
16+
{
17+
immutable => "true";
18+
}
19+
20+
body fsattrs set_mutable
21+
{
22+
immutable => "false";
23+
}
24+
25+
bundle agent init
26+
{
27+
files:
28+
"/tmp/01_immutable.txt"
29+
content => "I'm immutable",
30+
fsattrs => set_immutable;
31+
}
32+
33+
bundle agent test
34+
{
35+
meta:
36+
"description" -> { "CFE-1840", "ENT-10961" }
37+
string => "Test that immutable file CAN be edited by agent with fsattrs immutable constraint set to true";
38+
39+
# "test_soft_fail" will not work here, because init will not be able to set
40+
# the immutable bit, hence the agent will be able to mutate it
41+
"test_skip_unsupported" string => "hpux|aix|windows";
42+
meta => { "CFE-1840", "ENT-10961" };
43+
44+
commands:
45+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
46+
}
47+
48+
bundle agent check
49+
{
50+
vars:
51+
"expected"
52+
string => "I'm mutable";
53+
"actual"
54+
string => readfile("/tmp/01_immutable.txt");
55+
56+
classes:
57+
"ok"
58+
expression => strcmp("$(actual)", "$(expected)");
59+
60+
methods:
61+
"any"
62+
usebundle => dcs_passif("ok", "$(this.promise_filename)"),
63+
inherit => "true";
64+
65+
reports:
66+
any::
67+
"Expected: '$(expected)', actual: '$(actual)'";
68+
}
69+
70+
bundle agent destroy
71+
{
72+
files:
73+
# Make sure immutable bit is not set
74+
"/tmp/01_immutable.txt"
75+
fsattrs => set_mutable,
76+
delete => tidy;
77+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
body fsattrs set_immutable
2+
{
3+
immutable => "true";
4+
}
5+
6+
bundle agent main
7+
{
8+
files:
9+
"/tmp/01_immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
##############################################################################
2+
#
3+
# Test that immutable bit can be cleared by agent with fsattrs immutable
4+
# constraint set to false.
5+
#
6+
##############################################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
version => "1.0";
13+
}
14+
15+
body fsattrs set_immutable
16+
{
17+
immutable => "true";
18+
}
19+
20+
body fsattrs set_mutable
21+
{
22+
immutable => "false";
23+
}
24+
25+
bundle agent init
26+
{
27+
files:
28+
"/tmp/02_immutable.txt"
29+
content => "I'm immutable",
30+
fsattrs => set_immutable;
31+
}
32+
33+
bundle agent test
34+
{
35+
meta:
36+
"description" -> { "CFE-1840", "ENT-10961" }
37+
string => "Test that immutable bit can be cleared by agent with fsattrs immutable constraint set to false";
38+
39+
# "test_soft_fail" will not work here, because init will not be able to set
40+
# the immutable bit, hence the agent will be able to mutate it, even without
41+
# actually clearing it.
42+
"test_skip_unsupported" string => "hpux|aix|windows";
43+
meta => { "CFE-1840", "ENT-10961" };
44+
45+
commands:
46+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
47+
}
48+
49+
bundle agent check
50+
{
51+
vars:
52+
"expected"
53+
string => "I'm mutable";
54+
"actual"
55+
string => readfile("/tmp/02_immutable.txt");
56+
57+
classes:
58+
"ok"
59+
expression => strcmp("$(actual)", "$(expected)");
60+
61+
methods:
62+
"any"
63+
usebundle => dcs_passif("ok", "$(this.promise_filename)"),
64+
inherit => "true";
65+
66+
reports:
67+
any::
68+
"Expected: '$(expected)', actual: '$(actual)'";
69+
}
70+
71+
bundle agent destroy
72+
{
73+
files:
74+
# Make sure immutable bit is not set
75+
"/tmp/02_immutable.txt"
76+
fsattrs => set_mutable,
77+
delete => tidy;
78+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
body fsattrs set_immutable
2+
{
3+
immutable => "false";
4+
}
5+
6+
bundle agent main
7+
{
8+
files:
9+
"/tmp/02_immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}

0 commit comments

Comments
 (0)