diff --git a/.editorconfig b/.editorconfig index d77700e..ecb10a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,7 @@ # editorconfig.org -# MANAGED BY MODULESYNC +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ root = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f1f88cc..daceb64 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -25,7 +25,7 @@ By participating in this project you agree to abide by its terms. * Fork the repo. * Create a separate branch for your change. -* We only take pull requests with passing tests, and documentation. [travis-ci](http://travis-ci.org) runs the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). * Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. * Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. * Squash your commits down into logical components. Make sure to rebase against our current master. @@ -124,26 +124,36 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development system_tests release' +bundle install --jobs "$(nproc)" ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +bundle update +bundle clean ``` As an alternative to the `--jobs "$(nproc)` parameter, you can set an @@ -232,51 +242,31 @@ simple tests against it after applying the module. You can run this with: ```sh -bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -This will run the tests on the module's default nodeset. You can override the -nodeset used, e.g., +or ```sh -BEAKER_set=centos-7-x64 bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker ``` -There are default rake tasks for the various acceptance test modules, e.g., +This latter example will use the distribution's own version of Puppet. -```sh -bundle exec rake beaker:centos-7-x64 -bundle exec rake beaker:ssh:centos-7-x64 -``` - -If you don't want to have to recreate the virtual machine every time you can -use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at -least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the -created virtual machines will be in `.vagrant/beaker_vagrant_files`. - -Beaker also supports docker containers. We also use that in our automated CI -pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: - -```sh -PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker -``` - -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1604 -* ubuntu1804 * ubuntu2004 -* debian9 -* debian10 -* centos7 -* centos8 - -The easiest way to debug in a docker container is to open a shell: - -```sh -docker exec -it -u root ${container_id_or_name} bash -``` +* ubuntu2204 +* debian11 +* debian12 +* centos9 +* archlinux +* almalinux8 +* almalinux9 +* fedora36 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) repository. diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index cacadf2..0000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,3 +0,0 @@ -# Vox Pupuli Security Policy - -Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..f2d08d6 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f5b5d7a --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,42 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + + categories: + - title: Breaking Changes πŸ›  + labels: + - backwards-incompatible + + - title: New Features πŸŽ‰ + labels: + - enhancement + + - title: Bug Fixes πŸ› + labels: + - bug + + - title: Documentation Updates πŸ“š + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4f47e8..1f82c4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,75 +1,21 @@ -name: CI +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -on: pull_request +name: CI -jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - outputs: - beaker_setfiles: ${{ steps.get-outputs.outputs.beaker_setfiles }} - puppet_major_versions: ${{ steps.get-outputs.outputs.puppet_major_versions }} - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - env: - BUNDLE_WITHOUT: development:test:release - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Run rake validate - run: bundle exec rake validate - - name: Setup Test Matrix - id: get-outputs - run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false +on: + pull_request: {} + push: + branches: + - main + - master - unit: - needs: setup_matrix - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} - env: - BUNDLE_WITHOUT: development:system_tests:release - PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" - name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run tests - run: bundle exec rake +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true - acceptance: - needs: setup_matrix - runs-on: ubuntu-latest - env: - BUNDLE_WITHOUT: development:test:release - strategy: - fail-fast: false - matrix: - setfile: ${{fromJson(needs.setup_matrix.outputs.beaker_setfiles)}} - puppet: ${{fromJson(needs.setup_matrix.outputs.puppet_major_versions)}} - name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }} - steps: - - name: Enable IPv6 on docker - run: | - echo '{"ipv6":true,"fixed-cidr-v6":"2001:db8:1::/64"}' | sudo tee /etc/docker/daemon.json - sudo service docker restart - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Run tests - run: bundle exec rake beaker - env: - BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} - BEAKER_setfile: ${{ matrix.setfile.value }} +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..66127cd --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,17 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +on: + pull_request_target: {} + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 68b8528..93b33c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,7 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + name: Release on: @@ -5,25 +9,21 @@ on: tags: - '*' -env: - BUNDLE_WITHOUT: development:test:system_tests - jobs: - deploy: - name: 'deploy to forge' + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} + + create-github-release: + name: Create GitHub Release runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Build and Deploy - env: - # Configure secrets here: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets - BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' - BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' - run: bundle exec rake module:push + - name: Create GitHub release + uses: voxpupuli/gha-create-a-github-release@v1 diff --git a/.gitignore b/.gitignore index e9b3cf4..adea1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,25 @@ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock *.iml .*.sw? -.yardoc/ -Guardfile +/.yardoc/ +/Guardfile +bolt-debug.log +.rerun.json diff --git a/.msync.yml b/.msync.yml index a0770a8..95e8c97 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1,2 +1,5 @@ --- -modulesync_config_version: '4.0.0' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '9.1.0' diff --git a/.overcommit.yml b/.overcommit.yml index 0af0fdc..4ed994c 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -1,4 +1,5 @@ -# Managed by https://github.com/voxpupuli/modulesync_configs +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # # Hooks are only enabled if you take action. # @@ -42,10 +43,12 @@ PreCommit: enabled: true description: 'Runs rubocop on modified files only' command: ['bundle', 'exec', 'rubocop'] - PuppetLint: + RakeTarget: enabled: true - description: 'Runs puppet-lint on modified files only' - command: ['bundle', 'exec', 'puppet-lint'] + description: 'Runs lint on modified files only' + targets: + - 'lint' + command: ['bundle', 'exec', 'rake'] YamlSyntax: enabled: true JsonSyntax: diff --git a/.pmtignore b/.pmtignore index 33a8c65..10b9830 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,34 +1,38 @@ -docs/ -pkg/ -Gemfile -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/ -Rakefile -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.github/ -.librarian/ -Puppetfile.lock +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock *.iml -.editorconfig -.fixtures.yml -.gitignore -.msync.yml -.overcommit.yml -.pmtignore -.rspec -.rspec_parallel -.rubocop.yml -.sync.yml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml .*.sw? -.yardoc/ -.yardopts -Dockerfile +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..05d28a2 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,6 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rspec b/.rspec deleted file mode 100644 index 8c18f1a..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---format documentation ---color diff --git a/.rspec_parallel b/.rspec_parallel deleted file mode 100644 index e4d136b..0000000 --- a/.rspec_parallel +++ /dev/null @@ -1 +0,0 @@ ---format progress diff --git a/.rubocop.yml b/.rubocop.yml index 198a359..53ac189 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ --- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + inherit_gem: voxpupuli-test: rubocop.yml diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 3687f51..0000000 --- a/.yardopts +++ /dev/null @@ -1,2 +0,0 @@ ---markup markdown ---output-dir docs/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6fd6342..0000000 --- a/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM ruby:2.5.3 - -WORKDIR /opt/puppet - -# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 -RUN mkdir -p /etc/sv - -ARG PUPPET_VERSION="~> 6.0" -ARG PARALLEL_TEST_PROCESSORS=4 - -# Cache gems -COPY Gemfile . -RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} - -COPY . . - -RUN bundle install -RUN bundle exec rake release_checks - -# Container should not saved -RUN exit 1 diff --git a/Gemfile b/Gemfile index 0d0a9fb..7123c66 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,13 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 2.1', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false + gem 'voxpupuli-test', '~> 9.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false end group :development do @@ -12,22 +16,17 @@ group :development do end group :system_tests do - gem 'puppet_metadata', '~> 0.3.0', :require => false - gem 'voxpupuli-acceptance', :require => false + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end group :release do - gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' - gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false - gem 'puppet-strings', '>= 2.2', :require => false + gem 'voxpupuli-release', '~> 3.0', :require => false end -gem 'puppetlabs_spec_helper', '~> 2.0', :require => false gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_VERSION'] || '~> 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/Rakefile b/Rakefile index d1bf749..0179ca9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,9 +1,22 @@ -# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), # otherwise attempt to load it directly. begin require 'voxpupuli/test/rake' rescue LoadError - require 'puppetlabs_spec_helper/rake_tasks' + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end + +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError end # load optional tasks for releases @@ -11,6 +24,10 @@ end begin require 'voxpupuli/release/rake_tasks' rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-etherpad' end desc "Run main 'test' task and report merged results to coveralls" @@ -24,38 +41,4 @@ task test_with_coveralls: [:test] do end end -desc 'Generate REFERENCE.md' -task :reference, [:debug, :backtrace] do |t, args| - patterns = '' - Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) -end - -begin - require 'github_changelog_generator/task' - require 'puppet_blacksmith' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - version = (Blacksmith::Modulefile.new).version - config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/ - config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} - config.user = 'voxpupuli' - metadata_json = File.join(File.dirname(__FILE__), 'metadata.json') - metadata = JSON.load(File.read(metadata_json)) - config.project = metadata['name'] - end - - # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 - require 'rbconfig' - if RbConfig::CONFIG['host_os'] =~ /linux/ - task :changelog do - puts 'Fixing line endings...' - changelog_file = File.join(__dir__, 'CHANGELOG.md') - changelog_txt = File.read(changelog_file) - new_contents = changelog_txt.gsub(%r{\r\n}, "\n") - File.open(changelog_file, "w") {|file| file.puts new_contents } - end - end - -rescue LoadError -end # vim: syntax=ruby diff --git a/manifests/init.pp b/manifests/init.pp index fd4d20c..eb8c4a1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,7 +10,7 @@ String $service_name = 'etherpad', Enum['running', 'stopped'] $service_ensure = 'running', # again, should be an enum… # what if the fact doesn't exist (yet) or is b0rked? use Optional. - Optional[String] $service_provider = $::service_provider, + Optional[String] $service_provider = $facts['service_provider'], Boolean $manage_user = true, Boolean $manage_abiword = false, Stdlib::Absolutepath $abiword_path = '/usr/bin/abiword', diff --git a/metadata.json b/metadata.json index d3de029..75d3503 100644 --- a/metadata.json +++ b/metadata.json @@ -47,8 +47,8 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "16.04", - "18.04" + "20.04", + "22.04" ] } ] diff --git a/spec/acceptance/etherpad_spec.rb b/spec/acceptance/etherpad_spec.rb index 6f3b8ff..dbaa3bc 100644 --- a/spec/acceptance/etherpad_spec.rb +++ b/spec/acceptance/etherpad_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'etherpad' do @@ -36,8 +38,11 @@ class { 'etherpad': apply_manifest(pp, catch_changes: true) end - describe port(8000) do - it { is_expected.to be_listening } + describe port(8080) do + it { + sleep(10) # etherpad takes a while to start up + is_expected.to be_listening + } end describe process('node') do diff --git a/spec/classes/etherpad_spec.rb b/spec/classes/etherpad_spec.rb index 935c76d..c4f3787 100644 --- a/spec/classes/etherpad_spec.rb +++ b/spec/classes/etherpad_spec.rb @@ -1,441 +1,402 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'etherpad' do - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + context 'etherpad class without any parameters' do let(:pre_condition) do "package { 'nodejs' : ensure => present }" end - let(:facts) do - facts - end - context 'etherpad class without any parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_vcsrepo('/opt/etherpad') } - it { is_expected.to contain_file('/lib/systemd/system/etherpad.service') } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').with_content(%r{check the documentation}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{ldapauth}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{ep_button_link}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{\"ssl" :}) } - it { is_expected.to contain_service('etherpad') } - it { is_expected.to contain_user('etherpad') } - it { is_expected.to contain_group('etherpad') } - end + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_vcsrepo('/opt/etherpad') } + it { is_expected.to contain_file('/lib/systemd/system/etherpad.service') } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').with_content(%r{check the documentation}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{ldapauth}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{ep_button_link}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{"ssl" :}) } + it { is_expected.to contain_service('etherpad') } + it { is_expected.to contain_user('etherpad') } + it { is_expected.to contain_group('etherpad') } end - end - end - - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end - context 'etherpad class with plugins_list enabled' do - let(:params) do - { - plugins_list: { - 'ep_ldapauth' => true, - 'ep_button_link' => :undef, - 'ep_align' => false - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', - 'groupAttributeIsDN' => false - } + context 'etherpad class with plugins_list enabled' do + let(:params) do + { + plugins_list: { + 'ep_ldapauth' => true, + 'ep_button_link' => :undef, + 'ep_align' => false + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', + 'groupAttributeIsDN' => false } - end - - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap:\/\/ldap.foobar.com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"admin": {$|) } - it { is_expected.not_to contain_file('/opt/etherpad/node_modules/ep_align') } + } end + + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap://ldap.foobar.com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"admin": {$|) } + it { is_expected.not_to contain_file('/opt/etherpad/node_modules/ep_align') } end - end - end - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts + context 'etherpad class with button_link set and ssl enabled' do + let(:params) do + { + plugins_list: { + 'ep_button_link' => true + }, + button_link: { + 'text' => 'Link Button', + 'link' => 'https://example.com/pad-lister', + 'before' => "li[data-key='showTimeSlider']" + }, + ssl: 'enable', + ssl_key: '/yourpath/etherpad.key', + ssl_cert: '/yourpath/etherpad.crt' + } end - context 'etherpad class with button_link set and ssl enabled' do - let(:params) do - { - plugins_list: { - 'ep_button_link' => true - }, - button_link: { - 'text' => 'Link Button', - 'link' => 'https://example.com/pad-lister', - 'before' => "li[data-key='showTimeSlider']" - }, - ssl: 'enable', - ssl_key: '/yourpath/etherpad.key', - ssl_cert: '/yourpath/etherpad.crt' - } - end - - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"ssl\" :}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"key\" : \"/yourpath/etherpad.key\"}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"cert\" : \"/yourpath/etherpad.crt\"}) } - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r/^\s*"ep_button_link": {$/) } - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"text\": \"Link Button\",$}) } - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"link\": \"https://example.com/pad-lister\",$}) } - end + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"ssl" :}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"key" : "/yourpath/etherpad.key"}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"cert" : "/yourpath/etherpad.crt"}) } + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r/^\s*"ep_button_link": {$/) } + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"text": "Link Button",$}) } + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"link": "https://example.com/pad-lister",$}) } end - end - end - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts + context 'etherpad class with ep_ldapauth set' do + let(:params) do + { + plugins_list: { + 'ep_ldapauth' => true + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', + 'groupAttributeIsDN' => false + } + } end - context 'etherpad class with ep_ldapauth set' do - let(:params) do - { - plugins_list: { - 'ep_ldapauth' => true - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', - 'groupAttributeIsDN' => false - } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap://ldap.foobar.com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + end + + context 'etherpad class with ep_mypads set' do + let(:params) do + { + plugins_list: { + 'ep_mypads' => true + }, + mypads: { + 'url' => 'ldap://ldap.foobar.com', + 'searchBase' => 'o=staff,o=foo,dc=bar,dc=com' } - end - - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap:\/\/ldap.foobar.com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + } end - context 'etherpad class with ep_mypads set' do - let(:params) do - { - plugins_list: { - 'ep_mypads' => true - }, - mypads: { - 'url' => 'ldap://ldap.foobar.com', - 'searchBase' => 'o=staff,o=foo,dc=bar,dc=com' + it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r|^\s*"ep_mypads": {$|) } + it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r{^\s*"url": "ldap://ldap.foobar.com",$}) } + it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r{^\s*"searchBase": "o=staff,o=foo,dc=bar,dc=com"$}) } + end + + context 'etherpad class with ldapauth set' do + let(:params) do + { + plugins_list: { + 'ep_ldapauth' => true + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', + 'groupAttributeIsDN' => false + }, + users: { + 'test_user' => { + 'password' => 's3cr3t', + 'is_admin' => true } } - end - - it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r|^\s*"ep_mypads": {$|) } - it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r{^\s*"url": "ldap:\/\/ldap.foobar.com",$}) } - it { is_expected.to contain_concat_fragment('ep_mypads').with_content(%r{^\s*"searchBase": "o=staff,o=foo,dc=bar,dc=com"$}) } + } end - end - end - end - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap://ldap.foobar.com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + end - context 'etherpad class with ldapauth set' do - let(:params) do - { - plugins_list: { - 'ep_ldapauth' => true - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', - 'groupAttributeIsDN' => false - }, - users: { - 'test_user' => { - 'password' => 's3cr3t', - 'is_admin' => true - } + context 'etherpad class without default ldapauth' do + let(:params) do + { + use_default_ldapauth: false, + plugins_list: { + 'ep_ldapauth' => true + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', + 'groupAttributeIsDN' => false + }, + users: { + 'test_user' => { + 'password' => 's3cr3t', + 'is_admin' => true } } - end - - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap:\/\/ldap.foobar.com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false,$}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + } end - context 'etherpad class without default ldapauth' do - let(:params) do - { - use_default_ldapauth: false, - plugins_list: { - 'ep_ldapauth' => true - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'accountBase' => 'o=staff,o=foo,dc=bar,dc=com', - 'groupAttributeIsDN' => false - }, - users: { - 'test_user' => { - 'password' => 's3cr3t', - 'is_admin' => true - } - } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap://ldap.foobar.com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } + it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false$}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{searchPWD}) } + it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{searchDN}) } + end + + context 'etherpad class with button_link set' do + let(:params) do + { + plugins_list: { + 'ep_button_link' => true } - end - - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"users": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r|^\s*"ldapauth": {$|) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"url": "ldap:\/\/ldap.foobar.com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"accountBase": "o=staff,o=foo,dc=bar,dc=com",$}) } - it { is_expected.to contain_concat_fragment('ep_ldapauth').with_content(%r{^\s*"groupAttributeIsDN": false$}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{test_user}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{searchPWD}) } - it { is_expected.to contain_concat_fragment('settings-second.json.epp').without_content(%r{searchDN}) } + } end - context 'etherpad class with button_link set' do - let(:params) do - { - plugins_list: { - 'ep_button_link' => true - } - } - end + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r/^\s*"ep_button_link": {$/) } + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"text": "Hello world",$}) } + it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"link": "http://example.com",$}) } + end - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r/^\s*"ep_button_link": {$/) } - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"text\": \"Hello world\",$}) } - it { is_expected.to contain_concat_fragment('ep_button_link').with_content(%r{^\s*"link\": \"http://example.com\",$}) } + context 'etherpad class with users pad options set' do + let(:pre_condition) do + "package { 'nodejs' : ensure => present }" end - - context 'etherpad class with users pad options set' do - let(:pre_condition) do - "package { 'nodejs' : ensure => present }" - end - let(:params) do - { - 'padoptions' => { - 'noColors' => true, - 'lang' => 'fr' - } + let(:params) do + { + 'padoptions' => { + 'noColors' => true, + 'lang' => 'fr' } - end - - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"padOptions\":}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"noColors\": true,}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"lang\": \"fr\"}) } + } end - context 'etherpad class with bad users pad options set' do - let(:params) do - { - 'padoptions' => { - 'nocolor' => 'true', - 'Lang' => 'fr' - } - } - end + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"padOptions":}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"noColors": true,}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{^\s*"lang": "fr"}) } + end - it { is_expected.to compile.and_raise_error(%r{Error while evaluating a Resource Statement}) } + context 'etherpad class with bad users pad options set' do + let(:params) do + { + 'padoptions' => { + 'nocolor' => 'true', + 'Lang' => 'fr' + } + } end - context 'etherpad class with all parameters set and ssl enabled' do - let(:pre_condition) do - "package { 'nodejs' : ensure => present }" - end - let(:params) do - { - ensure: 'present', - service_name: 'etherpad', - service_ensure: 'running', - service_provider: facts[:service_provider], - manage_user: true, - manage_abiword: false, - abiword_path: '/usr/bin/abiword', - manage_tidy: false, - tidy_path: '/usr/bin/tidy', - user: 'etherpad', - group: 'etherpad', - root_dir: '/opt/etherpad', - source: 'https://github.com/ether/etherpad-lite.git', - - # Db - database_type: 'dirty', - database_host: 'localhost', - database_user: 'etherpad', - database_name: 'etherpad', - database_password: 'etherpad', - - # Network - ip: '*', - port: 9001, - trust_proxy: false, - - # Performance - max_age: 21_600, - minify: true, - - # Config - button_link: { - 'text' => 'Link Button', - 'link' => 'http://example.com/pad-lister', - 'before' => "li[data-key='showTimeSlider']" - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'groupAttributeIsDN' => true - }, - require_session: false, - edit_only: false, - require_authentication: false, - require_authorization: false, - pad_title: :undef, - default_pad_text: 'Welcome to etherpad!', - - # Users - 'users' => { - 'admin' => { - 'password' => 's3cr3t', - 'is_admin' => true - }, - 'user' => { - 'password' => 'secret', - 'is_admin' => false - } - }, + it { is_expected.to compile.and_raise_error(%r{Error while evaluating a Resource Statement}) } + end - # Ssl - ssl: 'enable', - ssl_key: '/yourpath/etherpad.key', - ssl_cert: '/yourpath/etherpad.crt', + context 'etherpad class with all parameters set and ssl enabled' do + let(:pre_condition) do + "package { 'nodejs' : ensure => present }" + end + let(:params) do + { + ensure: 'present', + service_name: 'etherpad', + service_ensure: 'running', + service_provider: facts[:service_provider], + manage_user: true, + manage_abiword: false, + abiword_path: '/usr/bin/abiword', + manage_tidy: false, + tidy_path: '/usr/bin/tidy', + user: 'etherpad', + group: 'etherpad', + root_dir: '/opt/etherpad', + source: 'https://github.com/ether/etherpad-lite.git', + + # Db + database_type: 'dirty', + database_host: 'localhost', + database_user: 'etherpad', + database_name: 'etherpad', + database_password: 'etherpad', + + # Network + ip: '*', + port: 9001, + trust_proxy: false, + + # Performance + max_age: 21_600, + minify: true, + + # Config + button_link: { + 'text' => 'Link Button', + 'link' => 'http://example.com/pad-lister', + 'before' => "li[data-key='showTimeSlider']" + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'groupAttributeIsDN' => true + }, + require_session: false, + edit_only: false, + require_authentication: false, + require_authorization: false, + pad_title: :undef, + default_pad_text: 'Welcome to etherpad!', + + # Users + 'users' => { + 'admin' => { + 'password' => 's3cr3t', + 'is_admin' => true + }, + 'user' => { + 'password' => 'secret', + 'is_admin' => false + } + }, - # Logging - logconfig_file: true, - logconfig_file_filename: '/var/log/etherpad.log', - logconfig_file_max_log_size: 1024, - logconfig_file_backups: 3, - logconfig_file_category: 'etherpad' + # Ssl + ssl: 'enable', + ssl_key: '/yourpath/etherpad.key', + ssl_cert: '/yourpath/etherpad.crt', - } - end + # Logging + logconfig_file: true, + logconfig_file_filename: '/var/log/etherpad.log', + logconfig_file_max_log_size: 1024, + logconfig_file_backups: 3, + logconfig_file_category: 'etherpad' - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"ssl\" :}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"key\" : \"/yourpath/etherpad.key\"}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"cert\" : \"/yourpath/etherpad.crt\"}) } - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file('/var/log/etherpad.log') } + } end - context 'etherpad class with all parameters set' do - let(:params) do - { - ensure: 'present', - service_name: 'etherpad', - service_ensure: 'running', - service_provider: facts[:service_provider], - manage_user: true, - manage_abiword: false, - abiword_path: '/usr/bin/abiword', - manage_tidy: false, - tidy_path: '/usr/bin/tidy', - user: 'etherpad', - group: 'etherpad', - root_dir: '/opt/etherpad', - source: 'https://github.com/ether/etherpad-lite.git', - - # Db - database_type: 'dirty', - database_host: 'localhost', - database_user: 'etherpad', - database_name: 'etherpad', - database_password: 'etherpad', - - # Network - ip: '*', - port: 9001, - trust_proxy: false, - - # Performance - max_age: 21_600, - minify: true, - - # Config - plugins_list: { - 'ep_button_link' => true, - 'ep_ldapauth' => true - }, - button_link: { - 'text' => 'Link Button', - 'link' => 'http://example.com/pad-lister', - 'before' => "li[data-key='showTimeSlider']" - }, - ldapauth: { - 'url' => 'ldap://ldap.foobar.com', - 'groupAttributeIsDN' => true - }, - use_default_ldapauth: false, - require_session: false, - edit_only: false, - require_authentication: false, - require_authorization: false, - pad_title: :undef, - default_pad_text: 'Welcome to etherpad!', - - # Users - 'users' => { - 'admin' => { - 'password' => 's3cr3t', - 'is_admin' => true - }, - 'user' => { - 'password' => 'secret', - 'is_admin' => false - } - }, + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"ssl" :}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"key" : "/yourpath/etherpad.key"}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"cert" : "/yourpath/etherpad.crt"}) } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('/var/log/etherpad.log') } + end - # Ssl - ssl: 'disable', - ssl_key: '/yourpath/foobar/etherpad.key', - ssl_cert: '/yourpath/foobar/etherpad.crt', - - # Logging - logconfig_file: true, - logconfig_file_filename: '/var/log/etherpad.log', - logconfig_file_max_log_size: 1024, - logconfig_file_backups: 3, - logconfig_file_category: 'etherpad' - } - end - - it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{\"ssl\" :}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{\"key\" : \"/yourpath/etherpad.key\"}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{\"cert\" : \"/yourpath/etherpad.crt\"}) } - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file('/var/log/etherpad.log') } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"padOptions\":}) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"noColors\": false,\n }) } - it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{\"lang\": \"en-gb\"}) } + context 'etherpad class with all parameters set' do + let(:params) do + { + ensure: 'present', + service_name: 'etherpad', + service_ensure: 'running', + service_provider: facts[:service_provider], + manage_user: true, + manage_abiword: false, + abiword_path: '/usr/bin/abiword', + manage_tidy: false, + tidy_path: '/usr/bin/tidy', + user: 'etherpad', + group: 'etherpad', + root_dir: '/opt/etherpad', + source: 'https://github.com/ether/etherpad-lite.git', + + # Db + database_type: 'dirty', + database_host: 'localhost', + database_user: 'etherpad', + database_name: 'etherpad', + database_password: 'etherpad', + + # Network + ip: '*', + port: 9001, + trust_proxy: false, + + # Performance + max_age: 21_600, + minify: true, + + # Config + plugins_list: { + 'ep_button_link' => true, + 'ep_ldapauth' => true + }, + button_link: { + 'text' => 'Link Button', + 'link' => 'http://example.com/pad-lister', + 'before' => "li[data-key='showTimeSlider']" + }, + ldapauth: { + 'url' => 'ldap://ldap.foobar.com', + 'groupAttributeIsDN' => true + }, + use_default_ldapauth: false, + require_session: false, + edit_only: false, + require_authentication: false, + require_authorization: false, + pad_title: :undef, + default_pad_text: 'Welcome to etherpad!', + + # Users + 'users' => { + 'admin' => { + 'password' => 's3cr3t', + 'is_admin' => true + }, + 'user' => { + 'password' => 'secret', + 'is_admin' => false + } + }, + + # Ssl + ssl: 'disable', + ssl_key: '/yourpath/foobar/etherpad.key', + ssl_cert: '/yourpath/foobar/etherpad.crt', + + # Logging + logconfig_file: true, + logconfig_file_filename: '/var/log/etherpad.log', + logconfig_file_max_log_size: 1024, + logconfig_file_backups: 3, + logconfig_file_category: 'etherpad' + } end + + it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{"ssl" :}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{"key" : "/yourpath/etherpad.key"}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').without_content(%r{"cert" : "/yourpath/etherpad.crt"}) } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('/var/log/etherpad.log') } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"padOptions":}) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"noColors": false,\n }) } + it { is_expected.to contain_concat_fragment('settings-first.json.epp').with_content(%r{"lang": "en-gb"}) } end end end diff --git a/spec/defines/etherpad_plugin_common_spec.rb b/spec/defines/etherpad_plugin_common_spec.rb index 42a809c..399b61a 100644 --- a/spec/defines/etherpad_plugin_common_spec.rb +++ b/spec/defines/etherpad_plugin_common_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'etherpad::plugins::common' do @@ -12,6 +14,7 @@ let(:title) { 'ep_myplugin' } it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_nodejs__npm('ep_myplugin').with( 'ensure' => 'present', diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d266f6b..58c9b66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,18 +1,24 @@ -# This file is managed via modulesync -# https://github.com/voxpupuli/modulesync -# https://github.com/voxpupuli/modulesync_config +# frozen_string_literal: true + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. -ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) require 'voxpupuli/test/spec_helper' +RSpec.configure do |c| + c.facterdb_string_keys = false +end + +add_mocked_facts! + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) - if facts - facts.each do |name, value| - add_custom_fact name.to_sym, value - end + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 3d21520..44c2320 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,17 +1,17 @@ +# frozen_string_literal: true + require 'voxpupuli/acceptance/spec_helper_acceptance' configure_beaker do |host| # Additional modules for soft deps required by puppet-nodejs - if fact_on(host, 'os.family') == 'Debian' - install_module_from_forge_on(host, 'puppetlabs-apt', '>= 4.4.0 < 8.0.0') - end + install_puppet_module_via_pmt_on(host, 'puppetlabs-apt') if fact_on(host, 'os.family') == 'Debian' # needed : # * a database and granted user # * a php with mysql driver # * git command used by vcsrepo - install_module_from_forge_on(host, 'puppetlabs-mysql', '>= 6.0.0 < 11.0.0') + install_puppet_module_via_pmt_on(host, 'puppetlabs-mysql') pp = %( include mysql::server