Skip to content

Commit 587ed51

Browse files
committed
Added acceptance test for immutable with edit_template
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 6b0b70d commit 587ed51

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
##############################################################################
2+
#
3+
# Test that agent can override the immutable bit when using edit_template
4+
# attribute with mustache
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/09_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+
create => "true",
32+
content => "Hello olehermanse!";
33+
34+
commands:
35+
"chattr +i $(global.testfile)"
36+
contain => in_shell;
37+
}
38+
39+
bundle agent test
40+
{
41+
meta:
42+
"description" -> { "CFE-1840", "ENT-10961" }
43+
string => "Test that agent can override the immutable bit on a file while using the edit_template attribute with mustache";
44+
45+
"test_skip_unsupported"
46+
string => "hpux|aix|solaris|windows";
47+
48+
vars:
49+
"object"
50+
data => '{ "user": "larsewi" }';
51+
52+
files:
53+
"$(global.testfile)"
54+
fsattrs => set_immutable,
55+
template_method => "inline_mustache",
56+
edit_template_string => "Hello {{{user}}}!",
57+
template_data => @(object);
58+
}
59+
60+
bundle agent check
61+
{
62+
vars:
63+
"expected"
64+
string => "Hello larsewi!";
65+
"actual"
66+
string => readfile("$(global.testfile)");
67+
68+
classes:
69+
"ok"
70+
expression => strcmp("$(actual)", "$(expected)");
71+
72+
reports:
73+
ok::
74+
"$(this.promise_filename) Pass";
75+
!ok::
76+
"$(this.promise_filename) FAIL";
77+
any::
78+
"Expecting '$(expected)', got '$(actual)'";
79+
}
80+
81+
bundle agent destroy
82+
{
83+
commands:
84+
"chattr -i $(global.testfile)"
85+
contain => in_shell,
86+
handle => "is mutable";
87+
88+
files:
89+
"$(global.testfile)"
90+
delete => tidy,
91+
depends_on => { "is mutable" };
92+
"$(global.testfile).cf-before-edit"
93+
delete => tidy;
94+
}

0 commit comments

Comments
 (0)