Skip to content

Commit df44134

Browse files
author
Joshua Hoblitt
committed
update pureftpd::config::mysql to use the common erb template + rspec
1 parent ab4cfb9 commit df44134

File tree

4 files changed

+115
-132
lines changed

4 files changed

+115
-132
lines changed

manifests/config/mysql.pp

+48-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,54 @@
1616
# - implement template and variables for the mysql config file
1717
#
1818

19-
class pureftpd::config::mysql inherits pureftpd::params {
19+
class pureftpd::config::mysql (
20+
$mysqlserver = undef,
21+
$mysqlport = undef,
22+
$mysqlsocket = undef,
23+
$mysqluser = undef,
24+
$mysqlpassword = undef,
25+
$mysqldatabase = undef,
26+
$mysqlcrypt = undef,
27+
$mysqltransactions = undef,
28+
$mysqlgetpw = undef,
29+
$mysqlgetuid = undef,
30+
$mysqldefaultuid = undef,
31+
$mysqlgetgid = undef,
32+
$mysqldefaultgid = undef,
33+
$mysqlgetdir = undef,
34+
$mysqlforcetildeexpansion = undef,
35+
$mysqlgetqtafs = undef,
36+
$mysqlgetqtasz = undef,
37+
$mysqlgetratioul = undef,
38+
$mysqlgetratiodl = undef,
39+
$mysqlgetbandwidthul = undef,
40+
$mysqlgetbandwidthdl = undef,
41+
) inherits pureftpd::params {
42+
43+
# options taken from pure-ftpd-1.0.30/configuration-file/log_mysql_p.h
44+
$conf_options = [
45+
'MYSQLServer',
46+
'MYSQLPort',
47+
'MYSQLSocket',
48+
'MYSQLUser',
49+
'MYSQLPassword',
50+
'MYSQLDatabase',
51+
'MYSQLCrypt',
52+
'MYSQLTransactions',
53+
'MYSQLGetPW',
54+
'MYSQLGetUID',
55+
'MYSQLDefaultUID',
56+
'MYSQLGetGID',
57+
'MYSQLDefaultGID',
58+
'MYSQLGetDir',
59+
'MYSQLForceTildeExpansion',
60+
'MYSQLGetQTAFS',
61+
'MYSQLGetQTASZ',
62+
'MYSQLGetRatioUL',
63+
'MYSQLGetRatioDL',
64+
'MYSQLGetBandwidthUL',
65+
'MYSQLGetBandwidthDL',
66+
]
2067

2168
file { $pureftpd::params::mysql_conf_path:
2269
ensure => file,

manifests/params.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
$ldap_conf_erb = 'redhat/pure-ftpd.conf.erb'
2424
$ldap_conf_path = "${config_dir}/pureftpd-ldap.conf"
2525

26-
$mysql_conf_erb = 'redhat/pureftpd-mysql.conf.erb'
26+
$mysql_conf_erb = 'redhat/pure-ftpd.conf.erb'
2727
$mysql_conf_path = "${config_dir}/pureftpd-mysql.conf"
2828

2929
$pgsql_conf_erb = 'redhat/pure-ftpd.conf.erb'

spec/classes/config_mysql_spec.rb

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require 'spec_helper'
2+
3+
test_options = [
4+
'MYSQLServer',
5+
'MYSQLPort',
6+
'MYSQLSocket',
7+
'MYSQLUser',
8+
'MYSQLPassword',
9+
'MYSQLDatabase',
10+
'MYSQLCrypt',
11+
'MYSQLTransactions',
12+
'MYSQLGetPW',
13+
'MYSQLGetUID',
14+
'MYSQLDefaultUID',
15+
'MYSQLGetGID',
16+
'MYSQLDefaultGID',
17+
'MYSQLGetDir',
18+
'MYSQLForceTildeExpansion',
19+
'MYSQLGetQTAFS',
20+
'MYSQLGetQTASZ',
21+
'MYSQLGetRatioUL',
22+
'MYSQLGetRatioDL',
23+
'MYSQLGetBandwidthUL',
24+
'MYSQLGetBandwidthDL',
25+
]
26+
27+
describe 'pureftpd::config::mysql' do
28+
29+
shared_examples 'config' do |params, content|
30+
let(:facts) {{ :osfamily=> 'RedHat' }}
31+
let(:params) { params }
32+
33+
it do
34+
should include_class('pureftpd::config::mysql')
35+
should contain_file('/etc/pure-ftpd/pureftpd-mysql.conf') \
36+
.with_ensure('file') \
37+
.with_content(content)
38+
end
39+
end
40+
41+
all_params = {}
42+
all_content = ''
43+
value = 'xxx'
44+
45+
# accumutate all of the params and content strings as we test each individual
46+
# option so we can use them for the next test
47+
context 'one option at a time' do
48+
test_options.each do |option|
49+
params = {}
50+
params[option.downcase.to_sym] = value
51+
content = sprintf("%-19s %s\n", option, value)
52+
53+
all_params.merge!(params)
54+
all_content += content
55+
56+
it_behaves_like 'config', params, content
57+
end
58+
end
59+
60+
# test all of the known options at once this works because the ordering of
61+
# options values in the output file is fixed
62+
context 'all options' do
63+
it_behaves_like 'config', all_params, all_content
64+
end
65+
66+
end

templates/redhat/pureftpd-mysql.conf.erb

-130
This file was deleted.

0 commit comments

Comments
 (0)