Skip to content

Commit 081704d

Browse files
committed
Acceptance test: override immutable bit with copy_from
Added acceptance test to test that the copy_from attribute of the files promise can override the immutable bit of the destination file. Ticket: ENT-10961, CFE-1840 Changelog: Commit Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 52375c6 commit 081704d

File tree

1 file changed

+83
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)