Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COOK-4491] fix minitest: escape regex interpolation #113

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"))
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").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