Skip to content

Commit e33b4d3

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

File tree

6 files changed

+254
-0
lines changed

6 files changed

+254
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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/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+
42+
commands:
43+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
44+
}
45+
46+
bundle agent check
47+
{
48+
vars:
49+
"expected"
50+
string => "I'm immutable";
51+
"actual"
52+
string => readfile("/tmp/immutable.txt");
53+
54+
classes:
55+
"ok"
56+
expression => strcmp("$(actual)", "$(expected)");
57+
58+
methods:
59+
"any"
60+
usebundle => dcs_passif("ok", "$(this.promise_filename)");
61+
62+
reports:
63+
"Expected: '$(expected)', actual: '$(actual)'";
64+
}
65+
66+
bundle agent destroy
67+
{
68+
files:
69+
# Make sure immutable bit is not set
70+
"/tmp/immutable.txt"
71+
fsattrs => set_mutable;
72+
}
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/immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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/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"
40+
string => "hpux|aix|windows";
41+
42+
commands:
43+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
44+
}
45+
46+
bundle agent check
47+
{
48+
vars:
49+
"expected"
50+
string => "I'm mutable";
51+
"actual"
52+
string => readfile("/tmp/immutable.txt");
53+
54+
classes:
55+
"ok"
56+
expression => strcmp("$(actual)", "$(expected)");
57+
58+
methods:
59+
"any"
60+
usebundle => dcs_passif("ok", "$(this.promise_filename)");
61+
62+
reports:
63+
any::
64+
"Expected: '$(expected)', actual: '$(actual)'";
65+
}
66+
67+
bundle agent destroy
68+
{
69+
files:
70+
# Make sure immutable bit is not set
71+
"/tmp/immutable.txt"
72+
fsattrs => set_mutable;
73+
}
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/immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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/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"
40+
string => "hpux|aix|windows";
41+
42+
commands:
43+
"$(sys.cf_agent) -Kf $(this.promise_filename).sub";
44+
}
45+
46+
bundle agent check
47+
{
48+
vars:
49+
"expected"
50+
string => "I'm mutable";
51+
"actual"
52+
string => readfile("/tmp/immutable.txt");
53+
54+
classes:
55+
"ok"
56+
expression => strcmp("$(actual)", "$(expected)");
57+
58+
methods:
59+
"any"
60+
usebundle => dcs_passif("ok", "$(this.promise_filename)");
61+
62+
reports:
63+
any::
64+
"Expected: '$(expected)', actual: '$(actual)'";
65+
}
66+
67+
bundle agent destroy
68+
{
69+
files:
70+
# Make sure immutable bit is not set
71+
"$(G.testfile)"
72+
fsattrs => set_mutable;
73+
}
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/immutable.txt"
10+
content => "I'm mutable",
11+
fsattrs => set_immutable;
12+
}

0 commit comments

Comments
 (0)