Skip to content

Commit 9f2b689

Browse files
committed
Added acceptance test for immutable with edit_xml
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 8e85661 commit 9f2b689

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_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+
bundle agent global
15+
{
16+
vars:
17+
"testfile"
18+
string => "/tmp/06_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+
content => '<foo>I\'m immutable</foo>';
31+
32+
commands:
33+
"chattr +i $(global.testfile)"
34+
contain => in_shell;
35+
}
36+
37+
bundle edit_xml edit_foo
38+
{
39+
set_text:
40+
"But agent can override"
41+
select_xpath => "/foo";
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_xml attribute";
49+
50+
"test_skip_unsupported"
51+
string => "hpux|aix|solaris|windows";
52+
53+
files:
54+
"$(global.testfile)"
55+
fsattrs => set_immutable,
56+
edit_xml => edit_foo;
57+
}
58+
59+
bundle agent check
60+
{
61+
vars:
62+
"expected"
63+
string => '<?xml version="1.0"?>$(const.n)<foo>But agent can override</foo>$(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: '$(expected)', actual: '$(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)