diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/integration/provider/mailalias/aliases/test1 | 31 | ||||
-rw-r--r-- | spec/integration/provider/mailalias/aliases_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/type/mailalias_spec.rb | 49 |
3 files changed, 90 insertions, 0 deletions
diff --git a/spec/fixtures/integration/provider/mailalias/aliases/test1 b/spec/fixtures/integration/provider/mailalias/aliases/test1 new file mode 100644 index 0000000..a69be8a --- /dev/null +++ b/spec/fixtures/integration/provider/mailalias/aliases/test1 @@ -0,0 +1,31 @@ +# Basic system aliases -- these MUST be present +MAILER-DAEMON: postmaster +postmaster: root + +# General redirections for pseudo accounts +bin: root +daemon: root +named: root +nobody: root +uucp: root +www: root +ftp-bugs: root +postfix: root + +# Put your local aliases here. + +# Well-known aliases +manager: root +dumper: root +operator: root +abuse: postmaster + +# trap decode to catch security attacks +decode: root + +# Other tests +anothertest: "|/path/to/rt-mailgate --queue 'another test' --action correspond --url http://my.com/" +test: "|/path/to/rt-mailgate --queue 'test' --action correspond --url http://my.com/" + +# Included file +incfile: :include: /tmp/somefile diff --git a/spec/integration/provider/mailalias/aliases_spec.rb b/spec/integration/provider/mailalias/aliases_spec.rb new file mode 100644 index 0000000..64cef1c --- /dev/null +++ b/spec/integration/provider/mailalias/aliases_spec.rb @@ -0,0 +1,10 @@ +#! /usr/bin/env ruby +require 'spec_helper' +require 'shared_behaviours/all_parsedfile_providers' + +provider_class = Puppet::Type.type(:mailalias).provider(:aliases) + +describe provider_class do + # #1560, in which we corrupt the format of complex mail aliases. + it_should_behave_like "all parsedfile providers", provider_class +end diff --git a/spec/unit/type/mailalias_spec.rb b/spec/unit/type/mailalias_spec.rb new file mode 100644 index 0000000..eb701c6 --- /dev/null +++ b/spec/unit/type/mailalias_spec.rb @@ -0,0 +1,49 @@ +#! /usr/bin/env ruby +require 'spec_helper' + +describe Puppet::Type.type(:mailalias) do + include PuppetSpec::Files + + let :tmpfile_path do tmpfile('afile') end + let :target do tmpfile('mailalias') end + let :recipient_resource do + described_class.new(:name => "luke", :recipient => "yay", :target => target) + end + + let :file_resource do + described_class.new(:name => "lukefile", :file => tmpfile_path, :target => target) + end + + it "should be initially absent as a recipient" do + expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent) + end + + it "should be initially absent as an included file" do + expect(file_resource.retrieve_resource[:file]).to eq(:absent) + end + + it "should try and set the recipient when it does the sync" do + expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent) + recipient_resource.property(:recipient).expects(:set).with(["yay"]) + recipient_resource.property(:recipient).sync + end + + it "should try and set the included file when it does the sync" do + expect(file_resource.retrieve_resource[:file]).to eq(:absent) + file_resource.property(:file).expects(:set).with(tmpfile_path) + file_resource.property(:file).sync + end + + it "should fail when file is not an absolute path" do + expect { + Puppet::Type.type(:mailalias).new(:name => 'x', :file => 'afile') + }.to raise_error Puppet::Error, /File paths must be fully qualified/ + end + + it "should fail when both file and recipient are specified" do + expect { + Puppet::Type.type(:mailalias).new(:name => 'x', :file => tmpfile_path, + :recipient => 'foo@example.com') + }.to raise_error Puppet::Error, /cannot specify both a recipient and a file/ + end +end |