From aa1569e597cf69763a2e6274ea9cebbdb78ac3f6 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Wed, 29 Jan 2025 14:26:30 -0800 Subject: [PATCH] Correctly fix aliases quoting logic We were previously incorrectly adding double quotes for the alias values. According to the man page it's not required. However, there is a requirement if its a command being pipe. In addition, the man page mentions this for the alias name: The name is a local address (no domain part). Use double quotes when the name contains any special characters such as whitespace, `#', `:', or `@'. The name is folded to lowercase, in order to make database lookups case insensitive. This includes logic to support this automatically. - Add new tests for aliases testing all types - Convert all serverspec tests to inspec - Add Github actions - Update platforms to test Signed-off-by: Lance Albertson --- .github/workflows/ci.yml | 60 +++++++++++++++++++ CHANGELOG.md | 17 +++--- kitchen.yml | 23 +++++-- templates/aliases.erb | 2 +- test/integration/aliases/controls/aliases.rb | 21 +++++++ test/integration/aliases/inspec.yml | 1 + .../aliases/serverspec/aliases_spec.rb | 24 -------- .../canonical/controls/canonical.rb | 9 +++ test/integration/canonical/inspec.yml | 1 + .../canonical/serverspec/canonical_spec.rb | 23 ------- test/integration/client/controls/client.rb | 7 +++ test/integration/client/inspec.yml | 4 ++ .../client/serverspec/client_spec.rb | 22 ------- test/integration/default/controls/default.rb | 14 +++++ test/integration/default/inspec.yml | 1 + .../default/serverspec/default_spec.rb | 33 ---------- .../helpers/serverspec/spec_helper.rb | 19 ------ .../controls/sasl_auth_multiple.rb | 19 ++++++ .../integration/sasl_auth_multiple/inspec.yml | 1 + .../serverspec/sasl_auth_multiple_spec.rb | 31 ---------- .../sasl_auth_none/controls/sasl_auth_none.rb | 17 ++++++ test/integration/sasl_auth_none/inspec.yml | 1 + .../serverspec/sasl_auth_none_spec.rb | 31 ---------- .../sasl_auth_one/controls/sasl_auth_one.rb | 18 ++++++ test/integration/sasl_auth_one/inspec.yml | 1 + .../serverspec/sasl_auth_one_spec.rb | 31 ---------- test/integration/server/controls/server.rb | 7 +++ test/integration/server/inspec.yml | 4 ++ .../server/serverspec/server_spec.rb | 21 ------- 29 files changed, 213 insertions(+), 250 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 test/integration/aliases/controls/aliases.rb create mode 100644 test/integration/aliases/inspec.yml delete mode 100644 test/integration/aliases/serverspec/aliases_spec.rb create mode 100644 test/integration/canonical/controls/canonical.rb create mode 100644 test/integration/canonical/inspec.yml delete mode 100644 test/integration/canonical/serverspec/canonical_spec.rb create mode 100644 test/integration/client/controls/client.rb create mode 100644 test/integration/client/inspec.yml delete mode 100644 test/integration/client/serverspec/client_spec.rb create mode 100644 test/integration/default/controls/default.rb create mode 100644 test/integration/default/inspec.yml delete mode 100644 test/integration/default/serverspec/default_spec.rb delete mode 100644 test/integration/helpers/serverspec/spec_helper.rb create mode 100644 test/integration/sasl_auth_multiple/controls/sasl_auth_multiple.rb create mode 100644 test/integration/sasl_auth_multiple/inspec.yml delete mode 100644 test/integration/sasl_auth_multiple/serverspec/sasl_auth_multiple_spec.rb create mode 100644 test/integration/sasl_auth_none/controls/sasl_auth_none.rb create mode 100644 test/integration/sasl_auth_none/inspec.yml delete mode 100644 test/integration/sasl_auth_none/serverspec/sasl_auth_none_spec.rb create mode 100644 test/integration/sasl_auth_one/controls/sasl_auth_one.rb create mode 100644 test/integration/sasl_auth_one/inspec.yml delete mode 100644 test/integration/sasl_auth_one/serverspec/sasl_auth_one_spec.rb create mode 100644 test/integration/server/controls/server.rb create mode 100644 test/integration/server/inspec.yml delete mode 100644 test/integration/server/serverspec/server_spec.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dac43163 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +--- +name: ci + +"on": + pull_request: + push: + branches: + - main + +jobs: + lint-unit: + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@3.0.0 + permissions: + actions: write + checks: write + pull-requests: write + statuses: write + + integration: + needs: 'lint-unit' + runs-on: ubuntu-latest + strategy: + matrix: + os: + - almalinux-8 + - almalinux-9 + - amazonlinux-2023 + - centos-stream-9 + - debian-11 + - debian-12 + - opensuse-leap-15 + - rockylinux-8 + - rockylinux-9 + - ubuntu-20.04 + - ubuntu-22.04 + - ubuntu-24.04 + suite: + - default + - aliases + - client + - server + - canonical + - sasl-auth-none + - sasl-auth-multiple + - sasl-auth-one + fail-fast: false + + steps: + - name: Check out code + uses: actions/checkout@v4 # v4 + - name: Install Chef + uses: actionshub/chef-install@2.0.4 + - name: Dokken + uses: actionshub/test-kitchen@2.1.0 + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.dokken.yml + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 25e73217..acb09558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,25 +4,24 @@ This file is used to list changes made in each version of the postfix cookbook. ## Unreleased -## 6.0.29 - *2024-11-18* +- Correctly fix aliases quoting logic +- Convert all serverspec tests to inspec +- Add Github actions +- Update platforms to test -Standardise files with files in sous-chefs/repo-management +## 6.0.29 - *2024-11-18* -Standardise files with files in sous-chefs/repo-management +- Standardise files with files in sous-chefs/repo-management ## 6.0.28 - *2024-07-15* -Standardise files with files in sous-chefs/repo-management - -Standardise files with files in sous-chefs/repo-management - -Standardise files with files in sous-chefs/repo-management +- Standardise files with files in sous-chefs/repo-management ## 6.0.27 - *2024-05-06* ## 6.0.26 - *2023-10-03* -- add installation of postfix addon packages for RHEL 8 +- Add installation of postfix addon packages for RHEL 8 ## 6.0.25 - *2023-10-03* diff --git a/kitchen.yml b/kitchen.yml index ba21b5f0..a227034f 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -14,16 +14,18 @@ verifier: platforms: - name: almalinux-8 - - name: amazonlinux-2 - - name: centos-7 - - name: centos-stream-8 - - name: debian-10 + - name: almalinux-9 + - name: amazonlinux-2023 + - name: centos-stream-9 - name: debian-11 + - name: debian-12 - name: fedora-latest - name: opensuse-leap-15 - name: rockylinux-8 - - name: ubuntu-18.04 + - name: rockylinux-9 - name: ubuntu-20.04 + - name: ubuntu-22.04 + - name: ubuntu-24.04 suites: - name: default @@ -33,6 +35,17 @@ suites: - name: aliases run_list: - recipe[postfix::aliases] + attributes: + postfix: + aliases: + foo1: bar + foo@bar: foo + foo2: "|/usr/bin/bar" + foo3: foo,bar + foo4: foo@example.com + foo5: + - foo + - bar - name: client run_list: diff --git a/templates/aliases.erb b/templates/aliases.erb index 3093154d..b5c2b20f 100644 --- a/templates/aliases.erb +++ b/templates/aliases.erb @@ -6,5 +6,5 @@ postmaster: root <% node['postfix']['aliases'].each do |name, value| %> -<%= name %>: <%= [value].flatten.map{|x| if (x.include?("@")) then x else %Q("#{x}") end}.join(', ') %> +<%= name.match?(/[\s#:@]/) ? "\"#{name}\"" : name %>: <%= [value].flatten.map{|x| x.include?("|") ? "\"#{x}\"" : x}.join(',') %> <% end unless node['postfix']['aliases'].nil? %> diff --git a/test/integration/aliases/controls/aliases.rb b/test/integration/aliases/controls/aliases.rb new file mode 100644 index 00000000..06bfe420 --- /dev/null +++ b/test/integration/aliases/controls/aliases.rb @@ -0,0 +1,21 @@ +control 'aliases' do + describe file '/etc/aliases' do + its('content') do + should cmp <<~EOF + # + # Auto-generated by Chef. + # Local modifications will be overwritten. + # + # See man 5 aliases for format + postmaster: root + + foo1: bar + "foo@bar": foo + foo2: "|/usr/bin/bar" + foo3: foo,bar + foo4: foo@example.com + foo5: foo,bar + EOF + end + end +end diff --git a/test/integration/aliases/inspec.yml b/test/integration/aliases/inspec.yml new file mode 100644 index 00000000..7584b60e --- /dev/null +++ b/test/integration/aliases/inspec.yml @@ -0,0 +1 @@ +name: aliases diff --git a/test/integration/aliases/serverspec/aliases_spec.rb b/test/integration/aliases/serverspec/aliases_spec.rb deleted file mode 100644 index 6262f374..00000000 --- a/test/integration/aliases/serverspec/aliases_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require_relative './spec_helper' - -describe 'postfix::aliases' do - context 'configures' do - describe file('/etc/aliases') do - its(:content) { should match(/^# Auto-generated by Chef/) } - end - end -end diff --git a/test/integration/canonical/controls/canonical.rb b/test/integration/canonical/controls/canonical.rb new file mode 100644 index 00000000..83bf3f7e --- /dev/null +++ b/test/integration/canonical/controls/canonical.rb @@ -0,0 +1,9 @@ +control 'canonical' do + describe file '/etc/postfix/recipient_canonical.db' do + it { should be_file } + end + + describe file '/etc/postfix/main.cf' do + its('content') { should match(%r{^\s*recipient_canonical_maps\s*=.*\/etc\/postfix\/recipient_canonical\s*$}) } + end +end diff --git a/test/integration/canonical/inspec.yml b/test/integration/canonical/inspec.yml new file mode 100644 index 00000000..f27b3cab --- /dev/null +++ b/test/integration/canonical/inspec.yml @@ -0,0 +1 @@ +name: canonical diff --git a/test/integration/canonical/serverspec/canonical_spec.rb b/test/integration/canonical/serverspec/canonical_spec.rb deleted file mode 100644 index 5b23ea60..00000000 --- a/test/integration/canonical/serverspec/canonical_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -require_relative './spec_helper' - -describe file('/etc/postfix/recipient_canonical.db') do - it { should be_file } -end - -describe file('/etc/postfix/main.cf') do - its(:content) { should match(%r{^\s*recipient_canonical_maps\s*=.*\/etc\/postfix\/recipient_canonical\s*$}) } -end diff --git a/test/integration/client/controls/client.rb b/test/integration/client/controls/client.rb new file mode 100644 index 00000000..90478c26 --- /dev/null +++ b/test/integration/client/controls/client.rb @@ -0,0 +1,7 @@ +include_controls 'default' + +control 'client' do + describe file '/etc/postfix/main.cf' do + its('content') { should match /Configured as client/ } + end +end diff --git a/test/integration/client/inspec.yml b/test/integration/client/inspec.yml new file mode 100644 index 00000000..3b860007 --- /dev/null +++ b/test/integration/client/inspec.yml @@ -0,0 +1,4 @@ +name: client +depends: + - name: default + path: test/integration/default diff --git a/test/integration/client/serverspec/client_spec.rb b/test/integration/client/serverspec/client_spec.rb deleted file mode 100644 index a6fb2755..00000000 --- a/test/integration/client/serverspec/client_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require_relative './spec_helper' - -describe 'postfix::client' do - it 'doesnt configure postfix because solo is unsupported' do - pending 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo' - end -end diff --git a/test/integration/default/controls/default.rb b/test/integration/default/controls/default.rb new file mode 100644 index 00000000..931e21f1 --- /dev/null +++ b/test/integration/default/controls/default.rb @@ -0,0 +1,14 @@ +control 'default' do + describe package 'postfix' do + it { should be_installed } + end + + describe service 'postfix' do + it { should be_enabled } + it { should be_running } + end + + describe file '/etc/postfix/main.cf' do + its('content') { should match(/^# Auto-generated by Chef/) } + end +end diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml new file mode 100644 index 00000000..970ba0c5 --- /dev/null +++ b/test/integration/default/inspec.yml @@ -0,0 +1 @@ +name: default diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb deleted file mode 100644 index df83558a..00000000 --- a/test/integration/default/serverspec/default_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require_relative './spec_helper' - -describe 'postfix::default' do - describe package('postfix') do - it { should be_installed } - end - - describe service('postfix') do - it { should be_enabled } - it { should be_running } - end - - context 'configures' do - describe file("#{postfix_conf_path}/main.cf") do - its(:content) { should match(/^# Auto-generated by Chef/) } - end - end -end diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb deleted file mode 100644 index f5629e67..00000000 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'serverspec' - -set :backend, :exec -set :path, '/sbin:/usr/local/sbin:$PATH' - -def family - fam = 'solaris2' - return fam unless File.exist? '/etc/release' - fam = 'omnios' if File.read('/etc/release') =~ /^\s*(OmniOS)/ - fam -end - -def postfix_conf_path - if os[:family] == 'solaris' && family == 'omnios' - '/opt/omni/etc/postfix/' - else - '/etc/postfix' - end -end diff --git a/test/integration/sasl_auth_multiple/controls/sasl_auth_multiple.rb b/test/integration/sasl_auth_multiple/controls/sasl_auth_multiple.rb new file mode 100644 index 00000000..ba259480 --- /dev/null +++ b/test/integration/sasl_auth_multiple/controls/sasl_auth_multiple.rb @@ -0,0 +1,19 @@ +control 'sasl_auth_multiple' do + describe file '/etc/postfix/sasl_passwd' do + its('content') do + should cmp <<~EOF + # Auto-generated by Chef. + # Local modifications will be overwritten. + + relayhost1 kitchenuser:not-a-real-thing + relayhost2 anotherkitchenuser:yet-not-a-real-thing + smtp_sasl_passwd : + smtp_sasl_user_name : + EOF + end + end + + describe postfix_conf '/etc/postfix/main.cf' do + its('smtp_sasl_password_maps') { should eq 'hash:/etc/postfix/sasl_passwd' } + end +end diff --git a/test/integration/sasl_auth_multiple/inspec.yml b/test/integration/sasl_auth_multiple/inspec.yml new file mode 100644 index 00000000..d4f1a815 --- /dev/null +++ b/test/integration/sasl_auth_multiple/inspec.yml @@ -0,0 +1 @@ +name: sasl_auth_multiple diff --git a/test/integration/sasl_auth_multiple/serverspec/sasl_auth_multiple_spec.rb b/test/integration/sasl_auth_multiple/serverspec/sasl_auth_multiple_spec.rb deleted file mode 100644 index c0c49792..00000000 --- a/test/integration/sasl_auth_multiple/serverspec/sasl_auth_multiple_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -require_relative './spec_helper' - -describe 'postfix::sasl_auth' do - let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' } - - it 'manages postfix sasl_passwd' do - expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for/) - end - - it 'configures postfix to use the sasl_passwd file' do - expect(file('/etc/postfix/main.cf').content).to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/) - end - - it 'configures postfix sasl_passwd with multiple entries' do - expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for .*\nrelayhost1 kitchenuser:not-a-real-thing\nrelayhost2 anotherkitchenuser:yet-not-a-real-thing\n/) - end -end diff --git a/test/integration/sasl_auth_none/controls/sasl_auth_none.rb b/test/integration/sasl_auth_none/controls/sasl_auth_none.rb new file mode 100644 index 00000000..1f6a4ad2 --- /dev/null +++ b/test/integration/sasl_auth_none/controls/sasl_auth_none.rb @@ -0,0 +1,17 @@ +control 'sasl_auth_none' do + describe file '/etc/postfix/sasl_passwd' do + its('content') do + should cmp <<~EOF + # Auto-generated by Chef. + # Local modifications will be overwritten. + + smtp_sasl_passwd : + smtp_sasl_user_name : + EOF + end + end + + describe postfix_conf '/etc/postfix/main.cf' do + its('smtp_sasl_password_maps') { should eq 'hash:/etc/postfix/sasl_passwd' } + end +end diff --git a/test/integration/sasl_auth_none/inspec.yml b/test/integration/sasl_auth_none/inspec.yml new file mode 100644 index 00000000..10386361 --- /dev/null +++ b/test/integration/sasl_auth_none/inspec.yml @@ -0,0 +1 @@ +name: sasl_auth_none diff --git a/test/integration/sasl_auth_none/serverspec/sasl_auth_none_spec.rb b/test/integration/sasl_auth_none/serverspec/sasl_auth_none_spec.rb deleted file mode 100644 index 46d86dcf..00000000 --- a/test/integration/sasl_auth_none/serverspec/sasl_auth_none_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -require_relative './spec_helper' - -describe 'postfix::sasl_auth' do - let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' } - - it 'manages postfix sasl_passwd' do - expect(file(sasl_passwd_file).content).to match(/^# Auto-generated by Chef/) - end - - it 'configures postfix to use the sasl_passwd file' do - expect(file('/etc/postfix/main.cf').content).to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/) - end - - it 'configures postfix sasl_passwd with nothing in it' do - expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for .*\n/) - end -end diff --git a/test/integration/sasl_auth_one/controls/sasl_auth_one.rb b/test/integration/sasl_auth_one/controls/sasl_auth_one.rb new file mode 100644 index 00000000..57455727 --- /dev/null +++ b/test/integration/sasl_auth_one/controls/sasl_auth_one.rb @@ -0,0 +1,18 @@ +control 'sasl_auth_one' do + describe file '/etc/postfix/sasl_passwd' do + its('content') do + should cmp <<~EOF + # Auto-generated by Chef. + # Local modifications will be overwritten. + + relayhost kitchenuser:not-a-real-thing + smtp_sasl_passwd : + smtp_sasl_user_name : + EOF + end + end + + describe postfix_conf '/etc/postfix/main.cf' do + its('smtp_sasl_password_maps') { should eq 'hash:/etc/postfix/sasl_passwd' } + end +end diff --git a/test/integration/sasl_auth_one/inspec.yml b/test/integration/sasl_auth_one/inspec.yml new file mode 100644 index 00000000..955d618c --- /dev/null +++ b/test/integration/sasl_auth_one/inspec.yml @@ -0,0 +1 @@ +name: sasl_auth_one diff --git a/test/integration/sasl_auth_one/serverspec/sasl_auth_one_spec.rb b/test/integration/sasl_auth_one/serverspec/sasl_auth_one_spec.rb deleted file mode 100644 index 1e3cb3df..00000000 --- a/test/integration/sasl_auth_one/serverspec/sasl_auth_one_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -require_relative './spec_helper' - -describe 'postfix::sasl_auth' do - let(:sasl_passwd_file) { '/etc/postfix/sasl_passwd' } - - it 'manages postfix sasl_passwd' do - expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for/) - end - - it 'configures postfix to use the sasl_passwd file' do - expect(file('/etc/postfix/main.cf').content).to match(/^\s*smtp_sasl_password_maps\s*=.*#{sasl_passwd_file}\s*$/) - end - - it 'configures postfix sasl_passwd with one entry' do - expect(file(sasl_passwd_file).content).to match(/^# This file is generated by Chef for .*\nrelayhost kitchenuser:not-a-real-thing\n/) - end -end diff --git a/test/integration/server/controls/server.rb b/test/integration/server/controls/server.rb new file mode 100644 index 00000000..072e4826 --- /dev/null +++ b/test/integration/server/controls/server.rb @@ -0,0 +1,7 @@ +include_controls 'default' + +control 'server' do + describe file '/etc/postfix/main.cf' do + its('content') { should match /Configured as master/ } + end +end diff --git a/test/integration/server/inspec.yml b/test/integration/server/inspec.yml new file mode 100644 index 00000000..f7dd6ed9 --- /dev/null +++ b/test/integration/server/inspec.yml @@ -0,0 +1,4 @@ +name: server +depends: + - name: default + path: test/integration/default diff --git a/test/integration/server/serverspec/server_spec.rb b/test/integration/server/serverspec/server_spec.rb deleted file mode 100644 index 2edb4928..00000000 --- a/test/integration/server/serverspec/server_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright:: 2012-2019, Chef Software, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -require_relative './spec_helper' - -describe 'postfix::server' do - it 'doesnt configure postfix because solo is unsupported' do - pending 'Postfix may be set up by default on the system, but not configured by Chef because this test assumes it is run under Chef Solo' - end -end