Skip to content

Commit cc559b7

Browse files
committed
Added tests for sys.policy_version
Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent d25b3b2 commit cc559b7

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

libenv/sysinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3950,7 +3950,7 @@ static void SysPolicyVersion(EvalContext *ctx)
39503950
if (version != NULL)
39513951
{
39523952
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, "policy_version", version, CF_DATA_TYPE_STRING,
3953-
"inventory,source=agent,attribute_name=CFEngine policy version,derived-from=common_control.version");
3953+
"inventory,source=agent,attribute_name=CFEngine policy version,derived-from=default:control_common.version");
39543954
}
39553955
}
39563956

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
body common control
2+
{
3+
bundlesequence => { "check" };
4+
version => "1.2.3";
5+
}
6+
7+
bundle agent check
8+
{
9+
classes:
10+
"ok"
11+
expression => and(
12+
strcmp("$(sys.policy_version)", "$(default:control_common.version)"),
13+
strcmp("$(sys.policy_version)", "1.2.3")
14+
);
15+
reports:
16+
ok::
17+
"$(this.promise_filename) Pass";
18+
!ok::
19+
"$(this.promise_filename) FAIL";
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
body common control
2+
{
3+
bundlesequence => { "check" };
4+
}
5+
6+
bundle agent check
7+
{
8+
classes:
9+
"ok"
10+
expression => not(isvariable("sys.policy_version"));
11+
reports:
12+
ok::
13+
"$(this.promise_filename) Pass";
14+
!ok::
15+
"$(this.promise_filename) FAIL";
16+
}

0 commit comments

Comments
 (0)