1# Test that merged data does not inherit variables from calling bundle
2
3body common control
4{
5      inputs => { "../../default.cf.sub" };
6      bundlesequence => { default("$(this.promise_filename)") };
7}
8
9bundle agent test
10{
11  meta:
12      "description" -> { "CFE-2551" }
13        string => "Test that merged data does not include variables from calling bundle.";
14
15      "test_soft_fail"
16        string => "any",
17        meta => { "CFE-2551"};
18
19  vars:
20
21      "a" string => "string a";
22      "b" string => "string b";
23
24      "vars1[a]" string => "$(a)";
25      "vars1[b]" string => "$(b)";
26
27  methods:
28
29      # Call bundle that will define and merge it's own vars1 data structure.
30
31      "Call another bundle"
32        usebundle => called_by_bundle_test;
33
34}
35
36bundle agent called_by_bundle_test
37{
38  vars:
39      "c" string => "string c";
40      "vars1[c]" string => "$(c)";
41
42      # Create a new data structure NOT including data from calling bundle
43
44      "merged_data_vars"
45        data => mergedata('{ "vars1": vars1 }');
46
47    DEBUG|EXTRA::
48      # We only care to stringify this if we need the debug reports
49      "merged_data_vars_string"
50        string => storejson( merged_data_vars );
51
52  reports:
53    DEBUG|EXTRA::
54      "Got:$(const.n)$(merged_data_vars_string)";
55      'Expect:
56{
57  "vars1": {
58    "c": "string c"
59  }
60}';
61}
62
63
64bundle agent check
65{
66  classes:
67
68      # We pass if the variable indicies found in bundle test are NOT found in
69      # the bundle it called, and we find the index defined in the bundle it
70      # called that we expect.
71
72      "pass"
73        expression => and(
74                           and(
75                               not( isvariable("called_by_bundle_test.merged_data_vars[vars1][a]")),
76                               not( isvariable("called_by_bundle_test.merged_data_vars[vars1][b]"))
77                           ),
78                           isvariable("called_by_bundle_test.merged_data_vars[vars1][c]")
79        );
80
81      # We fail if the variable indicies found in bundle test are also found in
82      # the bundle it called.
83
84      "fail"
85        or => {
86                isvariable( "called_by_bundle_test.merged_data_vars[vars1][a]" ),
87                isvariable( "called_by_bundle_test.merged_data_vars[vars1][b]" ),
88        };
89
90
91  reports:
92
93    fail::
94      "$(this.promise_filename) FAIL";
95
96    pass::
97      "$(this.promise_filename) Pass";
98  }
99