Skip to content

Commit 6b70a44

Browse files
committed
Acceptance test: override immutable bit with edit_template (mustache)
Added acceptance test to test that the edit_template attribute (with mustache) of the files promise can override the immutable bit of the destination file. It just works. No need to edit the code further. Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent fdc7304 commit 6b70a44

File tree

1 file changed

+88
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)