Skip to content

Commit 6e1442e

Browse files
committed
Store the testfile in a variable for easier maintenance
Ticket: CFE-1840, ENT-10961 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent e8dcd3e commit 6e1442e

13 files changed

+183
-92
lines changed

tests/acceptance/10_files/unsafe/00_immutable.cf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ body common control
1111
version => "1.0";
1212
}
1313

14+
bundle agent global
15+
{
16+
vars:
17+
"testfile"
18+
string => "/tmp/00_immutable.txt";
19+
}
20+
1421
body fsattrs set_immutable
1522
{
1623
immutable => "true";
@@ -19,11 +26,11 @@ body fsattrs set_immutable
1926
bundle agent init
2027
{
2128
files:
22-
"/tmp/immutable_00.txt"
29+
"$(global.testfile)"
2330
create => "true";
2431

2532
commands:
26-
"chattr -i /tmp/immutable_00.txt"
33+
"chattr -i $(global.testfile)"
2734
contain => in_shell;
2835
}
2936

@@ -38,26 +45,26 @@ bundle agent test
3845
meta => { "CFE-1840", "ENT-10961" };
3946

4047
files:
41-
"/tmp/immutable_00.txt"
48+
"$(global.testfile)"
4249
fsattrs => set_immutable;
4350
}
4451

4552
bundle agent check
4653
{
4754
methods:
4855
"check"
49-
usebundle => dcs_passif_output(".*Immutable.*", "", "lsattr -l /tmp/immutable_00.txt", "$(this.promise_filename)");
56+
usebundle => dcs_passif_output(".*Immutable.*", "", "lsattr -l $(global.testfile)", "$(this.promise_filename)");
5057
}
5158

5259
bundle agent destroy
5360
{
5461
commands:
55-
"chattr -i /tmp/immutable_00.txt"
62+
"chattr -i $(global.testfile)"
5663
contain => in_shell,
5764
handle => "is mutable";
5865

5966
files:
60-
"/tmp/immutable_00.txt"
67+
"$(global.testfile)"
6168
delete => tidy,
6269
depends_on => { "is mutable" };
6370
}

tests/acceptance/10_files/unsafe/01_immutable.cf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ body common control
1111
version => "1.0";
1212
}
1313

14+
bundle agent global
15+
{
16+
vars:
17+
"testfile"
18+
string => "/tmp/01_immutable.txt";
19+
}
20+
1421
body fsattrs clear_immutable
1522
{
1623
immutable => "false";
@@ -19,11 +26,11 @@ body fsattrs clear_immutable
1926
bundle agent init
2027
{
2128
files:
22-
"/tmp/immutable_01.txt"
29+
"$(global.testfile)"
2330
create => "true";
2431

2532
commands:
26-
"chattr +i /tmp/immutable_01.txt"
33+
"chattr +i $(global.testfile)"
2734
contain => in_shell;
2835
}
2936

@@ -38,26 +45,26 @@ bundle agent test
3845
meta => { "CFE-1840", "ENT-10961" };
3946

4047
files:
41-
"/tmp/immutable_01.txt"
48+
"$(global.testfile)"
4249
fsattrs => clear_immutable;
4350
}
4451

4552
bundle agent check
4653
{
4754
methods:
4855
"check"
49-
usebundle => dcs_passif_output(".*", ".*Immutable.*", "lsattr -l /tmp/immutable_01.txt", "$(this.promise_filename)");
56+
usebundle => dcs_passif_output(".*", ".*Immutable.*", "lsattr -l $(global.testfile)", "$(this.promise_filename)");
5057
}
5158

5259
bundle agent destroy
5360
{
5461
commands:
55-
"chattr -i /tmp/immutable_01.txt"
62+
"chattr -i $(global.testfile)"
5663
contain => in_shell,
5764
handle => "is mutable";
5865

5966
files:
60-
"/tmp/immutable_01.txt"
67+
"$(global.testfile)"
6168
delete => tidy,
6269
depends_on => { "is mutable" };
6370
}

tests/acceptance/10_files/unsafe/02_immutable.cf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ body common control
1212
version => "1.0";
1313
}
1414

15+
bundle agent global
16+
{
17+
vars:
18+
"testfile"
19+
string => "/tmp/02_immutable.txt";
20+
}
21+
1522
body fsattrs set_immutable
1623
{
1724
immutable => "true";
@@ -20,11 +27,11 @@ body fsattrs set_immutable
2027
bundle agent init
2128
{
2229
files:
23-
"/tmp/immutable_02.txt"
30+
"$(global.testfile)"
2431
content => "I'm immutable";
2532

2633
commands:
27-
"chattr +i /tmp/immutable_02.txt"
34+
"chattr +i $(global.testfile)"
2835
contain => in_shell;
2936
}
3037

@@ -39,7 +46,7 @@ bundle agent test
3946
meta => { "CFE-1840", "ENT-10961" };
4047

4148
files:
42-
"/tmp/immutable_02.txt"
49+
"$(global.testfile)"
4350
fsattrs => set_immutable,
4451
content => "But agent can override";
4552
}
@@ -50,7 +57,7 @@ bundle agent check
5057
"expected"
5158
string => "But agent can override";
5259
"actual"
53-
string => readfile("/tmp/immutable_02.txt");
60+
string => readfile("$(global.testfile)");
5461

5562
classes:
5663
"ok"
@@ -68,12 +75,12 @@ bundle agent check
6875
bundle agent destroy
6976
{
7077
commands:
71-
"chattr -i /tmp/immutable_02.txt"
78+
"chattr -i $(global.testfile)"
7279
contain => in_shell,
7380
handle => "is mutable";
7481

7582
files:
76-
"/tmp/immutable_02.txt"
83+
"$(global.testfile)"
7784
delete => tidy,
7885
depends_on => { "is mutable" };
7986
}

tests/acceptance/10_files/unsafe/03_immutable.cf

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ body common control
1212
version => "1.0";
1313
}
1414

15+
bundle agent global
16+
{
17+
vars:
18+
"testfile"
19+
string => "/tmp/03_immutable.txt";
20+
}
21+
1522
body fsattrs set_immutable
1623
{
1724
immutable => "true";
@@ -20,13 +27,13 @@ body fsattrs set_immutable
2027
bundle agent init
2128
{
2229
files:
23-
"/tmp/immutable_03.txt"
30+
"$(global.testfile)"
2431
content => "I'm immutable";
2532
"/tmp/content.txt"
2633
content => "But agent can override";
2734

2835
commands:
29-
"chattr +i /tmp/immutable_03.txt"
36+
"chattr +i $(global.testfile)"
3037
contain => in_shell;
3138
}
3239

@@ -41,7 +48,7 @@ bundle agent test
4148
meta => { "CFE-1840", "ENT-10961" };
4249

4350
files:
44-
"/tmp/immutable_03.txt"
51+
"$(global.testfile)"
4552
fsattrs => set_immutable,
4653
copy_from => local_dcp("/tmp/content.txt");
4754
}
@@ -52,7 +59,7 @@ bundle agent check
5259
"expected"
5360
string => "But agent can override";
5461
"actual"
55-
string => readfile("/tmp/immutable_03.txt");
62+
string => readfile("$(global.testfile)");
5663

5764
classes:
5865
"ok"
@@ -70,15 +77,15 @@ bundle agent check
7077
bundle agent destroy
7178
{
7279
commands:
73-
"chattr -i /tmp/immutable_03.txt"
80+
"chattr -i $(global.testfile)"
7481
contain => in_shell,
7582
handle => "is mutable";
7683

7784
files:
78-
"/tmp/immutable_03.txt"
85+
"$(global.testfile)"
7986
delete => tidy,
8087
depends_on => { "is mutable" };
81-
"/tmp/immutable_03.txt.cfsaved"
88+
"$(global.testfile).cfsaved"
8289
delete => tidy;
8390
"/tmp/content.txt"
8491
delete => tidy;

tests/acceptance/10_files/unsafe/04_immutable.cf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ body common control
1212
version => "1.0";
1313
}
1414

15+
bundle agent global
16+
{
17+
vars:
18+
"testfile"
19+
string => "/tmp/04_immutable.txt";
20+
}
21+
1522
body fsattrs set_immutable
1623
{
1724
immutable => "true";
@@ -20,11 +27,11 @@ body fsattrs set_immutable
2027
bundle agent init
2128
{
2229
files:
23-
"/tmp/immutable_04.txt"
30+
"$(global.testfile)"
2431
content => "I'm immutable";
2532

2633
commands:
27-
"chattr +i /tmp/immutable_04.txt"
34+
"chattr +i $(global.testfile)"
2835
contain => in_shell;
2936
}
3037

@@ -39,7 +46,7 @@ bundle agent test
3946
meta => { "CFE-1840", "ENT-10961" };
4047

4148
files:
42-
"/tmp/immutable_04.txt"
49+
"$(global.testfile)"
4350
fsattrs => set_immutable,
4451
delete => tidy;
4552
}
@@ -48,7 +55,7 @@ bundle agent check
4855
{
4956
classes:
5057
"ok"
51-
expression => not(fileexists("/tmp/immutable_04.txt"));
58+
expression => not(fileexists("$(global.testfile)"));
5259

5360
reports:
5461
ok::
@@ -60,12 +67,12 @@ bundle agent check
6067
bundle agent destroy
6168
{
6269
commands:
63-
"chattr -i /tmp/immutable_04.txt"
70+
"chattr -i $(global.testfile)"
6471
contain => in_shell,
6572
handle => "is mutable";
6673

6774
files:
68-
"/tmp/immutable_04.txt"
75+
"$(global.testfile)"
6976
delete => tidy,
7077
depends_on => { "is mutable" };
7178
}

tests/acceptance/10_files/unsafe/05_immutable.cf

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ body common control
1212
version => "1.0";
1313
}
1414

15+
bundle agent global
16+
{
17+
vars:
18+
"testfile"
19+
string => "/tmp/05_immutable.txt";
20+
}
21+
1522
body fsattrs set_immutable
1623
{
1724
immutable => "true";
@@ -20,11 +27,11 @@ body fsattrs set_immutable
2027
bundle agent init
2128
{
2229
files:
23-
"/tmp/immutable_05.txt"
30+
"$(global.testfile)"
2431
content => "I'm immutable";
2532

2633
commands:
27-
"chattr +i /tmp/immutable_05.txt"
34+
"chattr +i $(global.testfile)"
2835
contain => in_shell;
2936
}
3037

@@ -45,7 +52,7 @@ bundle agent test
4552
meta => { "CFE-1840", "ENT-10961" };
4653

4754
files:
48-
"/tmp/immutable_05.txt"
55+
"$(global.testfile)"
4956
fsattrs => set_immutable,
5057
edit_line => insert_line;
5158
}
@@ -56,7 +63,7 @@ bundle agent check
5663
"expected"
5764
string => "I'm immutable$(const.n)But agent can override$(const.n)";
5865
"actual"
59-
string => readfile("/tmp/immutable_05.txt");
66+
string => readfile("$(global.testfile)");
6067

6168
classes:
6269
"ok"
@@ -74,14 +81,14 @@ bundle agent check
7481
bundle agent destroy
7582
{
7683
commands:
77-
"chattr -i /tmp/immutable_05.txt"
84+
"chattr -i $(global.testfile)"
7885
contain => in_shell,
7986
handle => "is mutable";
8087

8188
files:
82-
"/tmp/immutable_05.txt"
89+
"$(global.testfile)"
8390
delete => tidy,
8491
depends_on => { "is mutable" };
85-
"/tmp/immutable_05.txt.cf-before-edit"
92+
"$(global.testfile).cf-before-edit"
8693
delete => tidy;
8794
}

0 commit comments

Comments
 (0)