Skip to content

Commit ab4cfb9

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

File tree

4 files changed

+105
-100
lines changed

4 files changed

+105
-100
lines changed

manifests/config/pgsql.pp

+41-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,48 @@
1212
#
1313
# - implement template and variables for the pgsql config file
1414
#
15+
class pureftpd::config::pgsql (
16+
$pgsqlserver = undef,
17+
$pgsqlport = undef,
18+
$pgsqluser = undef,
19+
$pgsqlpassword = undef,
20+
$pgsqldatabase = undef,
21+
$pgsqlcrypt = undef,
22+
$pgsqlgetpw = undef,
23+
$pgsqlgetuid = undef,
24+
$pgsqldefaultuid = undef,
25+
$pgsqlgetgid = undef,
26+
$pgsqldefaultgid = undef,
27+
$pgsqlgetdir = undef,
28+
$pgsqlgetqtafs = undef,
29+
$pgsqlgetqtasz = undef,
30+
$pgsqlgetratioul = undef,
31+
$pgsqlgetratiodl = undef,
32+
$pgsqlgetbandwidthul = undef,
33+
$pgsqlgetbandwidthdl = undef,
34+
) inherits pureftpd::params {
1535

16-
class pureftpd::config::pgsql inherits pureftpd::params {
36+
# pure-ftpd-1.0.30/src/log_pgsql_p.h
37+
$conf_options = [
38+
'PGSQLServer',
39+
'PGSQLPort',
40+
'PGSQLUser',
41+
'PGSQLPassword',
42+
'PGSQLDatabase',
43+
'PGSQLCrypt',
44+
'PGSQLGetPW',
45+
'PGSQLGetUID',
46+
'PGSQLDefaultUID',
47+
'PGSQLGetGID',
48+
'PGSQLDefaultGID',
49+
'PGSQLGetDir',
50+
'PGSQLGetQTAFS',
51+
'PGSQLGetQTASZ',
52+
'PGSQLGetRatioUL',
53+
'PGSQLGetRatioDL',
54+
'PGSQLGetBandwidthUL',
55+
'PGSQLGetBandwidthDL',
56+
]
1757

1858
file { $pureftpd::params::pgsql_conf_path:
1959
ensure => file,

manifests/params.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
$mysql_conf_erb = 'redhat/pureftpd-mysql.conf.erb'
2727
$mysql_conf_path = "${config_dir}/pureftpd-mysql.conf"
2828

29-
$pgsql_conf_erb = 'redhat/pureftpd-pgsql.conf.erb'
29+
$pgsql_conf_erb = 'redhat/pure-ftpd.conf.erb'
3030
$pgsql_conf_path = "${config_dir}/pureftpd-pgsql.conf"
3131
}
3232
default:{

spec/classes/config_pgsql_spec.rb

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
require 'spec_helper'
2+
3+
test_options = [
4+
'PGSQLServer',
5+
'PGSQLPort',
6+
'PGSQLUser',
7+
'PGSQLPassword',
8+
'PGSQLDatabase',
9+
'PGSQLCrypt',
10+
'PGSQLGetPW',
11+
'PGSQLGetUID',
12+
'PGSQLDefaultUID',
13+
'PGSQLGetGID',
14+
'PGSQLDefaultGID',
15+
'PGSQLGetDir',
16+
'PGSQLGetQTAFS',
17+
'PGSQLGetQTASZ',
18+
'PGSQLGetRatioUL',
19+
'PGSQLGetRatioDL',
20+
'PGSQLGetBandwidthUL',
21+
'PGSQLGetBandwidthDL',
22+
]
23+
24+
describe 'pureftpd::config::pgsql' do
25+
26+
shared_examples 'config' do |params, content|
27+
let(:facts) {{ :osfamily=> 'RedHat' }}
28+
let(:params) { params }
29+
30+
it do
31+
should include_class('pureftpd::config::pgsql')
32+
should contain_file('/etc/pure-ftpd/pureftpd-pgsql.conf') \
33+
.with_ensure('file') \
34+
.with_content(content)
35+
end
36+
end
37+
38+
all_params = {}
39+
all_content = ''
40+
value = 'xxx'
41+
42+
# accumutate all of the params and content strings as we test each individual
43+
# option so we can use them for the next test
44+
context 'one option at a time' do
45+
test_options.each do |option|
46+
params = {}
47+
params[option.downcase.to_sym] = value
48+
content = sprintf("%-19s %s\n", option, value)
49+
50+
all_params.merge!(params)
51+
all_content += content
52+
53+
it_behaves_like 'config', params, content
54+
end
55+
end
56+
57+
# test all of the known options at once this works because the ordering of
58+
# options values in the output file is fixed
59+
context 'all options' do
60+
it_behaves_like 'config', all_params, all_content
61+
end
62+
63+
end

templates/redhat/pureftpd-pgsql.conf.erb

-98
This file was deleted.

0 commit comments

Comments
 (0)