Skip to content

Commit

Permalink
added acceptance tests for an ssh instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Hoenscheid committed Mar 18, 2022
1 parent 85c0089 commit 8b563a5
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,33 @@ jobs:
bundler-cache: true
- name: Run tests
run: bundle exec rake parallel_spec
acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}}
name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: ${{ matrix.setfile.value }}
tests:
needs:
- unit
- acceptance
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed
68 changes: 68 additions & 0 deletions spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'ssh' do
context 'with defaults' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
'include ssh'
end

describe package('openssh-server') do
it { is_expected.to be_installed }
end
describe port(22) do
it { is_expected.to be_listening }
end
describe service('sshd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end
context 'Server with a seperate sftp_server_init instance on Port 8022' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'ssh':
'server_instances' => {
'sftp_server_init' => {
'ensure' => 'present',
'options' => {
'sshd_config' => {
'Port' => 8022,
'Protocol' => 2,
'AddressFamily' => 'any',
'HostKey' => '/etc/ssh/ssh_host_rsa_key',
'SyslogFacility' => 'AUTH',
'LogLevel' => 'INFO',
'PermitRootLogin' => 'no',
},
'sshd_service_options' => '',
'match_blocks' => {},
},
},
},
}
PUPPET
end

it 'works idempotently with no errors' do
apply_manifest(manifest, catch_failures: true)
apply_manifest(manifest, catch_changes: true)
end

describe package('openssh-server') do
it { is_expected.to be_installed }
end
describe port(8022) do
it { is_expected.to be_listening }
end
describe service('sftp_server_init') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end
end
5 changes: 5 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker

Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 comments on commit 8b563a5

Please sign in to comment.