diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2010-03-03 20:35:46 +0100 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | b581c2348e784ce5d857a4c1c0686399b87cc13f (patch) | |
| tree | d85c3e9d79d99c3ad9a2a679fa4d8666e74a2158 /spec/unit/parser | |
| parent | 490a03d55e57a5a54202207b44eb406dda4c8c65 (diff) | |
| download | puppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.tar.gz puppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.tar.xz puppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.zip | |
Fix #3229 - use original value in case/selector regex matching
The issue is that case/selectors are downcasing the value before it
is compared to the options.
Unfortunately regex are matching in a case sensitive way, which would
make the following manifest fail:
$var = "CaseSensitive"
case $var {
/CaseSensitive/: {
notice("worked")
}
default: {
fail "miserably"
}
}
This patch fixes the issue by making sure the regexp match is done
one the original (not downcased) value, but still doing a case
sensitive match.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/ast/casestatement.rb | 10 | ||||
| -rwxr-xr-x | spec/unit/parser/ast/leaf.rb | 13 | ||||
| -rwxr-xr-x | spec/unit/parser/ast/selector.rb | 10 |
3 files changed, 13 insertions, 20 deletions
diff --git a/spec/unit/parser/ast/casestatement.rb b/spec/unit/parser/ast/casestatement.rb index 554e295bc..657648e9d 100755 --- a/spec/unit/parser/ast/casestatement.rb +++ b/spec/unit/parser/ast/casestatement.rb @@ -28,16 +28,6 @@ describe Puppet::Parser::AST::CaseStatement do @casestmt.evaluate(@scope) end - it "should downcase the evaluated test value if allowed" do - Puppet.stubs(:[]).with(:casesensitive).returns(false) - value = stub 'test' - @test.stubs(:safeevaluate).with(@scope).returns(value) - - value.expects(:downcase) - - @casestmt.evaluate(@scope) - end - it "should scan each option" do @options.expects(:each).multiple_yields(@option1, @option2) diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb index 0c1c5864d..46458605d 100755 --- a/spec/unit/parser/ast/leaf.rb +++ b/spec/unit/parser/ast/leaf.rb @@ -40,6 +40,13 @@ describe Puppet::Parser::AST::Leaf do @leaf.evaluate_match(:undef, @scope).should be_true end + + it "should downcase the parameter value if wanted" do + parameter = stub 'parameter' + parameter.expects(:downcase).returns("value") + + @leaf.evaluate_match(parameter, @scope, :insensitive => true) + end end describe "when converting to string" do @@ -240,6 +247,12 @@ describe Puppet::Parser::AST::Regex do @regex.evaluate_match("value", @scope) end + it "should not downcase the paramater value" do + @value.expects(:match).with("VaLuE") + + @regex.evaluate_match("VaLuE", @scope) + end + it "should set ephemeral scope vars if there is a match" do @scope.expects(:ephemeral_from).with(true, nil, nil) diff --git a/spec/unit/parser/ast/selector.rb b/spec/unit/parser/ast/selector.rb index 2ba83ad7b..f9a1efe6c 100755 --- a/spec/unit/parser/ast/selector.rb +++ b/spec/unit/parser/ast/selector.rb @@ -40,16 +40,6 @@ describe Puppet::Parser::AST::Selector do @selector.evaluate(@scope) end - it "should downcase the evaluated param value if allowed" do - Puppet.stubs(:[]).with(:casesensitive).returns(false) - value = stub 'param' - @param.stubs(:safeevaluate).with(@scope).returns(value) - - value.expects(:downcase) - - @selector.evaluate(@scope) - end - it "should scan each option" do @values.expects(:each).multiple_yields(@value1, @value2) |
