Skip to content

Commit

Permalink
[COOK-4491] - Fix minitest: escape regex interpolation
Browse files Browse the repository at this point in the history
Signed-off-by: Sean OMeara <someara@opscode.com>
  • Loading branch information
JeanMertz authored and Sean OMeara committed Apr 10, 2014
1 parent cd2200d commit c65d482
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions files/default/tests/minitest/default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
end

it 'reports server name only, not detailed version info' do
assert_match(/^ServerTokens #{node['apache']['servertokens']} *$/, File.read("#{node['apache']['dir']}/conf.d/security.conf"))
assert_match(/^ServerTokens #{Regexp.escape(node['apache']['servertokens'])} *$/,
File.read("#{node['apache']['dir']}/conf.d/security"))
end

it 'listens on port 80' do
Expand All @@ -50,7 +51,8 @@
end

it 'reports server name only, not detailed version info' do
file("#{node['apache']['dir']}/conf.d/security.conf").must_match(/^ServerTokens #{node['apache']['servertokens']} *$/)
file("#{node['apache']['dir']}/conf.d/security").must_match(
/^ServerTokens #{Regexp.escape(node['apache']['servertokens'])} *$/)
end

it 'enables default_modules' do
Expand Down
2 changes: 1 addition & 1 deletion files/default/tests/minitest/mod_ssl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

it 'configures SSLCiphersuit from an attribute' do
assert_match(
/^SSLCipherSuite #{node['apache']['mod_ssl']['cipher_suite']}$/,
/SSLCipherSuite #{Regexp.escape(node['apache']['mod_ssl']['cipher_suite'])}$/,
File.read("#{node['apache']['dir']}/mods-enabled/ssl.conf")
)
end
Expand Down

0 comments on commit c65d482

Please sign in to comment.