|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'pureftpd::config_ldap' do |
| 4 | + let(:facts) {{ :osfamily=> 'RedHat' }} |
| 5 | + |
| 6 | + describe 'with no params' do |
| 7 | + it do |
| 8 | + should contain_class('pureftpd::config_ldap') |
| 9 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 10 | + .with_ensure('file').with_content('') |
| 11 | + end |
| 12 | + end |
| 13 | + |
| 14 | + describe 'with ldapport' do |
| 15 | + let(:params) {{ :ldapport => '389' }} |
| 16 | + it do |
| 17 | + should contain_class('pureftpd::config_ldap') |
| 18 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 19 | + .with_ensure('file') \ |
| 20 | + .with_content(/^LDAPPort 389/) |
| 21 | + end |
| 22 | + end |
| 23 | + |
| 24 | + describe 'with ldapbinddn' do |
| 25 | + let(:params) {{ :ldapbinddn => 'cn=Manager,dc=c9x,dc=org' }} |
| 26 | + it do |
| 27 | + should contain_class('pureftpd::config_ldap') |
| 28 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 29 | + .with_ensure('file') \ |
| 30 | + .with_content(/^LDAPBindDN cn=Manager,dc=c9x,dc=org/) |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + describe 'with ldapbindpw' do |
| 35 | + let(:params) {{ :ldapbindpw => 'r00tPaSsw0rD' }} |
| 36 | + it do |
| 37 | + should contain_class('pureftpd::config_ldap') |
| 38 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 39 | + .with_ensure('file') \ |
| 40 | + .with_content(/^LDAPBindPW r00tPaSsw0rD/) |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + describe 'with ldapbasedn' do |
| 45 | + let(:params) {{ :ldapbasedn => 'cn=Users,dc=c9x,dc=org' }} |
| 46 | + it do |
| 47 | + should contain_class('pureftpd::config_ldap') |
| 48 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 49 | + .with_ensure('file') \ |
| 50 | + .with_content(/^LDAPBaseDN cn=Users,dc=c9x,dc=org/) |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + describe 'with ldapfilter' do |
| 55 | + let(:params) {{ :ldapfilter => '(&(objectClass=posixAccount)(uid=\L))' }} |
| 56 | + it do |
| 57 | + should contain_class('pureftpd::config_ldap') |
| 58 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 59 | + .with_ensure('file') \ |
| 60 | + .with_content(Regexp.new(Regexp.quote('LDAPFilter (&(objectClass=posixAccount)(uid=\L))'))) |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + describe 'with ldaphomedir' do |
| 65 | + let(:params) {{ :ldaphomedir => 'homeDirectory' }} |
| 66 | + it do |
| 67 | + should contain_class('pureftpd::config_ldap') |
| 68 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 69 | + .with_ensure('file') \ |
| 70 | + .with_content(/^LDAPHomeDir homeDirectory/) |
| 71 | + end |
| 72 | + end |
| 73 | + |
| 74 | + describe 'with ldapversion' do |
| 75 | + let(:params) {{ :ldapversion => '3' }} |
| 76 | + it do |
| 77 | + should contain_class('pureftpd::config_ldap') |
| 78 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 79 | + .with_ensure('file') \ |
| 80 | + .with_content(/^LDAPVersion 3/) |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + describe 'with ldapdefaultuid' do |
| 85 | + let(:params) {{ :ldapdefaultuid => '100' }} |
| 86 | + it do |
| 87 | + should contain_class('pureftpd::config_ldap') |
| 88 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 89 | + .with_ensure('file') \ |
| 90 | + .with_content(/^LDAPDefaultUID 100/) |
| 91 | + end |
| 92 | + end |
| 93 | + |
| 94 | + describe 'with ldapforcedefaultuid' do |
| 95 | + let(:params) {{ :ldapforcedefaultuid => 'False' }} |
| 96 | + it do |
| 97 | + should contain_class('pureftpd::config_ldap') |
| 98 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 99 | + .with_ensure('file') \ |
| 100 | + .with_content(/^LDAPForceDefaultUID False/) |
| 101 | + end |
| 102 | + end |
| 103 | + |
| 104 | + describe 'with ldapdefaultgid' do |
| 105 | + let(:params) {{ :ldapdefaultgid => '100' }} |
| 106 | + it do |
| 107 | + should contain_class('pureftpd::config_ldap') |
| 108 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 109 | + .with_ensure('file') \ |
| 110 | + .with_content(/^LDAPDefaultGID 100/) |
| 111 | + end |
| 112 | + end |
| 113 | + |
| 114 | + describe 'with ldapdefaultgid' do |
| 115 | + let(:params) {{ :ldapdefaultgid => '100' }} |
| 116 | + it do |
| 117 | + should contain_class('pureftpd::config_ldap') |
| 118 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 119 | + .with_ensure('file') \ |
| 120 | + .with_content(/^LDAPDefaultGID 100/) |
| 121 | + end |
| 122 | + end |
| 123 | + |
| 124 | + describe 'with ldapforcedefaultgid' do |
| 125 | + let(:params) {{ :ldapforcedefaultgid => 'False' }} |
| 126 | + it do |
| 127 | + should contain_class('pureftpd::config_ldap') |
| 128 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 129 | + .with_ensure('file') \ |
| 130 | + .with_content(/^LDAPForceDefaultGID False/) |
| 131 | + end |
| 132 | + end |
| 133 | + |
| 134 | + describe 'with ldapusetls' do |
| 135 | + let(:params) {{ :ldapusetls => 'False' }} |
| 136 | + it do |
| 137 | + should contain_class('pureftpd::config_ldap') |
| 138 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 139 | + .with_ensure('file') \ |
| 140 | + .with_content(/^LDAPUseTLS False/) |
| 141 | + end |
| 142 | + end |
| 143 | + |
| 144 | + describe 'with ldapauthmethod' do |
| 145 | + let(:params) {{ :ldapauthmethod => 'PASSWORD' }} |
| 146 | + it do |
| 147 | + should contain_class('pureftpd::config_ldap') |
| 148 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 149 | + .with_ensure('file') \ |
| 150 | + .with_content(/^LDAPAuthMethod PASSWORD/) |
| 151 | + end |
| 152 | + end |
| 153 | + |
| 154 | + describe 'with everything' do |
| 155 | + let(:params) {{ |
| 156 | + :ldapauthmethod => 'PASSWORD', |
| 157 | + :ldapport => '389', |
| 158 | + :ldapbinddn => 'cn=Manager,dc=c9x,dc=org', |
| 159 | + :ldapbindpw => 'r00tPaSsw0rD', |
| 160 | + :ldapbasedn => 'cn=Users,dc=c9x,dc=org', |
| 161 | + :ldapfilter => '(&(objectClass=posixAccount)(uid=\L))', |
| 162 | + :ldaphomedir => 'homeDirectory', |
| 163 | + :ldapversion => '3', |
| 164 | + :ldapdefaultuid => '100', |
| 165 | + :ldapforcedefaultuid => 'False', |
| 166 | + :ldapdefaultgid => '100', |
| 167 | + :ldapdefaultgid => '100', |
| 168 | + :ldapforcedefaultgid => 'False', |
| 169 | + :ldapusetls => 'False', |
| 170 | + :ldapauthmethod => 'PASSWORD', |
| 171 | + }} |
| 172 | + it do |
| 173 | + should contain_class('pureftpd::config_ldap') |
| 174 | + should contain_file('/etc/pure-ftpd/pureftpd-ldap.conf') \ |
| 175 | + .with_ensure('file') \ |
| 176 | + .with_content(/^LDAPPort 389/) \ |
| 177 | + .with_content(/^LDAPBindDN cn=Manager,dc=c9x,dc=org/) \ |
| 178 | + .with_content(/^LDAPBindPW r00tPaSsw0rD/) \ |
| 179 | + .with_content(/^LDAPBaseDN cn=Users,dc=c9x,dc=org/) \ |
| 180 | + .with_content(Regexp.new(Regexp.quote('LDAPFilter (&(objectClass=posixAccount)(uid=\L))'))) \ |
| 181 | + .with_content(/^LDAPHomeDir homeDirectory/) \ |
| 182 | + .with_content(/^LDAPVersion 3/) \ |
| 183 | + .with_content(/^LDAPDefaultUID 100/) \ |
| 184 | + .with_content(/^LDAPForceDefaultUID False/) \ |
| 185 | + .with_content(/^LDAPDefaultGID 100/) \ |
| 186 | + .with_content(/^LDAPDefaultGID 100/) \ |
| 187 | + .with_content(/^LDAPForceDefaultGID False/) \ |
| 188 | + .with_content(/^LDAPUseTLS False/) \ |
| 189 | + .with_content(/^LDAPAuthMethod PASSWORD/) \ |
| 190 | + .with_content(/^LDAPAuthMethod PASSWORD/) |
| 191 | + end |
| 192 | + end |
| 193 | +end |
0 commit comments