Skip to content

Commit 6747fcd

Browse files
committed
Acceptance test: override immutable bit with rename
Added acceptance test to test that the rename attribute of the files promise can override the immutable bit of the destination file. Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent cee7907 commit 6747fcd

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
body fsattrs set_immutable
15+
{
16+
immutable => "true";
17+
}
18+
19+
bundle agent init
20+
{
21+
files:
22+
"/tmp/immutable_12.txt"
23+
create => "true";
24+
25+
commands:
26+
"chattr +i /tmp/immutable_12.txt"
27+
contain => in_shell;
28+
}
29+
30+
body rename nuke
31+
{
32+
disable => "true";
33+
disable_suffix => ".nuked";
34+
}
35+
36+
bundle agent test
37+
{
38+
meta:
39+
"description" -> { "CFE-1840", "ENT-10961" }
40+
string => "Test that agent can override the immutable bit on a file while using the rename attribute";
41+
42+
"test_soft_fail"
43+
string => "hpux|aix|windows",
44+
meta => { "CFE-1840", "ENT-10961" };
45+
46+
files:
47+
"/tmp/immutable_12.txt"
48+
fsattrs => set_immutable,
49+
rename => nuke;
50+
}
51+
52+
bundle agent check
53+
{
54+
classes:
55+
"original_exists"
56+
expression => fileexists("/tmp/immutable_12.txt");
57+
"nuked_exists"
58+
expression => fileexists("/tmp/immutable_12.txt.nuked");
59+
"ok"
60+
expression => "!original_exists&nuked_exists";
61+
62+
reports:
63+
ok::
64+
"$(this.promise_filename) Pass";
65+
!ok::
66+
"$(this.promise_filename) FAIL";
67+
any::
68+
"Expected file '/tmp/immutable_12.txt' to not exists $(with)"
69+
with => ifelse("!original_exists", "and it does not", "but it does");
70+
"Expected file '/tmp/immutable_12.txt.nuked' to exists $(with)"
71+
with => ifelse("nuked_exists", "and it does", "but it does not");
72+
}
73+
74+
bundle agent destroy
75+
{
76+
commands:
77+
"chattr -i /tmp/immutable_12.txt"
78+
contain => in_shell,
79+
handle => "is mutable",
80+
if => fileexists("/tmp/immutable_12.txt");
81+
82+
files:
83+
"/tmp/immutable_12.txt"
84+
delete => tidy,
85+
depends_on => { "is mutable" };
86+
files:
87+
"/tmp/immutable_12.txt.nuked"
88+
delete => tidy;
89+
}

0 commit comments

Comments
 (0)