-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ENT-4681: Test proper scoping of classes defined from non-default namespace
- Loading branch information
Showing
4 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
tests/acceptance/00_basics/04_bundles/agent-bundle-class-bundle-scope-default-perspective.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/var/cfengine/bin/cf-agent -f- | ||
body common control | ||
{ | ||
inputs => { "../../default.cf.sub" }; | ||
bundlesequence => { | ||
default("$(this.promise_filename)") }; | ||
version => "1.0"; | ||
} | ||
body file control { namespace => "test"; } | ||
bundle agent example | ||
{ | ||
classes: | ||
"TRIGGERED" | ||
expression => "any", | ||
scope => "bundle"; # Bundle scoped classes are NOT visible from other bundles | ||
} | ||
body file control { namespace => "default"; } | ||
bundle agent test | ||
{ | ||
meta: | ||
"description" -> {"ENT-4681" } | ||
string => "Test that bundle scoped classes defined from namespaced | ||
agent bundles are properly scoped. Specifically from the default | ||
namespace."; | ||
|
||
"test_soft_fail" | ||
string => "any", | ||
meta => { "ENT-4681" }; | ||
|
||
methods: | ||
"test:example"; | ||
} | ||
bundle agent check | ||
{ | ||
classes: | ||
# Expectation, default:TRIGGERED is NOT defined | ||
"default_TRIGGERED_OK" | ||
expression => "!default:TRIGGERED"; | ||
|
||
# Expectation, test:TRIGGERED is NOT defined (not visable since it's a bundle scoped class) | ||
"namespaced_TRIGGERED_OK" | ||
expression => "!test:TRIGGERED"; | ||
|
||
# Expectation, TRIGGERED is NOT defined, we are now in the default namespace, the TRIGGERED class was defined in the test namespace with a bundle scope | ||
"TRIGGERED_OK" | ||
expression => "!TRIGGERED"; | ||
|
||
|
||
"pass" and => { | ||
"default_TRIGGERED_OK", | ||
"namespaced_TRIGGERED_OK", | ||
"TRIGGERED_OK", | ||
}; | ||
reports: | ||
pass:: | ||
"Pass $(this.promise_filename)"; | ||
!pass:: | ||
"FAIL $(this.promise_filename)"; | ||
!default_TRIGGERED_OK:: | ||
"Expected 'default:TRIGGERED' to not be seen as defined, but expression '!default:TRIGGERED' resulted in true"; | ||
!namespaced_TRIGGERED_OK:: | ||
"Expected 'test:TRIGGERED' to NOT be seen as defined, but expression '!test:TRIGGERED' resulted in false"; | ||
!TRIGGERED_OK:: | ||
"Expected 'TRIGGERED' to NOT be seen as defined, but expression 'TRIGGERED' resulted in true even without specify the test namespace"; | ||
|
||
} | ||
bundle agent __main__ | ||
{ | ||
|
||
methods: | ||
"test:example"; | ||
"check"; | ||
} |
80 changes: 80 additions & 0 deletions
80
.../acceptance/00_basics/04_bundles/agent-bundle-class-bundle-scope-namespace-perspective.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/var/cfengine/bin/cf-agent -f- | ||
body common control | ||
{ | ||
inputs => { "../../default.cf.sub" }; | ||
bundlesequence => { | ||
default("$(this.promise_filename)") }; | ||
version => "1.0"; | ||
} | ||
body file control { namespace => "test"; } | ||
bundle agent example | ||
{ | ||
classes: | ||
"TRIGGERED" | ||
expression => "any", | ||
scope => "bundle"; # Namespace scoped classes are visible from other bundles | ||
} | ||
bundle agent check | ||
{ | ||
classes: | ||
# Expectation, default:TRIGGERED is NOT defined | ||
"default_TRIGGERED_OK" | ||
expression => "!default:TRIGGERED"; | ||
|
||
# Expectation, test:TRIGGERED is NOT defined (not visable since it's a bundle scoped class) | ||
"namespaced_TRIGGERED_OK" | ||
expression => "!test:TRIGGERED"; | ||
|
||
# Expectation, TRIGGERED is NOT defined, we are now in the test namespace where the TRIGGERED class was defined, but it was bundle scoped, so not visable from another bundle | ||
"TRIGGERED_OK" | ||
expression => "!TRIGGERED"; | ||
|
||
|
||
"pass" and => { | ||
"default_TRIGGERED_OK", | ||
"namespaced_TRIGGERED_OK", | ||
"TRIGGERED_OK", | ||
}; | ||
reports: | ||
pass:: | ||
"Pass $(this.promise_filename)"; | ||
!pass:: | ||
"FAIL $(this.promise_filename)"; | ||
!default_TRIGGERED_OK:: | ||
"Expected 'default:TRIGGERED' to not be seen as defined, but expression '!default:TRIGGERED' resulted in true"; | ||
!namespaced_TRIGGERED_OK:: | ||
"Expected 'test:TRIGGERED' to NOT be seen as defined, but expression '!test:TRIGGERED' resulted in false"; | ||
!TRIGGERED_OK:: | ||
"Expected 'TRIGGERED' to NOT be seen as defined, but expression '!TRIGGERED' resulted in false"; | ||
|
||
} | ||
body file control { namespace => "default"; } | ||
bundle agent test | ||
{ | ||
meta: | ||
"description" -> {"ENT-4681" } | ||
|
||
string => "Test that bundle scoped classes defined from namespaced | ||
agent bundles are properly scoped. Specifically from the perspective of | ||
the non-default namespace itself."; | ||
|
||
|
||
"test_soft_fail" | ||
string => "any", | ||
meta => { "ENT-4681" }; | ||
|
||
methods: | ||
"test:example"; | ||
} | ||
bundle agent check | ||
{ | ||
methods: | ||
"test:check"; | ||
} | ||
bundle agent __main__ | ||
{ | ||
|
||
methods: | ||
"test"; | ||
"check"; | ||
} |
83 changes: 83 additions & 0 deletions
83
tests/acceptance/00_basics/04_bundles/agent-bundle-namespaced-class-default-perspective.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/var/cfengine/bin/cf-agent -f- | ||
body common control | ||
{ | ||
inputs => { "../../default.cf.sub" }; | ||
bundlesequence => { | ||
default("$(this.promise_filename)") }; | ||
version => "1.0"; | ||
} | ||
body file control { namespace => "test"; } | ||
bundle agent example | ||
{ | ||
classes: | ||
"TRIGGERED" | ||
expression => "any", | ||
scope => "namespace"; # Namespace scoped classes are visible from other bundles | ||
|
||
reports: | ||
TRIGGERED:: | ||
"TRIGGERED is defined within $(this.namespace).$(this.bundle)"; | ||
|
||
default:TRIGGERED:: | ||
"default:TRIGGERED is defined within $(this.namespace).$(this.bundle)"; | ||
|
||
test:TRIGGERED:: | ||
"$(this.namespace):TRIGGERED is defined within $(this.namespace).$(this.bundle)"; | ||
} | ||
body file control { namespace => "default"; } | ||
bundle agent test | ||
{ | ||
meta: | ||
"description" -> {"ENT-4681" } | ||
string => "Test that namespace scoped classes defined from namespaced | ||
agent bundles are properly scoped. Specifically from the default | ||
namespace."; | ||
|
||
"test_soft_fail" | ||
string => "any", | ||
meta => { "ENT-4681" }; | ||
|
||
methods: | ||
"test:example"; | ||
} | ||
bundle agent check | ||
{ | ||
classes: | ||
# Expectation, default:TRIGGERED is NOT defined | ||
"default_TRIGGERED_OK" | ||
expression => "!default:TRIGGERED"; | ||
|
||
# Expectation, test:TRIGGERED is defined (visable since it's a namespace scoped class) | ||
"namespaced_TRIGGERED_OK" | ||
expression => "test:TRIGGERED"; | ||
|
||
# Expectation, TRIGGERED is NOT defined, we are now in the default namespace, the TRIGGERED class was defined in the test namespace and should not be seen without explicitly using it's namespace | ||
"TRIGGERED_OK" | ||
expression => "!TRIGGERED"; | ||
|
||
|
||
"pass" and => { | ||
"default_TRIGGERED_OK", | ||
"namespaced_TRIGGERED_OK", | ||
"TRIGGERED_OK", | ||
}; | ||
reports: | ||
pass:: | ||
"Pass $(this.promise_filename)"; | ||
!pass:: | ||
"FAIL $(this.promise_filename)"; | ||
!default_TRIGGERED_OK:: | ||
"Expected 'default:TRIGGERED' to not be seen as defined, but expression '!default:TRIGGERED' resulted in true"; | ||
!namespaced_TRIGGERED_OK:: | ||
"Expected 'test:TRIGGERED' to be seen as defined, but expression 'test:TRIGGERED' resulted in false"; | ||
!TRIGGERED_OK:: | ||
"Expected 'TRIGGERED' to NOT be seen as defined, but expression 'TRIGGERED' resulted in true even without specify the test namespace"; | ||
|
||
} | ||
bundle agent __main__ | ||
{ | ||
|
||
methods: | ||
"test:example"; | ||
"check"; | ||
} |
80 changes: 80 additions & 0 deletions
80
tests/acceptance/00_basics/04_bundles/agent-bundle-namespaced-class-namespace-perspective.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/var/cfengine/bin/cf-agent -f- | ||
body common control | ||
{ | ||
inputs => { "../../default.cf.sub" }; | ||
bundlesequence => { | ||
default("$(this.promise_filename)") }; | ||
version => "1.0"; | ||
} | ||
body file control { namespace => "test"; } | ||
bundle agent example | ||
{ | ||
classes: | ||
"TRIGGERED" | ||
expression => "any", | ||
scope => "namespace"; # Namespace scoped classes are visible from other bundles | ||
} | ||
bundle agent check | ||
{ | ||
classes: | ||
# Expectation, default:TRIGGERED is NOT defined | ||
"default_TRIGGERED_OK" | ||
expression => "!default:TRIGGERED"; | ||
|
||
# Expectation, test:TRIGGERED is defined (visable since it's a namespace scoped class) | ||
"namespaced_TRIGGERED_OK" | ||
expression => "test:TRIGGERED"; | ||
|
||
# Expectation, TRIGGERED is defined, we are now in the test namespace where the TRIGGERED class was defined. We should be able to reference classes defined in our current namespace without being explicit | ||
"TRIGGERED_OK" | ||
expression => "TRIGGERED"; | ||
|
||
|
||
"pass" and => { | ||
"default_TRIGGERED_OK", | ||
"namespaced_TRIGGERED_OK", | ||
"TRIGGERED_OK", | ||
}; | ||
reports: | ||
pass:: | ||
"Pass $(this.promise_filename)"; | ||
!pass:: | ||
"FAIL $(this.promise_filename)"; | ||
!default_TRIGGERED_OK:: | ||
"Expected 'default:TRIGGERED' to not be seen as defined, but expression '!default:TRIGGERED' resulted in true"; | ||
!namespaced_TRIGGERED_OK:: | ||
"Expected 'test:TRIGGERED' to be seen as defined, but expression 'test:TRIGGERED' resulted in false"; | ||
!TRIGGERED_OK:: | ||
"Expected 'TRIGGERED' to be seen as defined, but expression 'TRIGGERED' resulted in false"; | ||
|
||
} | ||
body file control { namespace => "default"; } | ||
bundle agent test | ||
{ | ||
meta: | ||
"description" -> {"ENT-4681" } | ||
|
||
string => "Test that namespace scoped classes defined from namespaced | ||
agent bundles are properly scoped. Specifically from the perspective of | ||
the non-default namespace itself."; | ||
|
||
|
||
"test_soft_fail" | ||
string => "any", | ||
meta => { "ENT-4681" }; | ||
|
||
methods: | ||
"test:example"; | ||
} | ||
bundle agent check | ||
{ | ||
methods: | ||
"test:check"; | ||
} | ||
bundle agent __main__ | ||
{ | ||
|
||
methods: | ||
"test"; | ||
"check"; | ||
} |