Skip to content

Commit b0ce49b

Browse files
committed
Added acceptance test for immutable with rename
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 40a4547 commit b0ce49b

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
##############################################################################
2+
#
3+
# Test that agent can override the immutable bit when using rename attribute
4+
#
5+
##############################################################################
6+
7+
body common control
8+
{
9+
inputs => { "../../default.cf.sub" };
10+
bundlesequence => { default("$(this.promise_filename)") };
11+
version => "1.0";
12+
}
13+
14+
bundle agent global
15+
{
16+
vars:
17+
"testfile"
18+
string => "/tmp/12_immutable.txt";
19+
}
20+
21+
body fsattrs set_immutable
22+
{
23+
immutable => "true";
24+
}
25+
26+
bundle agent init
27+
{
28+
files:
29+
"$(global.testfile)"
30+
create => "true";
31+
32+
commands:
33+
"chattr +i $(global.testfile)"
34+
contain => in_shell;
35+
}
36+
37+
body rename nuke
38+
{
39+
disable => "true";
40+
disable_suffix => ".nuked";
41+
}
42+
43+
bundle agent test
44+
{
45+
meta:
46+
"description" -> { "CFE-1840", "ENT-10961" }
47+
string => "Test that agent can override the immutable bit on a file while using the rename attribute";
48+
49+
"test_skip_unsupported"
50+
string => "hpux|aix|solaris|windows";
51+
52+
files:
53+
"$(global.testfile)"
54+
fsattrs => set_immutable,
55+
rename => nuke;
56+
}
57+
58+
bundle agent check
59+
{
60+
classes:
61+
"original_exists"
62+
expression => fileexists("$(global.testfile)");
63+
"nuked_exists"
64+
expression => fileexists("$(global.testfile).nuked");
65+
"ok"
66+
expression => "!original_exists&nuked_exists";
67+
68+
reports:
69+
ok::
70+
"$(this.promise_filename) Pass";
71+
!ok::
72+
"$(this.promise_filename) FAIL";
73+
any::
74+
"Expected file '$(global.testfile)' to not exists $(with)"
75+
with => ifelse("!original_exists", "and it does not", "but it does");
76+
"Expected file '$(global.testfile).nuked' to exists $(with)"
77+
with => ifelse("nuked_exists", "and it does", "but it does not");
78+
}
79+
80+
bundle agent destroy
81+
{
82+
commands:
83+
"chattr -i $(global.testfile)"
84+
contain => in_shell,
85+
handle => "orig is mutable",
86+
if => fileexists("$(global.testfile)");
87+
"chattr -i $(global.testfile).nuked"
88+
contain => in_shell,
89+
handle => "nuked is mutable",
90+
if => fileexists("$(global.testfile).nuked");
91+
92+
files:
93+
"$(global.testfile)"
94+
delete => tidy,
95+
depends_on => { "orig is mutable" };
96+
"$(global.testfile).nuked"
97+
delete => tidy,
98+
depends_on => { "nuked is mutable" };
99+
}

0 commit comments

Comments
 (0)