summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb
AgeCommit message (Collapse)Author
2012-08-09Make sure functions are loaded for each testPatrick Carlisle
The test_helper code in Puppet now resets function state between each test. This patch fixes two spec files where the function was not actually loaded in the tests, causing them to fail.
2012-07-23(Maint) use PuppetlabsSpec::PuppetSeams.parser_scope (2.3.x)Jeff McCune
This patch is the same approach as the one that want into 2.2.x. It covers the functions in 2.3.x that do not exist in 2.2.x. Without this patch all of the spec tests for parser functions in stdlib would instantiate their own scope instances. This is a problem because the standard library is tightly coupled with the internal behavior of Puppet. Tight coupling like this creates failures when we change the internal behavior of Puppet. This is exactly what happened recently when we changed the method signature for the initializer of Puppet::Parser::Scope instances. This patch fixes the problem by creating scope instances using the puppet labs spec helper. The specific method that provides scope instances in Puppet-version-independent way is something like this: let(:scope) { PuppetlabsSpec::PuppetInternals.scope } This patch simply implements this across the board.
2012-03-12(#12357) Fix broken compatibility with Puppet 2.6Jeff McCune
Without this patch, the previous change set to the validate_absolute_path() parser function contains Puppet 2.6 incompatible changes. stdlib 2.x is compatible with Puppet 2.6. These changes are a problem because we cannot introduce backwards incompatible changes in a minor release. This patch fixes the problem by back porting the implementation of the `Puppet::Util.absolute_path?` from 2.7.x to the function block itself. The function block tests to see if `Puppet::Util.absolute_path?` will respond and if not, falls back to the inline back ported implementation. The spec tests have been updated to simulate the behavior of Puppet 2.6 even when running with Puppet 2.7.
2012-03-07(#12357) Add validate_absolute_path() functionJeff McCune
This patch adds a new function to validate if a string is an absolute filesystem path or not. The intent of this is to make this functionality generic and reusable. Josh left a comment in another pull request I had: If node_installdir or $node_vardir is not defined, then we should raise an error, otherwise we may create a scheduled task to an untrusted directory. One solution to this comment is to validate the Puppet variable is an absolute path. Examples of this function look like: function_validate_absolute_path Using Puppet::Parser::Scope.new Garbage inputs validate_absolute_path(nil) should fail validate_absolute_path([nil]) should fail validate_absolute_path({"foo"=>"bar"}) should fail validate_absolute_path({}) should fail validate_absolute_path("") should fail relative paths validate_absolute_path("relative1") should fail validate_absolute_path(".") should fail validate_absolute_path("..") should fail validate_absolute_path("./foo") should fail validate_absolute_path("../foo") should fail validate_absolute_path("etc/puppetlabs/puppet") should fail validate_absolute_path("opt/puppet/bin") should fail absolute paths validate_absolute_path("C:/") should not fail validate_absolute_path("C:\\") should not fail validate_absolute_path("C:\\WINDOWS\\System32") should not fail validate_absolute_path("C:/windows/system32") should not fail validate_absolute_path("X:/foo/bar") should not fail validate_absolute_path("X:\\foo\\bar") should not fail validate_absolute_path("/var/tmp") should not fail validate_absolute_path("/var/lib/puppet") should not fail validate_absolute_path("/var/opt/../lib/puppet") should not fail validate_absolute_path("C:\\Program Files (x86)\\Puppet Labs\\Puppet Enterprise") should not fail validate_absolute_path("C:/Program Files (x86)/Puppet Labs/Puppet Enterprise") should not fail Finished in 0.05637 seconds 23 examples, 0 failures