Skip to content

Commit 672d59a

Browse files
committed
Acceptance test: override immutable bit with edit_xml
Added acceptance test to test that the edit_xml 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 3411b44 commit 672d59a

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_xml 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_06.txt"
23+
content => '<foo>I\'m immutable</foo>';
24+
25+
commands:
26+
"chattr +i /tmp/immutable_06.txt"
27+
contain => in_shell;
28+
}
29+
30+
bundle edit_xml edit_foo
31+
{
32+
set_text:
33+
"But agent can override"
34+
select_xpath => "/foo";
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_xml attribute";
42+
43+
"test_soft_fail"
44+
string => "hpux|aix|windows",
45+
meta => { "CFE-1840", "ENT-10961" };
46+
47+
files:
48+
"/tmp/immutable_06.txt"
49+
fsattrs => set_immutable,
50+
edit_xml => edit_foo;
51+
}
52+
53+
bundle agent check
54+
{
55+
vars:
56+
"expected"
57+
string => '<?xml version="1.0"?>$(const.n)<foo>But agent can override</foo>$(const.n)';
58+
"actual"
59+
string => readfile("/tmp/immutable_06.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: '$(expected)', actual: '$(actual)'";
72+
}
73+
74+
bundle agent destroy
75+
{
76+
commands:
77+
"chattr -i /tmp/immutable_06.txt"
78+
contain => in_shell,
79+
handle => "is mutable";
80+
81+
files:
82+
"/tmp/immutable_06.txt"
83+
delete => tidy,
84+
depends_on => { "is mutable" };
85+
"/tmp/immutable_06.txt.cf-before-edit"
86+
delete => tidy;
87+
}

0 commit comments

Comments
 (0)