Skip to content

Commit 2818e3a

Browse files
committed
Acceptance test: override immutable bit with edit_line
Added acceptance test to test that the edit_line 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 2abbb50 commit 2818e3a

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
##############################################################################
2+
#
3+
# Test that agent can override the immutable bit when using edit_line
4+
# attribute
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+
bundle agent init
21+
{
22+
files:
23+
"/tmp/immutable_05.txt"
24+
content => "I'm immutable";
25+
26+
commands:
27+
"chattr +i /tmp/immutable_05.txt"
28+
contain => in_shell;
29+
}
30+
31+
bundle edit_line insert_line
32+
{
33+
insert_lines:
34+
"But agent can override";
35+
}
36+
37+
bundle agent test
38+
{
39+
meta:
40+
"description" -> { "CFE-1840", "ENT-10961" }
41+
string => "Test that agent can override the immutable bit on a file while using the edit_line attribute";
42+
43+
"test_soft_fail"
44+
string => "hpux|aix|windows",
45+
meta => { "CFE-1840", "ENT-10961" };
46+
47+
files:
48+
"/tmp/immutable_05.txt"
49+
fsattrs => set_immutable,
50+
edit_line => insert_line;
51+
}
52+
53+
bundle agent check
54+
{
55+
vars:
56+
"expected"
57+
string => "I'm immutable$(const.n)But agent can override$(const.n)";
58+
"actual"
59+
string => readfile("/tmp/immutable_05.txt");
60+
61+
classes:
62+
"ok"
63+
expression => strcmp("$(actual)", "$(expected)");
64+
65+
reports:
66+
ok::
67+
"$(this.promise_filename) Pass";
68+
!ok::
69+
"$(this.promise_filename) FAIL";
70+
any::
71+
"Expected:$(const.n)'$(expected)',$(const.n)actual:$(const.n)'$(actual)'";
72+
}
73+
74+
bundle agent destroy
75+
{
76+
commands:
77+
"chattr -i /tmp/immutable_05.txt"
78+
contain => in_shell,
79+
handle => "is mutable";
80+
81+
files:
82+
"/tmp/immutable_05.txt"
83+
delete => tidy,
84+
depends_on => { "is mutable" };
85+
"/tmp/immutable_05.txt.cf-before-edit"
86+
delete => tidy;
87+
}

0 commit comments

Comments
 (0)