Skip to content

Commit 1229b41

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

File tree

1 file changed

+93
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)