Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Do not run recipe without username/password/domain #17

Merged
merged 2 commits into from
Feb 17, 2017
Merged
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
11 changes: 3 additions & 8 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -18,14 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

if node.attribute? 'sendmail_ses'
log 'check username, password, and domain' do
level :fatal
message 'Username, password and domain must be defined'
not_if { node['sendmail_ses']['username'] }
not_if { node['sendmail_ses']['password'] }
not_if { node['sendmail_ses']['domain'] }
end
if node['sendmail_ses'].attribute?('username') &&
node['sendmail_ses'].attribute?('password') &&
node['sendmail_ses'].attribute?('domain')

%w(m4 sendmail-cf).each do |p|
package p
14 changes: 10 additions & 4 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -16,10 +16,16 @@
stub_command('grep ses.cf /etc/mail/sendmail.mc').and_return(true)
chef_run.node.set['sendmail_ses'] = {}
chef_run.converge described_recipe
expect(chef_run).to write_log(
'Username, password and domain must be defined'
)
expect(chef_run).not_to restart_service('sendmail')

ses_cf_path = chef_run.node['sendmail']['ses_cf_path']

expect(chef_run).not_to create_template('/etc/mail/authinfo.ses')
expect(chef_run).not_to create_template('/etc/mail/access.ses')
expect(chef_run).not_to create_directory(ses_cf_path)
expect(chef_run).not_to create_template("#{ses_cf_path}/ses.cf")
template = chef_run.template("#{ses_cf_path}/ses.cf")
expect(template)
.not_to notify('execute[sendmail_test]').to(:run).immediately
end

context 'basic setup' do