Skip to content

update tests for all supported platform #9

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

Merged
merged 17 commits into from
Jul 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion default/roles/mysql.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"default_attributes" : {
"mysql": {
"server_root_password": "iloverandompasswordsbutthiswilldo",
"server_repl_password": "iloverandompasswordsbutthiswilldo",
"server_debian_password": "iloverandompasswordsbutthiswilldo"
}
},
Expand Down
34 changes: 23 additions & 11 deletions default/serverspec/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
end
end

mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf'

# set OS-dependent filenames and paths
case backend.check_os[:family]
when 'Ubuntu'
when 'Ubuntu', 'Debian'
mysql_config_file = '/etc/mysql/my.cnf'
mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf'
mysql_config_path = '/etc/mysql/'
mysql_data_path = '/var/lib/mysql/'
mysql_log_path = '/var/log/'
mysql_log_file = 'mysql.log'
mysql_log_group = 'adm'
os[:release] == '14.04' ? mysql_log_dir_group = 'syslog' : mysql_log_dir_group = 'root'
service_name = 'mysql'
when 'RedHat', 'Fedora'
mysql_config_file = '/etc/my.cnf'
mysql_hardening_file = '/etc/hardening.cnf'
mysql_config_path = '/etc/'
mysql_data_path = '/var/lib/mysql/'
mysql_log_path = '/var/log/'
mysql_log_file = 'mysqld.log'
mysql_log_group = 'mysql'
mysql_log_dir_group = 'root'
service_name = 'mysqld'
end

Expand Down Expand Up @@ -92,7 +98,7 @@

# Req. 299 (nur eine instanz pro server)
describe 'Req. 299: check for multiple instances' do
describe command('ps aux | grep mysqld | grep -v grep | wc -l') do
describe command('ps aux | grep mysqld | egrep -v "grep|mysqld_safe|logger" | wc -l') do
its(:stdout) { should match(/^1$/) }
end
end
Expand Down Expand Up @@ -136,7 +142,7 @@

# Req. 316 (skip-grant-tables)
describe file(tmp_config_file) do
its(:content) { should match(/^\s*?skip-grant-tables/) }
its(:content) { should_not match(/^\s*?skip-grant-tables/) }
end

# Req. 320 (kein "allow-suspicious-udfs")
Expand All @@ -151,27 +157,26 @@

describe file(mysql_data_path) do
it { should be_directory }
end

describe file(mysql_data_path) do
it { should be_owned_by 'mysql' }
it { should be_grouped_into 'mysql' }
end

describe file("#{mysql_data_path}/ibdata1") do
it { should be_owned_by 'mysql' }
it { should be_grouped_into 'mysql' }
it { should_not be_readable.by('others') }
end

describe file(mysql_log_path) do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_grouped_into mysql_log_dir_group }
end

describe file("#{mysql_log_path}/mysql.log") do
describe file("#{mysql_log_path}/#{mysql_log_file}") do
it { should be_owned_by 'mysql' }
it { should be_grouped_into 'adm' }
it { should be_grouped_into mysql_log_group }
it { should_not be_readable.by('others') }
end

end
Expand All @@ -190,6 +195,13 @@
describe file(mysql_config_file) do
it { should be_owned_by 'mysql' }
it { should be_grouped_into 'mysql' }
it { should_not be_readable.by('others') }
end

describe file(mysql_hardening_file) do
it { should be_owned_by 'mysql' }
it { should be_grouped_into 'root' }
it { should_not be_readable.by('others') }
end

end