# HG changeset patch # User IBBoard # Date 1665308072 -3600 # Node ID 4a2ee7e3b110dbc32c3eeaa8ac22aaa19fdc16ff # Parent a200bf678bec6ea1e57f35dda0aa961d268a9f65 Update stdlib in case it fixed deprecation diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.devcontainer/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.devcontainer/Dockerfile Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,6 @@ +FROM puppet/pdk:latest + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.devcontainer/devcontainer.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.devcontainer/devcontainer.json Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pdk --version", +} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.github/workflows/nightly.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.github/workflows/nightly.yml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,230 @@ +name: "nightly" + +on: + schedule: + - cron: '0 0 * * *' + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + +jobs: + setup_matrix: + name: "Setup Test Matrix" + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.get-matrix.outputs.matrix }} + + steps: + - name: "Honeycomb: Start recording" + uses: kvrhdn/gha-buildevents@v1.0.2 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: Start first step" + run: | + echo STEP_ID=0 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Checkout Source + uses: actions/checkout@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Activate Ruby 2.7 + uses: actions/setup-ruby@v1 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + ruby-version: "2.7" + + - name: Cache gems + uses: actions/cache@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + path: vendor/gems + key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-${{ github.event_name }}- + ${{ runner.os }}- + + - name: Install gems + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems + buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 + buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 + buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install + buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean + + - name: Setup Acceptance Test Matrix + id: get-matrix + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then + buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata + else + echo "::set-output name=matrix::{}" + fi + + - name: "Honeycomb: Record setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' + + Acceptance: + needs: + - setup_matrix + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} + + env: + BUILDEVENT_FILE: '../buildevents.txt' + + steps: + - run: | + echo 'platform=${{ matrix.platform }}' >> $BUILDEVENT_FILE + echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE + + - name: "Honeycomb: Start recording" + uses: kvrhdn/gha-buildevents@v1.0.2 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + matrix-key: ${{ matrix.platform }}-${{ matrix.collection }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-1 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Checkout Source + uses: actions/checkout@v2 + + - name: Activate Ruby 2.7 + uses: actions/setup-ruby@v1 + with: + ruby-version: "2.7" + + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/gems + key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-${{ github.event_name }}- + ${{ runner.os }}- + + - name: "Honeycomb: Record cache setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Cache retrieval' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-2 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Bundler Setup + run: | + buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems + buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 + buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 + buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install + buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Bundler Setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Bundler Setup' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-3 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Provision test environment + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platform }}' -- bundle exec rake 'litmus:provision[provision::provision_service,${{ matrix.platform }}]' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + echo ::group::=== INVENTORY === + sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true + echo ::endgroup:: + + # The provision service hands out machines as soon as they're provisioned. + # The GCP VMs might still take a while to spool up and configure themselves fully. + # This retry loop spins until all agents have been installed successfully. + - name: Install agent + uses: nick-invision/retry@v1 + with: + timeout_minutes: 30 + max_attempts: 5 + retry_wait_seconds: 60 + command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + + # The agent installer on windows does not finish in time for this to work. To + # work around this for now, retry after a minute if installing the module failed. + - name: Install module + uses: nick-invision/retry@v1 + with: + timeout_minutes: 30 + max_attempts: 2 + retry_wait_seconds: 60 + command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' + + - name: "Honeycomb: Record deployment times" + if: ${{ always() }} + run: | + echo ::group::honeycomb step + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-4 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + echo ::endgroup:: + + - name: Run acceptance tests + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' + + - name: "Honeycomb: Record acceptance testing times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-5 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Remove test environment + if: ${{ always() }} + run: | + if [ -f inventory.yaml ]; then + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + fi + + - name: "Honeycomb: Record removal times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' + + slack-workflow-status: + if: always() + name: Post Workflow Status To Slack + needs: + - Acceptance + runs-on: ubuntu-20.04 + steps: + - name: Slack Workflow Notification + uses: Gamesight/slack-workflow-status@v1.0.1 + with: + # Required Input + repo_token: ${{ secrets.GITHUB_TOKEN }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK }} + # Optional Input + channel: '#team-ia-bots' + name: 'GABot' diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.github/workflows/pr_test.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.github/workflows/pr_test.yml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,211 @@ +name: "PR Testing" + +on: [pull_request] + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + +jobs: + setup_matrix: + name: "Setup Test Matrix" + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.get-matrix.outputs.matrix }} + + steps: + - name: "Honeycomb: Start recording" + uses: kvrhdn/gha-buildevents@v1.0.2 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: Start first step" + run: | + echo STEP_ID=0 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Checkout Source + uses: actions/checkout@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + + - name: Activate Ruby 2.7 + uses: actions/setup-ruby@v1 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + ruby-version: "2.7" + + - name: Cache gems + uses: actions/cache@v2 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + path: vendor/gems + key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-${{ github.event_name }}- + ${{ runner.os }}- + + - name: Install gems + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems + buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 + buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 + buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install + buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean + + - name: Setup Acceptance Test Matrix + id: get-matrix + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + if [ '${{ github.repository_owner }}' == 'puppetlabs' ]; then + buildevents cmd $TRACE_ID $STEP_ID matrix_from_metadata -- bundle exec matrix_from_metadata + else + echo "::set-output name=matrix::{}" + fi + + - name: "Honeycomb: Record setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix' + + Acceptance: + needs: + - setup_matrix + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} + + env: + BUILDEVENT_FILE: '../buildevents.txt' + + steps: + - run: | + echo 'platform=${{ matrix.platform }}' >> $BUILDEVENT_FILE + echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE + + - name: "Honeycomb: Start recording" + uses: kvrhdn/gha-buildevents@v1.0.2 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + matrix-key: ${{ matrix.platform }}-${{ matrix.collection }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-1 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Checkout Source + uses: actions/checkout@v2 + + - name: Activate Ruby 2.7 + uses: actions/setup-ruby@v1 + with: + ruby-version: "2.7" + + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/gems + key: ${{ runner.os }}-${{ github.event_name }}-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-${{ github.event_name }}- + ${{ runner.os }}- + + - name: "Honeycomb: Record cache setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Cache retrieval' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-2 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Bundler Setup + run: | + buildevents cmd $TRACE_ID $STEP_ID 'bundle config path vendor/gems' -- bundle config path vendor/gems + buildevents cmd $TRACE_ID $STEP_ID 'bundle config jobs 8' -- bundle config jobs 8 + buildevents cmd $TRACE_ID $STEP_ID 'bundle config retry 3' -- bundle config retry 3 + buildevents cmd $TRACE_ID $STEP_ID 'bundle install' -- bundle install + buildevents cmd $TRACE_ID $STEP_ID 'bundle clean' -- bundle clean + echo ::group::bundler environment + buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env + echo ::endgroup:: + + - name: "Honeycomb: Record Bundler Setup time" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Bundler Setup' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-3 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Provision test environment + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platform }}' -- bundle exec rake 'litmus:provision[provision::provision_service,${{ matrix.platform }}]' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + echo ::group::=== INVENTORY === + sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true + echo ::endgroup:: + + # The provision service hands out machines as soon as they're provisioned. + # The GCP VMs might still take a while to spool up and configure themselves fully. + # This retry loop spins until all agents have been installed successfully. + - name: Install agent + uses: nick-invision/retry@v1 + with: + timeout_minutes: 30 + max_attempts: 5 + retry_wait_seconds: 60 + command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' + + # The agent installer on windows does not finish in time for this to work. To + # work around this for now, retry after a minute if installing the module failed. + - name: Install module + uses: nick-invision/retry@v1 + with: + timeout_minutes: 30 + max_attempts: 2 + retry_wait_seconds: 60 + command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module' + + - name: "Honeycomb: Record deployment times" + if: ${{ always() }} + run: | + echo ::group::honeycomb step + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-4 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + echo ::endgroup:: + + - name: Run acceptance tests + run: | + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel' + + - name: "Honeycomb: Record acceptance testing times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests' + echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-5 >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: Remove test environment + if: ${{ always() }} + run: | + if [ -f inventory.yaml ]; then + buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down' + echo ::group::=== REQUEST === + cat request.json || true + echo + echo ::endgroup:: + fi + + - name: "Honeycomb: Record removal times" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment' diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.gitpod.Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.gitpod.Dockerfile Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,18 @@ +FROM gitpod/workspace-full +RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ + wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ + sudo dpkg -i puppet6-release-bionic.deb && \ + sudo dpkg -i puppet-tools-release-bionic.deb && \ + sudo apt-get update && \ + sudo apt-get install -y pdk zsh puppet-agent && \ + sudo apt-get clean && \ + sudo rm -rf /var/lib/apt/lists/* +RUN sudo usermod -s $(which zsh) gitpod && \ + sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ + echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ + echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ + sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ + mkdir -p /home/gitpod/.config/puppet && \ + /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml +RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb +ENTRYPOINT /usr/bin/zsh diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.gitpod.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.gitpod.yml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,9 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: pdk bundle install + +vscode: + extensions: + - puppet.puppet-vscode@1.0.0:oSzfTkDf6Cmc1jOjgW33VA== diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.rubocop_todo.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.rubocop_todo.yml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,10 @@ +RSpec/NamedSubject: + Enabled: false +Lint/ScriptPermission: + Enabled: false +Style/HashSyntax: + Exclude: + - spec/spec_helper.rb + EnforcedStyle: hash_rockets +Layout/IndentHeredoc: + Enabled: false diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/.ruby-version --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/.ruby-version Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +2.6.3 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/CHANGELOG.md --- a/modules/stdlib/CHANGELOG.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/CHANGELOG.md Sun Oct 09 10:34:32 2022 +0100 @@ -2,6 +2,66 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v6.6.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.6.0) (2021-02-01) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.5.0...v6.6.0) + +### Added + +- stdlib::ensure: new fuction to cast ensure values [\#1150](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1150) ([b4ldr](https://github.com/b4ldr)) +- \(feat\) Add support for Puppet 7 [\#1144](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1144) ([daianamezdrea](https://github.com/daianamezdrea)) +- Allow options injection for to\_yaml [\#1137](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1137) ([baurmatt](https://github.com/baurmatt)) +- Allow start/end checks on empty strings [\#1135](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1135) ([jvrsantacruz](https://github.com/jvrsantacruz)) +- Stdlib::HttpStatus: add type for HTTP status codes as per rfc2616 [\#1132](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1132) ([b4ldr](https://github.com/b4ldr)) + +### Fixed + +- \(IAC-1375\) fix unit tests for pe\_version fact, when using later facte… [\#1155](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1155) ([tphoney](https://github.com/tphoney)) +- seeded\_rand: update funtion to ensure it returns an int not String [\#1139](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1139) ([b4ldr](https://github.com/b4ldr)) + +## [v6.5.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.5.0) (2020-09-30) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.4.0...v6.5.0) + +### Added + +- Add parsehocon\(\) function [\#1130](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1130) ([reidmv](https://github.com/reidmv)) +- Add new types for Stdlib::Ensure::File [\#1129](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1129) ([b4ldr](https://github.com/b4ldr)) +- Add additional types Stdlib::Port::Dynamic,Ephemeral,Registered,User} [\#1128](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1128) ([b4ldr](https://github.com/b4ldr)) +- Stdlib::Datasize: This CR adds a new data size type alias [\#1126](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1126) ([b4ldr](https://github.com/b4ldr)) + +## [v6.4.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.4.0) (2020-08-20) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.3.0...v6.4.0) + +### Added + +- pdksync - \(IAC-973\) - Update travis/appveyor to run on new default branch `main` [\#1117](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1117) ([david22swan](https://github.com/david22swan)) +- \(IAC-746\) - Add ubuntu 20.04 support [\#1110](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1110) ([david22swan](https://github.com/david22swan)) + +### Fixed + +- \[MODULES-10781\] Fix defined type defined\_with\_params\(\) [\#1122](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1122) ([trevor-vaughan](https://github.com/trevor-vaughan)) +- \[MODULES-10729\] defined\_with\_params - unnamed type [\#1115](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1115) ([trevor-vaughan](https://github.com/trevor-vaughan)) + +## [v6.3.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.3.0) (2020-04-16) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.2.0...v6.3.0) + +### Added + +- Add start\_with function [\#1086](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1086) ([baurmatt](https://github.com/baurmatt)) +- stdlib::end\_with: create String.end\_with function [\#1084](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1084) ([b4ldr](https://github.com/b4ldr)) +- Adding str2saltedpbkdf2 function [\#1040](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1040) ([genebean](https://github.com/genebean)) + +### Fixed + +- \(MODULES-10623\) explicitly top-scope calls to JSON methods [\#1101](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1101) ([tkishel](https://github.com/tkishel)) +- \[IAC-547\] Remove strftime from stdlib as it has already been replaced by the puppet agent since 4.8.0 [\#1097](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1097) ([carabasdaniel](https://github.com/carabasdaniel)) +- Add correct namespace for start\_with function [\#1095](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1095) ([baurmatt](https://github.com/baurmatt)) +- intersection: show types in exception due to invalid arguments [\#1077](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1077) ([runejuhl](https://github.com/runejuhl)) +- Make type aliases stricter [\#1066](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1066) ([pegasd](https://github.com/pegasd)) + ## [v6.2.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.2.0) (2019-12-10) [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.1.0...v6.2.0) @@ -389,7 +449,7 @@ - Permit double slash in absolute/Unix path types. #### Bugfixes -- Fix unsupported data type error with rspec-puppet master. +- Fix unsupported data type error with rspec-puppet server. - Now allows test module metadata.json to be read by Puppet. - Fix acceptance test failure "Hiera is not a class". - Removal of unsupported platforms and future parser setting in acceptance tests. @@ -1033,7 +1093,7 @@ ##### 2012-07-19 - Jeff McCune - 2.4.0 - * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88) + * (Maint) use PuppetlabsSpec::PuppetInternals.scope (main) (deafe88) ##### 2012-07-10 - Hailee Kenney - 2.4.0 @@ -1059,7 +1119,7 @@ * (#13595) initialize\_everything\_for\_tests couples modules Puppet ver (3222f35) * (#13439) Fix MRI 1.9 issue with spec\_helper (15c5fd1) * (#13439) Fix test failures with Puppet 2.6.x (665610b) - * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca) + * (#13439) refactor spec helper for compatibility with both puppet 2.7 and server (82194ca) * (#13494) Specify the behavior of zero padded strings (61891bb) ##### 2012-03-29 Puppet Labs - 2.1.3 @@ -1152,4 +1212,4 @@ * Add stdlib::stages class with a standard set of stages -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/CONTRIBUTING.md --- a/modules/stdlib/CONTRIBUTING.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/CONTRIBUTING.md Sun Oct 09 10:34:32 2022 +0100 @@ -108,7 +108,7 @@ To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of - directly on "master". + directly on "main". It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/Gemfile --- a/modules/stdlib/Gemfile Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' - -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} - - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] - else - [place_or_version, { require: false }] - end -end - -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - -group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') -end - -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} - -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] -end - -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params -end - -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] - -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end -# vim: syntax=ruby diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/Gemfile_puppet5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/Gemfile_puppet5 Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,299 @@ +GIT + remote: https://github.com/skywinder/github-changelog-generator + revision: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018 + ref: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018 + specs: + github_changelog_generator (1.15.0.pre.rc) + activesupport + faraday-http-cache + multi_json + octokit (~> 4.6) + rainbow (>= 2.2.1) + rake (>= 10.0) + retriable (~> 3.0) + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.6) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + ansi (1.5.0) + ast (2.4.0) + awesome_print (1.8.0) + bcrypt_pbkdf (1.0.1) + codecov (0.1.16) + json + simplecov + url + coderay (1.1.2) + concurrent-ruby (1.1.5) + dependency_checker (0.2.0) + parallel + puppet_forge (~> 2.2) + rake (~> 12.3) + semantic_puppet (~> 1.0) + diff-lcs (1.3) + docile (1.3.2) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + ed25519 (1.2.4) + facter (2.5.7) + facter (2.5.7-universal-darwin) + CFPropertyList (~> 2.2) + facterdb (1.4.0) + facter (< 4.0.0) + jgrep + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-http-cache (2.2.0) + faraday (>= 0.8) + faraday_middleware (0.14.0) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.34) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2, < 3.3.0) + locale + hiera (3.6.0) + hirb (0.7.3) + hocon (1.3.0) + http-accept (1.7.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + jgrep (1.5.2) + json (2.0.4) + json-schema (2.8.1) + addressable (>= 2.4) + locale (2.1.3) + metaclass (0.0.4) + metadata-json-lint (2.3.0) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + method_source (0.8.2) + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2020.0512) + minitar (0.9) + minitest (5.14.1) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.14.1) + multipart-post (2.1.1) + net-scp (3.0.0) + net-ssh (>= 2.6.5, < 7.0.0) + net-ssh (6.0.2) + net-telnet (0.1.1) + netrc (0.11.0) + octokit (4.18.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + parallel (1.19.1) + parallel_tests (2.14.2) + parallel + parser (2.5.1.2) + ast (~> 2.4.0) + pathspec (0.2.1) + pluginator (1.5.0) + powerpack (0.1.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + public_suffix (4.0.5) + puppet (5.5.20) + facter (> 2.0.1, < 4) + fast_gettext (~> 1.1.2) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + multi_json (~> 1.10) + puppet (5.5.20-universal-darwin) + CFPropertyList (~> 2.2) + facter (> 2.0.1, < 4) + fast_gettext (~> 1.1.2) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-blacksmith (6.0.0) + puppet-modulebuilder (~> 0.1) + rest-client (~> 2.0) + puppet-debugger (0.19.0) + awesome_print (~> 1.7) + bundler + facterdb (>= 0.4.0) + pluginator (~> 1.5.0) + puppet (>= 3.8) + rb-readline (>= 0.5.5) + table_print (>= 1.0.0) + puppet-lint (2.4.2) + puppet-module-posix-default-r2.4 (0.4.4) + puppet-module-posix-dev-r2.4 (0.4.4) + activesupport (>= 5.0.0, < 6.0.0) + codecov (~> 0.1.10) + concurrent-ruby (!= 1.1.6) + dependency_checker (~> 0.2) + facterdb (>= 0.8.1, < 2.0.0) + gettext-setup (~> 0.26) + metadata-json-lint (>= 2.0.2, < 3.0.0) + mocha (>= 1.0.0, < 1.2.0) + parallel_tests (>= 2.14.1, < 2.14.3) + parser (~> 2.5.1.2) + pry (~> 0.10.4) + puppet-blacksmith (>= 3.4.0) + puppet-debugger (~> 0.14) + puppet-lint (>= 2.3.0, < 3.0.0) + puppet-resource_api (~> 1.6) + puppet-strings (~> 2.0) + puppet-syntax (>= 2.4.1, < 3.0.0) + puppet_pot_generator (~> 1.0) + puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) + rainbow (~> 2.0) + rspec-puppet (>= 2.3.2, < 3.0.0) + rspec-puppet-facts (~> 1.10.0) + rspec_junit_formatter (~> 0.2) + rubocop (~> 0.49.0) + rubocop-i18n (~> 1.2.0) + rubocop-rspec (~> 1.16.0) + serverspec (~> 2.41) + simplecov (>= 0.14.1, < 1.0.0) + simplecov-console (~> 0.4.2) + specinfra (= 2.82.2) + puppet-modulebuilder (0.2.0) + minitar (~> 0.6) + pathspec (~> 0.2.1) + puppet-resource_api (1.8.13) + hocon (>= 1.0) + puppet-strings (2.4.0) + rgen + yard (~> 0.9.5) + puppet-syntax (2.6.1) + puppet (>= 5) + rake + puppet_forge (2.3.4) + faraday (>= 0.9.0, < 0.18.0, != 0.13.1) + faraday_middleware (>= 0.9.0, < 0.15.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppet_pot_generator (1.0.1) + puppet + puppetlabs_spec_helper (2.14.1) + mocha (~> 1.0) + pathspec (~> 0.2.1) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rainbow (2.2.2) + rake + rake (12.3.3) + rb-readline (0.5.5) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + retriable (3.1.2) + rgen (0.8.2) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-puppet (2.7.8) + rspec + rspec-puppet-facts (1.10.0) + facter + facterdb (>= 0.5.0) + json + puppet + rspec-support (3.9.3) + rspec_junit_formatter (0.4.1) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (0.49.1) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-i18n (1.2.0) + rubocop (~> 0.49.0) + rubocop-rspec (1.16.0) + rubocop (>= 0.49.0) + ruby-progressbar (1.10.1) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + semantic_puppet (1.0.2) + serverspec (2.41.5) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.72) + sfl (2.3) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.12.2) + slop (3.6.0) + spdx-licenses (1.2.0) + specinfra (2.82.2) + net-scp + net-ssh (>= 2.7) + net-telnet (= 0.1.1) + sfl + table_print (1.5.6) + text (1.3.1) + thread_safe (0.3.6) + tzinfo (1.2.7) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + url (0.3.2) + yard (0.9.25) + +PLATFORMS + ruby + x86_64-darwin-18 + +DEPENDENCIES + bcrypt_pbkdf (>= 1.0, < 2.0) + ed25519 (>= 1.2, < 2.0) + fast_gettext + github_changelog_generator! + json (= 2.0.4) + puppet (~> 5.0) + puppet-module-posix-default-r2.4 (~> 0.4) + puppet-module-posix-dev-r2.4 (~> 0.4) + puppet-module-win-default-r2.4 (~> 0.4) + puppet-module-win-dev-r2.4 (~> 0.4) + rb-readline (= 0.5.5) + +BUNDLED WITH + 2.1.4 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/Gemfile_puppet6 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/Gemfile_puppet6 Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,312 @@ +GIT + remote: https://github.com/skywinder/github-changelog-generator + revision: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018 + ref: 20ee04ba1234e9e83eb2ffb5056e23d641c7a018 + specs: + github_changelog_generator (1.15.0.pre.rc) + activesupport + faraday-http-cache + multi_json + octokit (~> 4.6) + rainbow (>= 2.2.1) + rake (>= 10.0) + retriable (~> 3.0) + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.6) + activesupport (5.2.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + ansi (1.5.0) + ast (2.4.0) + awesome_print (1.8.0) + bcrypt_pbkdf (1.0.1) + codecov (0.1.16) + json + simplecov + url + coderay (1.1.2) + concurrent-ruby (1.1.5) + deep_merge (1.2.1) + dependency_checker (0.2.0) + parallel + puppet_forge (~> 2.2) + rake (~> 12.3) + semantic_puppet (~> 1.0) + diff-lcs (1.3) + docile (1.3.2) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + ed25519 (1.2.4) + facter (4.0.22) + hocon (~> 1.3) + thor (>= 1.0.1, < 2.0) + facterdb (1.2.0) + facter + jgrep + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-http-cache (2.2.0) + faraday (>= 0.8) + faraday_middleware (0.14.0) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.34) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2, < 3.3.0) + locale + hiera (3.6.0) + hirb (0.7.3) + hocon (1.3.0) + http-accept (1.7.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + jgrep (1.5.2) + json (2.0.4) + json-schema (2.8.1) + addressable (>= 2.4) + locale (2.1.3) + metaclass (0.0.4) + metadata-json-lint (2.3.0) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + method_source (0.8.2) + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2020.0512) + minitar (0.9) + minitest (5.14.1) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.14.1) + multipart-post (2.1.1) + net-scp (3.0.0) + net-ssh (>= 2.6.5, < 7.0.0) + net-ssh (6.0.2) + net-telnet (0.1.1) + netrc (0.11.0) + octokit (4.18.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + parallel (1.19.1) + parallel_tests (2.14.2) + parallel + parser (2.5.1.2) + ast (~> 2.4.0) + pathspec (0.2.1) + pluginator (1.5.0) + powerpack (0.1.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + public_suffix (4.0.5) + puppet (6.15.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (~> 1.1) + hiera (>= 3.2.1, < 4) + httpclient (~> 2.8) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + semantic_puppet (~> 1.0) + puppet (6.15.0-universal-darwin) + CFPropertyList (~> 2.2) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (~> 1.1) + hiera (>= 3.2.1, < 4) + httpclient (~> 2.8) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + semantic_puppet (~> 1.0) + puppet-blacksmith (6.0.0) + puppet-modulebuilder (~> 0.1) + rest-client (~> 2.0) + puppet-debugger (0.19.0) + awesome_print (~> 1.7) + bundler + facterdb (>= 0.4.0) + pluginator (~> 1.5.0) + puppet (>= 3.8) + rb-readline (>= 0.5.5) + table_print (>= 1.0.0) + puppet-lint (2.4.2) + puppet-module-posix-default-r2.4 (0.4.4) + puppet-module-posix-dev-r2.4 (0.4.4) + activesupport (>= 5.0.0, < 6.0.0) + codecov (~> 0.1.10) + concurrent-ruby (!= 1.1.6) + dependency_checker (~> 0.2) + facterdb (>= 0.8.1, < 2.0.0) + gettext-setup (~> 0.26) + metadata-json-lint (>= 2.0.2, < 3.0.0) + mocha (>= 1.0.0, < 1.2.0) + parallel_tests (>= 2.14.1, < 2.14.3) + parser (~> 2.5.1.2) + pry (~> 0.10.4) + puppet-blacksmith (>= 3.4.0) + puppet-debugger (~> 0.14) + puppet-lint (>= 2.3.0, < 3.0.0) + puppet-resource_api (~> 1.6) + puppet-strings (~> 2.0) + puppet-syntax (>= 2.4.1, < 3.0.0) + puppet_pot_generator (~> 1.0) + puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) + rainbow (~> 2.0) + rspec-puppet (>= 2.3.2, < 3.0.0) + rspec-puppet-facts (~> 1.10.0) + rspec_junit_formatter (~> 0.2) + rubocop (~> 0.49.0) + rubocop-i18n (~> 1.2.0) + rubocop-rspec (~> 1.16.0) + serverspec (~> 2.41) + simplecov (>= 0.14.1, < 1.0.0) + simplecov-console (~> 0.4.2) + specinfra (= 2.82.2) + puppet-modulebuilder (0.2.0) + minitar (~> 0.6) + pathspec (~> 0.2.1) + puppet-resource_api (1.8.13) + hocon (>= 1.0) + puppet-strings (2.4.0) + rgen + yard (~> 0.9.5) + puppet-syntax (2.6.1) + puppet (>= 5) + rake + puppet_forge (2.3.4) + faraday (>= 0.9.0, < 0.18.0, != 0.13.1) + faraday_middleware (>= 0.9.0, < 0.15.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppet_pot_generator (1.0.1) + puppet + puppetlabs_spec_helper (2.14.1) + mocha (~> 1.0) + pathspec (~> 0.2.1) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rainbow (2.2.2) + rake + rake (12.3.3) + rb-readline (0.5.5) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + retriable (3.1.2) + rgen (0.8.2) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-its (1.3.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-puppet (2.7.8) + rspec + rspec-puppet-facts (1.10.0) + facter + facterdb (>= 0.5.0) + json + puppet + rspec-support (3.9.3) + rspec_junit_formatter (0.4.1) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (0.49.1) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-i18n (1.2.0) + rubocop (~> 0.49.0) + rubocop-rspec (1.16.0) + rubocop (>= 0.49.0) + ruby-progressbar (1.10.1) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + semantic_puppet (1.0.2) + serverspec (2.41.5) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.72) + sfl (2.3) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.12.2) + slop (3.6.0) + spdx-licenses (1.2.0) + specinfra (2.82.2) + net-scp + net-ssh (>= 2.7) + net-telnet (= 0.1.1) + sfl + table_print (1.5.6) + text (1.3.1) + thor (1.0.1) + thread_safe (0.3.6) + tzinfo (1.2.7) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + url (0.3.2) + yard (0.9.25) + +PLATFORMS + ruby + x86_64-darwin-18 + +DEPENDENCIES + bcrypt_pbkdf (>= 1.0, < 2.0) + ed25519 (>= 1.2, < 2.0) + fast_gettext + github_changelog_generator! + json (= 2.0.4) + puppet + puppet-module-posix-default-r2.4 (~> 0.4) + puppet-module-posix-dev-r2.4 (~> 0.4) + puppet-module-win-default-r2.4 (~> 0.4) + puppet-module-win-dev-r2.4 (~> 0.4) + rb-readline (= 0.5.5) + +BUNDLED WITH + 2.1.4 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/HISTORY.md --- a/modules/stdlib/HISTORY.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/HISTORY.md Sun Oct 09 10:34:32 2022 +0100 @@ -304,7 +304,7 @@ - Permit double slash in absolute/Unix path types. #### Bugfixes -- Fix unsupported data type error with rspec-puppet master. +- Fix unsupported data type error with rspec-puppet server. - Now allows test module metadata.json to be read by Puppet. - Fix acceptance test failure "Hiera is not a class". - Removal of unsupported platforms and future parser setting in acceptance tests. @@ -948,7 +948,7 @@ ##### 2012-07-19 - Jeff McCune - 2.4.0 - * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88) + * (Maint) use PuppetlabsSpec::PuppetInternals.scope (main) (deafe88) ##### 2012-07-10 - Hailee Kenney - 2.4.0 @@ -974,7 +974,7 @@ * (#13595) initialize\_everything\_for\_tests couples modules Puppet ver (3222f35) * (#13439) Fix MRI 1.9 issue with spec\_helper (15c5fd1) * (#13439) Fix test failures with Puppet 2.6.x (665610b) - * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca) + * (#13439) refactor spec helper for compatibility with both puppet 2.7 and server (82194ca) * (#13494) Specify the behavior of zero padded strings (61891bb) ##### 2012-03-29 Puppet Labs - 2.1.3 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/MAINTAINERS.md --- a/modules/stdlib/MAINTAINERS.md Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -## Maintenance - -Maintainers: - - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com` - -Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `stdlib`. diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/README.md --- a/modules/stdlib/README.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/README.md Sun Oct 09 10:34:32 2022 +0100 @@ -64,7 +64,7 @@ ## Reference -For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/REFERENCE.md). +For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/REFERENCE.md). ### Data types @@ -544,7 +544,7 @@ #### `puppet_server` -Returns the Puppet agent's `server` value, which is the hostname of the Puppet master with which the agent should communicate. +Returns the Puppet agent's `server` value, which is the hostname of the Puppet server with which the agent should communicate. #### `root_home` @@ -560,14 +560,13 @@ As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules. -For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/metadata.json) +For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/metadata.json) ## Development -Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/CONTRIBUTING.md). +Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/CONTRIBUTING.md). -To report or research a bug with any part of this module, please go to -[http://tickets.puppetlabs.com/browse/MODULES](http://tickets.puppetlabs.com/browse/MODULES). +To report or research a bug with any part of this module, please go to [http://tickets.puppetlabs.com/browse/MODULES](http://tickets.puppetlabs.com/browse/MODULES). ## Contributors diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/REFERENCE.md --- a/modules/stdlib/REFERENCE.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/REFERENCE.md Sun Oct 09 10:34:32 2022 +0100 @@ -1,20 +1,21 @@ # Reference + ## Table of Contents -**Classes** +### Classes * [`stdlib`](#stdlib): This module manages stdlib. * [`stdlib::stages`](#stdlibstages): This class manages a standard set of run stages for Puppet. It is managed by the stdlib class, and should not be declared independently. -**Resource types** +### Resource types * [`anchor`](#anchor): A simple resource type intended to be used as an anchor in a composite class. * [`file_line`](#file_line): Ensures that a given line is contained within a file. -**Functions** +### Functions * [`abs`](#abs): **Deprecated:** Returns the absolute value of a number * [`any2array`](#any2array): This converts any object to an array containing that object. @@ -44,8 +45,8 @@ from an array or key from a hash. * [`delete_undef_values`](#delete_undef_values): Returns a copy of input hash or array with all undefs deleted. * [`delete_values`](#delete_values): Deletes all instances of a given value from a hash. +* [`deprecation`](#deprecation): Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message te * [`deprecation`](#deprecation): Function to print deprecation warnings (this is the 3.X version of it). -* [`deprecation`](#deprecation): Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message te * [`difference`](#difference): This function returns the difference between two arrays. * [`dig`](#dig): **DEPRECATED** Retrieves a value within multiple layers of hashes and arrays via an array of keys containing a path. @@ -87,31 +88,31 @@ * [`is_a`](#is_a): Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. * [`is_absolute_path`](#is_absolute_path): **Deprecated:** Returns boolean true if the string represents an absolute path in the filesystem. -* [`is_absolute_path`](#is_absolute_path): Wrapper that calls the Puppet 3.x funtion of the same name. -* [`is_array`](#is_array): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_absolute_path`](#is_absolute_path): Wrapper that calls the Puppet 3.x function of the same name. * [`is_array`](#is_array): **Deprecated:** Returns true if the variable passed to this function is an array. -* [`is_bool`](#is_bool): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_array`](#is_array): Wrapper that calls the Puppet 3.x function of the same name. * [`is_bool`](#is_bool): **Deprecated:** Returns true if the variable passed to this function is a boolean. +* [`is_bool`](#is_bool): Wrapper that calls the Puppet 3.x function of the same name. * [`is_domain_name`](#is_domain_name): **Deprecated:** Returns true if the string passed to this function is a syntactically correct domain name. * [`is_email_address`](#is_email_address): **Deprecated:** Returns true if the string passed to this function is a valid email address. -* [`is_float`](#is_float): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_float`](#is_float): Wrapper that calls the Puppet 3.x function of the same name. * [`is_float`](#is_float): **Deprecated:** Returns true if the variable passed to this function is a float. * [`is_function_available`](#is_function_available): **Deprecated:** Determines whether the Puppet runtime has access to a function by that name. * [`is_hash`](#is_hash): **Deprecated:** Returns true if the variable passed to this function is a hash. * [`is_integer`](#is_integer): **Deprecated:** Returns true if the variable passed to this function is an Integer or a decimal (base 10) integer in String form. * [`is_ip_address`](#is_ip_address): **Deprecated:** Returns true if the string passed to this function is a valid IP address. -* [`is_ip_address`](#is_ip_address): Wrapper that calls the Puppet 3.x funtion of the same name. -* [`is_ipv4_address`](#is_ipv4_address): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_ip_address`](#is_ip_address): Wrapper that calls the Puppet 3.x function of the same name. +* [`is_ipv4_address`](#is_ipv4_address): Wrapper that calls the Puppet 3.x function of the same name. * [`is_ipv4_address`](#is_ipv4_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv4 address. +* [`is_ipv6_address`](#is_ipv6_address): Wrapper that calls the Puppet 3.x function of the same name. * [`is_ipv6_address`](#is_ipv6_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv6 address. -* [`is_ipv6_address`](#is_ipv6_address): Wrapper that calls the Puppet 3.x funtion of the same name. * [`is_mac_address`](#is_mac_address): **Deprecated:** Returns true if the string passed to this function is a valid mac address. -* [`is_numeric`](#is_numeric): Wrapper that calls the Puppet 3.x funtion of the same name. * [`is_numeric`](#is_numeric): **Deprecated:** Returns true if the given value is numeric. +* [`is_numeric`](#is_numeric): Wrapper that calls the Puppet 3.x function of the same name. +* [`is_string`](#is_string): Wrapper that calls the Puppet 3.x function of the same name. * [`is_string`](#is_string): **Deprecated:** Returns true if the variable passed to this function is a string. -* [`is_string`](#is_string): Wrapper that calls the Puppet 3.x funtion of the same name. * [`join`](#join): **Deprecated:** This function joins an array into a string using a separator. * [`join_keys_to_values`](#join_keys_to_values): This function joins each key of a hash to that key's corresponding value with a separator. @@ -132,6 +133,8 @@ * [`num2bool`](#num2bool): This function converts a number or a string representation of a number into a true boolean. * [`os_version_gte`](#os_version_gte): Checks if the OS version is at least a certain version. +* [`parsehocon`](#parsehocon): This function accepts HOCON as a string and converts it into the correct +Puppet structure * [`parsejson`](#parsejson): This function accepts JSON as a string and converts it into the correct Puppet structure. * [`parseyaml`](#parseyaml): This function accepts YAML as a string and converts it into the correct @@ -164,13 +167,16 @@ * [`sort`](#sort): Sorts strings and arrays lexically. * [`sprintf_hash`](#sprintf_hash): Uses sprintf with named references. * [`squeeze`](#squeeze): Returns a new string where runs of the same character that occur in this set are replaced by a single character. +* [`stdlib::end_with`](#stdlibend_with): Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. +* [`stdlib::ensure`](#stdlibensure): function to cast ensure parameter to resource specific value * [`stdlib::extname`](#stdlibextname): Returns the Extension (the Portion of Filename in Path starting from the last Period). * [`stdlib::ip_in_range`](#stdlibip_in_range): Returns true if the ipaddress is within the given CIDRs +* [`stdlib::start_with`](#stdlibstart_with): Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. * [`str2bool`](#str2bool): This converts a string to a boolean. +* [`str2saltedpbkdf2`](#str2saltedpbkdf2): Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+ * [`str2saltedsha512`](#str2saltedsha512): This converts a string to a salted-SHA512 password hash (which is used for OS X versions >= 10.7). -* [`strftime`](#strftime): This function returns formatted time. * [`strip`](#strip): This function removes leading and trailing whitespace from a string or from every string inside an array. * [`suffix`](#suffix): This function applies a suffix to all elements in an array, or to the keys @@ -194,9 +200,9 @@ * [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem. This function works for windows and unix style paths. * [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem. -* [`validate_array`](#validate_array): Validate the passed value represents an array. * [`validate_array`](#validate_array): Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check. +* [`validate_array`](#validate_array): Validate the passed value represents an array. * [`validate_augeas`](#validate_augeas): Perform validation of a string using an Augeas lens * [`validate_bool`](#validate_bool): Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check. @@ -206,21 +212,21 @@ Fail compilation if any value fails this check. * [`validate_email_address`](#validate_email_address): Validate that all values passed are valid email addresses. Fail compilation if any value fails this check. -* [`validate_hash`](#validate_hash): Validate the passed value represents a hash. * [`validate_hash`](#validate_hash): Validate that all passed values are hash data structures. Abort catalog compilation if any value fails this check. +* [`validate_hash`](#validate_hash): Validate the passed value represents a hash. * [`validate_integer`](#validate_integer): Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. * [`validate_integer`](#validate_integer): Validate the passed value represents an integer. -* [`validate_ip_address`](#validate_ip_address): Validate the passed value represents an ip_address. * [`validate_ip_address`](#validate_ip_address): Validate that all values passed are valid IP addresses, regardless they are IPv4 or IPv6 Fail compilation if any value fails this check. -* [`validate_ipv4_address`](#validate_ipv4_address): Validate the passed value represents an ipv4_address. +* [`validate_ip_address`](#validate_ip_address): Validate the passed value represents an ip_address. * [`validate_ipv4_address`](#validate_ipv4_address): Validate that all values passed are valid IPv4 addresses. Fail compilation if any value fails this check. -* [`validate_ipv6_address`](#validate_ipv6_address): Validate the passed value represents an ipv6_address. +* [`validate_ipv4_address`](#validate_ipv4_address): Validate the passed value represents an ipv4_address. * [`validate_ipv6_address`](#validate_ipv6_address): Validate that all values passed are valid IPv6 addresses. Fail compilation if any value fails this check. +* [`validate_ipv6_address`](#validate_ipv6_address): Validate the passed value represents an ipv6_address. * [`validate_legacy`](#validate_legacy): Validate a value against both the target_type (new) and the previous_validation function (old). * [`validate_numeric`](#validate_numeric): Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. * [`validate_numeric`](#validate_numeric): Validate the passed value represents a numeric value. @@ -228,10 +234,10 @@ expressions. * [`validate_re`](#validate_re): Perform validation of a string against one or more regular expressions. +* [`validate_slength`](#validate_slength): Validate that a passed string has length less/equal with the passed value * [`validate_slength`](#validate_slength): Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings, and if arg 2 and arg 3 are not convertable to a number. -* [`validate_slength`](#validate_slength): Validate that a passed string has length less/equal with the passed value * [`validate_string`](#validate_string): Validate that all passed values are string data structures. * [`validate_string`](#validate_string): Validate that all passed values are string data structures * [`validate_x509_rsa_key_pair`](#validate_x509_rsa_key_pair): Validates a PEM-formatted X.509 certificate and RSA private key using @@ -241,7 +247,7 @@ * [`values_at`](#values_at): Finds value inside an array based on location. * [`zip`](#zip): Takes one element from first array and merges corresponding elements from second array. -**Data types** +### Data types * [`Stdlib::Absolutepath`](#stdlibabsolutepath): A strict absolutepath type * [`Stdlib::Base32`](#stdlibbase32): Type to match base32 String @@ -252,47 +258,57 @@ * [`Stdlib::Compat::Float`](#stdlibcompatfloat): Emulate the is_float function The regex is what's currently used in is_float To keep your development moving forward, you can also add a depr * [`Stdlib::Compat::Hash`](#stdlibcompathash): Emulate the is_hash and validate_hash functions * [`Stdlib::Compat::Integer`](#stdlibcompatinteger): Emulate the is_integer and validate_integer functions The regex is what's currently used in is_integer validate_numeric also allows range che -* [`Stdlib::Compat::Ip_address`](#stdlibcompatip_address): +* [`Stdlib::Compat::Ip_address`](#stdlibcompatip_address) * [`Stdlib::Compat::Ipv4`](#stdlibcompatipv4): Emulate the validate_ipv4_address and is_ipv4_address functions -* [`Stdlib::Compat::Ipv6`](#stdlibcompatipv6): +* [`Stdlib::Compat::Ipv6`](#stdlibcompatipv6) * [`Stdlib::Compat::Numeric`](#stdlibcompatnumeric): Emulate the is_numeric and validate_numeric functions The regex is what's currently used in is_numeric validate_numeric also allows range che * [`Stdlib::Compat::String`](#stdlibcompatstring): Emulate the is_string and validate_string functions -* [`Stdlib::Ensure::Service`](#stdlibensureservice): -* [`Stdlib::Filemode`](#stdlibfilemode): See `man chmod.1` for the regular expression for symbolic mode +* [`Stdlib::Datasize`](#stdlibdatasize) +* [`Stdlib::Ensure::File`](#stdlibensurefile) +* [`Stdlib::Ensure::File::Directory`](#stdlibensurefiledirectory) +* [`Stdlib::Ensure::File::File`](#stdlibensurefilefile) +* [`Stdlib::Ensure::File::Link`](#stdlibensurefilelink) +* [`Stdlib::Ensure::Service`](#stdlibensureservice) +* [`Stdlib::Filemode`](#stdlibfilemode): See `man chmod.1` for the regular expression for symbolic mode lint:ignore:140chars * [`Stdlib::Filesource`](#stdlibfilesource): Validate the source parameter on file types -* [`Stdlib::Fqdn`](#stdlibfqdn): -* [`Stdlib::HTTPSUrl`](#stdlibhttpsurl): -* [`Stdlib::HTTPUrl`](#stdlibhttpurl): -* [`Stdlib::Host`](#stdlibhost): -* [`Stdlib::IP::Address`](#stdlibipaddress): -* [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet): -* [`Stdlib::IP::Address::V4`](#stdlibipaddressv4): -* [`Stdlib::IP::Address::V4::CIDR`](#stdlibipaddressv4cidr): -* [`Stdlib::IP::Address::V4::Nosubnet`](#stdlibipaddressv4nosubnet): -* [`Stdlib::IP::Address::V6`](#stdlibipaddressv6): -* [`Stdlib::IP::Address::V6::Alternative`](#stdlibipaddressv6alternative): -* [`Stdlib::IP::Address::V6::CIDR`](#stdlibipaddressv6cidr): -* [`Stdlib::IP::Address::V6::Compressed`](#stdlibipaddressv6compressed): -* [`Stdlib::IP::Address::V6::Full`](#stdlibipaddressv6full): -* [`Stdlib::IP::Address::V6::Nosubnet`](#stdlibipaddressv6nosubnet): -* [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#stdlibipaddressv6nosubnetalternative): -* [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#stdlibipaddressv6nosubnetcompressed): -* [`Stdlib::IP::Address::V6::Nosubnet::Full`](#stdlibipaddressv6nosubnetfull): +* [`Stdlib::Fqdn`](#stdlibfqdn) +* [`Stdlib::HTTPSUrl`](#stdlibhttpsurl) +* [`Stdlib::HTTPUrl`](#stdlibhttpurl) +* [`Stdlib::Host`](#stdlibhost) +* [`Stdlib::HttpStatus`](#stdlibhttpstatus) +* [`Stdlib::IP::Address`](#stdlibipaddress) +* [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet) +* [`Stdlib::IP::Address::V4`](#stdlibipaddressv4) +* [`Stdlib::IP::Address::V4::CIDR`](#stdlibipaddressv4cidr): lint:ignore:140chars +* [`Stdlib::IP::Address::V4::Nosubnet`](#stdlibipaddressv4nosubnet): lint:ignore:140chars +* [`Stdlib::IP::Address::V6`](#stdlibipaddressv6) +* [`Stdlib::IP::Address::V6::Alternative`](#stdlibipaddressv6alternative): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::CIDR`](#stdlibipaddressv6cidr): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::Compressed`](#stdlibipaddressv6compressed) +* [`Stdlib::IP::Address::V6::Full`](#stdlibipaddressv6full) +* [`Stdlib::IP::Address::V6::Nosubnet`](#stdlibipaddressv6nosubnet) +* [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#stdlibipaddressv6nosubnetalternative): lint:ignore:140chars +* [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#stdlibipaddressv6nosubnetcompressed) +* [`Stdlib::IP::Address::V6::Nosubnet::Full`](#stdlibipaddressv6nosubnetfull) * [`Stdlib::MAC`](#stdlibmac): A type for a MAC address -* [`Stdlib::ObjectStore`](#stdlibobjectstore): -* [`Stdlib::ObjectStore::GSUri`](#stdlibobjectstoregsuri): -* [`Stdlib::ObjectStore::S3Uri`](#stdlibobjectstores3uri): -* [`Stdlib::Port`](#stdlibport): -* [`Stdlib::Port::Privileged`](#stdlibportprivileged): -* [`Stdlib::Port::Unprivileged`](#stdlibportunprivileged): -* [`Stdlib::Syslogfacility`](#stdlibsyslogfacility): +* [`Stdlib::ObjectStore`](#stdlibobjectstore) +* [`Stdlib::ObjectStore::GSUri`](#stdlibobjectstoregsuri) +* [`Stdlib::ObjectStore::S3Uri`](#stdlibobjectstores3uri) +* [`Stdlib::Port`](#stdlibport) +* [`Stdlib::Port::Dynamic`](#stdlibportdynamic) +* [`Stdlib::Port::Ephemeral`](#stdlibportephemeral) +* [`Stdlib::Port::Privileged`](#stdlibportprivileged) +* [`Stdlib::Port::Registered`](#stdlibportregistered) +* [`Stdlib::Port::Unprivileged`](#stdlibportunprivileged) +* [`Stdlib::Port::User`](#stdlibportuser) +* [`Stdlib::Syslogfacility`](#stdlibsyslogfacility) * [`Stdlib::Unixpath`](#stdlibunixpath): this regex rejects any path component that does not start with "/" or is NUL -* [`Stdlib::Windowspath`](#stdlibwindowspath): -* [`Stdlib::Yes_no`](#stdlibyes_no): +* [`Stdlib::Windowspath`](#stdlibwindowspath) +* [`Stdlib::Yes_no`](#stdlibyes_no) ## Classes -### stdlib +### `stdlib` Most of stdlib's features are automatically loaded by Puppet, but this class should be declared in order to use the standardized run stages. @@ -300,7 +316,7 @@ Declares all other classes in the stdlib module. Currently, this consists of stdlib::stages. -### stdlib::stages +### `stdlib::stages` Declares various run-stages for deploying infrastructure, language runtimes, and application layers. @@ -328,7 +344,7 @@ ## Resource types -### anchor +### `anchor` In Puppet 2.6, when a class declares another class, the resources in the interior class are not contained by the exterior class. This interacts badly @@ -368,13 +384,15 @@ The following parameters are available in the `anchor` type. -##### `name` +* [`name`](#name) + +##### `name` namevar The name of the anchor resource. -### file_line +### `file_line` The implementation matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet @@ -476,11 +494,11 @@ ##### `ensure` -Valid values: present, absent +Valid values: `present`, `absent` Manage the state of this type. -Default value: present +Default value: `present` ##### `line` @@ -490,79 +508,97 @@ The following parameters are available in the `file_line` type. -##### `name` - -namevar - -An arbitrary name used as the identity of the resource. - -##### `match` +* [`after`](#after) +* [`append_on_no_match`](#append_on_no_match) +* [`encoding`](#encoding) +* [`match`](#match) +* [`match_for_absence`](#match_for_absence) +* [`multiple`](#multiple) +* [`name`](#name) +* [`path`](#path) +* [`provider`](#provider) +* [`replace`](#replace) +* [`replace_all_matches_not_matching_line`](#replace_all_matches_not_matching_line) + +##### `after` + +An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place) +This is also takes a regex. + +##### `append_on_no_match` + +Valid values: ``true``, ``false`` + +If true, append line if match is not found. If false, do not append line if a match is not found + +Default value: ``true`` + +##### `encoding` + +For files that are not UTF-8 encoded, specify encoding such as iso-8859-1 + +Default value: `UTF-8` + +##### `match` An optional ruby regular expression to run against existing lines in the file. If a match is found, we replace that line rather than adding a new line. A regex comparison is performed against the line value and if it does not match an exception will be raised. -##### `match_for_absence` - -Valid values: `true`, `false` +##### `match_for_absence` + +Valid values: ``true``, ``false`` An optional value to determine if match should be applied when ensure => absent. If set to true and match is set, the line that matches match will be deleted. If set to false (the default), match is ignored when ensure => absent. When `ensure => present`, match_for_absence is ignored. -Default value: `false` - -##### `multiple` - -Valid values: `true`, `false` +Default value: ``false`` + +##### `multiple` + +Valid values: ``true``, ``false`` An optional value to determine if match can change multiple lines. If set to false, an exception will be raised if more than one line matches -##### `after` - -An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place) -This is also takes a regex. - -##### `path` +##### `name` + +namevar + +An arbitrary name used as the identity of the resource. + +##### `path` The file Puppet will ensure contains the line specified by the line parameter. -##### `replace` - -Valid values: `true`, `false` +##### `provider` + +The specific backend to use for this `file_line` resource. You will seldom need to specify this --- Puppet will usually +discover the appropriate provider for your platform. + +##### `replace` + +Valid values: ``true``, ``false`` If true, replace line that matches. If false, do not write line if a match is found -Default value: `true` - -##### `replace_all_matches_not_matching_line` - -Valid values: `true`, `false` - -Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file. - -Default value: `false` - -##### `encoding` - -For files that are not UTF-8 encoded, specify encoding such as iso-8859-1 - -Default value: UTF-8 - -##### `append_on_no_match` - -Valid values: `true`, `false` - -If true, append line if match is not found. If false, do not append line if a match is not found - -Default value: `true` +Default value: ``true`` + +##### `replace_all_matches_not_matching_line` + +Valid values: ``true``, ``false`` + +Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, +regardless of whether the specified line is already present in the file. + +Default value: ``false`` ## Functions -### abs +### `abs` Type: Ruby 3.x API @@ -584,7 +620,7 @@ Returns: `Any` The absolute value of the given number if it was an Integer -### any2array +### `any2array` Type: Ruby 3.x API @@ -642,7 +678,7 @@ Returns: `Array` The new array containing the given object -### any2bool +### `any2bool` Type: Ruby 3.x API @@ -672,7 +708,7 @@ Returns: `Boolean` The boolean value of the object that was given -### assert_private +### `assert_private` Type: Ruby 3.x API @@ -684,7 +720,7 @@ Returns: `Any` set the current class or definition as private. -### base64 +### `base64` Type: Ruby 3.x API @@ -754,7 +790,7 @@ $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") ``` -### basename +### `basename` Type: Ruby 3.x API @@ -766,7 +802,7 @@ Returns: `String` The stripped filename -### bool2num +### `bool2num` Type: Ruby 3.x API @@ -812,7 +848,7 @@ Returns: `Integer` The converted value as a number -### bool2str +### `bool2str` Type: Ruby 3.x API @@ -874,7 +910,7 @@ Returns: `Any` The converted value to string of the given Boolean -### camelcase +### `camelcase` Type: Ruby 3.x API @@ -892,7 +928,7 @@ Returns: `String` The converted String, if it was a String that was given -### capitalize +### `capitalize` Type: Ruby 3.x API @@ -914,7 +950,7 @@ Returns: `String` The converted String, if it was a String that was given -### ceiling +### `ceiling` Type: Ruby 3.x API @@ -934,7 +970,7 @@ Returns: `Integer` The rounded value -### chomp +### `chomp` Type: Ruby 3.x API @@ -956,7 +992,7 @@ Returns: `String` The converted String, if it was a String that was given -### chop +### `chop` Type: Ruby 3.x API @@ -980,7 +1016,7 @@ Returns: `String` The given String, sans the last character. -### clamp +### `clamp` Type: Ruby 3.x API @@ -1024,7 +1060,7 @@ clamp([4, 3, '99'])` returns 4. ``` -### concat +### `concat` Type: Ruby 3.x API @@ -1068,7 +1104,7 @@ concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7'] ``` -### convert_base +### `convert_base` Type: Ruby 3.x API @@ -1120,7 +1156,7 @@ ``` -### count +### `count` Type: Ruby 3.x API @@ -1160,7 +1196,7 @@ Returns: `Integer` The amount of elements counted within the array -### deep_merge +### `deep_merge` Type: Ruby 3.x API @@ -1208,7 +1244,7 @@ When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." ``` -### defined_with_params +### `defined_with_params` Type: Ruby 3.x API @@ -1242,7 +1278,7 @@ Returns: `Boolean` returns `true` or `false` -### delete +### `delete` Type: Ruby 3.x API @@ -1328,7 +1364,7 @@ Would return: 'acada' ``` -### delete_at +### `delete_at` Type: Ruby 3.x API @@ -1374,7 +1410,7 @@ Returns: `Array` The given array, now missing the tar -### delete_regex +### `delete_regex` Type: Ruby 3.x API @@ -1436,7 +1472,7 @@ Would return: {'b'=>2,'c'=>3} ``` -### delete_undef_values +### `delete_undef_values` Type: Ruby 3.x API @@ -1484,7 +1520,7 @@ Would return: ['A','',false] ``` -### delete_values +### `delete_values` Type: Ruby 3.x API @@ -1524,21 +1560,7 @@ Would return: {'a'=>'A','c'=>'C','B'=>'D'} ``` -### deprecation - -Type: Ruby 3.x API - -The uniqueness key - can appear once. The msg is the message text including any positional -information that is formatted by the user/caller of the method.). - -#### `deprecation()` - -The uniqueness key - can appear once. The msg is the message text including any positional -information that is formatted by the user/caller of the method.). - -Returns: `String` return deprecation warnings - -### deprecation +### `deprecation` Type: Ruby 4.x API @@ -1576,7 +1598,21 @@ -### difference +### `deprecation` + +Type: Ruby 3.x API + +The uniqueness key - can appear once. The msg is the message text including any positional +information that is formatted by the user/caller of the method.). + +#### `deprecation()` + +The uniqueness key - can appear once. The msg is the message text including any positional +information that is formatted by the user/caller of the method.). + +Returns: `String` return deprecation warnings + +### `difference` Type: Ruby 3.x API @@ -1620,7 +1656,7 @@ Would return: `["a"]` ``` -### dig +### `dig` Type: Ruby 3.x API @@ -1701,7 +1737,7 @@ Returns: `Any` The function goes through the structure by each path component and tries to return the value at the end of the path. -### dig44 +### `dig44` Type: Ruby 3.x API @@ -1769,7 +1805,7 @@ Returns: `String` 'not_found' will be returned if nothing is found -### dirname +### `dirname` Type: Ruby 3.x API @@ -1781,7 +1817,7 @@ Returns: `String` the given path's dirname -### dos2unix +### `dos2unix` Type: Ruby 3.x API @@ -1793,7 +1829,7 @@ Returns: `Any` The retrieved version -### downcase +### `downcase` Type: Ruby 3.x API @@ -1813,7 +1849,7 @@ Returns: `String` The converted String, if it was a String that was given -### empty +### `empty` Type: Ruby 3.x API @@ -1828,7 +1864,7 @@ Returns: `Any` Returns `true` if the argument is an array or hash that contains no elements, or an empty string. Returns `false` when the argument is a numerical value. -### enclose_ipv6 +### `enclose_ipv6` Type: Ruby 3.x API @@ -1840,7 +1876,7 @@ Returns: `Any` encloses the ipv6 addresses with square brackets. -### ensure_packages +### `ensure_packages` Type: Ruby 3.x API @@ -1854,7 +1890,7 @@ Returns: `Any` install the passed packages -### ensure_resource +### `ensure_resource` Type: Ruby 3.x API @@ -1910,7 +1946,7 @@ ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) ``` -### ensure_resources +### `ensure_resources` Type: Ruby 3.x API @@ -1976,7 +2012,7 @@ } ``` -### fact +### `fact` Type: Ruby 4.x API @@ -2038,7 +2074,7 @@ The name of the fact to check -### flatten +### `flatten` Type: Ruby 3.x API @@ -2070,7 +2106,7 @@ flatten(['a', ['b', ['c']]])` returns: `['a','b','c'] ``` -### floor +### `floor` Type: Ruby 3.x API @@ -2088,7 +2124,7 @@ Returns: `Any` the largest integer less or equal to the argument. -### fqdn_rand_string +### `fqdn_rand_string` Type: Ruby 3.x API @@ -2130,7 +2166,7 @@ fqdn_rand_string(10, '', 'custom seed') ``` -### fqdn_rotate +### `fqdn_rotate` Type: Ruby 3.x API @@ -2163,7 +2199,7 @@ fqdn_rotate([1, 2, 3], 'custom seed') ``` -### fqdn_uuid +### `fqdn_uuid` Type: Ruby 3.x API @@ -2194,7 +2230,7 @@ fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09 ``` -### get_module_path +### `get_module_path` Type: Ruby 3.x API @@ -2231,7 +2267,7 @@ $module_path = get_module_path('stdlib') ``` -### getparam +### `getparam` Type: Ruby 3.x API @@ -2313,7 +2349,7 @@ example_get_param { 'show_notify': } ``` -### getvar +### `getvar` Type: Ruby 3.x API @@ -2361,7 +2397,7 @@ $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar ``` -### glob +### `glob` Type: Ruby 3.x API @@ -2389,7 +2425,7 @@ $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) ``` -### grep +### `grep` Type: Ruby 3.x API @@ -2423,7 +2459,7 @@ grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd'] ``` -### has_interface_with +### `has_interface_with` Type: Ruby 3.x API @@ -2465,7 +2501,7 @@ has_interface_with("lo") # Returns `true` ``` -### has_ip_address +### `has_ip_address` Type: Ruby 3.x API @@ -2479,7 +2515,7 @@ Returns: `Boolean` `true` or `false` -### has_ip_network +### `has_ip_network` Type: Ruby 3.x API @@ -2493,7 +2529,7 @@ Returns: `Any` Boolean value, `true` if the client has an IP address within the requested network. -### has_key +### `has_key` Type: Ruby 3.x API @@ -2543,7 +2579,7 @@ } ``` -### hash +### `hash` Type: Ruby 3.x API @@ -2585,7 +2621,7 @@ hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3} ``` -### intersection +### `intersection` Type: Ruby 3.x API @@ -2615,7 +2651,7 @@ intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) ``` -### is_a +### `is_a` Type: Ruby 4.x API @@ -2683,7 +2719,7 @@ The expected type -### is_absolute_path +### `is_absolute_path` Type: Ruby 3.x API @@ -2751,11 +2787,11 @@ is_absolute_path($undefined) ``` -### is_absolute_path +### `is_absolute_path` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_absolute_path(Any $scope, Any *$args)` @@ -2775,11 +2811,25 @@ Any additional values that are to be passed to the wrapped method -### is_array +### `is_array` + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_array()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### `is_array` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_array(Any $scope, Any *$args)` @@ -2799,25 +2849,25 @@ Any additional values that are to be passed to the wrapped method -### is_array +### `is_bool` Type: Ruby 3.x API > **Note:* **Deprecated** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). -#### `is_array()` +#### `is_bool()` > **Note:* **Deprecated** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). Returns: `Boolean` Returns `true` or `false` -### is_bool +### `is_bool` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_bool(Any $scope, Any *$args)` @@ -2837,21 +2887,7 @@ Any additional values that are to be passed to the wrapped method -### is_bool - -Type: Ruby 3.x API - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -#### `is_bool()` - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -Returns: `Boolean` Returns `true` or `false` - -### is_domain_name +### `is_domain_name` Type: Ruby 3.x API @@ -2865,7 +2901,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_email_address +### `is_email_address` Type: Ruby 3.x API @@ -2879,11 +2915,11 @@ Returns: `Boolean` Returns `true` or `false` -### is_float +### `is_float` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_float(Any $scope, Any *$args)` @@ -2903,7 +2939,7 @@ Any additional values that are to be passed to the wrapped method -### is_float +### `is_float` Type: Ruby 3.x API @@ -2917,7 +2953,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_function_available +### `is_function_available` Type: Ruby 3.x API @@ -2935,7 +2971,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_hash +### `is_hash` Type: Ruby 3.x API @@ -2949,7 +2985,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_integer +### `is_integer` Type: Ruby 3.x API @@ -2973,7 +3009,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_ip_address +### `is_ip_address` Type: Ruby 3.x API @@ -2987,11 +3023,11 @@ Returns: `Boolean` Returns `true` or `false` -### is_ip_address +### `is_ip_address` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_ip_address(Any $scope, Any *$args)` @@ -3011,11 +3047,11 @@ Any additional values that are to be passed to the wrapped method -### is_ipv4_address +### `is_ipv4_address` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_ipv4_address(Any $scope, Any *$args)` @@ -3035,7 +3071,7 @@ Any additional values that are to be passed to the wrapped method -### is_ipv4_address +### `is_ipv4_address` Type: Ruby 3.x API @@ -3049,25 +3085,11 @@ Returns: `Boolean` Returns `true` or `false` -### is_ipv6_address - -Type: Ruby 3.x API - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -#### `is_ipv6_address()` - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -Returns: `Boolean` Returns `true` or `false` - -### is_ipv6_address +### `is_ipv6_address` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. #### `is_ipv6_address(Any $scope, Any *$args)` @@ -3087,7 +3109,21 @@ Any additional values that are to be passed to the wrapped method -### is_mac_address +### `is_ipv6_address` + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_ipv6_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### `is_mac_address` Type: Ruby 3.x API @@ -3101,31 +3137,7 @@ Returns: `Boolean` Returns `true` or `false` -### is_numeric - -Type: Ruby 4.x API - -Wrapper that calls the Puppet 3.x funtion of the same name. - -#### `is_numeric(Any $scope, Any *$args)` - -The is_numeric function. - -Returns: `Boolea` A boolean value returned from the called 3.x function. - -##### `scope` - -Data type: `Any` - -The main value that will be passed to the wrapped method - -##### `*args` - -Data type: `Any` - -Any additional values that are to be passed to the wrapped method - -### is_numeric +### `is_numeric` Type: Ruby 3.x API @@ -3159,25 +3171,35 @@ Returns: `Boolean` Returns `true` or `false` -### is_string - -Type: Ruby 3.x API - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -#### `is_string()` - -> **Note:* **Deprecated** Will be removed in a future version of stdlib. See -[`validate_legacy`](#validate_legacy). - -Returns: `Boolean` Returns `true` or `false` - -### is_string +### `is_numeric` Type: Ruby 4.x API -Wrapper that calls the Puppet 3.x funtion of the same name. +Wrapper that calls the Puppet 3.x function of the same name. + +#### `is_numeric(Any $scope, Any *$args)` + +The is_numeric function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### `is_string` + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x function of the same name. #### `is_string(Any $scope, Any *$args)` @@ -3197,7 +3219,21 @@ Any additional values that are to be passed to the wrapped method -### join +### `is_string` + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_string()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### `join` Type: Ruby 3.x API @@ -3227,7 +3263,7 @@ join(['a','b','c'], ",") # Results in: "a,b,c" ``` -### join_keys_to_values +### `join_keys_to_values` Type: Ruby 3.x API @@ -3271,7 +3307,7 @@ join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"] ``` -### keys +### `keys` Type: Ruby 3.x API @@ -3285,7 +3321,7 @@ Returns: `Array` An array containing each of the hashes key values. -### length +### `length` Type: Ruby 4.x API @@ -3311,7 +3347,7 @@ The value whose length is to be found -### load_module_metadata +### `load_module_metadata` Type: Ruby 3.x API @@ -3341,7 +3377,7 @@ notify { $metadata['author']: } ``` -### loadjson +### `loadjson` Type: Ruby 3.x API @@ -3379,7 +3415,7 @@ $myhash = loadjson('no-file.json', {'default' => 'val ``` -### loadyaml +### `loadyaml` Type: Ruby 3.x API @@ -3417,7 +3453,7 @@ $myhash = loadyaml('no-file.yaml', {'default' => 'val ``` -### lstrip +### `lstrip` Type: Ruby 3.x API @@ -3431,7 +3467,7 @@ Returns: `String` The stripped string -### max +### `max` Type: Ruby 3.x API @@ -3449,7 +3485,7 @@ Returns: `Any` The highest value among those passed in -### member +### `member` Type: Ruby 3.x API @@ -3513,7 +3549,7 @@ member(['a', 'b', 'c'], ['d', 'b']) # Returns: false ``` -### merge +### `merge` Type: Ruby 3.x API @@ -3551,7 +3587,7 @@ $merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} ``` -### merge +### `merge` Type: Ruby 4.x API @@ -3644,7 +3680,7 @@ A block placed on the repeatable param `args` -### min +### `min` Type: Ruby 3.x API @@ -3662,7 +3698,7 @@ Returns: `Any` The lowest value among the given arguments -### num2bool +### `num2bool` Type: Ruby 3.x API @@ -3677,7 +3713,7 @@ Returns: `Boolean` Boolean(0) # false for any zero or negative number Boolean(1) # true for any positive number -### os_version_gte +### `os_version_gte` Type: Ruby 4.x API @@ -3721,7 +3757,48 @@ -### parsejson +### `parsehocon` + +Type: Ruby 4.x API + +This function accepts HOCON as a string and converts it into the correct +Puppet structure + +#### Examples + +##### How to parse hocon + +```puppet +$data = parsehocon("{any valid hocon: string}") +``` + +#### `parsehocon(String $hocon_string, Optional[Any] $default)` + +The parsehocon function. + +Returns: `Any` + +##### Examples + +###### How to parse hocon + +```puppet +$data = parsehocon("{any valid hocon: string}") +``` + +##### `hocon_string` + +Data type: `String` + +A valid HOCON string + +##### `default` + +Data type: `Optional[Any]` + +An optional default to return if parsing hocon_string fails + +### `parsejson` Type: Ruby 3.x API @@ -3737,7 +3814,7 @@ Returns: `Any` convert JSON into Puppet structure -### parseyaml +### `parseyaml` Type: Ruby 3.x API @@ -3753,7 +3830,7 @@ Returns: `Any` converted YAML into Puppet structure -### pick +### `pick` Type: Ruby 3.x API @@ -3783,7 +3860,7 @@ Returns: `Any` the first value in a list of values that is not undefined or an empty string. -### pick_default +### `pick_default` Type: Ruby 3.x API @@ -3825,7 +3902,7 @@ the first value in a list of values that is not undefined or an empty string If no value is found, it will return the last argument. -### prefix +### `prefix` Type: Ruby 3.x API @@ -3861,7 +3938,7 @@ Will return: ['pa','pb','pc'] ``` -### private +### `private` Type: Ruby 3.x API @@ -3874,7 +3951,7 @@ Returns: `Any` Sets the current class or definition as private -### pry +### `pry` Type: Ruby 3.x API @@ -3904,7 +3981,7 @@ `pry()` ``` -### pw_hash +### `pw_hash` Type: Ruby 3.x API @@ -3923,7 +4000,7 @@ The third argument to this function is the salt to use. -> *Note:*: this uses the Puppet Master's implementation of crypt(3). If your +> *Note:*: this uses the Puppet Server's implementation of crypt(3). If your environment contains several different operating systems, ensure that they are compatible before using this function. @@ -3944,13 +4021,13 @@ The third argument to this function is the salt to use. -> *Note:*: this uses the Puppet Master's implementation of crypt(3). If your +> *Note:*: this uses the Puppet Server's implementation of crypt(3). If your environment contains several different operating systems, ensure that they are compatible before using this function. Returns: `Hash` Provides a hash usable on most POSIX systems. -### range +### `range` Type: Ruby 3.x API @@ -4024,7 +4101,7 @@ Will return: [0,2,4,6,8] ``` -### regexpescape +### `regexpescape` Type: Ruby 3.x API @@ -4037,7 +4114,7 @@ Returns: `String` A string of characters with metacharacters converted to their escaped form. -### reject +### `reject` Type: Ruby 3.x API @@ -4075,7 +4152,7 @@ Would return: ['bbb','ccc'] ``` -### reverse +### `reverse` Type: Ruby 3.x API @@ -4087,7 +4164,7 @@ Returns: `Any` reversed string or array -### round +### `round` Type: Ruby 3.x API @@ -4109,7 +4186,7 @@ Returns: `Any` the rounded value as integer -### rstrip +### `rstrip` Type: Ruby 3.x API @@ -4123,7 +4200,7 @@ Returns: `Any` the string with leading spaces removed -### seeded_rand +### `seeded_rand` Type: Ruby 3.x API @@ -4157,7 +4234,7 @@ MAX must be a positive integer; SEED is any string. ``` -### seeded_rand_string +### `seeded_rand_string` Type: Ruby 4.x API @@ -4215,7 +4292,7 @@ String that contains characters to use for the random string. -### shell_escape +### `shell_escape` Type: Ruby 3.x API @@ -4233,7 +4310,7 @@ Returns: `Any` A string of characters with metacharacters converted to their escaped form. -### shell_join +### `shell_join` Type: Ruby 3.x API @@ -4249,7 +4326,7 @@ Returns: `Any` a command line string -### shell_split +### `shell_split` Type: Ruby 3.x API @@ -4261,7 +4338,7 @@ Returns: `Any` array of tokens -### shuffle +### `shuffle` Type: Ruby 3.x API @@ -4275,7 +4352,7 @@ Returns: `Any` randomized string or array -### size +### `size` Type: Ruby 3.x API @@ -4289,7 +4366,7 @@ Returns: `Any` the number of elements in a string, an array or a hash -### sort +### `sort` Type: Ruby 3.x API @@ -4301,7 +4378,7 @@ Returns: `Any` sorted string or array -### sprintf_hash +### `sprintf_hash` Type: Ruby 4.x API @@ -4361,7 +4438,7 @@ Hash with parameters. -### squeeze +### `squeeze` Type: Ruby 3.x API @@ -4373,7 +4450,75 @@ Returns: `Any` a new string where runs of the same character that occur in this set are replaced by a single character. -### stdlib::extname +### `stdlib::end_with` + +Type: Ruby 4.x API + +Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. + +#### Examples + +##### + +```puppet +'foobar'.stdlib::end_with('bar') => true +'foobar'.stdlib::end_with('foo') => false +'foobar'.stdlib::end_with(['foo', 'baz']) => false +``` + +#### `stdlib::end_with(String $test_string, Variant[String[1],Array[String[1], 1]] $suffixes)` + +The stdlib::end_with function. + +Returns: `Boolean` True or False + +##### Examples + +###### + +```puppet +'foobar'.stdlib::end_with('bar') => true +'foobar'.stdlib::end_with('foo') => false +'foobar'.stdlib::end_with(['foo', 'baz']) => false +``` + +##### `test_string` + +Data type: `String` + +The string to check + +##### `suffixes` + +Data type: `Variant[String[1],Array[String[1], 1]]` + +The suffixes to check + +### `stdlib::ensure` + +Type: Puppet Language + +function to cast ensure parameter to resource specific value + +#### `stdlib::ensure(Variant[Boolean, Enum['present', 'absent']] $ensure, Enum['directory', 'link', 'mounted', 'service', 'file'] $resource)` + +The stdlib::ensure function. + +Returns: `String` + +##### `ensure` + +Data type: `Variant[Boolean, Enum['present', 'absent']]` + + + +##### `resource` + +Data type: `Enum['directory', 'link', 'mounted', 'service', 'file']` + + + +### `stdlib::extname` Type: Ruby 4.x API @@ -4421,7 +4566,7 @@ The Filename -### stdlib::ip_in_range +### `stdlib::ip_in_range` Type: Ruby 4.x API @@ -4462,7 +4607,51 @@ One CIDR or an array of CIDRs defining the range(s) to check against -### str2bool +### `stdlib::start_with` + +Type: Ruby 4.x API + +Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. + +#### Examples + +##### + +```puppet +'foobar'.stdlib::start_with('foo') => true +'foobar'.stdlib::start_with('bar') => false +'foObar'.stdlib::start_with(['bar', 'baz']) => false +``` + +#### `stdlib::start_with(String $test_string, Variant[String[1],Array[String[1], 1]] $prefixes)` + +The stdlib::start_with function. + +Returns: `Boolean` True or False + +##### Examples + +###### + +```puppet +'foobar'.stdlib::start_with('foo') => true +'foobar'.stdlib::start_with('bar') => false +'foObar'.stdlib::start_with(['bar', 'baz']) => false +``` + +##### `test_string` + +Data type: `String` + +The string to check + +##### `prefixes` + +Data type: `Variant[String[1],Array[String[1], 1]]` + +The prefixes to check. + +### `str2bool` Type: Ruby 3.x API @@ -4477,7 +4666,81 @@ Returns: `Any` This attempt to convert to boolean strings that contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things like: 0, F,f, N,n, false, FALSE, no to 'false'. -### str2saltedsha512 +### `str2saltedpbkdf2` + +Type: Ruby 3.x API + +Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+. +Note, however, that Apple changes what's required periodically and this may not work for the latest +version of macOS. If that is the case you should get a helpful error message when Puppet tries to set +the pasword using the parameters you provide to the user resource. + +#### Examples + +##### Plain text password and salt + +```puppet +$pw_info = str2saltedpbkdf2('Pa55w0rd', 'Using s0m3 s@lt', 50000) +user { 'jdoe': + ensure => present, + iterations => $pw_info['interations'], + password => $pw_info['password_hex'], + salt => $pw_info['salt_hex'], +} +``` + +##### Sensitive password and salt + +```puppet +$pw = Sensitive.new('Pa55w0rd') +$salt = Sensitive.new('Using s0m3 s@lt') +$pw_info = Sensitive.new(str2saltedpbkdf2($pw, $salt, 50000)) +user { 'jdoe': + ensure => present, + iterations => unwrap($pw_info)['interations'], + password => unwrap($pw_info)['password_hex'], + salt => unwrap($pw_info)['salt_hex'], +} +``` + +#### `str2saltedpbkdf2()` + +Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+. +Note, however, that Apple changes what's required periodically and this may not work for the latest +version of macOS. If that is the case you should get a helpful error message when Puppet tries to set +the pasword using the parameters you provide to the user resource. + +Returns: `Hash` Provides a hash containing the hex version of the password, the hex version of the salt, and iterations. + +##### Examples + +###### Plain text password and salt + +```puppet +$pw_info = str2saltedpbkdf2('Pa55w0rd', 'Using s0m3 s@lt', 50000) +user { 'jdoe': + ensure => present, + iterations => $pw_info['interations'], + password => $pw_info['password_hex'], + salt => $pw_info['salt_hex'], +} +``` + +###### Sensitive password and salt + +```puppet +$pw = Sensitive.new('Pa55w0rd') +$salt = Sensitive.new('Using s0m3 s@lt') +$pw_info = Sensitive.new(str2saltedpbkdf2($pw, $salt, 50000)) +user { 'jdoe': + ensure => present, + iterations => unwrap($pw_info)['interations'], + password => unwrap($pw_info)['password_hex'], + salt => unwrap($pw_info)['salt_hex'], +} +``` + +### `str2saltedsha512` Type: Ruby 3.x API @@ -4493,145 +4756,7 @@ Returns: `Any` converted string as a hex version of a salted-SHA512 password hash -### strftime - -Type: Ruby 3.x API - -> *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this -function. It also supports the Timestamp and Timespan data types in the Puppet language. - -**Format meaning:** - - %a - The abbreviated weekday name (``Sun'') - %A - The full weekday name (``Sunday'') - %b - The abbreviated month name (``Jan'') - %B - The full month name (``January'') - %c - The preferred local date and time representation - %C - Century (20 in 2009) - %d - Day of the month (01..31) - %D - Date (%m/%d/%y) - %e - Day of the month, blank-padded ( 1..31) - %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) - %h - Equivalent to %b - %H - Hour of the day, 24-hour clock (00..23) - %I - Hour of the day, 12-hour clock (01..12) - %j - Day of the year (001..366) - %k - hour, 24-hour clock, blank-padded ( 0..23) - %l - hour, 12-hour clock, blank-padded ( 0..12) - %L - Millisecond of the second (000..999) - %m - Month of the year (01..12) - %M - Minute of the hour (00..59) - %n - Newline (\n) - %N - Fractional seconds digits, default is 9 digits (nanosecond) - %3N millisecond (3 digits) - %6N microsecond (6 digits) - %9N nanosecond (9 digits) - %p - Meridian indicator (``AM'' or ``PM'') - %P - Meridian indicator (``am'' or ``pm'') - %r - time, 12-hour (same as %I:%M:%S %p) - %R - time, 24-hour (%H:%M) - %s - Number of seconds since 1970-01-01 00:00:00 UTC. - %S - Second of the minute (00..60) - %t - Tab character (\t) - %T - time, 24-hour (%H:%M:%S) - %u - Day of the week as a decimal, Monday being 1. (1..7) - %U - Week number of the current year, - starting with the first Sunday as the first - day of the first week (00..53) - %v - VMS date (%e-%b-%Y) - %V - Week number of year according to ISO 8601 (01..53) - %W - Week number of the current year, - starting with the first Monday as the first - day of the first week (00..53) - %w - Day of the week (Sunday is 0, 0..6) - %x - Preferred representation for the date alone, no time - %X - Preferred representation for the time alone, no date - %y - Year without a century (00..99) - %Y - Year with century - %z - Time zone as hour offset from UTC (e.g. +0900) - %Z - Time zone name - %% - Literal ``%'' character - -#### Examples - -##### **Usage** - -```puppet - -To return the time since epoch: strftime("%s") -To return the date: strftime("%Y-%m-%d") -``` - -#### `strftime()` - -> *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this -function. It also supports the Timestamp and Timespan data types in the Puppet language. - -**Format meaning:** - - %a - The abbreviated weekday name (``Sun'') - %A - The full weekday name (``Sunday'') - %b - The abbreviated month name (``Jan'') - %B - The full month name (``January'') - %c - The preferred local date and time representation - %C - Century (20 in 2009) - %d - Day of the month (01..31) - %D - Date (%m/%d/%y) - %e - Day of the month, blank-padded ( 1..31) - %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) - %h - Equivalent to %b - %H - Hour of the day, 24-hour clock (00..23) - %I - Hour of the day, 12-hour clock (01..12) - %j - Day of the year (001..366) - %k - hour, 24-hour clock, blank-padded ( 0..23) - %l - hour, 12-hour clock, blank-padded ( 0..12) - %L - Millisecond of the second (000..999) - %m - Month of the year (01..12) - %M - Minute of the hour (00..59) - %n - Newline (\n) - %N - Fractional seconds digits, default is 9 digits (nanosecond) - %3N millisecond (3 digits) - %6N microsecond (6 digits) - %9N nanosecond (9 digits) - %p - Meridian indicator (``AM'' or ``PM'') - %P - Meridian indicator (``am'' or ``pm'') - %r - time, 12-hour (same as %I:%M:%S %p) - %R - time, 24-hour (%H:%M) - %s - Number of seconds since 1970-01-01 00:00:00 UTC. - %S - Second of the minute (00..60) - %t - Tab character (\t) - %T - time, 24-hour (%H:%M:%S) - %u - Day of the week as a decimal, Monday being 1. (1..7) - %U - Week number of the current year, - starting with the first Sunday as the first - day of the first week (00..53) - %v - VMS date (%e-%b-%Y) - %V - Week number of year according to ISO 8601 (01..53) - %W - Week number of the current year, - starting with the first Monday as the first - day of the first week (00..53) - %w - Day of the week (Sunday is 0, 0..6) - %x - Preferred representation for the date alone, no time - %X - Preferred representation for the time alone, no date - %y - Year without a century (00..99) - %Y - Year with century - %z - Time zone as hour offset from UTC (e.g. +0900) - %Z - Time zone name - %% - Literal ``%'' character - -Returns: `Any` converted time according to the directives in the given format string - -##### Examples - -###### **Usage** - -```puppet - -To return the time since epoch: strftime("%s") -To return the date: strftime("%Y-%m-%d") -``` - -### strip +### `strip` Type: Ruby 3.x API @@ -4665,7 +4790,7 @@ Would result in: "aaa" ``` -### suffix +### `suffix` Type: Ruby 3.x API @@ -4703,7 +4828,7 @@ Will return: ['ap','bp','cp'] ``` -### swapcase +### `swapcase` Type: Ruby 3.x API @@ -4735,7 +4860,7 @@ Would result in: "AbCd" ``` -### time +### `time` Type: Ruby 3.x API @@ -4775,7 +4900,7 @@ Will return something like: 1311972653 ``` -### to_bytes +### `to_bytes` Type: Ruby 3.x API @@ -4791,7 +4916,7 @@ Returns: `Any` converted value into bytes -### to_json +### `to_json` Type: Ruby 4.x API @@ -4833,7 +4958,7 @@ data structure which needs to be converted into JSON -### to_json_pretty +### `to_json_pretty` Type: Ruby 4.x API @@ -4856,11 +4981,30 @@ content => to_json_pretty({ param_one => 'value', param_two => undef, - }), + }, true), } -``` - -#### `to_json_pretty(Variant[Hash, Array] $data, Optional[Boolean] $skip_undef)` + +* how to output pretty JSON using tabs for indentation + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty({ + param_one => 'value', + param_two => { + param_more => 42, + }, + }, nil, {indent => ' '}), + } +``` + +#### `to_json_pretty(Variant[Hash, Array] $data, Optional[Optional[Boolean]] $skip_undef, Optional[Struct[{ +indent => Optional[String], +space => Optional[String], +space_before => Optional[String], +object_nl => Optional[String], +array_nl => Optional[String], +allow_nan => Optional[Boolean], +max_nesting => Optional[Integer[-1,default]], +}]] $opts)` The to_json_pretty function. @@ -4883,7 +5027,18 @@ content => to_json_pretty({ param_one => 'value', param_two => undef, - }), + }, true), + } + +* how to output pretty JSON using tabs for indentation + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty({ + param_one => 'value', + param_two => { + param_more => 42, + }, + }, nil, {indent => ' '}), } ``` @@ -4895,11 +5050,27 @@ ##### `skip_undef` -Data type: `Optional[Boolean]` +Data type: `Optional[Optional[Boolean]]` value `true` or `false` -### to_yaml +##### `opts` + +Data type: `Optional[Struct[{ +indent => Optional[String], +space => Optional[String], +space_before => Optional[String], +object_nl => Optional[String], +array_nl => Optional[String], +allow_nan => Optional[Boolean], +max_nesting => Optional[Integer[-1,default]], +}]]` + +hash-map of settings passed to JSON.pretty_generate, see +https://ruby-doc.org/stdlib-2.0.0/libdoc/json/rdoc/JSON.html#method-i-generate. +Note that `max_nesting` doesn't take the value `false`; use `-1` instead. + +### `to_yaml` Type: Ruby 4.x API @@ -4907,7 +5078,7 @@ #### Examples -##### how to output YAML +##### How to output YAML ```puppet # output yaml to a file @@ -4917,7 +5088,16 @@ } ``` -#### `to_yaml(Any $data)` +##### Use options control the output format + +```puppet +file { '/tmp/my.yaml': + ensure => file, + content => to_yaml($myhash, {indentation: 4}) +} +``` + +#### `to_yaml(Any $data, Optional[Hash] $options)` The to_yaml function. @@ -4925,7 +5105,7 @@ ##### Examples -###### how to output YAML +###### How to output YAML ```puppet # output yaml to a file @@ -4935,13 +5115,28 @@ } ``` +###### Use options control the output format + +```puppet +file { '/tmp/my.yaml': + ensure => file, + content => to_yaml($myhash, {indentation: 4}) +} +``` + ##### `data` Data type: `Any` -### try_get_value +##### `options` + +Data type: `Optional[Hash]` + + + +### `try_get_value` Type: Ruby 3.x API @@ -5008,7 +5203,7 @@ Returns: `Any` Looks up into a complex structure of arrays and hashes and returns a value or the default value if nothing was found. -### type +### `type` Type: Ruby 3.x API @@ -5034,7 +5229,7 @@ Returns: `Any` the type when passed a value. Type can be one of: -### type3x +### `type3x` Type: Ruby 3.x API @@ -5056,7 +5251,7 @@ Returns: `Any` the type when passed a value. Type can be one of: -### type_of +### `type_of` Type: Ruby 4.x API @@ -5114,7 +5309,7 @@ -### union +### `union` Type: Ruby 3.x API @@ -5146,7 +5341,7 @@ Would return: ["a","b","c","d"] ``` -### unique +### `unique` Type: Ruby 3.x API @@ -5188,7 +5383,7 @@ This returns: ["a","b","c"] ``` -### unix2dos +### `unix2dos` Type: Ruby 3.x API @@ -5200,7 +5395,7 @@ Returns: `Any` the DOS version of the given string. -### upcase +### `upcase` Type: Ruby 3.x API @@ -5234,7 +5429,7 @@ Will return ABCD ``` -### uriescape +### `uriescape` Type: Ruby 3.x API @@ -5247,7 +5442,7 @@ Returns: `String` a string that contains the converted value -### validate_absolute_path +### `validate_absolute_path` Type: Ruby 3.x API @@ -5316,7 +5511,7 @@ validate_absolute_path($undefin ``` -### validate_absolute_path +### `validate_absolute_path` Type: Ruby 4.x API @@ -5340,31 +5535,7 @@ Any additional values that are to be passed to the method -### validate_array - -Type: Ruby 4.x API - -Validate the passed value represents an array. - -#### `validate_array(Any $scope, Any *$args)` - -The validate_array function. - -Returns: `Any` A boolean value (`true` or `false`) returned from the called function. - -##### `scope` - -Data type: `Any` - -The main value that will be passed to the method - -##### `*args` - -Data type: `Any` - -Any additional values that are to be passed to the method - -### validate_array +### `validate_array` Type: Ruby 3.x API @@ -5413,7 +5584,31 @@ validate_array($undefined ``` -### validate_augeas +### `validate_array` + +Type: Ruby 4.x API + +Validate the passed value represents an array. + +#### `validate_array(Any $scope, Any *$args)` + +The validate_array function. + +Returns: `Any` A boolean value (`true` or `false`) returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### `validate_augeas` Type: Ruby 3.x API @@ -5487,7 +5682,7 @@ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') ``` -### validate_bool +### `validate_bool` Type: Ruby 3.x API @@ -5540,7 +5735,7 @@ validate_bool($some_array) ``` -### validate_bool +### `validate_bool` Type: Ruby 4.x API @@ -5565,7 +5760,7 @@ Any additional values that are to be passed to the method -### validate_cmd +### `validate_cmd` Type: Ruby 3.x API @@ -5619,7 +5814,7 @@ validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') ``` -### validate_domain_name +### `validate_domain_name` Type: Ruby 3.x API @@ -5674,7 +5869,7 @@ validate_domain_name('www.example.2com') ``` -### validate_email_address +### `validate_email_address` Type: Ruby 3.x API @@ -5723,31 +5918,7 @@ validate_email_address($some_array) ``` -### validate_hash - -Type: Ruby 4.x API - -Validate the passed value represents a hash. - -#### `validate_hash(Any $scope, Any *$args)` - -The validate_hash function. - -Returns: `Any` A boolean value (`true` or `false`) returned from the called function. - -##### `scope` - -Data type: `Any` - -The main value that will be passed to the method - -##### `*args` - -Data type: `Any` - -Any additional values that are to be passed to the method - -### validate_hash +### `validate_hash` Type: Ruby 3.x API @@ -5798,7 +5969,31 @@ validate_hash($undefined) ``` -### validate_integer +### `validate_hash` + +Type: Ruby 4.x API + +Validate the passed value represents a hash. + +#### `validate_hash(Any $scope, Any *$args)` + +The validate_hash function. + +Returns: `Any` A boolean value (`true` or `false`) returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### `validate_integer` Type: Ruby 3.x API @@ -5912,7 +6107,7 @@ Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. ``` -### validate_integer +### `validate_integer` Type: Ruby 4.x API @@ -5937,32 +6132,7 @@ Any additional values that are to be passed to the method -### validate_ip_address - -Type: Ruby 4.x API - -Validate the passed value represents an ip_address. - -#### `validate_ip_address(Any $scope, Any *$args)` - -The validate_ip_address function. - -Returns: `Boolean` `true` or `false` -A boolean value returned from the called function. - -##### `scope` - -Data type: `Any` - -The main value that will be passed to the method - -##### `*args` - -Data type: `Any` - -Any additional values that are to be passed to the method - -### validate_ip_address +### `validate_ip_address` Type: Ruby 3.x API @@ -6020,15 +6190,15 @@ validate_ip_address($some_array) ``` -### validate_ipv4_address +### `validate_ip_address` Type: Ruby 4.x API -Validate the passed value represents an ipv4_address. - -#### `validate_ipv4_address(Any $scope, Any *$args)` - -The validate_ipv4_address function. +Validate the passed value represents an ip_address. + +#### `validate_ip_address(Any $scope, Any *$args)` + +The validate_ip_address function. Returns: `Boolean` `true` or `false` A boolean value returned from the called function. @@ -6045,7 +6215,7 @@ Any additional values that are to be passed to the method -### validate_ipv4_address +### `validate_ipv4_address` Type: Ruby 3.x API @@ -6092,15 +6262,15 @@ validate_ipv4_address($some_array) ``` -### validate_ipv6_address +### `validate_ipv4_address` Type: Ruby 4.x API -Validate the passed value represents an ipv6_address. - -#### `validate_ipv6_address(Any $scope, Any *$args)` - -The validate_ipv6_address function. +Validate the passed value represents an ipv4_address. + +#### `validate_ipv4_address(Any $scope, Any *$args)` + +The validate_ipv4_address function. Returns: `Boolean` `true` or `false` A boolean value returned from the called function. @@ -6117,7 +6287,7 @@ Any additional values that are to be passed to the method -### validate_ipv6_address +### `validate_ipv6_address` Type: Ruby 3.x API @@ -6166,7 +6336,32 @@ validate_ipv6_address($some_array) ``` -### validate_legacy +### `validate_ipv6_address` + +Type: Ruby 4.x API + +Validate the passed value represents an ipv6_address. + +#### `validate_ipv6_address(Any $scope, Any *$args)` + +The validate_ipv6_address function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### `validate_legacy` Type: Ruby 4.x API @@ -6244,7 +6439,7 @@ Any additional values that are to be passed to the method -### validate_numeric +### `validate_numeric` Type: Ruby 3.x API @@ -6268,7 +6463,7 @@ Returns: `Any` Validate that the first argument is a numeric value (or an array of numeric values). Fail compilation if any of the checks fail. -### validate_numeric +### `validate_numeric` Type: Ruby 4.x API @@ -6293,7 +6488,7 @@ Any additional values that are to be passed to the method -### validate_re +### `validate_re` Type: Ruby 3.x API @@ -6365,7 +6560,7 @@ validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') ``` -### validate_re +### `validate_re` Type: Ruby 4.x API @@ -6393,7 +6588,32 @@ test, and the second argument should be a stringified regular expression (without the // delimiters) or an array of regular expressions -### validate_slength +### `validate_slength` + +Type: Ruby 4.x API + +Validate that a passed string has length less/equal with the passed value + +#### `validate_slength(Any $scope, Any *$args)` + +Validate that a passed string has length less/equal with the passed value + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### `validate_slength` Type: Ruby 3.x API @@ -6443,32 +6663,7 @@ validate_slength(["discombobulate","moo"],17,10) ``` -### validate_slength - -Type: Ruby 4.x API - -Validate that a passed string has length less/equal with the passed value - -#### `validate_slength(Any $scope, Any *$args)` - -Validate that a passed string has length less/equal with the passed value - -Returns: `Boolean` `true` or `false` -A boolean value returned from the called function. - -##### `scope` - -Data type: `Any` - -The main value that will be passed to the method - -##### `*args` - -Data type: `Any` - -Any additional values that are to be passed to the method - -### validate_string +### `validate_string` Type: Ruby 4.x API @@ -6493,7 +6688,7 @@ Any additional values that are to be passed to the method -### validate_string +### `validate_string` Type: Ruby 3.x API @@ -6552,7 +6747,7 @@ validate_string([ 'some', 'array' ]) ``` -### validate_x509_rsa_key_pair +### `validate_x509_rsa_key_pair` Type: Ruby 3.x API @@ -6564,7 +6759,7 @@ Returns: `Any` Fail compilation if any value fails this check. -### values +### `values` Type: Ruby 3.x API @@ -6610,7 +6805,7 @@ This example would return: ```[1,2,3]``` ``` -### values_at +### `values_at` Type: Ruby 3.x API @@ -6680,7 +6875,7 @@ Would return ['a','c','d'] ``` -### zip +### `zip` Type: Ruby 3.x API @@ -6712,25 +6907,37 @@ ## Data types -### Stdlib::Absolutepath +### `Stdlib::Absolutepath` A strict absolutepath type -Alias of `Variant[Stdlib::Windowspath, Stdlib::Unixpath]` - -### Stdlib::Base32 +Alias of + +```puppet +Variant[Stdlib::Windowspath, Stdlib::Unixpath] +``` + +### `Stdlib::Base32` Type to match base32 String -Alias of `Pattern[/^[a-z2-7]+={,6}$/, /^[A-Z2-7]+={,6}$/]` - -### Stdlib::Base64 +Alias of + +```puppet +Pattern[/\A[a-z2-7]+={,6}\z/, /\A[A-Z2-7]+={,6}\z/] +``` + +### `Stdlib::Base64` Type to match base64 String -Alias of `Pattern[/^[a-zA-Z0-9\/\+]+={,2}$/]` - -### Stdlib::Compat::Absolute_path +Alias of + +```puppet +Pattern[/\A[a-zA-Z0-9\/\+]+={,2}\z/] +``` + +### `Stdlib::Compat::Absolute_path` Emulate the is_absolute_path and validate_absolute_path functions @@ -6739,21 +6946,33 @@ name = '[^\\\\/]+' %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, -Alias of `Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]` - -### Stdlib::Compat::Array +Alias of + +```puppet +Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]] +``` + +### `Stdlib::Compat::Array` Emulate the is_array and validate_array functions -Alias of `Array[Any]` - -### Stdlib::Compat::Bool +Alias of + +```puppet +Array[Any] +``` + +### `Stdlib::Compat::Bool` Emulate the is_bool and validate_bool functions -Alias of `Boolean` - -### Stdlib::Compat::Float +Alias of + +```puppet +Boolean +``` + +### `Stdlib::Compat::Float` Emulate the is_float function The regex is what's currently used in is_float @@ -6774,15 +6993,23 @@ This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of `Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]` - -### Stdlib::Compat::Hash +Alias of + +```puppet +Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]] +``` + +### `Stdlib::Compat::Hash` Emulate the is_hash and validate_hash functions -Alias of `Hash[Any, Any]` - -### Stdlib::Compat::Integer +Alias of + +```puppet +Hash[Any, Any] +``` + +### `Stdlib::Compat::Integer` Emulate the is_integer and validate_integer functions The regex is what's currently used in is_integer @@ -6807,27 +7034,43 @@ This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of `Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]` - -### Stdlib::Compat::Ip_address +Alias of + +```puppet +Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]] +``` + +### `Stdlib::Compat::Ip_address` The Stdlib::Compat::Ip_address data type. -Alias of `Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]` - -### Stdlib::Compat::Ipv4 +Alias of + +```puppet +Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6] +``` + +### `Stdlib::Compat::Ipv4` Emulate the validate_ipv4_address and is_ipv4_address functions -Alias of `Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/]` - -### Stdlib::Compat::Ipv6 +Alias of + +```puppet +Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/] +``` + +### `Stdlib::Compat::Ipv6` The Stdlib::Compat::Ipv6 data type. -Alias of `Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/]` - -### Stdlib::Compat::Numeric +Alias of + +```puppet +Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] +``` + +### `Stdlib::Compat::Numeric` Emulate the is_numeric and validate_numeric functions The regex is what's currently used in is_numeric @@ -6852,206 +7095,443 @@ This allows you to find all places where a consumers of your code call it with unexpected values. -Alias of `Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]` - -### Stdlib::Compat::String +Alias of + +```puppet +Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]] +``` + +### `Stdlib::Compat::String` Emulate the is_string and validate_string functions -Alias of `Optional[String]` - -### Stdlib::Ensure::Service +Alias of + +```puppet +Optional[String] +``` + +### `Stdlib::Datasize` + +The Stdlib::Datasize data type. + +Alias of + +```puppet +Pattern[/^\d+(?i:[kmgt]b?|b)$/] +``` + +### `Stdlib::Ensure::File` + +The Stdlib::Ensure::File data type. + +Alias of + +```puppet +Enum['present', 'file', 'directory', 'link', 'absent'] +``` + +### `Stdlib::Ensure::File::Directory` + +The Stdlib::Ensure::File::Directory data type. + +Alias of + +```puppet +Enum['directory', 'absent'] +``` + +### `Stdlib::Ensure::File::File` + +The Stdlib::Ensure::File::File data type. + +Alias of + +```puppet +Enum['file', 'absent'] +``` + +### `Stdlib::Ensure::File::Link` + +The Stdlib::Ensure::File::Link data type. + +Alias of + +```puppet +Enum['link', 'absent'] +``` + +### `Stdlib::Ensure::Service` The Stdlib::Ensure::Service data type. -Alias of `Enum['stopped', 'running']` - -### Stdlib::Filemode +Alias of + +```puppet +Enum['stopped', 'running'] +``` + +### `Stdlib::Filemode` See `man chmod.1` for the regular expression for symbolic mode - -Alias of `Pattern[/^(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))$/]` - -### Stdlib::Filesource +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/] +``` + +### `Stdlib::Filesource` Validate the source parameter on file types -Alias of `Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[ - /^file:\/\/\/([^\/\0]+(\/)?)+$/, - /^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/, - ]]` - -### Stdlib::Fqdn +Alias of + +```puppet +Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[ + /\Afile:\/\/\/([^\n\/\0]+(\/)?)+\z/, + /\Apuppet:\/\/(([\w-]+\.?)+)?\/([^\n\/\0]+(\/)?)+\z/, + ]] +``` + +### `Stdlib::Fqdn` The Stdlib::Fqdn data type. -Alias of `Pattern[/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/]` - -### Stdlib::HTTPSUrl +Alias of + +```puppet +Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/] +``` + +### `Stdlib::HTTPSUrl` The Stdlib::HTTPSUrl data type. -Alias of `Pattern[/(?i:^https:\/\/)/]` - -### Stdlib::HTTPUrl +Alias of + +```puppet +Pattern[/(?i:\Ahttps:\/\/.*\z)/] +``` + +### `Stdlib::HTTPUrl` The Stdlib::HTTPUrl data type. -Alias of `Pattern[/(?i:^https?:\/\/)/]` - -### Stdlib::Host +Alias of + +```puppet +Pattern[/(?i:\Ahttps?:\/\/.*\z)/] +``` + +### `Stdlib::Host` The Stdlib::Host data type. -Alias of `Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]` - -### Stdlib::IP::Address +Alias of + +```puppet +Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address] +``` + +### `Stdlib::HttpStatus` + +The Stdlib::HttpStatus data type. + +Alias of + +```puppet +Integer[100, 599] +``` + +### `Stdlib::IP::Address` The Stdlib::IP::Address data type. -Alias of `Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6]` - -### Stdlib::IP::Address::Nosubnet +Alias of + +```puppet +Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6] +``` + +### `Stdlib::IP::Address::Nosubnet` The Stdlib::IP::Address::Nosubnet data type. -Alias of `Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet]` - -### Stdlib::IP::Address::V4 +Alias of + +```puppet +Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet] +``` + +### `Stdlib::IP::Address::V4` The Stdlib::IP::Address::V4 data type. -Alias of `Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet]` - -### Stdlib::IP::Address::V4::CIDR - -The Stdlib::IP::Address::V4::CIDR data type. - -Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/]` - -### Stdlib::IP::Address::V4::Nosubnet - -The Stdlib::IP::Address::V4::Nosubnet data type. - -Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` - -### Stdlib::IP::Address::V6 +Alias of + +```puppet +Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet] +``` + +### `Stdlib::IP::Address::V4::CIDR` + +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/] +``` + +### `Stdlib::IP::Address::V4::Nosubnet` + +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] +``` + +### `Stdlib::IP::Address::V6` The Stdlib::IP::Address::V6 data type. -Alias of `Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet]` - -### Stdlib::IP::Address::V6::Alternative - -The Stdlib::IP::Address::V6::Alternative data type. - -Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` - -### Stdlib::IP::Address::V6::CIDR - -The Stdlib::IP::Address::V6::CIDR data type. - -Alias of `Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/]` - -### Stdlib::IP::Address::V6::Compressed +Alias of + +```puppet +Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet] +``` + +### `Stdlib::IP::Address::V6::Alternative` + +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] +``` + +### `Stdlib::IP::Address::V6::CIDR` + +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/] +``` + +### `Stdlib::IP::Address::V6::Compressed` The Stdlib::IP::Address::V6::Compressed data type. -Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` - -### Stdlib::IP::Address::V6::Full +Alias of + +```puppet +Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] +``` + +### `Stdlib::IP::Address::V6::Full` The Stdlib::IP::Address::V6::Full data type. -Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` - -### Stdlib::IP::Address::V6::Nosubnet +Alias of + +```puppet +Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/] +``` + +### `Stdlib::IP::Address::V6::Nosubnet` The Stdlib::IP::Address::V6::Nosubnet data type. -Alias of `Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative]` - -### Stdlib::IP::Address::V6::Nosubnet::Alternative - -The Stdlib::IP::Address::V6::Nosubnet::Alternative data type. - -Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` - -### Stdlib::IP::Address::V6::Nosubnet::Compressed +Alias of + +```puppet +Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative] +``` + +### `Stdlib::IP::Address::V6::Nosubnet::Alternative` + +lint:ignore:140chars + +Alias of + +```puppet +Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] +``` + +### `Stdlib::IP::Address::V6::Nosubnet::Compressed` The Stdlib::IP::Address::V6::Nosubnet::Compressed data type. -Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/]` - -### Stdlib::IP::Address::V6::Nosubnet::Full +Alias of + +```puppet +Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/] +``` + +### `Stdlib::IP::Address::V6::Nosubnet::Full` The Stdlib::IP::Address::V6::Nosubnet::Full data type. -Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]` - -### Stdlib::MAC +Alias of + +```puppet +Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/] +``` + +### `Stdlib::MAC` A type for a MAC address -Alias of `Pattern[/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/, /^([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})$/]` - -### Stdlib::ObjectStore +Alias of + +```puppet +Pattern[/\A([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\z/, /\A([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})\z/] +``` + +### `Stdlib::ObjectStore` The Stdlib::ObjectStore data type. -Alias of `Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri]` - -### Stdlib::ObjectStore::GSUri +Alias of + +```puppet +Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri] +``` + +### `Stdlib::ObjectStore::GSUri` The Stdlib::ObjectStore::GSUri data type. -Alias of `Pattern[/^gs:\/\//]` - -### Stdlib::ObjectStore::S3Uri +Alias of + +```puppet +Pattern[/\Ags:\/\/.*\z/] +``` + +### `Stdlib::ObjectStore::S3Uri` The Stdlib::ObjectStore::S3Uri data type. -Alias of `Pattern[/^s3:\/\//]` - -### Stdlib::Port +Alias of + +```puppet +Pattern[/\As3:\/\/.*\z/] +``` + +### `Stdlib::Port` The Stdlib::Port data type. -Alias of `Integer[0, 65535]` - -### Stdlib::Port::Privileged +Alias of + +```puppet +Integer[0, 65535] +``` + +### `Stdlib::Port::Dynamic` + +The Stdlib::Port::Dynamic data type. + +Alias of + +```puppet +Integer[49152, 65535] +``` + +### `Stdlib::Port::Ephemeral` + +The Stdlib::Port::Ephemeral data type. + +Alias of + +```puppet +Stdlib::Port::Dynamic +``` + +### `Stdlib::Port::Privileged` The Stdlib::Port::Privileged data type. -Alias of `Integer[1, 1023]` - -### Stdlib::Port::Unprivileged +Alias of + +```puppet +Integer[1, 1023] +``` + +### `Stdlib::Port::Registered` + +The Stdlib::Port::Registered data type. + +Alias of + +```puppet +Stdlib::Port::User +``` + +### `Stdlib::Port::Unprivileged` The Stdlib::Port::Unprivileged data type. -Alias of `Integer[1024, 65535]` - -### Stdlib::Syslogfacility +Alias of + +```puppet +Integer[1024, 65535] +``` + +### `Stdlib::Port::User` + +The Stdlib::Port::User data type. + +Alias of + +```puppet +Integer[1024, 49151] +``` + +### `Stdlib::Syslogfacility` The Stdlib::Syslogfacility data type. -Alias of `Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7']` - -### Stdlib::Unixpath +Alias of + +```puppet +Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7'] +``` + +### `Stdlib::Unixpath` this regex rejects any path component that does not start with "/" or is NUL -Alias of `Pattern[/^\/([^\/\0]+\/*)*$/]` - -### Stdlib::Windowspath +Alias of + +```puppet +Pattern[/\A\/([^\n\/\0]+\/*)*\z/] +``` + +### `Stdlib::Windowspath` The Stdlib::Windowspath data type. -Alias of `Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/]` - -### Stdlib::Yes_no +Alias of + +```puppet +Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/] +``` + +### `Stdlib::Yes_no` The Stdlib::Yes_no data type. -Alias of `Pattern[/\A(?i:(yes|no))\z/]` - +Alias of + +```puppet +Pattern[/\A(?i:(yes|no))\z/] +``` + diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/RELEASE_PROCESS.markdown --- a/modules/stdlib/RELEASE_PROCESS.markdown Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/RELEASE_PROCESS.markdown Sun Oct 09 10:34:32 2022 +0100 @@ -3,12 +3,12 @@ * Work in a topic branch * Submit a github pull request * Address any comments / feeback - * Merge into master using --no-ff + * Merge into main using --no-ff # Releasing this module # * This module adheres to http://semver.org/ - * Look for API breaking changes using git diff vX.Y.Z..master + * Look for API breaking changes using git diff vX.Y.Z.. * If no API breaking changes, the minor version may be bumped. * If there are API breaking changes, the major version must be bumped. * If there are only small minor changes, the patch version may be bumped. diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/Rakefile --- a/modules/stdlib/Rakefile Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? -require 'puppet-lint/tasks/puppet-lint' - -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal -end - -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - - returnVal = nil - returnVal ||= begin - metadata_source = JSON.load(File.read('metadata.json'))['source'] - metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) - - metadata_source_match && metadata_source_match[1] - end - - raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? - - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal -end - -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal -end - -PuppetLint.configuration.send('disable_relative') - -if Bundler.rubygems.find_name('github_changelog_generator').any? - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["feature", "enhancement"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise <= Gem::Version.new('2.2.2')" -EOM - end -end - diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/appveyor.yml --- a/modules/stdlib/appveyor.yml Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ ---- -version: 1.1.x.{build} -branches: - only: - - master - - release -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - SIMPLECOV: yes - matrix: - - - RUBY_VERSION: 24-x64 - CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24-x64 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec - - - RUBY_VERSION: 25-x64 - ACCEPTANCE: yes - TARGET_HOST: localhost - - - RUBY_VERSION: 25-x64 - ACCEPTANCE: yes - TARGET_HOST: localhost - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 -for: -- - matrix: - only: - - ACCEPTANCE: yes - install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 - - type Gemfile.lock - test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake spec_prep - - bundle exec rake litmus:acceptance:localhost -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/checksums.json --- a/modules/stdlib/checksums.json Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,475 +0,0 @@ -{ - "CHANGELOG.md": "36a6c30e8a30de451a382da2154a2bf2", - "CODEOWNERS": "366aefdc1424442b8f864528c2e0db1d", - "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4", - "Gemfile": "84036526cd6deead5b9da36d40b31623", - "HISTORY.md": "6b78ee53e5d501d081c45c5ee8f604e1", - "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "MAINTAINERS.md": "b40ec4f2c16145af6f723c2c34bb2ff9", - "NOTICE": "b2e552587e5969886fdd60481e8b0351", - "README.md": "292f3898d725d5e153e3d06b63db7620", - "README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165", - "README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1", - "REFERENCE.md": "752ff41096c3e86e5ff8550895ad998d", - "RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9", - "Rakefile": "5069da2530bc861198a8c561f9681a99", - "appveyor.yml": "be9ede1f8e25ace60a8eae6db2da1384", - "distelli-manifest.yml": "2b03c8cae145c90561cd4a0b43f9eea5", - "examples/file_line.pp": "d8126b139dd1dce21ff26910d1c5a245", - "examples/has_interface_with.pp": "d69d520cf3ff4d0b495480afaca359ef", - "examples/has_ip_address.pp": "32f42575e49aa66f0f2398a70ae2a9f4", - "examples/has_ip_network.pp": "bfb8db068c58d77c4dd7ae9697536537", - "examples/init.pp": "b52fd907330ddbd9c3e070cf39f7b317", - "lib/facter/facter_dot_d.rb": "82a1f2646f4ce640c6dcea2bfcbbecc8", - "lib/facter/package_provider.rb": "b17127f4c7f20443f6c85c4836745bac", - "lib/facter/pe_version.rb": "b2c9b4cbc4b69c2a377770f7189d3e94", - "lib/facter/puppet_settings.rb": "d939328efb70ec800443c8515e885f69", - "lib/facter/root_home.rb": "c2a013cb787ef788c539980d3e954048", - "lib/facter/service_provider.rb": "66cc42526eae631e306b397391f1f01c", - "lib/facter/util/puppet_settings.rb": "f69007bcc02031cd772fa7f2dffa3c0c", - "lib/puppet/functions/deprecation.rb": "9f7706a22f47383421bc10e712ff9d0a", - "lib/puppet/functions/fact.rb": "a457dbc9ec08144b0886a964e74ba8a1", - "lib/puppet/functions/is_a.rb": "60372a583cc765976e7a49504de0684f", - "lib/puppet/functions/is_absolute_path.rb": "4d6a337eeb633639a58fb396b4d7176f", - "lib/puppet/functions/is_array.rb": "21d22504bf41733e1784e9a6c3dc59a5", - "lib/puppet/functions/is_bool.rb": "baadfbdb76d9b7c3cb5f8159a53c5bf3", - "lib/puppet/functions/is_float.rb": "b4327ddf6f33462b76f706ace51cea00", - "lib/puppet/functions/is_ip_address.rb": "fee3d0323de6f9966ed92cab5eabdfb3", - "lib/puppet/functions/is_ipv4_address.rb": "5d262c46367303d24195fa54d1226a0c", - "lib/puppet/functions/is_ipv6_address.rb": "ac870a59c005cd54d3cd1028a650073c", - "lib/puppet/functions/is_numeric.rb": "82ba88985c27ff7e5074baf2d3de0c19", - "lib/puppet/functions/is_string.rb": "d04e1e1312e2d5fe9cf91d9478aaa47a", - "lib/puppet/functions/length.rb": "d3a3bed61149d19e86c29c38fbf89a36", - "lib/puppet/functions/merge.rb": "ebae086c10f411f4c5cc52ae0a084eb8", - "lib/puppet/functions/os_version_gte.rb": "7c32f86861a7bc6b6a04c12d072644e2", - "lib/puppet/functions/seeded_rand_string.rb": "58f5005c4d667c27a06451339dad8bac", - "lib/puppet/functions/sprintf_hash.rb": "39a468b9c0f0bfbd319f19da28bdc9eb", - "lib/puppet/functions/stdlib/extname.rb": "ddafe4ddf35f3be7bc2aebc5fd975c39", - "lib/puppet/functions/stdlib/ip_in_range.rb": "62820a0b4bdc207b0000a11ca339a2d3", - "lib/puppet/functions/to_json.rb": "9be02065dd8fc8b4c14cc7daa52119c5", - "lib/puppet/functions/to_json_pretty.rb": "886e2b23fc8b9060e73d93dfd5a82e57", - "lib/puppet/functions/to_yaml.rb": "8ce138d4f3ba93ee480311d5b753259e", - "lib/puppet/functions/type_of.rb": "6e7c6e50f6fe92c32f578a644dd66b66", - "lib/puppet/functions/validate_absolute_path.rb": "5872ffdc5b0462eb5826ef10e614dc9d", - "lib/puppet/functions/validate_array.rb": "b219e008bc5441a7179faa01da0e98dd", - "lib/puppet/functions/validate_bool.rb": "9468b5124a3956d8c8120c90a5bcd57a", - "lib/puppet/functions/validate_hash.rb": "cda57f161742d37b8a0248865dab7ee0", - "lib/puppet/functions/validate_integer.rb": "fd0c34b11d4327cfefc53c2294f222e7", - "lib/puppet/functions/validate_ip_address.rb": "f54d16dc96f7851c60e5964a64da2398", - "lib/puppet/functions/validate_ipv4_address.rb": "c205d7b710eb0c234f9661d8cc703039", - "lib/puppet/functions/validate_ipv6_address.rb": "6fb3fb641c996132ae0ac352ff2e9f23", - "lib/puppet/functions/validate_legacy.rb": "7f4abc0b7fe49cf41847f2ee9d7562ed", - "lib/puppet/functions/validate_numeric.rb": "9cae03d48f6ca997fe3b4f482985f095", - "lib/puppet/functions/validate_re.rb": "55b302d7e594eb7557a0c6903cb4a3ac", - "lib/puppet/functions/validate_slength.rb": "eb14887b0e4c7659681d045334283de8", - "lib/puppet/functions/validate_string.rb": "0910a5c7de84edacafe8d00d1e86c2a1", - "lib/puppet/parser/functions/abs.rb": "1caab301efc51e6ac877eb310ea642e9", - "lib/puppet/parser/functions/any2array.rb": "f3bdf3cdd61c1a87c5c9892806cf9082", - "lib/puppet/parser/functions/any2bool.rb": "246bdf9237a49cd5fca8a46d0e5c3419", - "lib/puppet/parser/functions/assert_private.rb": "5a847d20e2945f431d011ed77942be33", - "lib/puppet/parser/functions/base64.rb": "75d1b726a0da0ab666375aaba1dfa05e", - "lib/puppet/parser/functions/basename.rb": "193dee93291bbac4055f12004c69e898", - "lib/puppet/parser/functions/bool2num.rb": "58e4e3d6902d77906edf512e4c9fd5ca", - "lib/puppet/parser/functions/bool2str.rb": "c3282f7e658e951c3b562250f06070d6", - "lib/puppet/parser/functions/camelcase.rb": "16a2e5a7c4980444ae412a832f6f799e", - "lib/puppet/parser/functions/capitalize.rb": "1d6dccd218cf7816e99453ac9eb5495b", - "lib/puppet/parser/functions/ceiling.rb": "0b1f1cc86e247a6264e2a694bc7460c5", - "lib/puppet/parser/functions/chomp.rb": "6b556817deaf53cafbfbe1126b5a7db2", - "lib/puppet/parser/functions/chop.rb": "6add3bc3fbfd419f96a5d0d627811dd9", - "lib/puppet/parser/functions/clamp.rb": "e2b41cb6c03b3f10c4573af79b020baa", - "lib/puppet/parser/functions/concat.rb": "c8552953e0677992f8930cbd26aa8c47", - "lib/puppet/parser/functions/convert_base.rb": "d65d544dec14d9819f013d01b654455a", - "lib/puppet/parser/functions/count.rb": "cace9e26cf58c571842ff7146bc0579e", - "lib/puppet/parser/functions/deep_merge.rb": "2796acbb37e779eb595ecf165788ab35", - "lib/puppet/parser/functions/defined_with_params.rb": "7f9a270365f9a047355a01492994e0ab", - "lib/puppet/parser/functions/delete.rb": "1885535df5a4c06e39c16b98220b746d", - "lib/puppet/parser/functions/delete_at.rb": "af1d44d9654694a7f6877b7e5b9ed639", - "lib/puppet/parser/functions/delete_regex.rb": "ad1e1ac49ad0589c20b433bd22da973d", - "lib/puppet/parser/functions/delete_undef_values.rb": "bc1221ac34bfabc4ff8e808bdd854ebf", - "lib/puppet/parser/functions/delete_values.rb": "eadb784d5c678961f324679a615347d6", - "lib/puppet/parser/functions/deprecation.rb": "cb5fdb8e71a888437ca2956d833edcf2", - "lib/puppet/parser/functions/difference.rb": "ce4921704459ab9d412e9c6a76f08470", - "lib/puppet/parser/functions/dig.rb": "babc1c588e32d7561b29e57460ceec31", - "lib/puppet/parser/functions/dig44.rb": "ad97e68abc70939375e7d8c156114994", - "lib/puppet/parser/functions/dirname.rb": "825b61480896626794a632f465858ed0", - "lib/puppet/parser/functions/dos2unix.rb": "6baffd01b4076fb3093d6a1659947625", - "lib/puppet/parser/functions/downcase.rb": "15115685c59ad44ec0dd4d8c404c13c1", - "lib/puppet/parser/functions/empty.rb": "39c8cae896b5200049898257b5580b7b", - "lib/puppet/parser/functions/enclose_ipv6.rb": "bc9e304cda8623148cf2b43eed50ee4e", - "lib/puppet/parser/functions/ensure_packages.rb": "b8d8398536030e18b9a611adbbc4ead0", - "lib/puppet/parser/functions/ensure_resource.rb": "ebc7ff4e6819f9a5571321ce94296622", - "lib/puppet/parser/functions/ensure_resources.rb": "fbff17623dbfe7abe699e5e101a58666", - "lib/puppet/parser/functions/flatten.rb": "8eb8ee688df30854ee6102f7916b95d4", - "lib/puppet/parser/functions/floor.rb": "9a3726fb87f6f3e1d93bc1a1d6378dbd", - "lib/puppet/parser/functions/fqdn_rand_string.rb": "f891ff98c960078f9ae0fad60e3f3448", - "lib/puppet/parser/functions/fqdn_rotate.rb": "3411883e14b61afcfcf98f21c917b1be", - "lib/puppet/parser/functions/fqdn_uuid.rb": "de08b8739e876a935aba2cd4948d2167", - "lib/puppet/parser/functions/get_module_path.rb": "7bce665daf99e68bd06bbec57b707f29", - "lib/puppet/parser/functions/getparam.rb": "0ee6179adda0795ec38bc1e90eaa6591", - "lib/puppet/parser/functions/getvar.rb": "7e943851d8be874b49e49e4b792e843f", - "lib/puppet/parser/functions/glob.rb": "506e79fd7ade56c13195c4cb11cad73e", - "lib/puppet/parser/functions/grep.rb": "018e6930aed61e72c29a847295bf0740", - "lib/puppet/parser/functions/has_interface_with.rb": "fa1bea02dabd790f1e33119b359cf7db", - "lib/puppet/parser/functions/has_ip_address.rb": "35ee815f26129bcaf820fc6108f96bb6", - "lib/puppet/parser/functions/has_ip_network.rb": "dd1dded44a27ee8052827c901c4d20bd", - "lib/puppet/parser/functions/has_key.rb": "44e5a56409ddee7c26f04cd50185aa17", - "lib/puppet/parser/functions/hash.rb": "d1d45cbb4a4fe27b4182a2c230026f94", - "lib/puppet/parser/functions/intersection.rb": "469b60a6a15b0380664039b8304c38cc", - "lib/puppet/parser/functions/is_absolute_path.rb": "d1d6c130ba7231d5c4987ae30e45f4e2", - "lib/puppet/parser/functions/is_array.rb": "4e4ca6ccfc2fd352351583f01989d10d", - "lib/puppet/parser/functions/is_bool.rb": "f1e09e73d4fca5ce0ffd0781de541b07", - "lib/puppet/parser/functions/is_domain_name.rb": "b51986bab6685bfc8bd3117bd4be9322", - "lib/puppet/parser/functions/is_email_address.rb": "f3a126e7d3cb10a4b25bb3db631fe442", - "lib/puppet/parser/functions/is_float.rb": "eff28cde457b69e50947fa1e462b6e11", - "lib/puppet/parser/functions/is_function_available.rb": "20b970c665432431c0b1879027572dd0", - "lib/puppet/parser/functions/is_hash.rb": "afdce2b8afbf9f43267a351f8dd47425", - "lib/puppet/parser/functions/is_integer.rb": "3a6b477144f55d46950dc06b049d98a1", - "lib/puppet/parser/functions/is_ip_address.rb": "3ef677e90e7345cd12e886fde0561727", - "lib/puppet/parser/functions/is_ipv4_address.rb": "3a125625891bde53b7a7e80981b69965", - "lib/puppet/parser/functions/is_ipv6_address.rb": "f4bab5d4223aa5af9606b3843db0b99a", - "lib/puppet/parser/functions/is_mac_address.rb": "25a695daa304d101ce42535341f85534", - "lib/puppet/parser/functions/is_numeric.rb": "400934c5f70239322f8ed3e77bd83c92", - "lib/puppet/parser/functions/is_string.rb": "46f41a621ad827f24fdb0a4f95b1eb7b", - "lib/puppet/parser/functions/join.rb": "94eb446f1c08c84245b3dc4d2c9f2575", - "lib/puppet/parser/functions/join_keys_to_values.rb": "7aa31c88062bff5de5763bca3b66c369", - "lib/puppet/parser/functions/keys.rb": "22dc39591357405e98751147c3f59c05", - "lib/puppet/parser/functions/load_module_metadata.rb": "715a14fde1d65b3894dfdcff460e5d3b", - "lib/puppet/parser/functions/loadjson.rb": "e0b63ae98a9bd95bfe648607ab5e391f", - "lib/puppet/parser/functions/loadyaml.rb": "4e4370d56487bdc8c0fd7ebc94532b1b", - "lib/puppet/parser/functions/lstrip.rb": "1a536f290d87c2287f9cd4a6647b90ad", - "lib/puppet/parser/functions/max.rb": "80f3fadc7a4ef00c2cea938f5552687e", - "lib/puppet/parser/functions/member.rb": "7b1dcef3f895d76a2250f4f998936b51", - "lib/puppet/parser/functions/merge.rb": "00d4573f8ccfb1b54cff984df3281770", - "lib/puppet/parser/functions/min.rb": "828e10db1bf46d880eba94c09367fc23", - "lib/puppet/parser/functions/num2bool.rb": "03101587ea7761f5d2043bef8a0e4813", - "lib/puppet/parser/functions/parsejson.rb": "84edfcfbdfa9be8df246cd6263bf27a4", - "lib/puppet/parser/functions/parseyaml.rb": "a63c7b27e3bdaf363e288be9a4689b9f", - "lib/puppet/parser/functions/pick.rb": "f4e94df732ed5d209c9fc8db5ac35207", - "lib/puppet/parser/functions/pick_default.rb": "17f442caa18d25075de2cd7abd65a791", - "lib/puppet/parser/functions/prefix.rb": "bcf32e7f5867dcb40ec0cdca8002329f", - "lib/puppet/parser/functions/private.rb": "681d49c29c4b8df691a41e90df7e6500", - "lib/puppet/parser/functions/pry.rb": "5bac48462794f5d18d3ad30f1141aeb1", - "lib/puppet/parser/functions/pw_hash.rb": "f9c7c8896ba99b9262196e6ea67fa07c", - "lib/puppet/parser/functions/range.rb": "3c445b69b908d96a388a1572cc359470", - "lib/puppet/parser/functions/regexpescape.rb": "27fe5962756477de3fb71a646135e96c", - "lib/puppet/parser/functions/reject.rb": "4cceb698ed1d0a2f0fbe8e91c4f68a21", - "lib/puppet/parser/functions/reverse.rb": "0b3fe898d9418db6b3affbade6c035c3", - "lib/puppet/parser/functions/round.rb": "e4d15bdb144ece4710608fd5356ab106", - "lib/puppet/parser/functions/rstrip.rb": "65ae5dd164e117a6d79595b47952ae05", - "lib/puppet/parser/functions/seeded_rand.rb": "8a2f323648633466001af665b6f6c624", - "lib/puppet/parser/functions/shell_escape.rb": "5ed2fe520fcebb2ef46ecd6f8cf1d414", - "lib/puppet/parser/functions/shell_join.rb": "d048ff0d100edeb148cb7d5ef13f9c82", - "lib/puppet/parser/functions/shell_split.rb": "5985ff9873995ed9d496935f81daee8a", - "lib/puppet/parser/functions/shuffle.rb": "9873cf32c81535410732125b21b2876c", - "lib/puppet/parser/functions/size.rb": "fa2e1774d0373ed0e61aa7966b5f4737", - "lib/puppet/parser/functions/sort.rb": "11cb9d7293aafd907fe55b319fc64a9b", - "lib/puppet/parser/functions/squeeze.rb": "8dd784412fbe111b13ce92744cdc1a29", - "lib/puppet/parser/functions/str2bool.rb": "70775b38472584f0522ae032bd54502d", - "lib/puppet/parser/functions/str2saltedsha512.rb": "37a123c3fca9cd8b3f472dc18227673f", - "lib/puppet/parser/functions/strftime.rb": "b526a0156b6f346ce64150a7263f1734", - "lib/puppet/parser/functions/strip.rb": "5fd70908ed62c6f6fb58098dbae3993e", - "lib/puppet/parser/functions/suffix.rb": "e986d3c52043586ed419b4689d27e745", - "lib/puppet/parser/functions/swapcase.rb": "e93d7a8e5eaa8e420234941a61199181", - "lib/puppet/parser/functions/time.rb": "911832e13dd13c3531ffbe1312aa22a0", - "lib/puppet/parser/functions/to_bytes.rb": "9b4040cc7173e6747739a9a2490ba6a0", - "lib/puppet/parser/functions/try_get_value.rb": "b1877fbff0a04c7beb15ddec3eae7b9e", - "lib/puppet/parser/functions/type.rb": "a544624a9f720d7774b1f672dd4064a0", - "lib/puppet/parser/functions/type3x.rb": "c8642e93f813bcfdb80476816b0bc596", - "lib/puppet/parser/functions/union.rb": "72eeb4e9ca3edc0d6f44d70fe5385e34", - "lib/puppet/parser/functions/unique.rb": "04aad75f752f2c85442613da72ae7265", - "lib/puppet/parser/functions/unix2dos.rb": "ba608b4b35b8e1bc99bfc8ada0b329f6", - "lib/puppet/parser/functions/upcase.rb": "5fff4d1a0a3ca212387749786d5c19e9", - "lib/puppet/parser/functions/uriescape.rb": "ee7242decf04d2d44a91d196f79e8488", - "lib/puppet/parser/functions/validate_absolute_path.rb": "3d0d00999ebfd0c6bec4ac04a1b9b285", - "lib/puppet/parser/functions/validate_array.rb": "9abed7f85fd4724fab21ff1073de8b41", - "lib/puppet/parser/functions/validate_augeas.rb": "4a9795e7945193afe0fc3a614a2f6022", - "lib/puppet/parser/functions/validate_bool.rb": "f04a095d2c645329a748ddb3fd60798f", - "lib/puppet/parser/functions/validate_cmd.rb": "19537747b1df38084b968fbb4f6f0f17", - "lib/puppet/parser/functions/validate_domain_name.rb": "0f0be32a421c34e8df570f817f307617", - "lib/puppet/parser/functions/validate_email_address.rb": "a7af8b3f2bd4148a104e9dc1390d2faa", - "lib/puppet/parser/functions/validate_hash.rb": "e72a8b38f87586fed6616b23e4a3de5c", - "lib/puppet/parser/functions/validate_integer.rb": "55277d89d5b6e13d889b784578730f74", - "lib/puppet/parser/functions/validate_ip_address.rb": "093d46312d6dd618954c0076a8f667f7", - "lib/puppet/parser/functions/validate_ipv4_address.rb": "65bb41c57c489f8032d1b892b4534061", - "lib/puppet/parser/functions/validate_ipv6_address.rb": "abc96d513f8bd739c69cb78cd8811dc5", - "lib/puppet/parser/functions/validate_numeric.rb": "0f8225b9decf1c908e5c387ca039f2b0", - "lib/puppet/parser/functions/validate_re.rb": "26ebeaba9c6b0d7c2ab2a7c1fadca37b", - "lib/puppet/parser/functions/validate_slength.rb": "fd26a0f026f12181801f18e9d7a27534", - "lib/puppet/parser/functions/validate_string.rb": "77fd937008ec3da670b5acf2c7920227", - "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "bb34e2398eaaacf053dfb9c27be3442b", - "lib/puppet/parser/functions/values.rb": "f7d883ec3b76ae7a1ab7a8ed68feec06", - "lib/puppet/parser/functions/values_at.rb": "4a88d4dd856930d9218b93c97ce9829c", - "lib/puppet/parser/functions/zip.rb": "186ad52bdd38054d2fcb42a32a80281f", - "lib/puppet/provider/file_line/ruby.rb": "fb2376cadd33481286e5427489fdff00", - "lib/puppet/type/anchor.rb": "5a5df539a80bf1593b70d12a9ec3458f", - "lib/puppet/type/file_line.rb": "5e944a6f40914fe71920ca1307127069", - "locales/config.yaml": "d3795b3334faf13674a5d1e3759064ac", - "locales/ja/puppetlabs-stdlib.po": "805e5d893d2025ad57da8ec0614a6753", - "locales/puppetlabs-stdlib.pot": "23c892ac0683aef4b09aabe0037750ae", - "manifests/init.pp": "b7b0b780b800ba4fa1b7bc77d5c760e7", - "manifests/stages.pp": "4c455c755205fb405b1b598b172358f0", - "metadata.json": "6525355879b3cba4dfee5168650751ba", - "provision.yaml": "b663fd9d53332d37876da98fee81f88a", - "readmes/README_ja_JP.md": "3c20e2c1d8edeffa0935fb7b8d0be64b", - "spec/acceptance/anchor_spec.rb": "8da30674d0c852e84776bb66bd6fa450", - "spec/acceptance/file_line_spec.rb": "223c241e3fca6ed815612176fbcb801e", - "spec/default_facts.yml": "973bd7e9b429cde3c8d45d57c2fa21ed", - "spec/fixtures/dscacheutil/root": "e1a7622f55f3d1be258c9a5b16b474be", - "spec/fixtures/lsuser/root": "2ed657fa157372a81634539bb1a56be8", - "spec/fixtures/test/manifests/base32.pp": "2662eb916f3830689f40decfe8fddae8", - "spec/fixtures/test/manifests/base64.pp": "935f9c1b4ac741c58b7abd49d3cfb794", - "spec/fixtures/test/manifests/deftype.pp": "1f2e86fa39604fdfde8fd20b9ae92813", - "spec/fixtures/test/manifests/ensure_resources.pp": "898c473ba5641313294827f4b4845bd6", - "spec/functions/abs_spec.rb": "1d2758920667c0920f77998882ca2b32", - "spec/functions/any2array_spec.rb": "8ca97ceb68a60ff5c4ade6e6aa7b81df", - "spec/functions/any2bool_spec.rb": "48b23ce295c256aa14cfeac0501cc3a5", - "spec/functions/assert_private_spec.rb": "d48bc3c4ed2115c18859b2db1490795c", - "spec/functions/base64_spec.rb": "5083c40b825f86863cc2950d97d3807b", - "spec/functions/basename_spec.rb": "31d3cb7e871b59f909154372fc983751", - "spec/functions/bool2num_spec.rb": "49b6cc96b6c215e1c4bf1ad303913ff9", - "spec/functions/bool2str_spec.rb": "286b56a5bab37d4849e10b7f0f9630ed", - "spec/functions/camelcase_spec.rb": "e4693de9fcd022bc9c798e27bf1c11ae", - "spec/functions/capitalize_spec.rb": "be58e5ff4956bcca07055d66369021d2", - "spec/functions/ceiling_spec.rb": "211eb2e796a1e8671ec528a60d6926c2", - "spec/functions/chomp_spec.rb": "c9516458b1ca71f61399e077bdd8b1b5", - "spec/functions/chop_spec.rb": "0d4d38ae09fc8ba02b50711ecac6e876", - "spec/functions/clamp_spec.rb": "e9502b5652b205c01aa6115c69ab7a79", - "spec/functions/concat_spec.rb": "cdadaafc6e42b319d6a1f0d4aaa1bca9", - "spec/functions/convert_base_spec.rb": "534bd90106b2c58f736b897974c5a10a", - "spec/functions/count_spec.rb": "d5990b080447cff101f05d8aeb1e6df6", - "spec/functions/deep_merge_spec.rb": "2bb3422045040c4dac2ad75fbae07995", - "spec/functions/defined_with_params_spec.rb": "b4e13e71b935fd4823321b297abfb3e9", - "spec/functions/delete_at_spec.rb": "10e09867a03e94623f8d0e040c288480", - "spec/functions/delete_regex_spec.rb": "7bfc5d6ded6cb48830b6cc6934c9c455", - "spec/functions/delete_spec.rb": "bb7d3606a64492ad51384979b6be74d6", - "spec/functions/delete_undef_values_spec.rb": "7252fb2c51c3e1ad969a285965d54d0e", - "spec/functions/delete_values_spec.rb": "80e23a8f6083703728858604a55a35f6", - "spec/functions/deprecation_spec.rb": "a8c77ef118546f3a9bacbe3e71fa1f16", - "spec/functions/difference_spec.rb": "dbb47074b5143c53cd6870b2d86556f7", - "spec/functions/dig44_spec.rb": "30abd1bd2c5b1b840b3178d24b2ac8ca", - "spec/functions/dig_spec.rb": "ac6671760e3864540aa0790ee37bd5ab", - "spec/functions/dirname_spec.rb": "7d9af39a3276e3f4de82e067aedb38d1", - "spec/functions/dos2unix_spec.rb": "62e06e17b0dea96720d4c016e9866a53", - "spec/functions/downcase_spec.rb": "b7de6605596cb6d95b453af2152acd63", - "spec/functions/empty_spec.rb": "e3db267a4e0c79ec50b886e29bc1db59", - "spec/functions/ensure_packages_spec.rb": "aa087a5474ffe29d3a8a6f5e8bf5aacb", - "spec/functions/ensure_resource_spec.rb": "e3762777948cf285c5c2ce806ef1992b", - "spec/functions/ensure_resources_spec.rb": "9222a26a12afacf5e31ae19174a534fd", - "spec/functions/extname_spec.rb": "1b8fff4c728711931b66d36caabae937", - "spec/functions/flatten_spec.rb": "a32ff65cf680993ad67199942bd31bc8", - "spec/functions/floor_spec.rb": "2a7eb8a32a874791259def91eaa077cf", - "spec/functions/fqdn_rand_string_spec.rb": "91371725b89be5b026a7d9a179066021", - "spec/functions/fqdn_rotate_spec.rb": "e940b050175501f857efcb1b279f53a4", - "spec/functions/fqdn_uuid_spec.rb": "186f9dc35bb09b887dfec17f13a16bbe", - "spec/functions/get_module_path_spec.rb": "2d22d3b677b3fe67337d6d9e88994cc9", - "spec/functions/getparam_spec.rb": "807694642f3ebdfafca4c8f0eca4c062", - "spec/functions/getvar_spec.rb": "f4b6e5e025feb8ef1a1425d85c615ae0", - "spec/functions/glob_spec.rb": "537139a45aa1acfb605aa0cb6b598b73", - "spec/functions/grep_spec.rb": "c8bd616f1d4940261e8a9f7b05254528", - "spec/functions/has_interface_with_spec.rb": "d484da75727170eb3ff22bbc71394fd1", - "spec/functions/has_ip_address_spec.rb": "ff9bb2bd0bd5a9d2f2109871ff16fc98", - "spec/functions/has_ip_network_spec.rb": "32120659b36ac71a769594b3227ac083", - "spec/functions/has_key_spec.rb": "d4d97da7d35a794e72d1bbc5e0a4838f", - "spec/functions/hash_spec.rb": "a9d483dfbd3f2d66b457851ff3144b1a", - "spec/functions/intersection_spec.rb": "72688d38e9301d9e15bae6bb3f7d8568", - "spec/functions/ip_in_range_spec.rb": "513e2718af40ccc65373fc212a7d74d8", - "spec/functions/is_a_spec.rb": "e657f393cc3572883aa2ab872840f4bf", - "spec/functions/is_array_spec.rb": "9e9bc571ecb67b57ad0033da1e02a578", - "spec/functions/is_bool_spec.rb": "598acad9be16faa86a4370d7646b06d9", - "spec/functions/is_domain_name_spec.rb": "250ceb83bc0b85dafbbae809aa678c35", - "spec/functions/is_email_address_spec.rb": "f3e60f28e9d66d7707a434a8edc79900", - "spec/functions/is_float_spec.rb": "d4051f03f193cab8ba81896038772080", - "spec/functions/is_function_available_spec.rb": "98987ebd25e5050948673f3db95cb237", - "spec/functions/is_hash_spec.rb": "2e4b2a2690947509c11032dab5645c83", - "spec/functions/is_integer_spec.rb": "0ba7bc665d334191a838bd34f6c97a75", - "spec/functions/is_ip_address_spec.rb": "f04e3ee8b4b41b82cd24dd714b0e81db", - "spec/functions/is_ipv4_address_spec.rb": "fa7ed52ae8e95eb53640ddedfb75c776", - "spec/functions/is_ipv6_address_spec.rb": "73d89a99e3a3e67da7c503122dd02f97", - "spec/functions/is_mac_address_spec.rb": "be6fc820b9583aa23730581a7fd0218b", - "spec/functions/is_numeric_spec.rb": "7d4846a71d0a9bc2376dcc9f512b7430", - "spec/functions/is_string_spec.rb": "641b0b76f520d70e0a6df33ca26dbc78", - "spec/functions/join_keys_to_values_spec.rb": "a365b021aea1a0a54f27b24b0b1d3f24", - "spec/functions/join_spec.rb": "2c1da15b52b6a9cea55825328f2e0ada", - "spec/functions/keys_spec.rb": "185acb2eeb716cf93c99cbbd41327224", - "spec/functions/length_spec.rb": "2f9edfc8fbb4058a267bd00674cad654", - "spec/functions/load_module_metadata_spec.rb": "e85aedac6540d4dbec21120afd31e361", - "spec/functions/loadjson_spec.rb": "bebf061634829a66072f4abcde61cde8", - "spec/functions/loadyaml_spec.rb": "0a6dd0a389c49f90d61f915b6718411a", - "spec/functions/lstrip_spec.rb": "552c469f04c8de63b6c8cefb0280cba3", - "spec/functions/max_spec.rb": "e82809c424860b8d94ef8af70abd4891", - "spec/functions/member_spec.rb": "bc3cb6ff6d32dea36045b2c1f370e7b0", - "spec/functions/merge_spec.rb": "b5389b77b34509dfc4775d9d2b0c28c1", - "spec/functions/min_spec.rb": "085856878e00b66f1dd572e12fec6069", - "spec/functions/num2bool_spec.rb": "4b76538824434d08fce88f7acf337c66", - "spec/functions/os_version_gte_spec.rb": "25df25bf257e5f5f7d523e5acf0dc990", - "spec/functions/parsejson_spec.rb": "70b494139e7289908b6adb36ea8f3bed", - "spec/functions/parseyaml_spec.rb": "070ca4698f0a468d2c03af84e72f5384", - "spec/functions/pick_default_spec.rb": "43306416fdac7e7a3378fe51cb9bf9e7", - "spec/functions/pick_spec.rb": "856384e60757e1d94ca3aef161be3d0a", - "spec/functions/prefix_spec.rb": "5e6eb13f3f9834e975152812f22f2e99", - "spec/functions/private_spec.rb": "dbb87b05cdabb852a4abcb373303da50", - "spec/functions/pw_hash_spec.rb": "d9bdce271d38ce6ec1d8258e807a7c67", - "spec/functions/range_spec.rb": "4351efcda0bdf89d9fc4b533ab085e66", - "spec/functions/regexpescape_spec.rb": "2e36ec5d28cb6deb264cf50356ba52c3", - "spec/functions/reject_spec.rb": "6b083c5d8519eb2af796150596e659de", - "spec/functions/reverse_spec.rb": "dbabe39664d7323a99e25c248e2c0ae8", - "spec/functions/round_spec.rb": "9dbb5c89f9c4fc56588830acbf38e713", - "spec/functions/rstrip_spec.rb": "c96cc66210bbd5fa4914ed9080e91fd5", - "spec/functions/seeded_rand_spec.rb": "d0473836456fa59f0a4ded16057d75aa", - "spec/functions/seeded_rand_string_spec.rb": "3388ad5479b51a87a9ff1f7539ee11fb", - "spec/functions/shell_escape_spec.rb": "513534e47818ce650b343985febedf9e", - "spec/functions/shell_join_spec.rb": "d9861fe1324a239784873ee9eeadfe7c", - "spec/functions/shell_split_spec.rb": "f6ab347d718d140ffdcccd0590c889d8", - "spec/functions/shuffle_spec.rb": "3c775cb2fae13839f477cbec188eea1a", - "spec/functions/size_spec.rb": "dc4aa41250a64e728ce8135e888e3081", - "spec/functions/sort_spec.rb": "97475dc1e162991a8ebdcb3f1334f6ee", - "spec/functions/sprintf_hash_spec.rb": "1b014e8c0a44b935ec0c045e275ad6b3", - "spec/functions/squeeze_spec.rb": "fa3531e7cd49989b1ece7d48ccd10255", - "spec/functions/str2bool_spec.rb": "d099ca74f02ac231f699e59d7a41bafb", - "spec/functions/str2saltedsha512_spec.rb": "815dfb2f7c65f81769c117129e45bf85", - "spec/functions/strftime_spec.rb": "e4ff0163ab707966186d7941b0e5f18d", - "spec/functions/strip_spec.rb": "1212eef324f730400c8a62d9db95a22c", - "spec/functions/suffix_spec.rb": "61754a258fda440bc0f5e00af91f30a9", - "spec/functions/swapcase_spec.rb": "d0dc69eda3fcdf043cc116ccb6ee3b28", - "spec/functions/time_spec.rb": "0d1032f734d35e53ee33904d17465cbc", - "spec/functions/to_bytes_spec.rb": "dbc093a1a72429a0a67e784ecabc100a", - "spec/functions/to_json_pretty_spec.rb": "3fac39d1ec9b4b3c482c4419cb212d2d", - "spec/functions/to_json_spec.rb": "1e2d9917ddf37af4e241b89bd9e009e3", - "spec/functions/to_yaml_spec.rb": "1c3302e5d19b2ae929ecdf44668b0492", - "spec/functions/try_get_value_spec.rb": "c98599d09b8d4eabbfbc2c273c3337b4", - "spec/functions/type3x_spec.rb": "9898ca5ab31f4fded1a5d38767e7e981", - "spec/functions/type_of_spec.rb": "ecfeb9d47e54f5aae421f7855853d47a", - "spec/functions/type_spec.rb": "7c70254652b2e46ef7c80dce5667c32b", - "spec/functions/union_spec.rb": "c3bf55649e068b810e72cbb5bfcf7cbb", - "spec/functions/unique_spec.rb": "c596db252b2730fe4a603900110f3b03", - "spec/functions/unix2dos_spec.rb": "77e6d0e7c703576924981038472c8e4e", - "spec/functions/upcase_spec.rb": "363e49846e4ca0a3a6eca2c19e0f2c04", - "spec/functions/uriescape_spec.rb": "d0730544b94c15d63e99e7ed50c13e92", - "spec/functions/validate_absolute_path_spec.rb": "d55aa2bb90d4b687aa9de9edcdd03208", - "spec/functions/validate_array_spec.rb": "b25dfc7ab21645d2a3dae2c5de11de95", - "spec/functions/validate_augeas_spec.rb": "4bf035ec4548a00d42f73643374d6f58", - "spec/functions/validate_bool_spec.rb": "d19f26dd3d51f4145ce0ed0db5da9897", - "spec/functions/validate_cmd_spec.rb": "179e570e9aec94c5dcaf337a6b431d20", - "spec/functions/validate_domain_name_spec.rb": "611f3b301003d11a6a55e293dc3a8e5c", - "spec/functions/validate_email_address_spec.rb": "8bac32b793f1e4264ae32df975d4d893", - "spec/functions/validate_hash_spec.rb": "27fd29cf193662834c6056726d7cc1e2", - "spec/functions/validate_integer_spec.rb": "10affb4021ea0c64e54d4f6bcaf70c78", - "spec/functions/validate_ip_address_spec.rb": "dd1abc13784514aa328e44bf2057561a", - "spec/functions/validate_ipv4_address_spec.rb": "146dc770bc7e7427bbf1bb2f332e0a92", - "spec/functions/validate_ipv6_address_spec.rb": "4bdd3a680ec2d256a9187c174e32f9ba", - "spec/functions/validate_legacy_spec.rb": "f5b522d41c65a8a52a0b4f0056b68da6", - "spec/functions/validate_numeric_spec.rb": "36891aa54f3b0f3d6c70758ccd2e3ac7", - "spec/functions/validate_re_spec.rb": "acacf14849bb3ec47643cd83bffea2ec", - "spec/functions/validate_slength_spec.rb": "4a4440cf424665ccc8b09cfaca52517c", - "spec/functions/validate_string_spec.rb": "3a65a2f90be1ee23b04a5713b98a9d7d", - "spec/functions/validate_x509_rsa_key_pair_spec.rb": "d73371004571f46dda1837dec3661d39", - "spec/functions/values_at_spec.rb": "9b0d8851c3b1ef74dbbfcacd68c033ef", - "spec/functions/values_spec.rb": "debbd0e2c93ddf45adfeae82caa2b50f", - "spec/functions/zip_spec.rb": "469ec7bd49ec9a7bba90e9f2ed4c2afb", - "spec/monkey_patches/alias_should_to_must.rb": "3455626d32375d114ee5622e19a1fa6c", - "spec/monkey_patches/publicize_methods.rb": "d2ae9210754b0a4eae0d6bf33737fe90", - "spec/spec_helper.rb": "ec40d36ed109d8dba0df527c34c2c6db", - "spec/spec_helper_acceptance.rb": "cce39efa586eb23fd74fbd3d8ed58db3", - "spec/spec_helper_local.rb": "5644c5ce611a9e131cf37106e2a8b841", - "spec/support/shared_data.rb": "dfe4cbdbe2833d670a89bcdf3163839b", - "spec/type_aliases/absolute_path_spec.rb": "a03a9c6fe2e3e6fbb23cd62c263032c2", - "spec/type_aliases/array_spec.rb": "5a7a5be96ccb1347a5a806ef436064e6", - "spec/type_aliases/base32_spec.rb": "0468562ed8bffb61bd867b5880941c7a", - "spec/type_aliases/base64_spec.rb": "bf479faed128ad00993a88ad390639e9", - "spec/type_aliases/bool_spec.rb": "798d1fb0b43cdc7c560ba8b61fb742e6", - "spec/type_aliases/compat__ip_address.rb": "7ee3a1f901e33a5a72632cd390629450", - "spec/type_aliases/compat__ipv4_spec.rb": "d091b3dcd1fc3a30fe080d9b53a69014", - "spec/type_aliases/compat__ipv6_spec.rb": "08005590462f404047995ec86a80e85c", - "spec/type_aliases/filemode_spec.rb": "5a42362fc453ab543b8c7e44192e6756", - "spec/type_aliases/filesource_spec.rb": "641b9fd2855c4a45b34bc2f4b3d2001b", - "spec/type_aliases/float_spec.rb": "e566885fdf22399a54450022bfbfd31a", - "spec/type_aliases/fqdn_spec.rb": "21965142591e1fa04c057616caa168f4", - "spec/type_aliases/hash_spec.rb": "1b8c49a76db8b5ef44f0f0a8e56c5eb3", - "spec/type_aliases/host_spec.rb": "501b84bf281625804d830eb20daf46e3", - "spec/type_aliases/httpsurl_spec.rb": "9b2e7d9fc1a0b804d213b1804b175467", - "spec/type_aliases/httpurl_spec.rb": "e1063021f8c212933abd560a25cb98b8", - "spec/type_aliases/integer_spec.rb": "8f66ae64602543d65e4b784527bf1463", - "spec/type_aliases/ip_address_nosubnet_spec.rb": "9d196b9b9522a91ac2bc3a67ccd02d5f", - "spec/type_aliases/ip_address_spec.rb": "ae9c24b0ee7d77b967b93ffb13fb67bb", - "spec/type_aliases/ip_address_v4_nosubnet_spec.rb": "c30a31b7bcb92eed728be5fef7b45724", - "spec/type_aliases/ip_address_v4_spec.rb": "0aacb3967d4ca3a7f8bc3a17e93f141f", - "spec/type_aliases/ip_address_v6_alternative_spec.rb": "17da75c696f406ffbd4829a13828fcc5", - "spec/type_aliases/ip_address_v6_cidr_spec.rb": "68d397e1c958e018a0537bcabca23d8c", - "spec/type_aliases/ip_address_v6_compressed_spec.rb": "508f6e102bbc3c7af4bd24df5e640f40", - "spec/type_aliases/ip_address_v6_full_spec.rb": "35ff79b1855e77ffff7c38599cfafaa2", - "spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb": "020fc117a134398818910b41a76094aa", - "spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb": "f97969e6cdae00e5a1ffbbd71ba7e08e", - "spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb": "c5fad1a8e5fee0cfac3ee9f1b5083804", - "spec/type_aliases/ip_address_v6_spec.rb": "74a4c54bf8fffc4ebc3e33c12b085640", - "spec/type_aliases/numeric_spec.rb": "06ae28964dfad6ca60ac59468c33104b", - "spec/type_aliases/objectstore_gsuri_spec.rb": "189bdf8314c75dcdc39a05375c166a80", - "spec/type_aliases/objectstore_s3uri_spec.rb": "7eb47306dd35f2993ee9ca01061e5663", - "spec/type_aliases/objectstore_spec.rb": "49673c2ec656d39f23c326052181f78a", - "spec/type_aliases/port__privileged_spec.rb": "531e8567e3251548324088e1cdac29d6", - "spec/type_aliases/port__unprivileged_spec.rb": "ec5aa19f8bfb62307617c0e9b002475d", - "spec/type_aliases/port_spec.rb": "6fff6e2cfc7b91e49b6dd169629f8a53", - "spec/type_aliases/string_spec.rb": "458ac453f5870066824b6a11ec49f9ae", - "spec/type_aliases/unixpath_spec.rb": "04e31be6626f96e605459b4ce8c94395", - "spec/type_aliases/windowspath_spec.rb": "a1473316f1745fa3e20be83a2eb026c7", - "spec/type_aliases/yes_no_spec.rb": "65925081b1eee87e5fe56028e9706fcd", - "spec/unit/facter/facter_dot_d_spec.rb": "3853da05ad110c512bbbacce81e17176", - "spec/unit/facter/package_provider_spec.rb": "c23d89ad7313f647f917d8a945815693", - "spec/unit/facter/pe_version_spec.rb": "f013e4ef5aa532fc2af19ddf3a82cf48", - "spec/unit/facter/root_home_spec.rb": "5e8ad2acdfc42674a5f96f4152faab6b", - "spec/unit/facter/service_provider_spec.rb": "15ad81eb65f2c87f3e7147da43b91a81", - "spec/unit/facter/util/puppet_settings_spec.rb": "f9b29b26e2232cd428d694095e1bb700", - "spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb": "c572341a1324a519b14ea6a6981f6a51", - "spec/unit/puppet/parser/functions/is_absolute_path_spec.rb": "258f55b8c9563bad0aaa9e98df4d6fc6", - "spec/unit/puppet/provider/file_line/ruby_spec.rb": "f5aca0856046c760832822816c44c705", - "spec/unit/puppet/provider/file_line/ruby_spec_alter.rb": "afa3589fb59f743bb8c2242c294951b2", - "spec/unit/puppet/provider/file_line/ruby_spec_use_cases.rb": "13d2c5198ca879f29d70ca230288b1e8", - "spec/unit/puppet/type/anchor_spec.rb": "5f67ab4f4a0cfc40cd2fcdb3f148f026", - "spec/unit/puppet/type/file_line_spec.rb": "92c3ac78210f730fc2135e012ded86bb", - "types/absolutepath.pp": "3ae6f48dd95835df87c5dacea13c88d2", - "types/base32.pp": "c1e7d9939641c49af90b07043a52112e", - "types/base64.pp": "6e61a5c608ab2147fdf295f97b1052c9", - "types/compat/absolute_path.pp": "c500d00e471fa7684abce8c67e2a0a3e", - "types/compat/array.pp": "43c41022dd743d55c8e9e82ce3ed741c", - "types/compat/bool.pp": "6e0cd7b2a7e1b9efaa0e273937211e58", - "types/compat/float.pp": "fd134a0e0e1abd420cec2107780a7afa", - "types/compat/hash.pp": "3535d98f0f3eaec44d443190f258e9ba", - "types/compat/integer.pp": "d73ad743def0a4e754cbf2e82d5c6b5d", - "types/compat/ip_address.pp": "d42c7435de30a469a71b69c45d642da7", - "types/compat/ipv4.pp": "962713ea8483c01f2188f87fac1fefa8", - "types/compat/ipv6.pp": "bc2c5d46bb49c5180c70c64a8a9ee6ea", - "types/compat/numeric.pp": "b9543932cda152dfc2cb7fb554a307f7", - "types/compat/re.pp": "70b05d4697e61f9af0c212ba063f395d", - "types/compat/string.pp": "b9a179664c85e121aa0277021627d126", - "types/ensure/service.pp": "efa28f903420bb9555910c27a9b810e8", - "types/filemode.pp": "3645997b51880205b2272d44d8f04368", - "types/filesource.pp": "6cf279ac41a7c44589eedb5a20f0f7ab", - "types/fqdn.pp": "f6fb6bf625dab3bd0ab63a1ff7983fb8", - "types/host.pp": "69260768a909759bdc31aeaae58d449e", - "types/httpsurl.pp": "0355078bb141e257d019dced8d84c729", - "types/httpurl.pp": "9928cc404a6d62ef9784ffe2488cfb66", - "types/ip/address/nosubnet.pp": "e7c5a338634dfd0eea60cf36092f3fd8", - "types/ip/address/v4/cidr.pp": "97c96e70c823cae39d4593d59d4ce037", - "types/ip/address/v4/nosubnet.pp": "9590ebd639bc47fd25288d32dee5405d", - "types/ip/address/v4.pp": "18165fd02c81c08dff234f83d50662a0", - "types/ip/address/v6/alternative.pp": "98d1336a9328653fa5d6d45b72aab76c", - "types/ip/address/v6/cidr.pp": "5a09a1ba5e9e75b850a9341ebf0e95ff", - "types/ip/address/v6/compressed.pp": "e6daf1c302c84d7f2060a4e8468624a6", - "types/ip/address/v6/full.pp": "90527ba76faec01d42f302a754c9ce3c", - "types/ip/address/v6/nosubnet/alternative.pp": "b9a6cd5a4c2a2e8013022fd4cfd11a3e", - "types/ip/address/v6/nosubnet/compressed.pp": "ca2f53bcc3f659d994a6e0d3fe17861e", - "types/ip/address/v6/nosubnet/full.pp": "5fa0bb70ed3e72ac52738ba182f22c1c", - "types/ip/address/v6/nosubnet.pp": "612651452cd225ade84fe31750d02903", - "types/ip/address/v6.pp": "1f3c0aa34dbc083d26f135246c8576eb", - "types/ip/address.pp": "9929a758afc9469acbcff0c2050bb0ab", - "types/mac.pp": "6c4a697bca8a68bdc6db1394108df6d0", - "types/objectstore/gsuri.pp": "8c315d523e14eaca1f1ae40fd0ef1389", - "types/objectstore/s3uri.pp": "ebb69db2ae883d4a59bf57b6bd434e63", - "types/objectstore.pp": "3955f09901518fa97d6dbb1630c893f7", - "types/port/privileged.pp": "c4ce776dd07a3c8dd3379db8cd49e32a", - "types/port/unprivileged.pp": "85359128fa9261fe8bf58c8525574404", - "types/port.pp": "b1edd08c4eff860b3ea8bd84cd48ba81", - "types/syslogfacility.pp": "b5d29bc1d50708ae16edd13f6bb4b1fe", - "types/unixpath.pp": "b64a48701e7adfda45d31fd80bee4ad0", - "types/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448", - "types/yes_no.pp": "9837204961362ecc238bd9f8cac38a39" -} \ No newline at end of file diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/data/common.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/data/common.yaml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +--- {} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/distelli-manifest.yml --- a/modules/stdlib/distelli-manifest.yml Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -team-modules/puppetlabs-stdlib: - PreBuild: - - source /opt/rh/rh-ruby25/enable - - echo "--- LETS update BUNDLER ---" - - bundle install --path vendor/bundle --jobs 3 - Build: - - echo "--- PROVISIONING ---" - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:provision_list[release_checks] - - cat inventory.yaml - - echo "--- AGENT INSTALLATION ---" - - bundle exec rake litmus:install_agent - - echo "--- MODULE INSTALLATION ---" - - bundle exec rake litmus:install_module - - echo "--- TESTS RUNNING ---" - - bundle exec rake litmus:acceptance:parallel - AfterBuildSuccess: - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:tear_down - AfterBuildFailure: - - source /opt/rh/rh-ruby25/enable - - bundle exec rake litmus:tear_down - CommitData: - - RepoType: Git - - RepoPath: . diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/examples/has_interface_with.pp --- a/modules/stdlib/examples/has_interface_with.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/examples/has_interface_with.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,4 +1,4 @@ -include ::stdlib +include stdlib info('has_interface_with(\'lo\'):', has_interface_with('lo')) info('has_interface_with(\'loX\'):', has_interface_with('loX')) info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1')) diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/examples/has_ip_address.pp --- a/modules/stdlib/examples/has_ip_address.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/examples/has_ip_address.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,3 +1,3 @@ -include ::stdlib +include stdlib info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256')) info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1')) diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/examples/has_ip_network.pp --- a/modules/stdlib/examples/has_ip_network.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/examples/has_ip_network.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,3 +1,3 @@ -include ::stdlib +include stdlib info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0')) info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0')) diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/examples/init.pp --- a/modules/stdlib/examples/init.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/examples/init.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -include ::stdlib +include stdlib diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/functions/ensure.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/functions/ensure.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,24 @@ +# @summary function to cast ensure parameter to resource specific value +function stdlib::ensure( + Variant[Boolean, Enum['present', 'absent']] $ensure, + Enum['directory', 'link', 'mounted', 'service', 'file'] $resource, +) >> String { + $_ensure = $ensure ? { + Boolean => $ensure.bool2str('present', 'absent'), + default => $ensure, + } + case $resource { + 'service': { + $_ensure ? { + 'present' => 'running', + default => 'stopped', + } + } + default: { + $_ensure ? { + 'present' => $resource, + default => $_ensure, + } + } + } +} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/hiera.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/hiera.yaml Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,21 @@ +--- +version: 5 + +defaults: # Used for any hierarchy level that omits these keys. + datadir: data # This path is relative to hiera.yaml's directory. + data_hash: yaml_data # Use the built-in YAML backend. + +hierarchy: + - name: "osfamily/major release" + paths: + # Used to distinguish between Debian and Ubuntu + - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" + - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" + # Used for Solaris + - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" + - name: "osfamily" + paths: + - "os/%{facts.os.name}.yaml" + - "os/%{facts.os.family}.yaml" + - name: 'common' + path: 'common.yaml' diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/facter/facter_dot_d.rb --- a/modules/stdlib/lib/facter/facter_dot_d.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,215 +0,0 @@ -# @summary -# A Facter plugin that loads facts from /etc/facter/facts.d -# and /etc/puppetlabs/facter/facts.d. -# -# Facts can be in the form of JSON, YAML or Text files -# and any executable that returns key=value pairs. -# -# In the case of scripts you can also create a file that -# contains a cache TTL. For foo.sh store the ttl as just -# a number in foo.sh.ttl -# -# The cache is stored in $libdir/facts_dot_d.cache as a mode -# 600 file and will have the end result of not calling your -# fact scripts more often than is needed -class Facter::Util::DotD - require 'yaml' - # These will be nil if Puppet is not available. - def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'facts_dot_d.cache')) - @dir = dir - @cache_file = cache_file - @cache = nil - @types = { '.txt' => :txt, '.json' => :json, '.yaml' => :yaml } - end - - # entries - def entries - Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) } - rescue - [] - end - - # fact_type - # @param file - def fact_type(file) - extension = File.extname(file) - - type = @types[extension] || :unknown - - type = :script if type == :unknown && File.executable?(file) - - type - end - - # txt_parser - # @param file - def txt_parser(file) - File.readlines(file).each do |line| - next unless line =~ %r{^([^=]+)=(.+)$} - var = Regexp.last_match(1) - val = Regexp.last_match(2) - - Facter.add(var) do - setcode { val } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}") - end - - # json_parser - # @param file - def json_parser(file) - begin - require 'json' - rescue LoadError - retry if require 'rubygems' - raise - end - - JSON.parse(File.read(file)).each_pair do |f, v| - Facter.add(f) do - setcode { v } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}") - end - - # yaml_parser - # @param file - def yaml_parser(file) - require 'yaml' - - YAML.load_file(file).each_pair do |f, v| - Facter.add(f) do - setcode { v } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}") - end - - # script_parser - # @param file - def script_parser(file) - result = cache_lookup(file) - ttl = cache_time(file) - - if result - Facter.debug("Using cached data for #{file}") - else - result = Facter::Util::Resolution.exec(file) - - if ttl > 0 - Facter.debug("Updating cache for #{file}") - cache_store(file, result) - cache_save! - end - end - - result.split("\n").each do |line| - next unless line =~ %r{^(.+)=(.+)$} - var = Regexp.last_match(1) - val = Regexp.last_match(2) - - Facter.add(var) do - setcode { val } - end - end - rescue StandardError => e - Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}") - Facter.debug(e.backtrace.join("\n\t")) - end - - # cache_save - def cache_save! - cache = load_cache - File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) } - rescue # rubocop:disable Lint/HandleExceptions - end - - # cache_store - # @param file - def cache_store(file, data) - load_cache - - @cache[file] = { :data => data, :stored => Time.now.to_i } - rescue # rubocop:disable Lint/HandleExceptions - end - - # cache_lookup - # @param file - def cache_lookup(file) - cache = load_cache - - return nil if cache.empty? - - ttl = cache_time(file) - - return nil unless cache[file] - now = Time.now.to_i - - return cache[file][:data] if ttl == -1 - return cache[file][:data] if (now - cache[file][:stored]) <= ttl - return nil - rescue - return nil - end - - # cache_time - # @param file - def cache_time(file) - meta = file + '.ttl' - - return File.read(meta).chomp.to_i - rescue - return 0 - end - - # load_cache - def load_cache - @cache ||= if File.exist?(@cache_file) - YAML.load_file(@cache_file) - else - {} - end - - return @cache - rescue - @cache = {} - return @cache - end - - # create - def create - entries.each do |fact| - type = fact_type(fact) - parser = "#{type}_parser" - - next unless respond_to?("#{type}_parser") - Facter.debug("Parsing #{fact} using #{parser}") - - send(parser, fact) - end - end -end - -mdata = Facter.version.match(%r{(\d+)\.(\d+)\.(\d+)}) -if mdata - (major, minor, _patch) = mdata.captures.map { |v| v.to_i } - if major < 2 - # Facter 1.7 introduced external facts support directly - unless major == 1 && minor > 6 - Facter::Util::DotD.new('/etc/facter/facts.d').create - Facter::Util::DotD.new('/etc/puppetlabs/facter/facts.d').create - - # Windows has a different configuration directory that defaults to a vendor - # specific sub directory of the %COMMON_APPDATA% directory. - if Dir.const_defined? 'COMMON_APPDATA' # rubocop:disable Metrics/BlockNesting : Any attempt to alter this breaks it - windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d') - Facter::Util::DotD.new(windows_facts_dot_d).create - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/facter/puppet_settings.rb --- a/modules/stdlib/lib/facter/puppet_settings.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/facter/puppet_settings.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,7 +1,7 @@ # These facter facts return the value of the Puppet vardir and environment path # settings for the node running puppet or puppet agent. The intent is to # enable Puppet modules to automatically have insight into a place where they -# can place variable data, or for modules running on the puppet master to know +# can place variable data, or for modules running on the puppet server to know # where environments are stored. # # The values should be directly usable in a File resource path attribute. diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_absolute_path.rb --- a/modules/stdlib/lib/puppet/functions/is_absolute_path.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_absolute_path.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_absolute_path) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_array.rb --- a/modules/stdlib/lib/puppet/functions/is_array.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_array.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_array) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_bool.rb --- a/modules/stdlib/lib/puppet/functions/is_bool.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_bool.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_bool) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_float.rb --- a/modules/stdlib/lib/puppet/functions/is_float.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_float.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_float) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_ip_address.rb --- a/modules/stdlib/lib/puppet/functions/is_ip_address.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_ip_address.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_ip_address) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_ipv4_address.rb --- a/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_ipv4_address) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_ipv6_address.rb --- a/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_ipv6_address) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_numeric.rb --- a/modules/stdlib/lib/puppet/functions/is_numeric.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_numeric.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_numeric) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/is_string.rb --- a/modules/stdlib/lib/puppet/functions/is_string.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/is_string.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # @summary -# Wrapper that calls the Puppet 3.x funtion of the same name. +# Wrapper that calls the Puppet 3.x function of the same name. Puppet::Functions.create_function(:is_string) do # @param scope # The main value that will be passed to the wrapped method diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/parsehocon.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/lib/puppet/functions/parsehocon.rb Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# @summary +# This function accepts HOCON as a string and converts it into the correct +# Puppet structure +# +# @return +# Data +# +# @example How to parse hocon +# $data = parsehocon("{any valid hocon: string}") +# +Puppet::Functions.create_function(:parsehocon) do + # @param hocon_string A valid HOCON string + # @param default An optional default to return if parsing hocon_string fails + dispatch :parsehocon do + param 'String', :hocon_string + optional_param 'Any', :default + end + + def parsehocon(hocon_string, default = :no_default_provided) + require 'hocon/config_factory' + + begin + data = Hocon::ConfigFactory.parse_string(hocon_string) + data.resolve.root.unwrapped + rescue Hocon::ConfigError::ConfigParseError => err + Puppet.debug("Parsing hocon failed with error: #{err.message}") + raise err if default == :no_default_provided + default + end + end +end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/stdlib/end_with.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/lib/puppet/functions/stdlib/end_with.rb Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,21 @@ +# @summary +# Returns true if str ends with one of the prefixes given. Each of the prefixes should be a String. +# +Puppet::Functions.create_function(:'stdlib::end_with') do + # @param test_string The string to check + # @param suffixes The suffixes to check + # @example + # 'foobar'.stdlib::end_with('bar') => true + # 'foobar'.stdlib::end_with('foo') => false + # 'foobar'.stdlib::end_with(['foo', 'baz']) => false + # @return [Boolean] True or False + dispatch :end_with do + param 'String', :test_string + param 'Variant[String[1],Array[String[1], 1]]', :suffixes + return_type 'Boolean' + end + + def end_with(test_string, suffixes) + test_string.end_with?(*suffixes) + end +end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/stdlib/start_with.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/lib/puppet/functions/stdlib/start_with.rb Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,21 @@ +# @summary +# Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. +# +Puppet::Functions.create_function(:'stdlib::start_with') do + # @param test_string The string to check + # @param prefixes The prefixes to check. + # @example + # 'foobar'.stdlib::start_with('foo') => true + # 'foobar'.stdlib::start_with('bar') => false + # 'foObar'.stdlib::start_with(['bar', 'baz']) => false + # @return [Boolean] True or False + dispatch :start_with do + param 'String', :test_string + param 'Variant[String[1],Array[String[1], 1]]', :prefixes + return_type 'Boolean' + end + + def start_with(test_string, prefixes) + test_string.start_with?(*prefixes) + end +end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/to_json_pretty.rb --- a/modules/stdlib/lib/puppet/functions/to_json_pretty.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/to_json_pretty.rb Sun Oct 09 10:34:32 2022 +0100 @@ -1,4 +1,5 @@ require 'json' + # @summary # Convert data structure and output to pretty JSON # @@ -72,6 +73,8 @@ data = data.reject { |_, value| value.nil? } end end - JSON.pretty_generate(data, opts) << "\n" + # Call ::JSON to ensure it references the JSON library from Ruby's standard library + # instead of a random JSON namespace that might be in scope due to user code. + ::JSON.pretty_generate(data, opts) << "\n" end end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/functions/to_yaml.rb --- a/modules/stdlib/lib/puppet/functions/to_yaml.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/functions/to_yaml.rb Sun Oct 09 10:34:32 2022 +0100 @@ -2,21 +2,28 @@ # @summary # Convert a data structure and output it as YAML # -# @example how to output YAML +# @example How to output YAML # # output yaml to a file # file { '/tmp/my.yaml': # ensure => file, # content => to_yaml($myhash), # } +# @example Use options control the output format +# file { '/tmp/my.yaml': +# ensure => file, +# content => to_yaml($myhash, {indentation: 4}) +# } Puppet::Functions.create_function(:to_yaml) do # @param data + # @param options # # @return [String] dispatch :to_yaml do param 'Any', :data + optional_param 'Hash', :options end - def to_yaml(data) - data.to_yaml + def to_yaml(data, options = {}) + data.to_yaml(options) end end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb --- a/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb Sun Oct 09 10:34:32 2022 +0100 @@ -48,16 +48,32 @@ title = nil end - resource = findresource(type, title) - if resource + resources = if title.empty? + catalog.resources.select { |r| r.type == type } + else + [findresource(type, title)] + end + + resources.compact.each do |res| + # If you call this from within a defined type, it will find itself + next if res.to_s == resource.to_s + matches = params.map do |key, value| # eql? avoids bugs caused by monkeypatching in puppet - resource_is_undef = resource[key].eql?(:undef) || resource[key].nil? + res_is_undef = res[key].eql?(:undef) || res[key].nil? value_is_undef = value.eql?(:undef) || value.nil? - (resource_is_undef && value_is_undef) || (resource[key] == value) + found_match = (res_is_undef && value_is_undef) || (res[key] == value) + + Puppet.debug("Matching resource is #{res}") if found_match + + found_match end ret = params.empty? || !matches.include?(false) + + break if ret end - Puppet.debug("Resource #{reference} was not determined to be defined") + + Puppet.debug("Resource #{reference} was not determined to be defined") unless ret + ret end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/intersection.rb --- a/modules/stdlib/lib/puppet/parser/functions/intersection.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/intersection.rb Sun Oct 09 10:34:32 2022 +0100 @@ -22,7 +22,7 @@ second = arguments[1] unless first.is_a?(Array) && second.is_a?(Array) - raise(Puppet::ParseError, 'intersection(): Requires 2 arrays') + raise(Puppet::ParseError, "intersection(): Requires 2 arrays, got #{first.class} and #{second.class}") end result = first & second diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb --- a/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb Sun Oct 09 10:34:32 2022 +0100 @@ -37,7 +37,7 @@ path = args[0] # This logic was borrowed from - # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb) + # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/main/lib/puppet/file_serving/base.rb) # Puppet 2.7 and beyond will have Puppet::Util.absolute_path? Fall back to a back-ported implementation otherwise. if Puppet::Util.respond_to?(:absolute_path?) value = (Puppet::Util.absolute_path?(path, :posix) || Puppet::Util.absolute_path?(path, :windows)) diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/pry.rb --- a/modules/stdlib/lib/puppet/parser/functions/pry.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/pry.rb Sun Oct 09 10:34:32 2022 +0100 @@ -29,7 +29,7 @@ if $stdout.isatty binding.pry # rubocop:disable Lint/Debugger else - Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized master' + Puppet.warning 'pry(): cowardly refusing to start the debugger on a daemonized server' end end end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/pw_hash.rb --- a/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb Sun Oct 09 10:34:32 2022 +0100 @@ -28,7 +28,7 @@ @return [Hash] Provides a hash usable on most POSIX systems. - > *Note:*: this uses the Puppet Master's implementation of crypt(3). If your + > *Note:*: this uses the Puppet Server's implementation of crypt(3). If your environment contains several different operating systems, ensure that they are compatible before using this function. DOC diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb --- a/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb Sun Oct 09 10:34:32 2022 +0100 @@ -28,5 +28,5 @@ max = args[0].to_i seed = Digest::MD5.hexdigest(args[1]).hex - Puppet::Util.deterministic_rand(seed, max) + Puppet::Util.deterministic_rand_int(seed, max) end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/str2saltedpbkdf2.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/lib/puppet/parser/functions/str2saltedpbkdf2.rb Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,68 @@ +# str2saltedpbkdf2.rb +# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. +# +module Puppet::Parser::Functions + newfunction(:str2saltedpbkdf2, :type => :rvalue, :doc => <<-DOC + @summary Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+ + + Convert a string into a salted SHA512 PBKDF2 password hash like requred for OS X / macOS 10.8+. + Note, however, that Apple changes what's required periodically and this may not work for the latest + version of macOS. If that is the case you should get a helpful error message when Puppet tries to set + the pasword using the parameters you provide to the user resource. + + @example Plain text password and salt + $pw_info = str2saltedpbkdf2('Pa55w0rd', 'Using s0m3 s@lt', 50000) + user { 'jdoe': + ensure => present, + iterations => $pw_info['interations'], + password => $pw_info['password_hex'], + salt => $pw_info['salt_hex'], + } + + @example Sensitive password and salt + $pw = Sensitive.new('Pa55w0rd') + $salt = Sensitive.new('Using s0m3 s@lt') + $pw_info = Sensitive.new(str2saltedpbkdf2($pw, $salt, 50000)) + user { 'jdoe': + ensure => present, + iterations => unwrap($pw_info)['interations'], + password => unwrap($pw_info)['password_hex'], + salt => unwrap($pw_info)['salt_hex'], + } + + @return [Hash] + Provides a hash containing the hex version of the password, the hex version of the salt, and iterations. + DOC + ) do |args| + require 'openssl' + + raise ArgumentError, "str2saltedpbkdf2(): wrong number of arguments (#{args.size} for 3)" if args.size != 3 + + args.map! do |arg| + if (defined? Puppet::Pops::Types::PSensitiveType::Sensitive) && (arg.is_a? Puppet::Pops::Types::PSensitiveType::Sensitive) + arg.unwrap + else + arg + end + end + + raise ArgumentError, 'str2saltedpbkdf2(): first argument must be a string' unless args[0].is_a?(String) + raise ArgumentError, 'str2saltedpbkdf2(): second argument must be a string' unless args[1].is_a?(String) + raise ArgumentError, 'str2saltedpbkdf2(): second argument must be at least 8 bytes long' unless args[1].bytesize >= 8 + raise ArgumentError, 'str2saltedpbkdf2(): third argument must be an integer' unless args[2].is_a?(Integer) + raise ArgumentError, 'str2saltedpbkdf2(): third argument must be between 40,000 and 70,000' unless args[2] > 40_000 && args[2] < 70_000 + + password = args[0] + salt = args[1] + iterations = args[2] + keylen = 128 + digest = OpenSSL::Digest::SHA512.new + hash = OpenSSL::PKCS5.pbkdf2_hmac(password, salt, iterations, keylen, digest) + + { + 'password_hex' => hash.unpack('H*').first, + 'salt_hex' => salt.unpack('H*').first, + 'iterations' => iterations, + } + end +end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/lib/puppet/parser/functions/strftime.rb --- a/modules/stdlib/lib/puppet/parser/functions/strftime.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -# -# strftime.rb -# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. -# -module Puppet::Parser::Functions - newfunction(:strftime, :type => :rvalue, :doc => <<-DOC - @summary - This function returns formatted time. - - @return - converted time according to the directives in the given format string - - > *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this - function. It also supports the Timestamp and Timespan data types in the Puppet language. - - @example **Usage** - - To return the time since epoch: strftime("%s") - To return the date: strftime("%Y-%m-%d") - - **Format meaning:** - - %a - The abbreviated weekday name (``Sun'') - %A - The full weekday name (``Sunday'') - %b - The abbreviated month name (``Jan'') - %B - The full month name (``January'') - %c - The preferred local date and time representation - %C - Century (20 in 2009) - %d - Day of the month (01..31) - %D - Date (%m/%d/%y) - %e - Day of the month, blank-padded ( 1..31) - %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) - %h - Equivalent to %b - %H - Hour of the day, 24-hour clock (00..23) - %I - Hour of the day, 12-hour clock (01..12) - %j - Day of the year (001..366) - %k - hour, 24-hour clock, blank-padded ( 0..23) - %l - hour, 12-hour clock, blank-padded ( 0..12) - %L - Millisecond of the second (000..999) - %m - Month of the year (01..12) - %M - Minute of the hour (00..59) - %n - Newline (\n) - %N - Fractional seconds digits, default is 9 digits (nanosecond) - %3N millisecond (3 digits) - %6N microsecond (6 digits) - %9N nanosecond (9 digits) - %p - Meridian indicator (``AM'' or ``PM'') - %P - Meridian indicator (``am'' or ``pm'') - %r - time, 12-hour (same as %I:%M:%S %p) - %R - time, 24-hour (%H:%M) - %s - Number of seconds since 1970-01-01 00:00:00 UTC. - %S - Second of the minute (00..60) - %t - Tab character (\t) - %T - time, 24-hour (%H:%M:%S) - %u - Day of the week as a decimal, Monday being 1. (1..7) - %U - Week number of the current year, - starting with the first Sunday as the first - day of the first week (00..53) - %v - VMS date (%e-%b-%Y) - %V - Week number of year according to ISO 8601 (01..53) - %W - Week number of the current year, - starting with the first Monday as the first - day of the first week (00..53) - %w - Day of the week (Sunday is 0, 0..6) - %x - Preferred representation for the date alone, no time - %X - Preferred representation for the time alone, no date - %y - Year without a century (00..99) - %Y - Year with century - %z - Time zone as hour offset from UTC (e.g. +0900) - %Z - Time zone name - %% - Literal ``%'' character - DOC - ) do |arguments| - - # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "strftime(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? - - format = arguments[0] - - raise(Puppet::ParseError, 'strftime(): You must provide format for evaluation') if format.empty? - - # The Time Zone argument is optional ... - time_zone = arguments[1] if arguments[1] - - time = Time.new - - # There is probably a better way to handle Time Zone ... - if time_zone && !time_zone.empty? - original_zone = ENV['TZ'] - - local_time = time.clone - local_time = local_time.utc - - ENV['TZ'] = time_zone - - time = local_time.localtime - - ENV['TZ'] = original_zone - end - - result = time.strftime(format) - - return result - end -end - -# vim: set ts=2 sw=2 et : diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/manifests/init.pp --- a/modules/stdlib/manifests/init.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/manifests/init.pp Sun Oct 09 10:34:32 2022 +0100 @@ -8,5 +8,5 @@ # of stdlib::stages. # class stdlib { - include ::stdlib::stages + include stdlib::stages } diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/manifests/stages.pp --- a/modules/stdlib/manifests/stages.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/manifests/stages.pp Sun Oct 09 10:34:32 2022 +0100 @@ -22,7 +22,6 @@ # } # class stdlib::stages { - stage { 'setup': before => Stage['main'] } stage { 'runtime': require => Stage['main'] } -> stage { 'setup_infra': } @@ -30,5 +29,4 @@ -> stage { 'setup_app': } -> stage { 'deploy_app': } -> stage { 'deploy': } - } diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/metadata.json --- a/modules/stdlib/metadata.json Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/metadata.json Sun Oct 09 10:34:32 2022 +0100 @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "6.2.0", + "version": "6.6.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", @@ -8,9 +8,8 @@ "project_page": "https://github.com/puppetlabs/puppetlabs-stdlib", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ - + ], - "data_provider": null, "operatingsystem_support": [ { "operatingsystem": "RedHat", @@ -66,7 +65,8 @@ "operatingsystemrelease": [ "14.04", "16.04", - "18.04" + "18.04", + "20.04" ] }, { @@ -102,11 +102,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 5.5.10 < 7.0.0" + "version_requirement": ">= 5.5.10 < 8.0.0" } ], "description": "Standard Library for Puppet Modules", - "pdk-version": "1.14.1", - "template-url": "https://github.com/puppetlabs/pdk-templates#master", - "template-ref": "heads/master-0-g643529a" + "pdk-version": "1.18.1", + "template-url": "https://github.com/puppetlabs/pdk-templates#main", + "template-ref": "heads/main-0-g5afcd3d" } diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/provision.yaml --- a/modules/stdlib/provision.yaml Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/provision.yaml Sun Oct 09 10:34:32 2022 +0100 @@ -1,19 +1,120 @@ --- default: provisioner: docker - images: ['waffleimage/centos7'] -waffle_debian: - provisioner: docker - images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04'] -waffle_el6: - provisioner: docker - images: ['waffleimage/centos6', 'waffleimage/scientificlinux6'] -waffle_el7: - provisioner: docker - images: ['waffleimage/centos7', 'waffleimage/oraclelinux7', 'waffleimage/scientificlinux7'] + images: + - litmusimage/centos:7 vagrant: provisioner: vagrant - images: ['centos/7', 'generic/ubuntu1804', 'gusztavvargadr/windows-server'] -release_checks: - provisioner: vmpooler - images: ['redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-5-x86_64', 'centos-6-x86_64', 'centos-7-x86_64', 'centos-8-x86_64', 'oracle-5-x86_64', 'oracle-6-x86_64', 'oracle-7-x86_64', 'scientific-6-x86_64', 'scientific-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'win-2008-x86_64', 'win-2008r2-x86_64', 'win-2012-x86_64', 'win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64', 'win-7-x86_64', 'win-81-x86_64', 'win-10-pro-x86_64'] + images: + - centos/7 + - generic/ubuntu1804 + - gusztavvargadr/windows-server +travis_deb: + provisioner: docker + images: + - litmusimage/debian:8 + - litmusimage/debian:9 + - litmusimage/debian:10 +travis_ub_5: + provisioner: docker + images: + - litmusimage/ubuntu:14.04 + - litmusimage/ubuntu:16.04 + - litmusimage/ubuntu:18.04 +travis_ub_6: + provisioner: docker + images: + - litmusimage/ubuntu:14.04 + - litmusimage/ubuntu:16.04 + - litmusimage/ubuntu:18.04 + - litmusimage/ubuntu:20.04 +travis_el7: + provisioner: docker + images: + - litmusimage/centos:7 + - litmusimage/oraclelinux:7 + - litmusimage/scientificlinux:7 +travis_el8: + provisioner: docker + images: + - litmusimage/centos:8 +release_checks_5: + provisioner: abs + images: + - redhat-6-x86_64 + - redhat-7-x86_64 + - redhat-8-x86_64 + - centos-6-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - oracle-5-x86_64 + - oracle-6-x86_64 + - oracle-7-x86_64 + - scientific-6-x86_64 + - scientific-7-x86_64 + - debian-8-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - sles-12-x86_64 + - ubuntu-1404-x86_64 + - ubuntu-1604-x86_64 + - ubuntu-1804-x86_64 + - win-2008-x86_64 + - win-2008r2-x86_64 + - win-2012-x86_64 + - win-2012r2-x86_64 + - win-2016-x86_64 + - win-2019-x86_64 + - win-7-x86_64 + - win-81-x86_64 + - win-10-pro-x86_64 +release_checks_6: + provisioner: abs + images: + - redhat-6-x86_64 + - redhat-7-x86_64 + - redhat-8-x86_64 + - centos-6-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - oracle-5-x86_64 + - oracle-6-x86_64 + - oracle-7-x86_64 + - scientific-6-x86_64 + - scientific-7-x86_64 + - debian-8-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - sles-12-x86_64 + - ubuntu-1404-x86_64 + - ubuntu-1604-x86_64 + - ubuntu-1804-x86_64 + - ubuntu-2004-x86_64 + - win-2008-x86_64 + - win-2008r2-x86_64 + - win-2012-x86_64 + - win-2012r2-x86_64 + - win-2016-x86_64 + - win-2019-x86_64 + - win-7-x86_64 + - win-81-x86_64 + - win-10-pro-x86_64 +release_checks_7: + provisioner: abs + images: + - redhat-7-x86_64 + - redhat-8-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - oracle-7-x86_64 + - scientific-7-x86_64 + - sles-12-x86_64 + - sles-15-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - ubuntu-1804-x86_64 + - ubuntu-2004-x86_64 + - win-2012r2-x86_64 + - win-2016-x86_64 + - win-2019-x86_64 + - win-10-pro-x86_64 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/readmes/README_ja_JP.md --- a/modules/stdlib/readmes/README_ja_JP.md Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/readmes/README_ja_JP.md Sun Oct 09 10:34:32 2022 +0100 @@ -726,7 +726,7 @@ #### `puppet_server` -Puppet agentの`server`値を返します。この値は、agentが通信するPuppet masterのホストネームです。 +Puppet agentの`server`値を返します。この値は、agentが通信するPuppet serverのホストネームです。 #### `root_home` @@ -2065,7 +2065,7 @@ #### `pry` -現在のスコープオブジェクトでpryデバッグセッションを起動します。コンパイル中の特定ポイントにおけるマニフェストコードのデバッグに役立ちます。`puppet apply`の実行中またはフォアグラウンドでPuppet masterを実行しているときにのみ使用する必要があります。PuppetのRubyGemsに`pry` gemがインストールされている必要があります。 +現在のスコープオブジェクトでpryデバッグセッションを起動します。コンパイル中の特定ポイントにおけるマニフェストコードのデバッグに役立ちます。`puppet apply`の実行中またはフォアグラウンドでPuppet serverを実行しているときにのみ使用する必要があります。PuppetのRubyGemsに`pry` gemがインストールされている必要があります。 *例:* @@ -2095,7 +2095,7 @@ この関数の第3の引数は、使用するソルトです。 -この関数は、Puppet masterのcrypt(3)実装を使用しています。お使いの環境に複数の異なるオペレーティングシステムが含まれている場合は、この関数を使用する前に、互換性があることを確認してください。 +この関数は、Puppet serverのcrypt(3)実装を使用しています。お使いの環境に複数の異なるオペレーティングシステムが含まれている場合は、この関数を使用する前に、互換性があることを確認してください。 *タイプ*: 右辺値 @@ -3109,7 +3109,7 @@ Puppet Enterprise 3.7では、stdlibモジュールがPEに含まれていません。PEユーザは、Puppetと互換性のあるstdlibの最新リリースをインストールする必要があります。 -サポートされているオペレーティングシステムの一覧については、[metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/metadata.json)を参照してください。 +サポートされているオペレーティングシステムの一覧については、[metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/main/metadata.json)を参照してください。 ### バージョン互換性 diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/acceptance/anchor_spec.rb --- a/modules/stdlib/spec/acceptance/anchor_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'anchor type' do - let(:pp) do - <<-MANIFEST - class anchored { - anchor { 'anchored::begin': } - ~> anchor { 'anchored::end': } - } - - class anchorrefresh { - notify { 'first': } - ~> class { 'anchored': } - ~> anchor { 'final': } - } - - include anchorrefresh - MANIFEST - end - - it 'applies manifest, anchors resources in correct order' do - apply_manifest(pp) do |r| - expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'}) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/acceptance/file_line_spec.rb --- a/modules/stdlib/spec/acceptance/file_line_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -require 'spec_helper_acceptance' - -test_file = (os[:family] == 'windows') ? 'C:\Users\Administrator\file_line_test.txt' : '/tmp/file_line_test.txt' - -describe 'file_line type' do - before(:each) do - pp_test_file = <<-MANIFEST - file { '#{test_file}': - ensure => present, - content => 'a wild test file has appeared!', - } - MANIFEST - apply_manifest(pp_test_file) - end - - context 'ensure line' do - let(:pp) do - <<-MANIFEST - file_line { 'test_ensure': - path => '#{test_file}', - line => 'test file uses attack!', - } - MANIFEST - end - - it 'applies manifest, adds line' do - idempotent_apply(pp) - expect(file(test_file)).to be_file - expect(file(test_file).content).to match(%r{test file uses attack!}) - end - end - - context 'matches and replaces line' do - let(:pp) do - <<-MANIFEST - file_line { 'test_match': - path => '#{test_file}', - line => 'a tame test file has appeared!', - match => '^a wild', - } - MANIFEST - end - - it 'applies manifest, replaces line' do - idempotent_apply(pp) - expect(file(test_file)).to be_file - expect(file(test_file).content).to match(%r{a tame test file has appeared!}) - end - end - - context 'remove line' do - context 'using match' do - let(:pp) do - <<-MANIFEST - file_line { 'test_absent_match': - ensure => absent, - path => '#{test_file}', - match => '^a wild', - match_for_absence => true, - } - MANIFEST - end - - it 'applies manifest, removes line' do - idempotent_apply(pp) - expect(file(test_file)).to be_file - expect(file(test_file).content).to be_empty - end - end - - context 'using line' do - let(:pp) do - <<-MANIFEST - file_line { 'test_absent_line': - ensure => absent, - path => '#{test_file}', - line => 'a wild test file has appeared!', - } - MANIFEST - end - - it 'applies manifest, removes line' do - idempotent_apply(pp) - expect(file(test_file)).to be_file - expect(file(test_file).content).to be_empty - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/default_facts.yml --- a/modules/stdlib/spec/default_facts.yml Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -ipaddress: "172.16.254.254" -ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/dscacheutil/root --- a/modules/stdlib/spec/fixtures/dscacheutil/root Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -name: root -password: * -uid: 0 -gid: 0 -dir: /var/root -shell: /bin/bash -gecos: rawr Root - diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/lsuser/root --- a/modules/stdlib/spec/fixtures/lsuser/root Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#name:home -root:/root diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/test/manifests/base32.pp --- a/modules/stdlib/spec/fixtures/test/manifests/base32.pp Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -# Class to test the Stdlib::Base32 type alias -class test::base32 ( - Stdlib::Base32 $value, - ) { - notice('Success') -} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/test/manifests/base64.pp --- a/modules/stdlib/spec/fixtures/test/manifests/base64.pp Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -# Class to test the Stdlib::Base64 type alias -class test::base64 ( - Stdlib::Base64 $value, - ) { - notice('Success') -} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/test/manifests/deftype.pp --- a/modules/stdlib/spec/fixtures/test/manifests/deftype.pp Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -# Class to test deftype -define test::deftype( $param = 'foo' ) { - notify { "deftype: ${title}": } -} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp --- a/modules/stdlib/spec/fixtures/test/manifests/ensure_resources.pp Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -# A helper class to test the ensure_resources function -class test::ensure_resources( $resource_type, $title_hash, $attributes_hash ) { - ensure_resources($resource_type, $title_hash, $attributes_hash) -} diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/abs_spec.rb --- a/modules/stdlib/spec/functions/abs_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -require 'spec_helper' -if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 - describe 'abs' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params(-34).and_return(34) } - it { is_expected.to run.with_params('-34').and_return(34) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params('34').and_return(34) } - it { is_expected.to run.with_params(-34.5).and_return(34.5) } - it { is_expected.to run.with_params('-34.5').and_return(34.5) } - it { is_expected.to run.with_params(34.5).and_return(34.5) } - it { is_expected.to run.with_params('34.5').and_return(34.5) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/any2array_spec.rb --- a/modules/stdlib/spec/functions/any2array_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'any2array' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_return([]) } - it { is_expected.to run.with_params('').and_return([]) } - it { is_expected.to run.with_params(true).and_return([true]) } - it { is_expected.to run.with_params('one').and_return(['one']) } - it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) } - it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params('key' => 'value').and_return(['key', 'value']) } - - it { is_expected.to run.with_params('‰').and_return(['‰']) } - it { is_expected.to run.with_params('竹').and_return(['竹']) } - it { is_expected.to run.with_params('Ü').and_return(['Ü']) } - it { is_expected.to run.with_params('∇').and_return(['∇']) } - it { is_expected.to run.with_params('€', '万', 'Ö', '♥', '割').and_return(['€', '万', 'Ö', '♥', '割']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/any2bool_spec.rb --- a/modules/stdlib/spec/functions/any2bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe 'any2bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - it { is_expected.to run.with_params(true).and_return(true) } - it { is_expected.to run.with_params(false).and_return(false) } - - it { is_expected.to run.with_params('1.5').and_return(true) } - - describe 'when testing stringy values that mean "true"' do - ['TRUE', '1', 't', 'y', 'true', 'yes'].each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - end - - describe 'when testing stringy values that mean "false"' do - ['FALSE', '', '0', 'f', 'n', 'false', 'no', 'undef', 'undefined', nil, :undef].each do |value| - it { is_expected.to run.with_params(value).and_return(false) } - end - end - - describe 'when testing numeric values that mean "true"' do - [1, '1', 1.5, '1.5'].each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - end - - describe 'when testing numeric that mean "false"' do - [-1, '-1', -1.5, '-1.5', '0', 0].each do |value| - it { is_expected.to run.with_params(value).and_return(false) } - end - end - - describe 'everything else returns true' do - [[], {}, ['1'], [1], { :one => 1 }].each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/assert_private_spec.rb --- a/modules/stdlib/spec/functions/assert_private_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'assert_private' do - context 'when called from inside module' do - it 'does not fail' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('foo') - - is_expected.to run.with_params - end - end - - context 'when called from private class' do - it 'fails with a class error message' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar') - expect(scope.source).to receive(:name).and_return('foo::baz') - expect(scope.source).to receive(:type).and_return('hostclass') - - is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Class foo::baz is private}) - end - - it 'fails with an explicit failure message' do - is_expected.to run.with_params('failure message!').and_raise_error(Puppet::ParseError, %r{failure message!}) - end - end - - context 'when called from private definition' do - it 'fails with a class error message' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar') - expect(scope.source).to receive(:name).and_return('foo::baz') - expect(scope.source).to receive(:type).and_return('definition') - - is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Definition foo::baz is private}) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/base64_spec.rb --- a/modules/stdlib/spec/functions/base64_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -require 'spec_helper' - -describe 'base64' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument must be one of}) } - it { is_expected.to run.with_params('encode', ['two']).and_raise_error(Puppet::ParseError, %r{second argument must be a string}) } - it { is_expected.to run.with_params('encode', 2).and_raise_error(Puppet::ParseError, %r{second argument must be a string}) } - it { is_expected.to run.with_params('encode', 'thestring', 'three').and_raise_error(Puppet::ParseError, %r{third argument must be one of}) } - it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n", 'strict').and_raise_error(ArgumentError) } - - it { is_expected.to run.with_params('encode', 'thestring').and_return("dGhlc3RyaW5n\n") } - it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n').and_return('thestring') } - it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n").and_return('thestring') } - - it { is_expected.to run.with_params('encode', 'thestring', 'default').and_return("dGhlc3RyaW5n\n") } - it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n', 'default').and_return('thestring') } - it { is_expected.to run.with_params('decode', "dGhlc3RyaW5n\n", 'default').and_return('thestring') } - - it { is_expected.to run.with_params('encode', 'thestring', 'strict').and_return('dGhlc3RyaW5n') } - it { is_expected.to run.with_params('decode', 'dGhlc3RyaW5n', 'strict').and_return('thestring') } - - it { - is_expected.to run.with_params('encode', 'a very long string that will cause the base64 encoder to produce output with multiple lines') - .and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n") - } - it { - is_expected.to run.with_params('decode', "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n") - .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines') - } - it { - is_expected.to run.with_params('decode', 'YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==') - .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines') - } - it { - is_expected.to run.with_params('encode', 'a very long string that will cause the base64 encoder to produce output with multiple lines', 'strict') - .and_return('YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==') - } - it { - is_expected.to run.with_params('decode', 'YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==', 'strict') - .and_return('a very long string that will cause the base64 encoder to produce output with multiple lines') - } - it { - is_expected.to run.with_params('encode', 'https://www.google.com.tw/?gws_rd=ssl#q=hello+world', 'urlsafe') - .and_return('aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk') - } - it { - is_expected.to run.with_params('decode', 'aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk', 'urlsafe') - .and_return('https://www.google.com.tw/?gws_rd=ssl#q=hello+world') - } - it { - is_expected.to run.with_params('encode', 'https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add', 'urlsafe') - .and_return('aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=') - } - it { - is_expected.to run.with_params('decode', 'aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=', 'urlsafe') - .and_return('https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add') - } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/basename_spec.rb --- a/modules/stdlib/spec/functions/basename_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -require 'spec_helper' - -describe 'basename' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{No arguments given}) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Too many arguments given}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as first argument}) } - it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError, %r{Requires string as second argument}) } - it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('file.ext') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('file.ext') } - it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') } - it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') } - it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/bool2num_spec.rb --- a/modules/stdlib/spec/functions/bool2num_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe 'bool2num' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - - [true, 'true', 't', '1', 'y', 'yes', AlsoString.new('true')].each do |truthy| - it { is_expected.to run.with_params(truthy).and_return(1) } - end - - [false, 'false', 'f', '0', 'n', 'no', AlsoString.new('false')].each do |falsey| - it { is_expected.to run.with_params(falsey).and_return(0) } - end - - [[], 10, 'invalid', 1.0].each do |falsey| - it { is_expected.to run.with_params(falsey).and_raise_error(Puppet::ParseError) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/bool2str_spec.rb --- a/modules/stdlib/spec/functions/bool2str_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe 'bool2str' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - ['true', 'false', nil, :undef, ''].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError) } - end - it { is_expected.to run.with_params(true, 'yes', 'no', 'maybe').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true, 'maybe').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true, 0, 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(true).and_return('true') } - it { is_expected.to run.with_params(false).and_return('false') } - it { is_expected.to run.with_params(true, 'yes', 'no').and_return('yes') } - it { is_expected.to run.with_params(false, 'yes', 'no').and_return('no') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/camelcase_spec.rb --- a/modules/stdlib/spec/functions/camelcase_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'camelcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('abc').and_return('Abc') } - it { is_expected.to run.with_params('aa_bb_cc').and_return('AaBbCc') } - it { is_expected.to run.with_params('_aa__bb__cc_').and_return('AaBbCc') } - it { is_expected.to run.with_params('100').and_return('100') } - it { is_expected.to run.with_params('1_00').and_return('100') } - it { is_expected.to run.with_params('_').and_return('') } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['abc', 'aa_bb_cc']).and_return(['Abc', 'AaBbCc']) } - it { is_expected.to run.with_params(['abc', 1, 'aa_bb_cc']).and_return(['Abc', 1, 'AaBbCc']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/capitalize_spec.rb --- a/modules/stdlib/spec/functions/capitalize_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'capitalize', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_return('One') } - it { is_expected.to run.with_params('one two').and_return('One two') } - it { is_expected.to run.with_params('ONE TWO').and_return('One two') } - - it { is_expected.to run.with_params(AlsoString.new('one')).and_return('One') } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one', 'two']).and_return(['One', 'Two']) } - it { is_expected.to run.with_params(['one', 1, 'two']).and_return(['One', 1, 'Two']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/ceiling_spec.rb --- a/modules/stdlib/spec/functions/ceiling_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe 'ceiling', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{Wrong argument type given}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong argument type given}) } - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params(-34).and_return(-34) } - it { is_expected.to run.with_params(33.1).and_return(34) } - it { is_expected.to run.with_params(-33.1).and_return(-33) } - it { is_expected.to run.with_params('33.1').and_return(34) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/chomp_spec.rb --- a/modules/stdlib/spec/functions/chomp_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'chomp', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments given}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params("one\n").and_return('one') } - it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'two', 'three']) } - - it { is_expected.to run.with_params(AlsoString.new('one')).and_return('one') } - it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') } - it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } - it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'two', 'three']) } - - it { is_expected.to run.with_params([1, 2, 3]).and_return([1, 2, 3]) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } - it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/chop_spec.rb --- a/modules/stdlib/spec/functions/chop_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'chop', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either an array or string}) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params('one').and_return('on') } - it { is_expected.to run.with_params("one\n").and_return('one') } - it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'tw', 'three']) } - - it { is_expected.to run.with_params(AlsoString.new('one')).and_return('on') } - it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') } - it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } - it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'tw', 'three']) } - - it { is_expected.to run.with_params([1, 2, 3]).and_return([1, 2, 3]) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } - it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/clamp_spec.rb --- a/modules/stdlib/spec/functions/clamp_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'clamp' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, need three to clamp}) } - it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, %r{Required explicit numeric}) } - it { is_expected.to run.with_params(1, 2, 'a' => 55).and_raise_error(Puppet::ParseError, %r{The Hash type is not allowed}) } - - it { is_expected.to run.with_params('24', [575, 187]).and_return(187) } - it { is_expected.to run.with_params([4, 3, '99']).and_return(4) } - it { is_expected.to run.with_params(16, 750, 88).and_return(88) } - it { is_expected.to run.with_params([3, 873], 73).and_return(73) } - it { is_expected.to run.with_params([4], 8, 75).and_return(8) } - it { is_expected.to run.with_params([6], [31], 9911).and_return(31) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/concat_spec.rb --- a/modules/stdlib/spec/functions/concat_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe 'concat' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError, %r{Requires array}) } - it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) } - it { is_expected.to run.with_params(['1', '2', '3'], ['4', '5', '6']).and_return(['1', '2', '3', '4', '5', '6']) } - it { is_expected.to run.with_params(['1', '2', '3'], '4').and_return(['1', '2', '3', '4']) } - it { is_expected.to run.with_params(['1', '2', '3'], [['4', '5'], '6']).and_return(['1', '2', '3', ['4', '5'], '6']) } - it { is_expected.to run.with_params(['1', '2'], ['3', '4'], ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) } - it { is_expected.to run.with_params(['1', '2'], '3', '4', ['5', '6']).and_return(['1', '2', '3', '4', '5', '6']) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params([{ 'a' => 'b' }], 'c' => 'd', 'e' => 'f').and_return([{ 'a' => 'b' }, { 'c' => 'd', 'e' => 'f' }]) } - it { is_expected.to run.with_params(['ấ', 'β', '©'], ['đ', 'ể', '文字列']).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) } - end - - arguments = [['1', '2', '3'], ['4', '5', '6']] - originals = [arguments[0].dup, arguments[1].dup] - it 'leaves the original array intact' do - _result = subject.execute(arguments[0], arguments[1]) - arguments.each_with_index do |argument, index| - expect(argument).to eq(originals[index]) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/convert_base_spec.rb --- a/modules/stdlib/spec/functions/convert_base_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'convert_base' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('asdf').and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('asdf', 'moo', 'cow').and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(['1'], '2').and_raise_error(Puppet::ParseError, %r{argument must be either a string or an integer}) } - it { is_expected.to run.with_params('1', ['2']).and_raise_error(Puppet::ParseError, %r{argument must be either a string or an integer}) } - it { is_expected.to run.with_params('1', 1).and_raise_error(Puppet::ParseError, %r{base must be at least 2 and must not be greater than 36}) } - it { is_expected.to run.with_params('1', 37).and_raise_error(Puppet::ParseError, %r{base must be at least 2 and must not be greater than 36}) } - - it 'raises a ParseError if argument 1 is a string that does not correspond to an integer in base 10' do - is_expected.to run.with_params('ten', 6).and_raise_error(Puppet::ParseError, %r{argument must be an integer or a string corresponding to an integer in base 10}) - end - - it 'raises a ParseError if argument 2 is a string and does not correspond to an integer in base 10' do - is_expected.to run.with_params(100, 'hex').and_raise_error(Puppet::ParseError, %r{argument must be an integer or a string corresponding to an integer in base 10}) - end - - it { is_expected.to run.with_params('11', '16').and_return('b') } - it { is_expected.to run.with_params('35', '36').and_return('z') } - it { is_expected.to run.with_params(5, 2).and_return('101') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/count_spec.rb --- a/modules/stdlib/spec/functions/count_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'count' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('one').and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('one', 'two').and_return(1) } - it { - pending('should actually be like this, and not like above') - is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError) - } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } - it { is_expected.to run.with_params(['one', 'two', 'two'], 'two').and_return(2) } - it { is_expected.to run.with_params(['one', nil, 'two']).and_return(2) } - it { is_expected.to run.with_params(['one', '', 'two']).and_return(2) } - it { is_expected.to run.with_params(['one', :undef, 'two']).and_return(2) } - - it { is_expected.to run.with_params(['ổņ℮', 'ŧщộ', 'three']).and_return(3) } - it { is_expected.to run.with_params(['ổņ℮', 'ŧщộ', 'ŧщộ'], 'ŧщộ').and_return(2) } - it { is_expected.to run.with_params(['ổņ℮', nil, 'ŧщộ']).and_return(2) } - it { is_expected.to run.with_params(['ổņ℮', :undef, 'ŧщộ']).and_return(2) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/deep_merge_spec.rb --- a/modules/stdlib/spec/functions/deep_merge_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -require 'spec_helper' - -describe 'deep_merge' do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('key' => 'value').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, %r{unexpected argument type String}) } - it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, %r{unexpected argument}) } - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}, {}).and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') } - it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2').and_return('key1' => 'value1', 'key2' => 'value2') } - - describe 'when arguments have key collisions' do - it 'prefers values from the last hash' do - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2' }, 'key2' => 'replacement_value', 'key3' => 'value3') \ - .and_return('key1' => 'value1', 'key2' => 'replacement_value', 'key3' => 'value3') - end - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1' }, { 'key1' => 'value2' }, 'key1' => 'value3') \ - .and_return('key1' => 'value3') - } - end - - describe 'when arguments have subhashes' do - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1' }, 'key2' => 'value2', 'key3' => { 'subkey1' => 'value4' }) \ - .and_return('key1' => 'value1', 'key2' => 'value2', 'key3' => { 'subkey1' => 'value4' }) - } - it { - is_expected.to run \ - .with_params({ 'key1' => { 'subkey1' => 'value1' } }, 'key1' => { 'subkey2' => 'value2' }) \ - .and_return('key1' => { 'subkey1' => 'value1', 'subkey2' => 'value2' }) - } - it { - is_expected.to run \ - .with_params({ 'key1' => { 'subkey1' => { 'subsubkey1' => 'value1' } } }, 'key1' => { 'subkey1' => { 'subsubkey1' => 'value2' } }) \ - .and_return('key1' => { 'subkey1' => { 'subsubkey1' => 'value2' } }) - } - end - - arguments = { 'key1' => 'value1' }, { 'key2' => 'value2' } - originals = [arguments[0].dup, arguments[1].dup] - it 'does not change the original hashes' do - subject.execute(arguments[0], arguments[1]) - arguments.each_with_index do |argument, index| - expect(argument).to eq(originals[index]) - end - end - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params({ 'ĸέỹ1' => 'ϋǻļủë1' }, 'この文字列' => '万').and_return('ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/defined_with_params_spec.rb --- a/modules/stdlib/spec/functions/defined_with_params_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -require 'spec_helper' - -describe 'defined_with_params' do - describe 'when no resource is specified' do - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - end - describe 'when compared against a resource with no attributes' do - let :pre_condition do - 'user { "dan": }' - end - - it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } - it { is_expected.to run.with_params('User[bob]', {}).and_return(false) } - it { is_expected.to run.with_params('User[dan]', 'foo' => 'bar').and_return(false) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) } - it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) } - end - end - - describe 'when compared against a resource with attributes' do - let :pre_condition do - 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}' - end - - it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } - it { is_expected.to run.with_params('User[dan]', '').and_return(true) } - it { is_expected.to run.with_params('User[dan]', 'ensure' => 'present').and_return(true) } - it { is_expected.to run.with_params('User[dan]', 'ensure' => 'present', 'managehome' => false).and_return(true) } - it { is_expected.to run.with_params('User[dan]', 'ensure' => 'absent', 'managehome' => false).and_return(false) } - end - - describe 'when passing undef values' do - let :pre_condition do - 'file { "/tmp/a": ensure => present }' - end - let(:is_puppet_6_or_greater) { Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') >= 0 } - let(:undef_value) { is_puppet_6_or_greater ? nil : :undef } # even if :undef would work on 6.0.1, :undef should not be used - - it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) } - it { is_expected.to run.with_params('File[/tmp/a]', 'ensure' => 'present', 'owner' => undef_value).and_return(true) } - end - - describe 'when the reference is a' do - let :pre_condition do - 'user { "dan": }' - end - - context 'with reference' do - it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) } - end - if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 - context 'with array' do - it 'fails' do - expect { - subject.execute(['User[dan]'], {}) - }.to raise_error(ArgumentError, %r{not understood: 'Array'}) - end - end - end - end - - describe 'when passed a defined type' do - let :pre_condition do - 'define test::deftype() { } test::deftype { "foo": }' - end - - it { is_expected.to run.with_params('Test::Deftype[foo]', {}).and_return(true) } - it { is_expected.to run.with_params('Test::Deftype[bar]', {}).and_return(false) } - it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[foo]'), {}).and_return(true) } - it { is_expected.to run.with_params(Puppet::Resource.new('Test::Deftype[bar]'), {}).and_return(false) } - end - - describe 'when passed a class' do - let :pre_condition do - 'class test () { } class { "test": }' - end - - it { is_expected.to run.with_params('Class[test]', {}).and_return(true) } - it { is_expected.to run.with_params('Class["bar"]', {}).and_return(false) } - it { is_expected.to run.with_params('Class[bar]', {}).and_return(false) } - it { is_expected.to run.with_params(Puppet::Resource.new('class', 'test'), {}).and_return(true) } - it { is_expected.to run.with_params(Puppet::Resource.new('Class["bar"]'), {}).and_return(false) } - it { is_expected.to run.with_params(Puppet::Resource.new('Class[bar]'), {}).and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/delete_at_spec.rb --- a/modules/stdlib/spec/functions/delete_at_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'delete_at' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError, %r{Requires array}) } - it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, %r{Requires array}) } - it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError, %r{You must provide non-negative numeric}) } - it { - pending('Current implementation ignores parameters after the first two.') - is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError) - } - - describe 'argument validation' do - it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, %r{Given index exceeds size of array}) } - end - - it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) } - it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) } - it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) } - it { is_expected.to run.with_params(['ƒờở', 'βāř', 'ьầż'], 1).and_return(['ƒờở', 'ьầż']) } - - it 'leaves the original array intact' do - argument = [1, 2, 3] - original = argument.dup - _result = subject.execute(argument, 2) - expect(argument).to eq(original) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/delete_regex_spec.rb --- a/modules/stdlib/spec/functions/delete_regex_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -require 'spec_helper' - -describe 'delete_regex' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([], 'two') } - it { is_expected.to run.with_params({}, 'two') } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be an Array, Hash, or String}) } - - describe 'deleting from an array' do - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], '^t.*').and_return(['one']) } - it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['abracadabra'], 'abr').and_return(['abracadabra']) } - it { is_expected.to run.with_params(['abracadabra'], '^.*jimbob.*$').and_return(['abracadabra']) } - end - - describe 'deleting from an array' do - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({}, 'key').and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \ - .and_return('key1' => 'value1', 'key3' => 'value3') - } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \ - .and_return('key3' => 'value3') - } - end - - it 'leaves the original array intact' do - argument1 = ['one', 'two', 'three'] - original1 = argument1.dup - subject.execute(argument1, 'two') - expect(argument1).to eq(original1) - end - it 'leaves the original hash intact' do - argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' } - original1 = argument1.dup - subject.execute(argument1, 'key2') - expect(argument1).to eq(original1) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/delete_spec.rb --- a/modules/stdlib/spec/functions/delete_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -require 'spec_helper' - -describe 'delete' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([], 'two') } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be an Array, String, or Hash}) } - - describe 'deleting from an array' do - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) } - it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) } - it { is_expected.to run.with_params(['ồאּẻ', 'ŧẅơ', 'ŧңŗё℮', 'ŧẅơ'], ['ồאּẻ', 'ŧẅơ']).and_return(['ŧңŗё℮']) } - end - - describe 'deleting from a string' do - it { is_expected.to run.with_params('', '').and_return('') } - it { is_expected.to run.with_params('bar', '').and_return('bar') } - it { is_expected.to run.with_params('', 'bar').and_return('') } - it { is_expected.to run.with_params('bar', 'bar').and_return('') } - it { is_expected.to run.with_params('barbar', 'bar').and_return('') } - it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') } - it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') } - it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') } - it { is_expected.to run.with_params('ƒōōβậяβậβậяź', ['ƒōō', 'βậя']).and_return('βậź') } - - it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') } - it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') } - end - - describe 'deleting from an array' do - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({}, 'key').and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \ - .and_return('key1' => 'value1', 'key3' => 'value3') - } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \ - .and_return('key3' => 'value3') - } - it { - is_expected.to run \ - .with_params({ 'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3' }, ['ĸəұ1', 'ĸəұ2']) \ - .and_return('ĸəұ3' => 'νãŀủĕ3') - } - end - - it 'leaves the original array intact' do - argument1 = ['one', 'two', 'three'] - original1 = argument1.dup - _result = subject.execute(argument1, 'two') - expect(argument1).to eq(original1) - end - it 'leaves the original string intact' do - argument1 = 'onetwothree' - original1 = argument1.dup - _result = subject.execute(argument1, 'two') - expect(argument1).to eq(original1) - end - it 'leaves the original hash intact' do - argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' } - original1 = argument1.dup - _result = subject.execute(argument1, 'key2') - expect(argument1).to eq(original1) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/delete_undef_values_spec.rb --- a/modules/stdlib/spec/functions/delete_undef_values_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe 'delete_undef_values' do - let(:is_puppet_6) { Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') == 0 } - - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } - - describe 'when deleting from an array' do - # Behavior is different in Puppet 6.0.0, and fixed in PUP-9180 in Puppet 6.0.1 - [:undef, '', nil].each do |undef_value| - describe "when undef is represented by #{undef_value.inspect}" do - before(:each) do - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == '' - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == :undef && is_puppet_6 - end - it { is_expected.to run.with_params([undef_value]).and_return([]) } - it { is_expected.to run.with_params(['one', undef_value, 'two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['ớņέ', undef_value, 'ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 'ŧשּׁō', 'ŧħґëə']) } - end - - it 'leaves the original argument intact' do - argument = ['one', undef_value, 'two'] - original = argument.dup - _result = subject.execute(argument, 2) - expect(argument).to eq(original) - end - end - - it { is_expected.to run.with_params(['undef']).and_return(['undef']) } - end - - describe 'when deleting from a hash' do - [:undef, '', nil].each do |undef_value| - describe "when undef is represented by #{undef_value.inspect}" do - before(:each) do - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == '' - pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == :undef && is_puppet_6 - end - it { is_expected.to run.with_params('key' => undef_value).and_return({}) } - it { - is_expected.to run \ - .with_params('key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2') \ - .and_return('key1' => 'value1', 'key2' => 'value2') - } - end - - it 'leaves the original argument intact' do - argument = { 'key1' => 'value1', 'key2' => undef_value } - original = argument.dup - _result = subject.execute(argument, 2) - expect(argument).to eq(original) - end - end - - it { is_expected.to run.with_params('key' => 'undef').and_return('key' => 'undef') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/delete_values_spec.rb --- a/modules/stdlib/spec/functions/delete_values_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -require 'spec_helper' - -describe 'delete_values' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - describe 'when the first argument is not a hash' do - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } - it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } - end - - describe 'when deleting from a hash' do - it { is_expected.to run.with_params({}, 'value').and_return({}) } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1' }, 'non-existing value') \ - .and_return('key1' => 'value1') - } - it { - is_expected.to run \ - .with_params({ 'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete' }, 'value to delete') \ - .and_return('ҝếỵ1 ' => 'νâĺūẹ1') - } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė' }, 'νǎŀữ℮ ťớ đêłểťė') \ - .and_return('key1' => 'value1') - } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete' }, 'value to delete') \ - .and_return('key1' => 'value1') - } - end - - it 'leaves the original argument intact' do - argument = { 'key1' => 'value1', 'key2' => 'value2' } - original = argument.dup - _result = subject.execute(argument, 'value2') - expect(argument).to eq(original) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/deprecation_spec.rb --- a/modules/stdlib/spec/functions/deprecation_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'deprecation' do - before(:each) do - # this is to reset the strict variable to default - Puppet.settings[:strict] = :warning - end - - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - - it 'displays a single warning' do - if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 - expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key') - expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") - else - expect(Puppet).to receive(:warning).with(include('heelo')).once - end - is_expected.to run.with_params('key', 'heelo') - end - - it 'displays a single warning, despite multiple calls' do - if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 - expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice - expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") - else - expect(Puppet).to receive(:warning).with(include('heelo')).once - end - (0..1).each do |_i| - is_expected.to run.with_params('key', 'heelo') - end - end - - it 'fails twice with message, with multiple calls. when strict= :error' do - Puppet.settings[:strict] = :error - expect(Puppet).to receive(:warning).with(include('heelo')).never - (0..1).each do |_i| - is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo}) - end - end - - it 'displays nothing, despite multiple calls. strict= :off' do - Puppet.settings[:strict] = :off - expect(Puppet).to receive(:warning).with(include('heelo')).never - (0..1).each do |_i| - is_expected.to run.with_params('key', 'heelo') - end - end - - after(:each) do - # this is to reset the strict variable to default - Puppet.settings[:strict] = :warning - end - end -elsif Puppet.version.to_f < 4.0 - # Puppet version < 4 will use these tests. - describe 'deprecation' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - before(:each) do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - end - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - it 'displays a single warning' do - expect(scope).to receive(:warning).with(include('heelo')) - is_expected.to run.with_params('key', 'heelo') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/difference_spec.rb --- a/modules/stdlib/spec/functions/difference_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'difference' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } - - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return([]) } - it { is_expected.to run.with_params(['one'], ['one']).and_return([]) } - it { is_expected.to run.with_params(['ớņέ'], ['']).and_return(['ớņέ']) } - it { is_expected.to run.with_params(['one'], []).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['ớņέ', 'ŧשּׁō', 'ŧħґëə', 2], ['ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 2]) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) } - it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/dig44_spec.rb --- a/modules/stdlib/spec/functions/dig44_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -require 'spec_helper' - -describe 'dig44' do - let(:undef_value) do - (Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0) ? :undef : nil - end - - let(:data) do - { - 'a' => { - 'g' => '2', - 'e' => [ - 'f0', - 'f1', - { - 'x' => { - 'y' => 'z', - }, - }, - 'f3', - ], - }, - 'b' => true, - 'c' => false, - 'd' => '1', - 'e' => undef_value, - 'f' => nil, - } - end - - let(:utf8_data) do - { - 'ẵ' => { - 'в' => [ - '©', - 'ĝ', - 'に', - ], - }, - } - end - - context 'with single values' do - it 'exists' do - is_expected.not_to be_nil - end - - it 'requires two arguments' do - is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) - end - - it 'fails if the data is not a structure' do - is_expected.to run.with_params('test', []).and_raise_error(Puppet::Error, %r{first argument must be a hash or an array}) - end - - it 'fails if the path is not an array' do - is_expected.to run.with_params({}, '').and_raise_error(Puppet::Error, %r{second argument must be an array}) - end - - it 'returns the value if the value is string' do - is_expected.to run.with_params(data, ['d'], 'default').and_return('1') - end - - it 'returns true if the value is true' do - is_expected.to run.with_params(data, ['b'], 'default').and_return(true) - end - - it 'returns false if the value is false' do - is_expected.to run.with_params(data, ['c'], 'default').and_return(false) - end - - it 'returns the default if the value is nil' do - is_expected.to run.with_params(data, ['f'], 'default').and_return('default') - end - - it 'returns the default if the value is :undef (same as nil)' do - is_expected.to run.with_params(data, ['e'], 'default').and_return('default') - end - - it 'returns the default if the path is not found' do - is_expected.to run.with_params(data, ['missing'], 'default').and_return('default') - end - end - - context 'with structured values' do - it 'is able to extract a deeply nested hash value' do - is_expected.to run.with_params(data, ['a', 'g'], 'default').and_return('2') - end - - it 'returns the default value if the path is too long' do - is_expected.to run.with_params(data, ['a', 'g', 'c', 'd'], 'default').and_return('default') - end - - it 'supports an array index (number) in the path' do - is_expected.to run.with_params(data, ['a', 'e', 1], 'default').and_return('f1') - end - - it 'supports an array index (string) in the path' do - is_expected.to run.with_params(data, ['a', 'e', '1'], 'default').and_return('f1') - end - - it 'returns the default value if an array index is not a number' do - is_expected.to run.with_params(data, ['a', 'b', 'c'], 'default').and_return('default') - end - - it 'returns the default value if and index is out of array length' do - is_expected.to run.with_params(data, ['a', 'e', '5'], 'default').and_return('default') - end - - it 'is able to path though both arrays and hashes' do - is_expected.to run.with_params(data, ['a', 'e', '2', 'x', 'y'], 'default').and_return('z') - end - - it 'returns "nil" if value is not found and no default value is provided' do - is_expected.to run.with_params(data, ['a', '1']).and_return(nil) - end - end - - context 'with internationalization (i18N) values' do - it 'is able to return a unicode character' do - is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 0]).and_return('©') - end - - it 'is able to return a utf8 character' do - is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 1]).and_return('ĝ') - end - - it 'is able to return a double byte character' do - is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 2]).and_return('に') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/dig_spec.rb --- a/modules/stdlib/spec/functions/dig_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'dig' do - it 'exists' do - expect(Puppet::Parser::Functions.function('dig')).to eq('function_dig') - end - - it 'gives a deprecation warning when called' do - expect(scope).to receive(:warning).with('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.') - scope.function_dig([{}, []]) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/dirname_spec.rb --- a/modules/stdlib/spec/functions/dirname_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'dirname' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{No arguments given}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Too many arguments given}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires a non-empty string as argument}) } - it { is_expected.to run.with_params(:undef).and_raise_error(Puppet::ParseError, %r{string as argument}) } - it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError, %r{string as argument}) } - it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') } - it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('scheme:///√ạĺűē') } - it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ').and_return('ҝẽγ:/√ạĺűē') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/dos2unix_spec.rb --- a/modules/stdlib/spec/functions/dos2unix_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'dos2unix' do - context 'when checking parameter validity' do - it { is_expected.not_to eq(nil) } - it do - is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) - end - it do - is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments}) - end - it do - is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) - end - it do - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) - end - it do - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) - end - end - - context 'when converting from dos to unix format' do - sample_text = "Hello\r\nWorld\r\n" - desired_output = "Hello\nWorld\n" - - it 'outputs unix format' do - is_expected.to run.with_params(sample_text).and_return(desired_output) - end - end - - context 'with internationalization (i18N) values' do - sample_text_utf8 = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n" - desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n" - - sample_text_doublebyte = "こんにちは\r\n世界\r\n" - desired_output_doublebyte = "こんにちは\n世界\n" - - it 'outputs uft8 string' do - is_expected.to run.with_params(sample_text_utf8).and_return(desired_output_utf8) - end - - it 'outputs double byte string' do - is_expected.to run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/downcase_spec.rb --- a/modules/stdlib/spec/functions/downcase_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'downcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) } - it { is_expected.to run.with_params('abc').and_return('abc') } - it { is_expected.to run.with_params('Abc').and_return('abc') } - it { is_expected.to run.with_params('ABC').and_return('abc') } - - it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('abc') } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['ONE', 'TWO']).and_return(['one', 'two']) } - it { is_expected.to run.with_params(['One', 1, 'Two']).and_return(['one', 1, 'two']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/empty_spec.rb --- a/modules/stdlib/spec/functions/empty_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'empty', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params(false).and_raise_error(Puppet::ParseError, %r{Requires either array, hash, string or integer}) } - it { is_expected.to run.with_params(0).and_return(false) } - it { is_expected.to run.with_params('').and_return(true) } - it { is_expected.to run.with_params('one').and_return(false) } - - it { is_expected.to run.with_params(AlsoString.new('')).and_return(true) } - it { is_expected.to run.with_params(AlsoString.new('one')).and_return(false) } - - it { is_expected.to run.with_params([]).and_return(true) } - it { is_expected.to run.with_params(['one']).and_return(false) } - - it { is_expected.to run.with_params({}).and_return(true) } - it { is_expected.to run.with_params('key' => 'value').and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/ensure_packages_spec.rb --- a/modules/stdlib/spec/functions/ensure_packages_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -require 'spec_helper' - -describe 'ensure_packages' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { - pending('should not accept numbers as arguments') - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) - } - it { - pending('should not accept numbers as arguments') - is_expected.to run.with_params(['packagename', 1]).and_raise_error(Puppet::ParseError) - } - it { is_expected.to run.with_params('packagename') } - it { is_expected.to run.with_params(['packagename1', 'packagename2']) } - - context 'when given a catalog with "package { puppet: ensure => absent }"' do - let(:pre_condition) { 'package { puppet: ensure => absent }' } - - describe 'after running ensure_package("facter")' do - before(:each) { subject.execute('facter') } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent') } - it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present') } - end - - describe 'after running ensure_package("facter", { "provider" => "gem" })' do - before(:each) { subject.execute('facter', 'provider' => 'gem') } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider } - it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present').with_provider('gem') } - end - end - - context 'when given an empty packages array' do - let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' } - - describe 'after running ensure_package(["vim", ""])' do - it { expect { catalogue }.to raise_error(Puppet::ParseError, %r{Empty String provided}) } - end - end - - context 'when given hash of packages' do - before(:each) do - subject.execute({ 'foo' => { 'provider' => 'rpm' }, 'bar' => { 'provider' => 'gem' } }, 'ensure' => 'present') - subject.execute('パッケージ' => { 'ensure' => 'absent' }) - subject.execute('ρǻ¢κầģẻ' => { 'ensure' => 'absent' }) - end - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'present') } - it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'present') } - - context 'with UTF8 and double byte characters' do - it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') } - it { expect(-> { catalogue }).to contain_package('ρǻ¢κầģẻ').with('ensure' => 'absent') } - end - end - - context 'when given a catalog with "package { puppet: ensure => present }"' do - let(:pre_condition) { 'package { puppet: ensure => present }' } - - describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do - before(:each) { subject.execute('puppet', 'ensure' => 'installed') } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/ensure_resource_spec.rb --- a/modules/stdlib/spec/functions/ensure_resource_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -require 'spec_helper' - -describe 'ensure_resource' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a type}) } - it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, %r{Must specify a title}) } - if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 - it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(ArgumentError) } - else - it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } - end - - it { - pending('should not accept numbers as arguments') - is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError) - } - - context 'when given an empty catalog' do - describe 'after running ensure_resource("user", "username1", {})' do - before(:each) { subject.execute('User', 'username1', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').without_ensure } - end - - describe 'after running ensure_resource("user", "username1", { gid => undef })' do - before(:each) { subject.execute('User', 'username1', 'gid' => undef_value) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').without_ensure } - it { expect(-> { catalogue }).to contain_user('username1').without_gid } - end - - describe 'after running ensure_resource("user", "username1", { ensure => present, gid => undef })' do - before(:each) { subject.execute('User', 'username1', 'ensure' => 'present', 'gid' => undef_value) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('username1').without_gid } - end - - describe 'after running ensure_resource("test::deftype", "foo", {})' do - let(:pre_condition) { 'define test::deftype { }' } - - before(:each) { subject.execute('test::deftype', 'foo', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_test__deftype('foo').without_ensure } - end - end - - context 'when given a catalog with UTF8 chars' do - describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do - before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } - end - - describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do - before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', 'gid' => undef_value) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } - it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } - end - - describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do - before(:each) { subject.execute('User', 'Şắოрŀễ Ţëם', 'ensure' => 'present', 'gid' => undef_value) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } - end - end - - context 'when given a catalog with "user { username1: ensure => present }"' do - let(:pre_condition) { 'user { username1: ensure => present }' } - - describe 'after running ensure_resource("user", "username1", {})' do - before(:each) { subject.execute('User', 'username1', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } - end - - describe 'after running ensure_resource("user", "username2", {})' do - before(:each) { subject.execute('User', 'username2', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('username2').without_ensure } - end - - describe 'after running ensure_resource("user", "username1", { gid => undef })' do - before(:each) { subject.execute('User', 'username1', 'gid' => undef_value) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } - end - - describe 'after running ensure_resource("user", ["username1", "username2"], {})' do - before(:each) { subject.execute('User', ['username1', 'username2'], {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('username2').without_ensure } - end - - describe 'when providing already set params' do - let(:params) { { 'ensure' => 'present' } } - - before(:each) { subject.execute('User', ['username2', 'username3'], params) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('username1').with(params) } - it { expect(-> { catalogue }).to contain_user('username2').with(params) } - end - - context 'when trying to add params' do - it { - is_expected.to run \ - .with_params('User', 'username1', 'ensure' => 'present', 'shell' => true) \ - .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, %r{User\[username1\] is already declared}) - } - end - end - - context 'when given a catalog with "test::deftype { foo: }"' do - let(:pre_condition) { 'define test::deftype { } test::deftype { "foo": }' } - - describe 'after running ensure_resource("test::deftype", "foo", {})' do - before(:each) { subject.execute('test::deftype', 'foo', {}) } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_test__deftype('foo').without_ensure } - end - end - - if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 - def undef_value - :undef - end - else - def undef_value - nil - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/ensure_resources_spec.rb --- a/modules/stdlib/spec/functions/ensure_resources_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe 'ensure_resources' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a type}) } - it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, %r{Must specify a title}) } - - describe 'given a title hash of multiple resources' do - before(:each) do - subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' }, 'alex' => { 'gid' => 'mygroup', 'uid' => '700' } }, 'ensure' => 'present') - end - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('alex').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') } - it { expect(-> { catalogue }).to contain_user('alex').with('gid' => 'mygroup', 'uid' => '700') } - end - - describe 'given a title hash of a single resource' do - before(:each) { subject.execute('user', { 'dan' => { 'gid' => 'mygroup', 'uid' => '600' } }, 'ensure' => 'present') } - - # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_user('dan').with_ensure('present') } - it { expect(-> { catalogue }).to contain_user('dan').with('gid' => 'mygroup', 'uid' => '600') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/extname_spec.rb --- a/modules/stdlib/spec/functions/extname_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe 'stdlib::extname' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::extname' expects 1 argument, got none}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{'stdlib::extname' expects 1 argument, got 2}) } - it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, %r{'stdlib::extname' parameter 'filename' expects a String value, got Array}) } - it { is_expected.to run.with_params('test.rb').and_return('.rb') } - it { is_expected.to run.with_params('a/b/d/test.rb').and_return('.rb') } - it { is_expected.to run.with_params('test').and_return('') } - it { is_expected.to run.with_params('.profile').and_return('') } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('file_√ạĺűē/竹.rb').and_return('.rb') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/flatten_spec.rb --- a/modules/stdlib/spec/functions/flatten_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe 'flatten', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires array}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array}) } - - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params([['one']]).and_return(['one']) } - it { is_expected.to run.with_params(['a', 'b', 'c', 'd', 'e', 'f', 'g']).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) } - it { is_expected.to run.with_params([['a', 'b', ['c', ['d', 'e'], 'f', 'g']]]).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) } - it { is_expected.to run.with_params(['ã', 'β', ['ĉ', ['đ', 'ẽ', 'ƒ', 'ġ']]]).and_return(['ã', 'β', 'ĉ', 'đ', 'ẽ', 'ƒ', 'ġ']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/floor_spec.rb --- a/modules/stdlib/spec/functions/floor_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe 'floor', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } - it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{Wrong argument type}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong argument type}) } - - it { is_expected.to run.with_params(34).and_return(34) } - it { is_expected.to run.with_params(-34).and_return(-34) } - it { is_expected.to run.with_params(33.1).and_return(33) } - it { is_expected.to run.with_params(-33.1).and_return(-34) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/fqdn_rand_string_spec.rb --- a/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -require 'spec_helper' - -describe 'fqdn_rand_string' do - let(:default_charset) { %r{\A[a-zA-Z0-9]{100}\z} } - - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(0).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(1.5).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(-10).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params('-10').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params('string').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params({}).and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) } - it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) } - it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, %r{second argument must be undef or a string}) } - it { is_expected.to run.with_params(100).and_return(default_charset) } - it { is_expected.to run.with_params('100').and_return(default_charset) } - it { is_expected.to run.with_params(100, nil).and_return(default_charset) } - it { is_expected.to run.with_params(100, '').and_return(default_charset) } - it { is_expected.to run.with_params(100, 'a').and_return(%r{\Aa{100}\z}) } - it { is_expected.to run.with_params(100, 'ab').and_return(%r{\A[ab]{100}\z}) } - it { is_expected.to run.with_params(100, 'ãβ').and_return(%r{\A[ãβ]{100}\z}) } - - it "provides the same 'random' value on subsequent calls for the same host" do - expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10)) - end - - it 'considers the same host and same extra arguments to have the same random sequence' do - first_random = fqdn_rand_string(10, :extra_identifier => [1, 'same', 'host']) - second_random = fqdn_rand_string(10, :extra_identifier => [1, 'same', 'host']) - - expect(first_random).to eql(second_random) - end - - it 'allows extra arguments to control the random value on a single host' do - first_random = fqdn_rand_string(10, :extra_identifier => [1, 'different', 'host']) - second_different_random = fqdn_rand_string(10, :extra_identifier => [2, 'different', 'host']) - - expect(first_random).not_to eql(second_different_random) - end - - it 'returns different strings for different hosts' do - val1 = fqdn_rand_string(10, :host => 'first.host.com') - val2 = fqdn_rand_string(10, :host => 'second.host.com') - - expect(val1).not_to eql(val2) - end - - def fqdn_rand_string(max, args = {}) - host = args[:host] || '127.0.0.1' - charset = args[:charset] - extra = args[:extra_identifier] || [] - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host) - - function_args = [max] - if args.key?(:charset) || !extra.empty? - function_args << charset - end - function_args += extra - scope.function_fqdn_rand_string(function_args) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/fqdn_rotate_spec.rb --- a/modules/stdlib/spec/functions/fqdn_rotate_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -require 'spec_helper' - -describe 'fqdn_rotate' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('ã').and_return('ã') } - - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - - it 'rotates a string and the result should be the same size' do - expect(fqdn_rotate('asdf').size).to eq(4) - end - - it 'rotates a string to give the same results for one host' do - val1 = fqdn_rotate('abcdefg', :host => 'one') - val2 = fqdn_rotate('abcdefg', :host => 'one') - expect(val1).to eq(val2) - end - - it 'allows extra arguments to control the random rotation on a single host' do - val1 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'different', 'host']) - val2 = fqdn_rotate('abcdefg', :extra_identifier => [2, 'different', 'host']) - expect(val1).not_to eq(val2) - end - - it 'considers the same host and same extra arguments to have the same random rotation' do - val1 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'same', 'host']) - val2 = fqdn_rotate('abcdefg', :extra_identifier => [1, 'same', 'host']) - expect(val1).to eq(val2) - end - - it 'rotates a string to give different values on different hosts' do - val1 = fqdn_rotate('abcdefg', :host => 'one') - val2 = fqdn_rotate('abcdefg', :host => 'two') - expect(val1).not_to eq(val2) - end - - it 'accepts objects which extend String' do - result = fqdn_rotate(AlsoString.new('asdf')) - expect(result).to eq('dfas') - end - - it 'uses the Puppet::Util.deterministic_rand function' do - skip 'Puppet::Util#deterministic_rand not available' unless Puppet::Util.respond_to?(:deterministic_rand) - - expect(Puppet::Util).to receive(:deterministic_rand).with(44_489_829_212_339_698_569_024_999_901_561_968_770, 4) - fqdn_rotate('asdf') - end - - it 'does not leave the global seed in a deterministic state' do - fqdn_rotate('asdf') - rand1 = rand - fqdn_rotate('asdf') - rand2 = rand - expect(rand1).not_to eql(rand2) - end - - def fqdn_rotate(value, args = {}) - host = args[:host] || '127.0.0.1' - extra = args[:extra_identifier] || [] - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - allow(scope).to receive(:lookupvar).with('::fqdn').and_return(host) - - function_args = [value] + extra - scope.function_fqdn_rotate(function_args) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/fqdn_uuid_spec.rb --- a/modules/stdlib/spec/functions/fqdn_uuid_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe 'fqdn_uuid' do - context 'with invalid parameters' do - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{No arguments given}) } - it { is_expected.to run.with_params('puppetlabs.com', 'google.com').and_raise_error(ArgumentError, %r{Too many arguments given}) } - it { is_expected.to run.with_params({}).and_raise_error(TypeError, %r{no implicit conversion of Hash}) } - it { is_expected.to run.with_params(0).and_raise_error(TypeError, %r{no implicit conversion of Integer}) } - end - - context 'with given string' do - it { is_expected.to run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') } - it { is_expected.to run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') } - it { is_expected.to run.with_params('0').and_return('6af613b6-569c-5c22-9c37-2ed93f31d3af') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/get_module_path_spec.rb --- a/modules/stdlib/spec/functions/get_module_path_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -require 'spec_helper' - -describe 'get_module_path' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, expects one}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Could not find module}) } - - # class Stubmodule - class StubModule - attr_reader :path - def initialize(path) - @path = path - end - end - - describe 'when locating a module' do - let(:modulepath) { '/tmp/does_not_exist' } - let(:path_of_module_foo) { StubModule.new('/tmp/does_not_exist/foo') } - - before(:each) do - Puppet[:modulepath] = modulepath - end - - context 'when in the default environment' do - before(:each) do - allow(Puppet::Module).to receive(:find).with('foo', 'rp_env').and_return(path_of_module_foo) - end - it 'runs against foo' do - is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) - end - - it 'when the modulepath is a list' do - Puppet[:modulepath] = modulepath + 'tmp/something_else' - - is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) - end - end - - context 'when in a non-default default environment' do - let(:environment) { 'test' } - - before(:each) do - allow(Puppet::Module).to receive(:find).with('foo', 'test').and_return(path_of_module_foo) - end - it 'runs against foo' do - is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) - end - - it 'when the modulepath is a list' do - Puppet[:modulepath] = modulepath + 'tmp/something_else' - is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/getparam_spec.rb --- a/modules/stdlib/spec/functions/getparam_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'getparam' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a reference}) } - it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, %r{Must specify name of a parameter}) } - it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) } - it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) } - it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) } - - describe 'when compared against a user resource with no params' do - let(:pre_condition) { 'user { "one": }' } - - it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[one]', 'shell').and_return('') } - end - - describe 'when compared against a user resource with params' do - let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' } - - it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') } - it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') } - it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') } - it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) } - end - - describe 'when compared against a user resource with UTF8 and double byte params' do - let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' } - - it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') } - it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/getvar_spec.rb --- a/modules/stdlib/spec/functions/getvar_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -require 'spec_helper' - -describe 'getvar' do - it { is_expected.not_to eq(nil) } - - describe 'before Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'from Puppet 6.0.0', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') >= 0 do - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got none}i) } - it { is_expected.to run.with_params('one', 'two').and_return('two') } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError, %r{expects between 1 and 2 arguments, got 3}i) } - end - - it { is_expected.to run.with_params('::foo').and_return(nil) } - - context 'with given variables in namespaces' do - let(:pre_condition) do - <<-PUPPETCODE - class site::data { $foo = 'baz' } - include site::data - PUPPETCODE - end - - it { is_expected.to run.with_params('site::data::foo').and_return('baz') } - it { is_expected.to run.with_params('::site::data::foo').and_return('baz') } - it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } - end - - context 'with given variables in namespaces' do - let(:pre_condition) do - <<-PUPPETCODE - class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' } - class site::new { $item = '万Ü€‰' } - include site::info - include site::new - PUPPETCODE - end - - it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') } - it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/glob_spec.rb --- a/modules/stdlib/spec/functions/glob_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe 'glob' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('').and_return([]) } - it { is_expected.to run.with_params(['']).and_return([]) } - it { is_expected.to run.with_params(['', '']).and_return([]) } - it { is_expected.to run.with_params(['/etc/xyzxyzxyz', '/etcxyzxyzxyz']).and_return([]) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/grep_spec.rb --- a/modules/stdlib/spec/functions/grep_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'grep' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('grep does not actually check this, and raises NoMethodError instead') - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array}) - } - it { - pending('grep does not actually check this, and raises NoMethodError instead') - is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array}) - } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) } - it { is_expected.to run.with_params(['ờאּê', 'ţשּׂỡ', 'ţһŗəè'], 'ţ(שּׂỡ|һŗəè)').and_return(['ţשּׂỡ', 'ţһŗəè']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/has_interface_with_spec.rb --- a/modules/stdlib/spec/functions/has_interface_with_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe 'has_interface_with' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - # We need to mock out the Facts so we can specify how we expect this function - # to behave on different platforms. - context 'when on Mac OS X Systems' do - let(:facts) { { :interfaces => 'lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0' } } - - it { is_expected.to run.with_params('lo0').and_return(true) } - it { is_expected.to run.with_params('lo').and_return(false) } - end - - context 'when on Linux Systems' do - let(:facts) do - { - :interfaces => 'eth0,lo', - :ipaddress => '10.0.0.1', - :ipaddress_lo => '127.0.0.1', - :ipaddress_eth0 => '10.0.0.1', - :muppet => 'kermit', - :muppet_lo => 'mspiggy', - :muppet_eth0 => 'kermit', - } - end - - it { is_expected.to run.with_params('lo').and_return(true) } - it { is_expected.to run.with_params('lo0').and_return(false) } - it { is_expected.to run.with_params('ipaddress', '127.0.0.1').and_return(true) } - it { is_expected.to run.with_params('ipaddress', '10.0.0.1').and_return(true) } - it { is_expected.to run.with_params('ipaddress', '8.8.8.8').and_return(false) } - it { is_expected.to run.with_params('muppet', 'kermit').and_return(true) } - it { is_expected.to run.with_params('muppet', 'mspiggy').and_return(true) } - it { is_expected.to run.with_params('muppet', 'bigbird').and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/has_ip_address_spec.rb --- a/modules/stdlib/spec/functions/has_ip_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'has_ip_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - context 'when on Linux Systems' do - let(:facts) do - { - :interfaces => 'eth0,lo', - :ipaddress => '10.0.0.1', - :ipaddress_lo => '127.0.0.1', - :ipaddress_eth0 => '10.0.0.1', - } - end - - it { is_expected.to run.with_params('127.0.0.1').and_return(true) } - it { is_expected.to run.with_params('10.0.0.1').and_return(true) } - it { is_expected.to run.with_params('8.8.8.8').and_return(false) } - it { is_expected.to run.with_params('invalid').and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/has_ip_network_spec.rb --- a/modules/stdlib/spec/functions/has_ip_network_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'has_ip_network' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - context 'when on Linux Systems' do - let(:facts) do - { - :interfaces => 'eth0,lo', - :network_lo => '127.0.0.0', - :network_eth0 => '10.0.0.0', - } - end - - it { is_expected.to run.with_params('127.0.0.0').and_return(true) } - it { is_expected.to run.with_params('10.0.0.0').and_return(true) } - it { is_expected.to run.with_params('8.8.8.0').and_return(false) } - it { is_expected.to run.with_params('invalid').and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/has_key_spec.rb --- a/modules/stdlib/spec/functions/has_key_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'has_key' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{expects the first argument to be a hash}) } - - it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return(true) } - it { is_expected.to run.with_params({}, 'key').and_return(false) } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'not a key').and_return(false) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, 'κéỳ ').and_return(true) } - it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, 'キー').and_return(true) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/hash_spec.rb --- a/modules/stdlib/spec/functions/hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe 'hash' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, %r{Unable to compute}) } - it { is_expected.to run.with_params([]).and_return({}) } - it { is_expected.to run.with_params(['key1', 'value1']).and_return('key1' => 'value1') } - it { is_expected.to run.with_params(['κ℮ұ1', '√āĺűẻ1']).and_return('κ℮ұ1' => '√āĺűẻ1') } - it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return('key1' => 'value1', 'key2' => 'value2') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/intersection_spec.rb --- a/modules/stdlib/spec/functions/intersection_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'intersection' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return([]) } - it { is_expected.to run.with_params(['one'], []).and_return([]) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ['ŧשợ', 'ţђŕẽё']).and_return(['ŧשợ', 'ţђŕẽё']) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) } - it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/ip_in_range_spec.rb --- a/modules/stdlib/spec/functions/ip_in_range_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'stdlib::ip_in_range' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got none}) } - it { is_expected.to run.with_params('one', 'two', '3').and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got 3}) } - it { is_expected.to run.with_params([], []).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'ipaddress' expects a String value, got Array}) } - it { is_expected.to run.with_params('1.1.1.1', 7).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'range' expects a value of type String or Array, got Integer}) } - end - - describe 'basic validation inputs' do - it { is_expected.to run.with_params('192.168.100.12', '192.168.100.0/24').and_return(true) } - it { is_expected.to run.with_params('192.168.100.12', ['10.10.10.10/24', '192.168.100.0/24']).and_return(true) } - it { is_expected.to run.with_params('10.10.10.10', '192.168.100.0/24').and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_a_spec.rb --- a/modules/stdlib/spec/functions/is_a_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -require 'spec_helper' - -if ENV['FUTURE_PARSER'] == 'yes' - describe 'type_of' do - pending 'teach rspec-puppet to load future-only functions under 3.7.5' do - it { is_expected.not_to eq(nil) } - end - end -end - -if Puppet.version.to_f >= 4.0 - describe 'is_a' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) } - - it 'succeeds when comparing a string and a string' do - is_expected.to run.with_params('hello world', String).and_return(true) - end - - it 'fails when comparing an integer and a string' do - is_expected.to run.with_params(5, String).and_return(false) - end - - it 'suceeds when comparing an UTF8 and double byte characters' do - comparison_array = ['このテキスト', 'ŧћịś ŧêχŧ'] - comparison_array.each do |comparison_value| - is_expected.to run.with_params(comparison_value, String).and_return(true) - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_array_spec.rb --- a/modules/stdlib/spec/functions/is_array_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'is_array' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params([]).and_return(true) } - it { is_expected.to run.with_params(['one']).and_return(true) } - it { is_expected.to run.with_params([1]).and_return(true) } - it { is_expected.to run.with_params([{}]).and_return(true) } - it { is_expected.to run.with_params([[]]).and_return(true) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(['1.2.3.4']).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(['1.2.3.4']).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_bool_spec.rb --- a/modules/stdlib/spec/functions/is_bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'is_bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(true).and_return(true) } - it { is_expected.to run.with_params(false).and_return(true) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params([{}]).and_return(false) } - it { is_expected.to run.with_params([[]]).and_return(false) } - it { is_expected.to run.with_params([true]).and_return(false) } - it { is_expected.to run.with_params('true').and_return(false) } - it { is_expected.to run.with_params('false').and_return(false) } - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(true).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(false).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_domain_name_spec.rb --- a/modules/stdlib/spec/functions/is_domain_name_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe 'is_domain_name' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('.').and_return(true) } - it { is_expected.to run.with_params('com').and_return(true) } - it { is_expected.to run.with_params('com.').and_return(true) } - it { is_expected.to run.with_params('x.com').and_return(true) } - it { is_expected.to run.with_params('x.com.').and_return(true) } - it { is_expected.to run.with_params('foo.example.com').and_return(true) } - it { is_expected.to run.with_params('foo.example.com.').and_return(true) } - it { is_expected.to run.with_params('2foo.example.com').and_return(true) } - it { is_expected.to run.with_params('2foo.example.com.').and_return(true) } - it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) } - it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) } - it { is_expected.to run.with_params(true).and_return(false) } - - describe 'inputs with spaces' do - it { is_expected.to run.with_params('invalid domain').and_return(false) } - end - - describe 'inputs with hyphens' do - it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) } - it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) } - it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) } - it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) } - it { is_expected.to run.with_params('-foo.example.com').and_return(false) } - it { is_expected.to run.with_params('-foo.example.com.').and_return(false) } - end - - # Values obtained from Facter values will be frozen strings - # in newer versions of Facter: - it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) } - - describe 'top level domain must be alphabetic if there are multiple labels' do - it { is_expected.to run.with_params('2com').and_return(true) } - it { is_expected.to run.with_params('www.example.2com').and_return(false) } - end - - describe 'IP addresses are not domain names' do - it { is_expected.to run.with_params('192.168.1.1').and_return(false) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_email_address_spec.rb --- a/modules/stdlib/spec/functions/is_email_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'is_email_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('bob@gmail.com').and_return(true) } - it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com').and_return(true) } - it { is_expected.to run.with_params('peter.parker@gmail.com').and_return(true) } - it { is_expected.to run.with_params('1.2.3@domain').and_return(false) } - it { is_expected.to run.with_params('1.2.3.4.5@').and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_float_spec.rb --- a/modules/stdlib/spec/functions/is_float_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'is_float' do - it { is_expected.not_to eq(nil) } - - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('0.1').and_return(true) } - it { is_expected.to run.with_params('1.0').and_return(true) } - it { is_expected.to run.with_params('1').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params('one 1.0').and_return(false) } - it { is_expected.to run.with_params('1.0 one').and_return(false) } - it { is_expected.to run.with_params(0.1).and_return(true) } - it { is_expected.to run.with_params(1.0).and_return(true) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(2.2).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(1.0).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_function_available_spec.rb --- a/modules/stdlib/spec/functions/is_function_available_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'is_function_available' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('include').and_return(true) } - it { is_expected.to run.with_params('no_such_function').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_hash_spec.rb --- a/modules/stdlib/spec/functions/is_hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe 'is_hash' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params({}).and_return(true) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params([{ 'aaa' => 'bbb' }]).and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_integer_spec.rb --- a/modules/stdlib/spec/functions/is_integer_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -require 'spec_helper' - -describe 'is_integer' do - it { is_expected.not_to eq(nil) } - - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - it { is_expected.to run.with_params(3).and_return(true) } - it { is_expected.to run.with_params('3').and_return(true) } - it { is_expected.to run.with_params(-3).and_return(true) } - it { is_expected.to run.with_params('-3').and_return(true) } - it { is_expected.to run.with_params("123\nfoo").and_return(true) } - it { is_expected.to run.with_params("foo\n123").and_return(true) } - - it { is_expected.to run.with_params(3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - it { is_expected.to run.with_params(-3.7).and_return(false) } - it { is_expected.to run.with_params('-3.7').and_return(false) } - - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('0001234').and_return(false) } - it { is_expected.to run.with_params("foo\nbar").and_return(false) } - - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(50).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(50).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_ip_address_spec.rb --- a/modules/stdlib/spec/functions/is_ip_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'is_ip_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('1.2.3.4').and_return(true) } - it { is_expected.to run.with_params('1.2.3.255').and_return(true) } - it { is_expected.to run.with_params('1.2.3.256').and_return(false) } - it { is_expected.to run.with_params('1.2.3').and_return(false) } - it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } - it { is_expected.to run.with_params('fe00::1').and_return(true) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74').and_return(true) } - it { is_expected.to run.with_params('FE80:0000:CD12:D123:E2F8:47FF:FE09:DD74').and_return(true) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:zzzz').and_return(false) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09').and_return(false) } - it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74:dd74').and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params(1).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params('thisstring').and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_ipv4_address_spec.rb --- a/modules/stdlib/spec/functions/is_ipv4_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'is_ipv4_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - SharedData::IPV4_PATTERNS.each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - - SharedData::IPV4_NEGATIVE_PATTERNS.each do |value| - it { is_expected.to run.with_params(value).and_return(false) } - end - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_ipv6_address_spec.rb --- a/modules/stdlib/spec/functions/is_ipv6_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'is_ipv6_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) } - it { is_expected.to run.with_params('85a3:0000:0000:8a2e:0370:7334:100.100.100.100').and_return(true) } - it { is_expected.to run.with_params('1.2.3').and_return(false) } - it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334:ggg').and_return(false) } - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334').and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_mac_address_spec.rb --- a/modules/stdlib/spec/functions/is_mac_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'is_mac_address' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('00:a0:1f:12:7f:a0').and_return(true) } - it { is_expected.to run.with_params('00:A0:1F:12:7F:A0').and_return(true) } - it { is_expected.to run.with_params('80:00:02:09:fe:80:00:00:00:00:00:00:00:24:65:ff:ff:91:a3:12').and_return(true) } - it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) } - it { is_expected.to run.with_params('').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('ƒốưř').and_return(false) } - it { is_expected.to run.with_params('三+').and_return(false) } - end - - it { - pending 'should properly typecheck its arguments' - is_expected.to run.with_params(1).and_return(false) - } - it { - pending 'should properly typecheck its arguments' - is_expected.to run.with_params({}).and_return(false) - } - it { - pending 'should properly typecheck its arguments' - is_expected.to run.with_params([]).and_return(false) - } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_numeric_spec.rb --- a/modules/stdlib/spec/functions/is_numeric_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe 'is_numeric' do - it { is_expected.not_to eq(nil) } - - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - it { is_expected.to run.with_params(3).and_return(true) } - it { is_expected.to run.with_params('3').and_return(true) } - it { is_expected.to run.with_params(-3).and_return(true) } - it { is_expected.to run.with_params('-3').and_return(true) } - - it { is_expected.to run.with_params(3.7).and_return(true) } - it { is_expected.to run.with_params('3.7').and_return(true) } - it { is_expected.to run.with_params(-3.7).and_return(true) } - it { is_expected.to run.with_params('-3.7').and_return(true) } - - it { is_expected.to run.with_params('-342.2315e-12').and_return(true) } - - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('0001234').and_return(false) } - it { is_expected.to run.with_params(' - 1234').and_return(false) } - it { is_expected.to run.with_params(['aaa.com', 'bbb', 'ccc']).and_return(false) } - - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(7).and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(7).and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/is_string_spec.rb --- a/modules/stdlib/spec/functions/is_string_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -require 'spec_helper' - -describe 'is_string' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - - it { is_expected.to run.with_params(3).and_return(false) } - it { is_expected.to run.with_params('3').and_return(false) } - it { is_expected.to run.with_params(-3).and_return(false) } - it { is_expected.to run.with_params('-3').and_return(false) } - - it { is_expected.to run.with_params(3.7).and_return(false) } - it { is_expected.to run.with_params('3.7').and_return(false) } - it { is_expected.to run.with_params(-3.7).and_return(false) } - it { is_expected.to run.with_params('-3.7').and_return(false) } - - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params([1]).and_return(false) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params(true).and_return(false) } - it { is_expected.to run.with_params(false).and_return(false) } - it { is_expected.to run.with_params('one').and_return(true) } - it { is_expected.to run.with_params('0001234').and_return(true) } - it { is_expected.to run.with_params('aaa' => 'www.com').and_return(false) } - - context 'with deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('sponge').and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params('bob').and_return(true) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/join_keys_to_values_spec.rb --- a/modules/stdlib/spec/functions/join_keys_to_values_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'join_keys_to_values' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Takes exactly two arguments}) } - it { is_expected.to run.with_params({}, '', '').and_raise_error(Puppet::ParseError, %r{Takes exactly two arguments}) } - it { is_expected.to run.with_params('one', '').and_raise_error(TypeError, %r{The first argument must be a hash}) } - it { is_expected.to run.with_params({}, 2).and_raise_error(TypeError, %r{The second argument must be a string}) } - - it { is_expected.to run.with_params({}, '').and_return([]) } - it { is_expected.to run.with_params({}, ':').and_return([]) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) } - it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, ':').and_return(['ҝẽγ:√ạĺűē']) } - it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) } - end - - if Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0 - it { is_expected.to run.with_params({ 'key' => '' }, ':').and_return(['key:']) } - else - it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) } - end - - it 'runs join_keys_to_values(, ":") and return the proper array' do - is_expected.to run.with_params({ 'key1' => 'value1', 'key2' => 'value2' }, ':').and_return(['key1:value1', 'key2:value2']) - end - - it 'runs join_keys_to_values(, " ") and return the proper array' do - expected_result = ['key1 value1', 'key2 value2', 'key2 value3'] - is_expected.to run.with_params({ 'key1' => 'value1', 'key2' => ['value2', 'value3'] }, ' ').and_return(expected_result) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/join_spec.rb --- a/modules/stdlib/spec/functions/join_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'join', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the second.') - is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) } - - it { is_expected.to run.with_params([]).and_return('') } - it { is_expected.to run.with_params([], ':').and_return('') } - it { is_expected.to run.with_params(['one']).and_return('one') } - it { is_expected.to run.with_params(['one'], ':').and_return('one') } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') } - it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') } - it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/keys_spec.rb --- a/modules/stdlib/spec/functions/keys_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe 'keys', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params('key' => 'value').and_return(['key']) } - it 'returns the array of keys' do - result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }]) - expect(result).to match_array(['key1', 'key2']) - end - - it 'runs with UTF8 and double byte characters' do - result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }]) - expect(result).to match_array(['ҝểү', 'キー']) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/length_spec.rb --- a/modules/stdlib/spec/functions/length_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'length', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'length' expects 1 argument, got none}) } - it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, %r{'length' expects 1 argument, got 2}) } - it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Integer}) } - it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Boolean}) } - it { is_expected.to run.with_params('1').and_return(1) } - it { is_expected.to run.with_params('1.0').and_return(3) } - it { is_expected.to run.with_params([]).and_return(0) } - it { is_expected.to run.with_params(['a']).and_return(1) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } - - it { is_expected.to run.with_params({}).and_return(0) } - it { is_expected.to run.with_params('1' => '2').and_return(1) } - it { is_expected.to run.with_params('1' => '2', '4' => '4').and_return(2) } - it { is_expected.to run.with_params('€' => '@', '竹' => 'ǿňè').and_return(2) } - - it { is_expected.to run.with_params('').and_return(0) } - it { is_expected.to run.with_params('a').and_return(1) } - it { is_expected.to run.with_params('abc').and_return(3) } - it { is_expected.to run.with_params('abcd').and_return(4) } - it { is_expected.to run.with_params('万').and_return(1) } - it { is_expected.to run.with_params('āβćđ').and_return(4) } - - context 'when using a class extending String' do - it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return(9) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/load_module_metadata_spec.rb --- a/modules/stdlib/spec/functions/load_module_metadata_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe 'load_module_metadata' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'when calling with valid arguments' do - before :each do - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}') - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}') - # Additional modules used by litmus which are identified while running these dues to being in fixtures - allow(File).to receive(:read).with(%r{\/(provision|puppet_agent|facts)\/metadata.json}, :encoding => 'utf-8') - end - - context 'when calling with valid utf8 and double byte character arguments' do - before :each do - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - -この文字"}') - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - -この文字"}') - end - - let(:prefix) { 'C:' if Puppet::Util::Platform.windows? } - - it 'jsons parse the file' do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/") - allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(true) - allow(File).to receive(:read).with("#{prefix}/path/to/module/metadata.json").and_return('{"name": "spencer-science"}') - - result = subject.execute('science') - expect(result['name']).to eq('spencer-science') - end - - it 'fails by default if there is no metadata.json' do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/") - allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(false) - expect { subject.call(['science']) }.to raise_error(Puppet::ParseError) - end - - it 'returns nil if user allows empty metadata.json' do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return("#{prefix}/path/to/module/") - allow(File).to receive(:exists?).with("#{prefix}/path/to/module/metadata.json").and_return(false) - result = subject.execute('science', true) - expect(result).to eq({}) - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/loadjson_spec.rb --- a/modules/stdlib/spec/functions/loadjson_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -require 'spec_helper' - -describe 'loadjson' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - - describe 'when calling with valid arguments' do - before :each do - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}') - allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}') - # Additional modules used by litmus which are identified while running these dues to being in fixtures - allow(File).to receive(:read).with(%r{\/(provision|puppet_agent|facts)\/metadata.json}, :encoding => 'utf-8') - end - - context 'when a non-existing file is specified' do - let(:filename) do - if Puppet::Util::Platform.windows? - 'C:/tmp/doesnotexist' - else - '/tmp/doesnotexist' - end - end - - before(:each) do - allow(File).to receive(:exists?).with(filename).and_return(false).once - allow(PSON).to receive(:load).never - end - it { is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') } - it { is_expected.to run.with_params(filename, 'đẽƒằưļŧ' => '٧ẵłựέ').and_return('đẽƒằưļŧ' => '٧ẵłựέ') } - it { is_expected.to run.with_params(filename, 'デフォルト' => '値').and_return('デフォルト' => '値') } - end - - context 'when an existing file is specified' do - let(:filename) do - if Puppet::Util::Platform.windows? - 'C:/tmp/doesexist' - else - '/tmp/doesexist' - end - end - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } - - before(:each) do - allow(File).to receive(:exists?).with(filename).and_return(true).once - allow(File).to receive(:read).with(filename).and_return(json).once - allow(File).to receive(:read).with(filename).and_return(json).once - allow(PSON).to receive(:load).with(json).and_return(data).once - end - it { is_expected.to run.with_params(filename).and_return(data) } - end - - context 'when the file could not be parsed' do - let(:filename) do - if Puppet::Util::Platform.windows? - 'C:/tmp/doesexist' - else - '/tmp/doesexist' - end - end - let(:json) { '{"key":"value"}' } - - before(:each) do - allow(File).to receive(:exists?).with(filename).and_return(true).once - allow(File).to receive(:read).with(filename).and_return(json).once - allow(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!' - end - it { is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') } - end - - context 'when an existing URL is specified' do - let(:filename) do - 'https://example.local/myhash.json' - end - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(json) - expect(PSON).to receive(:load).with(json).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when an existing URL (with username and password) is specified' do - let(:filename) do - 'https://user1:pass1@example.local/myhash.json' - end - let(:url_no_auth) { 'https://example.local/myhash.json' } - let(:basic_auth) { { :http_basic_authentication => ['user1', 'pass1'] } } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } - - it { - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) - expect(PSON).to receive(:load).with(json).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when an existing URL (with username) is specified' do - let(:filename) do - 'https://user1@example.local/myhash.json' - end - let(:url_no_auth) { 'https://example.local/myhash.json' } - let(:basic_auth) { { :http_basic_authentication => ['user1', ''] } } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } - - it { - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(json) - expect(PSON).to receive(:load).with(json).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when the URL output could not be parsed, with default specified' do - let(:filename) do - 'https://example.local/myhash.json' - end - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - let(:json) { ',;{"key":"value"}' } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(json) - expect(PSON).to receive(:load).with(json).once.and_raise StandardError, 'Something terrible have happened!' - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - } - end - - context 'when the URL does not exist, with default specified' do - let(:filename) do - 'https://example.local/myhash.json' - end - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_raise OpenURI::HTTPError, '404 File not Found' - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/loadyaml_spec.rb --- a/modules/stdlib/spec/functions/loadyaml_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -require 'spec_helper' - -describe 'loadyaml' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - - context 'when a non-existing file is specified' do - let(:filename) { '/tmp/doesnotexist' } - - it "'default' => 'value'" do - expect(File).to receive(:exists?).with(filename).and_return(false).once - expect(YAML).to receive(:load_file).never - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - end - end - - context 'when an existing file is specified' do - let(:filename) { '/tmp/doesexist' } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - - it "returns 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'" do - expect(File).to receive(:exists?).with(filename).and_return(true).once - expect(YAML).to receive(:load_file).with(filename).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - end - end - - context 'when the file could not be parsed' do - let(:filename) { '/tmp/doesexist' } - - it 'filename /tmp/doesexist' do - expect(File).to receive(:exists?).with(filename).and_return(true).once - allow(YAML).to receive(:load_file).with(filename).once.and_raise(StandardError, 'Something terrible have happened!') - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - end - end - - context 'when an existing URL is specified' do - let(:filename) { 'https://example.local/myhash.yaml' } - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - let(:yaml) { 'Dummy YAML' } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(yaml) - expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when an existing URL (with username and password) is specified' do - let(:filename) { 'https://user1:pass1@example.local/myhash.yaml' } - let(:url_no_auth) { 'https://example.local/myhash.yaml' } - let(:basic_auth) { { :http_basic_authentication => ['user1', 'pass1'] } } - let(:yaml) { 'Dummy YAML' } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - - it { - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(yaml) - expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when an existing URL (with username) is specified' do - let(:filename) { 'https://user1@example.local/myhash.yaml' } - let(:url_no_auth) { 'https://example.local/myhash.yaml' } - let(:basic_auth) { { :http_basic_authentication => ['user1', ''] } } - let(:yaml) { 'Dummy YAML' } - let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値' } } - - it { - expect(OpenURI).to receive(:open_uri).with(url_no_auth, basic_auth).and_return(yaml) - expect(YAML).to receive(:safe_load).with(yaml).and_return(data).once - is_expected.to run.with_params(filename).and_return(data) - } - end - - context 'when an existing URL could not be parsed, with default specified' do - let(:filename) { 'https://example.local/myhash.yaml' } - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - let(:yaml) { 'Dummy YAML' } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_return(yaml) - expect(YAML).to receive(:safe_load).with(yaml).and_raise StandardError, 'Cannot parse data' - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - } - end - - context 'when a URL does not exist, with default specified' do - let(:filename) { 'https://example.local/myhash.yaml' } - let(:basic_auth) { { :http_basic_authentication => ['', ''] } } - let(:yaml) { 'Dummy YAML' } - - it { - expect(OpenURI).to receive(:open_uri).with(filename, basic_auth).and_raise OpenURI::HTTPError, '404 File not Found' - is_expected.to run.with_params(filename, 'default' => 'value').and_return('default' => 'value') - } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/lstrip_spec.rb --- a/modules/stdlib/spec/functions/lstrip_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'lstrip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params("\tone").and_return('one') } - it { is_expected.to run.with_params("\t one").and_return('one') } - it { is_expected.to run.with_params('one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params(' one ').and_return('one ') } - it { is_expected.to run.with_params(' ǿňè ').and_return('ǿňè ') } - it { is_expected.to run.with_params("\tone ").and_return('one ') } - it { is_expected.to run.with_params("\t one ").and_return('one ') } - it { is_expected.to run.with_params("one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params(" one \t").and_return("one \t") } - it { is_expected.to run.with_params("\tone \t").and_return("one \t") } - it { is_expected.to run.with_params("\t one \t").and_return("one \t") } - it { is_expected.to run.with_params(' o n e ').and_return('o n e ') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one ') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/max_spec.rb --- a/modules/stdlib/spec/functions/max_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'max', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(1, 2).and_return(2) } - it { is_expected.to run.with_params(1, 2, 3).and_return(3) } - it { is_expected.to run.with_params(3, 2, 1).and_return(3) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('two') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('two') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('two') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return('one') } - it { is_expected.to run.with_params('1', 'one').and_return('one') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.4e0') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.3e1) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/member_spec.rb --- a/modules/stdlib/spec/functions/member_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'member' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params([], '').and_return(false) } - it { is_expected.to run.with_params([], ['']).and_return(false) } - it { is_expected.to run.with_params([''], '').and_return(true) } - it { is_expected.to run.with_params([''], ['']).and_return(true) } - it { is_expected.to run.with_params([], 'one').and_return(false) } - it { is_expected.to run.with_params([], ['one']).and_return(false) } - it { is_expected.to run.with_params(['one'], 'one').and_return(true) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } - it { is_expected.to run.with_params([1, 2, 3, 4], [4, 2]).and_return(true) } - it { is_expected.to run.with_params([1, 'a', 'b', 4], [4, 'b']).and_return(true) } - it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } - it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/merge_spec.rb --- a/modules/stdlib/spec/functions/merge_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -require 'spec_helper' - -describe 'merge' do - it { is_expected.not_to eq(nil) } - it { - is_expected.to run \ - .with_params({}, 'two') \ - .and_raise_error( - ArgumentError, \ - Regexp.new(Regexp.escape("rejected: parameter 'args' expects a value of type Undef, Hash, or String[0, 0], got String")), - ) - } - it { - is_expected.to run \ - .with_params({}, 1) \ - .and_raise_error(ArgumentError, %r{parameter 'args' expects a value of type Undef, Hash, or String, got Integer}) - } - it { - is_expected.to run \ - .with_params({ 'one' => 1, 'three' => { 'four' => 4 } }, 'two' => 'dos', 'three' => { 'five' => 5 }) \ - .and_return('one' => 1, 'three' => { 'five' => 5 }, 'two' => 'dos') - } - - it { is_expected.to run.with_params.and_return({}) } - it { is_expected.to run.with_params({}).and_return({}) } - it { is_expected.to run.with_params({}, {}).and_return({}) } - it { is_expected.to run.with_params({}, {}, {}).and_return({}) } - - describe 'should accept empty strings as puppet undef' do - it { is_expected.to run.with_params({}, '').and_return({}) } - end - - it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return('key' => 'value') } - it { is_expected.to run.with_params({}, 'key' => 'value').and_return('key' => 'value') } - it { is_expected.to run.with_params({ 'key' => 'value1' }, 'key' => 'value2').and_return('key' => 'value2') } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, 'key3' => 'value3') \ - .and_return('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3') - } - describe 'should accept iterable and merge produced hashes' do - it { - is_expected.to run \ - .with_params([1, 2, 3]) \ - .with_lambda { |_hsh, val| { val => val } } \ - .and_return(1 => 1, 2 => 2, 3 => 3) - } - it { - is_expected.to run \ - .with_params([1, 2, 3]) \ - .with_lambda { |_hsh, val| { val => val } unless val == 2 } \ - .and_return(1 => 1, 3 => 3) - } - it { - is_expected.to run \ - .with_params([1, 2, 3]) \ - # rubocop:disable Style/Semicolon - .with_lambda { |_hsh, val| raise StopIteration if val == 3; { val => val } } \ - .and_return(1 => 1, 2 => 2) - } - it { - is_expected.to run \ - .with_params(['a', 'b', 'b', 'c', 'b']) \ - .with_lambda { |hsh, val| { val => (hsh[val] || 0) + 1 } } \ - .and_return('a' => 1, 'b' => 3, 'c' => 1) - } - it { - is_expected.to run \ - .with_params(['a', 'b', 'c']) \ - .with_lambda { |_hsh, idx, val| { idx => val } } \ - .and_return(0 => 'a', 1 => 'b', 2 => 'c') - } - it { - is_expected.to run \ - .with_params('a' => 'A', 'b' => 'B', 'c' => 'C') \ - .with_lambda { |_hsh, key, val| { key => "#{key}#{val}" } } \ - .and_return('a' => 'aA', 'b' => 'bB', 'c' => 'cC') - } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/min_spec.rb --- a/modules/stdlib/spec/functions/min_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'min', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(1, 2).and_return(1) } - it { is_expected.to run.with_params(1, 2, 3).and_return(1) } - it { is_expected.to run.with_params(3, 2, 1).and_return(1) } - it { is_expected.to run.with_params(12, 8).and_return(8) } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') } - it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') } - it { is_expected.to run.with_params('the', 'public', 'art', 'galleries').and_return('art') } - - describe 'implementation artifacts' do - it { is_expected.to run.with_params(1, 'one').and_return(1) } - it { is_expected.to run.with_params('1', 'one').and_return('1') } - it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.3e1') } - it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.4e0) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/num2bool_spec.rb --- a/modules/stdlib/spec/functions/num2bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'num2bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('abc').and_raise_error(Puppet::ParseError, %r{does not look like a number}) } - it { is_expected.to run.with_params(1).and_return(true) } - it { is_expected.to run.with_params('1').and_return(true) } - it { is_expected.to run.with_params(1.5).and_return(true) } - it { is_expected.to run.with_params('1.5').and_return(true) } - it { is_expected.to run.with_params(-1).and_return(false) } - it { is_expected.to run.with_params('-1').and_return(false) } - it { is_expected.to run.with_params(-1.5).and_return(false) } - it { is_expected.to run.with_params('-1.5').and_return(false) } - it { is_expected.to run.with_params(0).and_return(false) } - it { is_expected.to run.with_params('0').and_return(false) } - it { is_expected.to run.with_params([]).and_return(false) } - it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, %r{does not look like a number}) } - it { is_expected.to run.with_params({}).and_return(false) } - it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, %r{does not look like a number}) } - it { is_expected.to run.with_params(['-50', '1']).and_return(false) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/os_version_gte_spec.rb --- a/modules/stdlib/spec/functions/os_version_gte_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -require 'spec_helper' - -describe 'os_version_gte' do - context 'on Debian 9' do - let(:facts) do - { - :operatingsystem => 'Debian', - :operatingsystemmajrelease => '9', - } - end - - it { is_expected.to run.with_params('Debian', '9').and_return(true) } - it { is_expected.to run.with_params('Debian', '8').and_return(false) } - it { is_expected.to run.with_params('Debian', '8.0').and_return(false) } - it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(false) } - it { is_expected.to run.with_params('Fedora', '29').and_return(false) } - end - - context 'on Ubuntu 16.04' do - let(:facts) do - { - :operatingsystem => 'Ubuntu', - :operatingsystemmajrelease => '16.04', - } - end - - it { is_expected.to run.with_params('Debian', '9').and_return(false) } - it { is_expected.to run.with_params('Ubuntu', '16').and_return(false) } - it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(true) } - it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(true) } - it { is_expected.to run.with_params('Fedora', '29').and_return(false) } - end - - context 'with invalid params' do - let(:facts) do - { - :operatingsystem => 'Ubuntu', - :operatingsystemmajrelease => '16.04', - } - end - - it { is_expected.to run.with_params('123', 'abc').and_return(false) } - it { is_expected.to run.with_params([], 123).and_raise_error(ArgumentError) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/parsejson_spec.rb --- a/modules/stdlib/spec/functions/parsejson_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -require 'spec_helper' - -describe 'parsejson' do - it 'exists' do - is_expected.not_to eq(nil) - end - - it 'raises an error if called without any arguments' do - is_expected.to run.with_params - .and_raise_error(%r{wrong number of arguments}i) - end - - context 'with correct JSON data' do - it 'is able to parse JSON data with a Hash' do - is_expected.to run.with_params('{"a":"1","b":"2"}') - .and_return('a' => '1', 'b' => '2') - end - - it 'is able to parse JSON data with an Array' do - is_expected.to run.with_params('["a","b","c"]') - .and_return(['a', 'b', 'c']) - end - - it 'is able to parse empty JSON values' do - actual_array = ['[]', '{}'] - expected = [[], {}] - actual_array.each_with_index do |actual, index| - is_expected.to run.with_params(actual).and_return(expected[index]) - end - end - - it 'is able to parse JSON data with a mixed structure' do - is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}') - .and_return('a' => '1', 'b' => 2, 'c' => { 'd' => [true, false] }) - end - - it 'is able to parse JSON data with a UTF8 and double byte characters' do - is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}') - .and_return('×' => 'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] }) - end - - it 'does not return the default value if the data was parsed correctly' do - is_expected.to run.with_params('{"a":"1"}', 'default_value') - .and_return('a' => '1') - end - end - - context 'with incorrect JSON data' do - it 'raises an error with invalid JSON and no default' do - is_expected.to run.with_params('') - .and_raise_error(PSON::ParserError) - end - - it 'supports a structure for a default value' do - is_expected.to run.with_params('', 'a' => '1') - .and_return('a' => '1') - end - - ['', 1, 1.2, nil, true, false, [], {}, :yaml].each do |value| - it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do - is_expected.to run.with_params(value, 'default_value') - .and_return('default_value') - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/parseyaml_spec.rb --- a/modules/stdlib/spec/functions/parseyaml_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -require 'spec_helper' - -describe 'parseyaml' do - it 'exists' do - is_expected.not_to eq(nil) - end - - it 'raises an error if called without any arguments' do - is_expected.to run.with_params - .and_raise_error(%r{wrong number of arguments}i) - end - - context 'with correct YAML data' do - it 'is able to parse a YAML data with a String' do - actual_array = ['--- just a string', 'just a string'] - actual_array.each do |actual| - is_expected.to run.with_params(actual).and_return('just a string') - end - end - - it 'is able to parse YAML data with a Hash' do - is_expected.to run.with_params("---\na: '1'\nb: '2'\n") - .and_return('a' => '1', 'b' => '2') - end - - it 'is able to parse YAML data with an Array' do - is_expected.to run.with_params("---\n- a\n- b\n- c\n") - .and_return(['a', 'b', 'c']) - end - - it 'is able to parse YAML data with a mixed structure' do - is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n d:\n - :a\n - true\n - false\n") - .and_return('a' => '1', 'b' => 2, 'c' => { 'd' => [:a, true, false] }) - end - - it 'is able to parse YAML data with a UTF8 and double byte characters' do - is_expected.to run.with_params("---\na: ×\nこれ: 記号\nです:\n ©:\n - Á\n - ß\n") - .and_return('a' => '×', 'これ' => '記号', 'です' => { '©' => ['Á', 'ß'] }) - end - - it 'does not return the default value if the data was parsed correctly' do - is_expected.to run.with_params("---\na: '1'\n", 'default_value') - .and_return('a' => '1') - end - end - - it 'raises an error with invalid YAML and no default' do - is_expected.to run.with_params('["one"') - .and_raise_error(Psych::SyntaxError) - end - - context 'with incorrect YAML data' do - it 'supports a structure for a default value' do - is_expected.to run.with_params('', 'a' => '1') - .and_return('a' => '1') - end - - [1, 1.2, nil, true, false, [], {}, :yaml].each do |value| - it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do - is_expected.to run.with_params(value, 'default_value') - .and_return('default_value') - end - end - - context 'when running on modern rubies' do - ['---', '...', '*8', ''].each do |value| - it "should return the default value for an incorrect #{value.inspect} string parameter" do - is_expected.to run.with_params(value, 'default_value') - .and_return('default_value') - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/pick_default_spec.rb --- a/modules/stdlib/spec/functions/pick_default_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'pick_default' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(RuntimeError, %r{Must receive at least one argument}) } - - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('ớņệ', 'ťωơ').and_return('ớņệ') } - it { is_expected.to run.with_params('', 'two').and_return('two') } - it { is_expected.to run.with_params(:undef, 'two').and_return('two') } - it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } - it { is_expected.to run.with_params(nil, 'two').and_return('two') } - - ['', :undef, :undefined, nil, {}, [], 1, 'default'].each do |value| - describe "when providing #{value.inspect} as default" do - it { is_expected.to run.with_params('one', value).and_return('one') } - it { is_expected.to run.with_params('ớņệ', value).and_return('ớņệ') } - it { is_expected.to run.with_params([], value).and_return([]) } - it { is_expected.to run.with_params({}, value).and_return({}) } - it { is_expected.to run.with_params(value, value).and_return(mapped_value(value)) } - it { is_expected.to run.with_params(:undef, value).and_return(mapped_value(value)) } - it { is_expected.to run.with_params(:undefined, value).and_return(mapped_value(value)) } - it { is_expected.to run.with_params(nil, value).and_return(mapped_value(value)) } - end - end - - if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 || - Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0 - def mapped_value(v) - v - end - else - def mapped_value(v) - # Puppet 6.0.0 will always map arguments the same way as the Puppet Language - # even if function is called from Ruby via call_function - # The 3x function API expects nil and :undef to be represented as empty string - (v.nil? || v == :undef) ? '' : v - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/pick_spec.rb --- a/modules/stdlib/spec/functions/pick_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'pick' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{must receive at least one non empty value}) } - it { is_expected.to run.with_params('', nil, :undef, :undefined).and_raise_error(Puppet::ParseError, %r{must receive at least one non empty value}) } - it { is_expected.to run.with_params('one', 'two').and_return('one') } - it { is_expected.to run.with_params('', 'two').and_return('two') } - it { is_expected.to run.with_params(:undef, 'two').and_return('two') } - it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } - it { is_expected.to run.with_params(nil, 'two').and_return('two') } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') } - it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/prefix_spec.rb --- a/modules/stdlib/spec/functions/prefix_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'prefix' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the second.') - is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array or a Hash}) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{expected second argument to be a String}) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } - it { is_expected.to run.with_params(['ớņệ', 2]).and_return(['ớņệ', '2']) } - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([''], '').and_return(['']) } - it { is_expected.to run.with_params(['one'], 'pre').and_return(['preone']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'pre').and_return(['preone', 'pretwo', 'prethree']) } - it { is_expected.to run.with_params({}).and_return({}) } - it { is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) } - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'pre').and_return('prekey' => 'value') } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'pre') \ - .and_return('prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3') - } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/private_spec.rb --- a/modules/stdlib/spec/functions/private_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -require 'spec_helper' - -describe 'private' do - it 'issues a warning' do - expect(scope).to receive(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : unable to cut line to required length - begin - subject.execute - rescue # rubocop:disable Lint/HandleExceptions - # ignore this - end - end - - context 'when called from inside module' do - it 'does not fail' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('foo') - expect { - subject.execute - }.not_to raise_error - end - end - - context 'with an explicit failure message' do - it 'prints the failure message on error' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar') - expect { - subject.execute('failure message!') - }.to raise_error(Puppet::ParseError, %r{failure message!}) - end - end - - context 'when called from private class' do - it 'fails with a class error message' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar') - expect(scope.source).to receive(:name).and_return('foo::baz') - expect(scope.source).to receive(:type).and_return('hostclass') - expect { subject.execute }.to raise_error(Puppet::ParseError, %r{Class foo::baz is private}) - end - end - - context 'when called from private definition' do - it 'fails with a class error message' do - expect(scope).to receive(:lookupvar).with('module_name').and_return('foo') - expect(scope).to receive(:lookupvar).with('caller_module_name').and_return('bar') - expect(scope.source).to receive(:name).and_return('foo::baz') - expect(scope.source).to receive(:type).and_return('definition') - expect { subject.execute }.to raise_error(Puppet::ParseError, %r{Definition foo::baz is private}) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/pw_hash_spec.rb --- a/modules/stdlib/spec/functions/pw_hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -require 'spec_helper' - -describe 'pw_hash' do - it { is_expected.not_to eq(nil) } - - context 'when there are less than 3 arguments' do - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('password').and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('password', 'sha-256').and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - end - - context 'when there are more than 3 arguments' do - it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra').and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra', 'extra').and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - end - - context 'when the first argument is not a string' do - it { is_expected.to run.with_params([], 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) } - it { is_expected.to run.with_params({}, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) } - it { is_expected.to run.with_params(1, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) } - it { is_expected.to run.with_params(true, 'sha-256', 'salt').and_raise_error(ArgumentError, %r{first argument must be a string}) } - end - - context 'when the first argument is undefined' do - it { is_expected.to run.with_params('', 'sha-256', 'salt').and_return(nil) } - it { is_expected.to run.with_params(nil, 'sha-256', 'salt').and_return(nil) } - end - - context 'when the second argument is not a string' do - it { is_expected.to run.with_params('password', [], 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) } - it { is_expected.to run.with_params('password', {}, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) } - it { is_expected.to run.with_params('password', 1, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) } - it { is_expected.to run.with_params('password', true, 'salt').and_raise_error(ArgumentError, %r{second argument must be a string}) } - end - - context 'when the second argument is not one of the supported hashing algorithms' do - it { is_expected.to run.with_params('password', 'no such algo', 'salt').and_raise_error(ArgumentError, %r{is not a valid hash type}) } - end - - context 'when the third argument is not a string' do - it { is_expected.to run.with_params('password', 'sha-256', []).and_raise_error(ArgumentError, %r{third argument must be a string}) } - it { is_expected.to run.with_params('password', 'sha-256', {}).and_raise_error(ArgumentError, %r{third argument must be a string}) } - it { is_expected.to run.with_params('password', 'sha-256', 1).and_raise_error(ArgumentError, %r{third argument must be a string}) } - it { is_expected.to run.with_params('password', 'sha-256', true).and_raise_error(ArgumentError, %r{third argument must be a string}) } - end - - context 'when the third argument is empty' do - it { is_expected.to run.with_params('password', 'sha-512', '').and_raise_error(ArgumentError, %r{third argument must not be empty}) } - end - - context 'when the third argument contains invalid characters' do - it { is_expected.to run.with_params('password', 'sha-512', 'one%').and_raise_error(ArgumentError, %r{characters in salt must be in the set}) } - end - - context 'when running on a platform with a weak String#crypt implementation' do - before(:each) { allow_any_instance_of(String).to receive(:crypt).with('$1$1').and_return('a bad hash') } # rubocop:disable RSpec/AnyInstance : Unable to find a viable replacement - - it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, %r{system does not support enhanced salts}) } - end - - if RUBY_PLATFORM == 'java' || 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.' - describe 'on systems with enhanced salts support' do - it { is_expected.to run.with_params('password', 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } - it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') } - it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') } - end - - if Puppet::Util::Package.versioncmp(Puppet.version, '4.7.0') >= 0 - describe 'when arguments are sensitive' do - it { is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } - it { - is_expected.to run.with_params(Puppet::Pops::Types::PSensitiveType::Sensitive.new('password'), 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')) - .and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') - } - it { is_expected.to run.with_params('password', 'md5', Puppet::Pops::Types::PSensitiveType::Sensitive.new('salt')).and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') } - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/range_spec.rb --- a/modules/stdlib/spec/functions/range_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -require 'spec_helper' - -describe 'range' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the third.') - is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, %r{Unable to compute range}i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Unknown range format}i) } - end - - describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params.and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params('').and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params({}).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params([]).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params(true).and_raise_error(ArgumentError) - } - it { - is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 4 implementation' - is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError) - } - end - - context 'with characters as bounds' do - it { is_expected.to run.with_params('d', 'a').and_return([]) } - it { is_expected.to run.with_params('a', 'a').and_return(['a']) } - it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) } - it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) } - it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) } - it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) } - it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) } - it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) } - end - - context 'with strings as bounds' do - it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) } - it { is_expected.to run.with_params('two', 'one').and_return([]) } - it { is_expected.to run.with_params('true', 'false').and_return([]) } - it { is_expected.to run.with_params('false', 'true').and_return(['false']) } - end - - context 'with integers as bounds' do - it { is_expected.to run.with_params(4, 1).and_return([]) } - it { is_expected.to run.with_params(1, 1).and_return([1]) } - it { is_expected.to run.with_params(1, 2).and_return([1, 2]) } - it { is_expected.to run.with_params(1, 4).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, 1).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, '1').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params(1, 4, 2).and_return([1, 3]) } - it { is_expected.to run.with_params(1, 4, -2).and_return([1, 3]) } - it { is_expected.to run.with_params(1, 4, 3).and_return([1, 4]) } - it { is_expected.to run.with_params(1, 4, 4).and_return([1]) } - end - - context 'with integers as strings as bounds' do - it { is_expected.to run.with_params('4', '1').and_return([]) } - it { is_expected.to run.with_params('1', '1').and_return([1]) } - it { is_expected.to run.with_params('1', '2').and_return([1, 2]) } - it { is_expected.to run.with_params('1', '4').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', 1).and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', '1').and_return([1, 2, 3, 4]) } - it { is_expected.to run.with_params('1', '4', 2).and_return([1, 3]) } - it { is_expected.to run.with_params('1', '4', -2).and_return([1, 3]) } - it { is_expected.to run.with_params('1', '4', 3).and_return([1, 4]) } - it { is_expected.to run.with_params('1', '4', 4).and_return([1]) } - end - - context 'with prefixed numbers as strings as bounds' do - it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) } - it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) } - end - - context 'with prefixed numbers as utf8 strings as bounds' do - it { is_expected.to run.with_params('ħөŝŧ01', 'ħөŝŧ04').and_return(['ħөŝŧ01', 'ħөŝŧ02', 'ħөŝŧ03', 'ħөŝŧ04']) } - end - - context 'with prefixed numbers as double byte character strings as bounds' do - it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) } - end - - context 'with dash-range syntax' do - it { is_expected.to run.with_params('4-1').and_return([]) } - it { is_expected.to run.with_params('1-1').and_return([1]) } - it { is_expected.to run.with_params('1-2').and_return([1, 2]) } - it { is_expected.to run.with_params('1-4').and_return([1, 2, 3, 4]) } - end - - context 'with two-dot-range syntax' do - it { is_expected.to run.with_params('4..1').and_return([]) } - it { is_expected.to run.with_params('1..1').and_return([1]) } - it { is_expected.to run.with_params('1..2').and_return([1, 2]) } - it { is_expected.to run.with_params('1..4').and_return([1, 2, 3, 4]) } - end - - context 'with three-dot-range syntax' do - it { is_expected.to run.with_params('4...1').and_return([]) } - it { is_expected.to run.with_params('1...1').and_return([]) } - it { is_expected.to run.with_params('1...2').and_return([1]) } - it { is_expected.to run.with_params('1...3').and_return([1, 2]) } - it { is_expected.to run.with_params('1...5').and_return([1, 2, 3, 4]) } - end - - describe 'when passing mixed arguments as bounds' do - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length - is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds}) - } - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length - is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds}) - } - it { - pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially') # rubocop:disable Metrics/LineLength : unable to cut line to required length - is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, %r{cannot interpolate between numeric and non-numeric bounds}) - } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/regexpescape_spec.rb --- a/modules/stdlib/spec/functions/regexpescape_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe 'regexpescape' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - end - - describe 'handling normal strings' do - it 'calls ruby\'s Regexp.escape function' do - expect(Regexp).to receive(:escape).with('regexp_string').and_return('escaped_regexp_string').once - is_expected.to run.with_params('regexp_string').and_return('escaped_regexp_string') - end - end - - describe 'handling classes derived from String' do - it 'calls ruby\'s Regexp.escape function' do - regexp_string = AlsoString.new('regexp_string') - expect(Regexp).to receive(:escape).with(regexp_string).and_return('escaped_regexp_string').once - is_expected.to run.with_params(regexp_string).and_return('escaped_regexp_string') - end - end - - describe 'strings in arrays handling' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one*', 'two']).and_return(['one\*', 'two']) } - it { is_expected.to run.with_params(['one*', 1, true, {}, 'two']).and_return(['one\*', 1, true, {}, 'two']) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(['ŏʼnε*']).and_return(['ŏʼnε\*']) } - it { is_expected.to run.with_params(['インターネット*']).and_return(['インターネット\*']) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/reject_spec.rb --- a/modules/stdlib/spec/functions/reject_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'reject' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], 'pattern', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - it { - pending('reject does not actually check this, and raises NoMethodError instead') - is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array}) - } - it { - pending('reject does not actually check this, and raises NoMethodError instead') - is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array}) - } - it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) } - it { is_expected.to run.with_params(['όʼnệ', 'ţщồ', 'ţңяέέ'], 'ţ(щồ|ңяέέ)').and_return(['όʼnệ']) } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/reverse_spec.rb --- a/modules/stdlib/spec/functions/reverse_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe 'reverse' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } - it { is_expected.to run.with_params(['ổňë', 'ťŵọ', 'ŧңяəė', 'ƒŏůŗ']).and_return(['ƒŏůŗ', 'ŧңяəė', 'ťŵọ', 'ổňë']) } - - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('abc').and_return('cba') } - it { is_expected.to run.with_params('abcd').and_return('dcba') } - it { is_expected.to run.with_params('āβćđ').and_return('đćβā') } - - context 'when using a class extending String' do - it 'calls its reverse method' do - value = AlsoString.new('asdfghjkl') - expect_any_instance_of(AlsoString).to receive(:reverse).and_return('foo') # rubocop:disable RSpec/AnyInstance - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/round_spec.rb --- a/modules/stdlib/spec/functions/round_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe 'round', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params(34.3).and_return(34) } - it { is_expected.to run.with_params(-34.3).and_return(-34) } - it { is_expected.to run.with_params(34.5).and_return(35) } - it { is_expected.to run.with_params(-34.5).and_return(-35) } - it { is_expected.to run.with_params(34.7).and_return(35) } - it { is_expected.to run.with_params(-34.7).and_return(-35) } - it { is_expected.to run.with_params('test').and_raise_error Puppet::ParseError } - it { is_expected.to run.with_params('test', 'best').and_raise_error Puppet::ParseError } - it { is_expected.to run.with_params(3, 4).and_raise_error Puppet::ParseError } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/rstrip_spec.rb --- a/modules/stdlib/spec/functions/rstrip_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'rstrip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return(' one') } - it { is_expected.to run.with_params(' one').and_return(' one') } - it { is_expected.to run.with_params("\tone").and_return("\tone") } - it { is_expected.to run.with_params("\t one").and_return("\t one") } - it { is_expected.to run.with_params('one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return(' one') } - it { is_expected.to run.with_params(' one ').and_return(' one') } - it { is_expected.to run.with_params(' ǿňè ').and_return(' ǿňè') } - it { is_expected.to run.with_params("\tone ").and_return("\tone") } - it { is_expected.to run.with_params("\t one ").and_return("\t one") } - it { is_expected.to run.with_params("one\t").and_return('one') } - it { is_expected.to run.with_params(" one\t").and_return(' one') } - it { is_expected.to run.with_params(" one\t").and_return(' one') } - it { is_expected.to run.with_params("\tone\t").and_return("\tone") } - it { is_expected.to run.with_params("\t one\t").and_return("\t one") } - it { is_expected.to run.with_params(' o n e ').and_return(' o n e') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return(' one') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/seeded_rand_spec.rb --- a/modules/stdlib/spec/functions/seeded_rand_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -require 'spec_helper' - -describe 'seeded_rand' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(0, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(1.5, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(-10, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params('-10', '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params('string', '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params([], '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params({}, '').and_raise_error(ArgumentError, %r{first argument must be a positive integer}) } - it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, %r{second argument must be a string}) } - it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, %r{second argument must be a string}) } - it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, %r{second argument must be a string}) } - - it 'provides a random number strictly less than the given max' do - expect(seeded_rand(3, 'seed')).to satisfy { |n| n.to_i < 3 } # rubocop:disable Lint/AmbiguousBlockAssociation : Cannot parenthesize without break code or violating other Rubocop rules - end - - it 'provides a random number greater or equal to zero' do - expect(seeded_rand(3, 'seed')).to satisfy { |n| n.to_i >= 0 } # rubocop:disable Lint/AmbiguousBlockAssociation : Cannot parenthesize without break code or violating other Rubocop rules - end - - it "provides the same 'random' value on subsequent calls for the same host" do - expect(seeded_rand(10, 'seed')).to eql(seeded_rand(10, 'seed')) - end - - it 'allows seed to control the random value on a single host' do - first_random = seeded_rand(1000, 'seed1') - second_different_random = seeded_rand(1000, 'seed2') - - expect(first_random).not_to eql(second_different_random) - end - - it 'does not return different values for different hosts' do - val1 = seeded_rand(1000, 'foo', :host => 'first.host.com') - val2 = seeded_rand(1000, 'foo', :host => 'second.host.com') - - expect(val1).to eql(val2) - end - - def seeded_rand(max, seed, args = {}) - host = args[:host] || '127.0.0.1' - - # workaround not being able to use let(:facts) because some tests need - # multiple different hostnames in one context - allow(scope).to receive(:lookupvar).with('::fqdn', {}).and_return(host) - - scope.function_seeded_rand([max, seed]) - end - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(1000, 'ǿňè') } - it { is_expected.to run.with_params(1000, '文字列') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/seeded_rand_string_spec.rb --- a/modules/stdlib/spec/functions/seeded_rand_string_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'seeded_rand_string' do - it { is_expected.not_to be(nil) } - - # Test for erroneous params - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects between.+got none}i) } - it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{expects between.+got 1}i) } - it { is_expected.to run.with_params('1', 'hello').and_raise_error(ArgumentError, %r{parameter 'length' expects an Integer value}i) } - it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, %r{parameter 'seed' expects a String value}i) } - it { is_expected.to run.with_params(1, 'hello', 1).and_raise_error(ArgumentError, %r{parameter 'charset' expects a.+String}i) } - - # Test regular run - it { is_expected.to run.with_params(100, 'hello') } - - # Test custom charsets - it { is_expected.to run.with_params(100, 'hello', 'abcd').and_return(%r{[a-d]{100}}) } - it { is_expected.to run.with_params(100, 'hello', 'abcdefgh').and_return(%r{[a-h]{100}}) } - it { is_expected.to run.with_params(100, 'hello', 'ab,|').and_return(%r{[ab,|]{100}}) } - - # Test behavior - it 'generates the same string with the same seed' do - rand_str_one = call_function(:seeded_rand_string, 300, 'my_seed') - rand_str_two = call_function(:seeded_rand_string, 300, 'my_seed') - - expect(rand_str_one).to eq(rand_str_two) - end - it 'generates different strings if seeded differently' do - rand_str_one = call_function(:seeded_rand_string, 300, 'my_seed_one') - rand_str_two = call_function(:seeded_rand_string, 300, 'my_seed_two') - - expect(rand_str_one).not_to eq(rand_str_two) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/shell_escape_spec.rb --- a/modules/stdlib/spec/functions/shell_escape_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe 'shell_escape' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation' do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'stringification' do - it { is_expected.to run.with_params(10).and_return('10') } - it { is_expected.to run.with_params(false).and_return('false') } - end - - describe 'escaping' do - it { is_expected.to run.with_params('foo').and_return('foo') } - it { is_expected.to run.with_params('foo bar').and_return('foo\ bar') } - it { - is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?') - .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') - } - end - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('スペー スを含むテ キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') } - it { is_expected.to run.with_params('μťƒ 8 ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/shell_join_spec.rb --- a/modules/stdlib/spec/functions/shell_join_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'shell_join' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation' do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(['foo'], ['bar']).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{is not an Array}i) } - end - - describe 'shell argument joining' do - it { is_expected.to run.with_params(['foo']).and_return('foo') } - it { is_expected.to run.with_params(['foo', 'bar']).and_return('foo bar') } - it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') } - it { - is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) - .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') - } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(['μťƒ', '8', 'ŧĕχť']).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') } - it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') } - end - end - - describe 'stringification' do - it { is_expected.to run.with_params([10, false, 'foo']).and_return('10 false foo') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/shell_split_spec.rb --- a/modules/stdlib/spec/functions/shell_split_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe 'shell_split' do - it { is_expected.not_to eq(nil) } - - describe 'signature validation' do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('foo', 'bar').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'stringification' do - it { is_expected.to run.with_params(10).and_return(['10']) } - it { is_expected.to run.with_params(false).and_return(['false']) } - end - - describe 'shell line spliting' do - it { is_expected.to run.with_params('foo').and_return(['foo']) } - it { is_expected.to run.with_params('foo bar').and_return(['foo', 'bar']) } - it { - is_expected.to run.with_params('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') - .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) - } - it { - is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') - .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) - } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(['μťƒ', '8', 'ŧĕχť']) } - it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/shuffle_spec.rb --- a/modules/stdlib/spec/functions/shuffle_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'shuffle' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - - context 'when running with a specific seed' do - # make tests deterministic - before(:each) { srand(2) } - - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } - - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('abc').and_return('bac') } - it { is_expected.to run.with_params('abcd').and_return('dcba') } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') } - it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') } - end - - context 'when using a class extending String' do - it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/size_spec.rb --- a/modules/stdlib/spec/functions/size_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'size', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Unknown type given}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Unknown type given}) } - it { is_expected.to run.with_params('1').and_raise_error(Puppet::ParseError, %r{Requires either string, array or hash to work}) } - it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, %r{Requires either string, array or hash to work}) } - it { is_expected.to run.with_params([]).and_return(0) } - it { is_expected.to run.with_params(['a']).and_return(1) } - it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } - it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } - - it { is_expected.to run.with_params({}).and_return(0) } - it { is_expected.to run.with_params('1' => '2').and_return(1) } - it { is_expected.to run.with_params('1' => '2', '4' => '4').and_return(2) } - it { is_expected.to run.with_params('€' => '@', '竹' => 'ǿňè').and_return(2) } - - it { is_expected.to run.with_params('').and_return(0) } - it { is_expected.to run.with_params('a').and_return(1) } - it { is_expected.to run.with_params('abc').and_return(3) } - it { is_expected.to run.with_params('abcd').and_return(4) } - it { is_expected.to run.with_params('万').and_return(1) } - it { is_expected.to run.with_params('āβćđ').and_return(4) } - - context 'when using a class extending String', :unless => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') == 0 do - it 'calls its size method' do - value = AlsoString.new('asdfghjkl') - expect(value).to receive(:size).and_return('foo') - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/sort_spec.rb --- a/modules/stdlib/spec/functions/sort_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe 'sort', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('stricter input checking') - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{requires string or array}) - } - it { - pending('stricter input checking') - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{requires string or array}) - } - it { - pending('stricter input checking') - is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{requires string or array}) - } - end - - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['c', 'b', 'a']).and_return(['a', 'b', 'c']) } - end - - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('cbda').and_return('abcd') } - end - - context 'when called with a number' do - it { is_expected.to run.with_params('9478').and_return('4789') } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/sprintf_hash_spec.rb --- a/modules/stdlib/spec/functions/sprintf_hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe 'sprintf_hash' do - it 'exists' do - is_expected.not_to eq(nil) - end - - context 'with param count' do - it 'fails with no arguments' do - is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 2 arguments}i) - end - it 'fails with 1 argument' do - is_expected.to run.with_params('').and_raise_error(ArgumentError, %r{expects 2 arguments}i) - end - it 'fails with too many arguments' do - is_expected.to run.with_params('', '', '').and_raise_error(ArgumentError, %r{expects 2 arguments}i) - end - end - - context 'with param type' do - it 'fails with wrong format type' do - is_expected.to run.with_params(false, {}).and_raise_error(ArgumentError, %r{parameter 'format' expects a String value}i) - end - it 'fails with wrong arguments type' do - is_expected.to run.with_params('', false).and_raise_error(ArgumentError, %r{parameter 'arguments' expects a Hash value}i) - end - end - - it 'prints formats with name placeholders' do - is_expected.to run.with_params('string %s and integer %b', 'foo' => '_foo_', 'bar' => 5) # rubocop:disable Style/FormatStringToken : Template tokens needed for purposes of test - .and_return('string _foo_ and integer 101') - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/squeeze_spec.rb --- a/modules/stdlib/spec/functions/squeeze_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -require 'spec_helper' - -describe 'squeeze' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) } - it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) } - it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) } - - context 'when squeezing a single string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaa').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') } - it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') } - end - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậậậậ').and_return('ậ') } - it { is_expected.to run.with_params('語語語語語語語', '語').and_return('語') } - it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậ語語語語©©©©©', '©').and_return('ậậậậậậậậậậậậậậậậậ語語語語©') } - end - - context 'when squeezing values in an array' do - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \ - .and_return(['', 'a', 'a', 'abc']) - } - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \ - .and_return(['', 'a', 'a', 'abbbbbbbbbbcccccccccc']) - } - it { - is_expected.to run \ - .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \ - .and_return(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc']) - } - end - - context 'when using a class extending String' do - it 'calls its squeeze method' do - value = AlsoString.new('aaaaaaaaa') - expect_any_instance_of(AlsoString).to receive(:squeeze).and_return('foo') # rubocop:disable RSpec/AnyInstance - expect(subject).to run.with_params(value).and_return('foo') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/str2bool_spec.rb --- a/modules/stdlib/spec/functions/str2bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'str2bool' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Unknown type of boolean given}) } - - describe 'when testing values that mean "true"' do - ['TRUE', '1', 't', 'y', 'true', 'yes', true].each do |value| - it { is_expected.to run.with_params(value).and_return(true) } - end - end - - describe 'when testing values that mean "false"' do - ['FALSE', '', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined'].each do |value| - it { is_expected.to run.with_params(value).and_return(false) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/str2saltedsha512_spec.rb --- a/modules/stdlib/spec/functions/str2saltedsha512_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'str2saltedsha512' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('password', 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires a String argument}) } - - context 'when running with a specific seed' do - # make tests deterministic - before(:each) { srand(2) } - - it { - is_expected.to run.with_params('') - .and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a') - } - it { - is_expected.to run.with_params('password') - .and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956') - } - it { - is_expected.to run.with_params('verylongpassword') - .and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039') - } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/strftime_spec.rb --- a/modules/stdlib/spec/functions/strftime_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'strftime' do - it 'exists' do - expect(Puppet::Parser::Functions.function('strftime')).to eq('function_strftime') - end - - it 'raises a ParseError if there is less than 1 arguments' do - expect { scope.function_strftime([]) }.to(raise_error(Puppet::ParseError)) - end - - it 'using %s should be higher then when I wrote this test' do - result = scope.function_strftime(['%s']) - expect(result.to_i).to(be > 1_311_953_157) - end - - it 'using %s should be greater than 1.5 trillion' do - result = scope.function_strftime(['%s']) - expect(result.to_i).to(be > 1_500_000_000) - end - - it 'returns a date when given %Y-%m-%d' do - result = scope.function_strftime(['%Y-%m-%d']) - expect(result).to match(%r{^\d{4}-\d{2}-\d{2}$}) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/strip_spec.rb --- a/modules/stdlib/spec/functions/strip_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'strip', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work with}) } - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params(' ').and_return('') } - it { is_expected.to run.with_params("\t").and_return('') } - it { is_expected.to run.with_params("\t ").and_return('') } - it { is_expected.to run.with_params('one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params(' one').and_return('one') } - it { is_expected.to run.with_params("\tone").and_return('one') } - it { is_expected.to run.with_params("\t one").and_return('one') } - it { is_expected.to run.with_params('one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return('one') } - it { is_expected.to run.with_params(' one ').and_return('one') } - it { is_expected.to run.with_params("\tone ").and_return('one') } - it { is_expected.to run.with_params("\t one ").and_return('one') } - it { is_expected.to run.with_params("one \t").and_return('one') } - it { is_expected.to run.with_params(" one \t").and_return('one') } - it { is_expected.to run.with_params(" one \t").and_return('one') } - it { is_expected.to run.with_params("\tone \t").and_return('one') } - it { is_expected.to run.with_params("\t one \t").and_return('one') } - it { is_expected.to run.with_params(' o n e ').and_return('o n e') } - it { is_expected.to run.with_params(' ỏŋέ ').and_return('ỏŋέ') } - it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/suffix_spec.rb --- a/modules/stdlib/spec/functions/suffix_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'suffix' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the second.') - is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array}) } - it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{expected second argument to be a String}) } - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } - it { is_expected.to run.with_params([], '').and_return([]) } - it { is_expected.to run.with_params([''], '').and_return(['']) } - it { is_expected.to run.with_params(['one'], 'post').and_return(['onepost']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) } - it { is_expected.to run.with_params(['ỗńέ', 'ťשׂǿ', 'ŧҺř℮ə'], 'рổŝţ').and_return(['ỗńέрổŝţ', 'ťשׂǿрổŝţ', 'ŧҺř℮əрổŝţ']) } - - it { is_expected.to run.with_params({}).and_return({}) } - it { is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) } - it { is_expected.to run.with_params({}, '').and_return({}) } - it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') } - it { is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return('keypost' => 'value') } - it { - is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \ - .and_return('key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3') - } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/swapcase_spec.rb --- a/modules/stdlib/spec/functions/swapcase_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'swapcase' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - describe 'with strings as inputs' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('one').and_return('ONE') } - it { is_expected.to run.with_params('ONE').and_return('one') } - it { is_expected.to run.with_params('oNe').and_return('OnE') } - end - describe 'with arrays as inputs' do - it { is_expected.to run.with_params([]).and_return([]) } - describe 'only containing strings' do - it { is_expected.to run.with_params(['']).and_return(['']) } - it { is_expected.to run.with_params(['one']).and_return(['ONE']) } - it { is_expected.to run.with_params(['ONE']).and_return(['one']) } - it { is_expected.to run.with_params(['oNe']).and_return(['OnE']) } - it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) } - it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) } - it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) } - end - describe 'containing mixed types' do - it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) } - it { is_expected.to run.with_params(['OnE', 1]).and_return(['oNe', 1]) } - it { is_expected.to run.with_params(['OnE', []]).and_return(['oNe', []]) } - it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) } - end - end - it 'accepts objects which extend String' do - is_expected.to run.with_params(AlsoString.new('OnE')).and_return('oNe') - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/time_spec.rb --- a/modules/stdlib/spec/functions/time_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'time' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - context 'when running at a specific time' do - before(:each) do - # get a value before stubbing the function - test_time = Time.utc(2006, 10, 13, 8, 15, 11) - allow(Time).to receive(:new).with(no_args).and_return(test_time).once - end - it { is_expected.to run.with_params.and_return(1_160_727_311) } - it { is_expected.to run.with_params('').and_return(1_160_727_311) } - it { is_expected.to run.with_params([]).and_return(1_160_727_311) } - it { is_expected.to run.with_params({}).and_return(1_160_727_311) } - it { is_expected.to run.with_params('foo').and_return(1_160_727_311) } - it { is_expected.to run.with_params('UTC').and_return(1_160_727_311) } - it { is_expected.to run.with_params('America/New_York').and_return(1_160_727_311) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/to_bytes_spec.rb --- a/modules/stdlib/spec/functions/to_bytes_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -require 'spec_helper' - -describe 'to_bytes' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('1', 'extras').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([]).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) Array (in)?to String}) } - it { is_expected.to run.with_params({}).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) Hash (in)?to String}) } - it { is_expected.to run.with_params(true).and_raise_error(TypeError, %r{(can't convert|no implicit conversion of) (TrueClass|true) (in)?to String}) } - - describe 'when passing numbers' do - it { is_expected.to run.with_params(0).and_return(0) } - it { is_expected.to run.with_params(1).and_return(1) } - it { is_expected.to run.with_params(-1).and_return(-1) } - it { is_expected.to run.with_params(1.1).and_return(1.1) } - it { is_expected.to run.with_params(-1.1).and_return(-1.1) } - end - - describe 'when passing numbers as strings' do - describe 'without a unit' do - it { is_expected.to run.with_params('1').and_return(1) } - it { is_expected.to run.with_params('-1').and_return(-1) } - # these are so wrong - it { is_expected.to run.with_params('1.1').and_return(1) } - it { is_expected.to run.with_params('-1.1').and_return(-1) } - end - - describe 'with a unit' do - it { is_expected.to run.with_params('1k').and_return(1024) } - it { is_expected.to run.with_params('-1kB').and_return(-1024) } - it { is_expected.to run.with_params('1M').and_return(1024 * 1024) } - it { is_expected.to run.with_params('1G').and_return(1024 * 1024 * 1024) } - it { is_expected.to run.with_params('1T').and_return(1024 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('1P').and_return(1024 * 1024 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('1E').and_return(1024 * 1024 * 1024 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('1.5e3M').and_return(1_572_864_000) } - - it { is_expected.to run.with_params('4k').and_return(4 * 1024) } - it { is_expected.to run.with_params('-4kB').and_return(4 * -1024) } - it { is_expected.to run.with_params('4M').and_return(4 * 1024 * 1024) } - it { is_expected.to run.with_params('4G').and_return(4 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('4T').and_return(4 * 1024 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('4P').and_return(4 * 1024 * 1024 * 1024 * 1024 * 1024) } - it { is_expected.to run.with_params('4E').and_return(4 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024) } - - # these are so wrong - it { is_expected.to run.with_params('1.0001 k').and_return(1024) } - it { is_expected.to run.with_params('-1.0001 kB').and_return(-1024) } - end - - describe 'with a unknown unit' do - it { is_expected.to run.with_params('1KB').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - it { is_expected.to run.with_params('1K').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - it { is_expected.to run.with_params('1mb').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - it { is_expected.to run.with_params('1m').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - it { is_expected.to run.with_params('1%').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - it { is_expected.to run.with_params('1 p').and_raise_error(Puppet::ParseError, %r{Unknown prefix}) } - end - end - - # these are so wrong - describe 'when passing random stuff' do - it { is_expected.to run.with_params('-1....1').and_return(-1) } - it { is_expected.to run.with_params('-1.e.e.e.1').and_return(-1) } - it { is_expected.to run.with_params('-1+1').and_return(-1) } - it { is_expected.to run.with_params('1-1').and_return(1) } - it { is_expected.to run.with_params('1 kaboom').and_return(1024) } - it { is_expected.to run.with_params('kaboom').and_return(0) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/to_json_pretty_spec.rb --- a/modules/stdlib/spec/functions/to_json_pretty_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -require 'spec_helper' - -describe 'to_json_pretty' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params([]).and_return("[\n\n]\n") } - it { is_expected.to run.with_params(['one']).and_return("[\n \"one\"\n]\n") } - it { is_expected.to run.with_params(['one', 'two']).and_return("[\n \"one\",\n \"two\"\n]\n") } - it { is_expected.to run.with_params({}).and_return("{\n}\n") } - it { is_expected.to run.with_params('key' => 'value').and_return("{\n \"key\": \"value\"\n}\n") } - it { - is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) - .and_return("{\n \"one\": {\n \"oneA\": \"A\",\n \"oneB\": {\n \"oneB1\": \"1\",\n \"oneB2\": \"2\"\n }\n },\n \"two\": [\n \"twoA\",\n \"twoB\"\n ]\n}\n") # rubocop:disable Metrics/LineLength : Unable to reduce line to required length - } - it { is_expected.to run.with_params({ 'one' => '1', 'two' => nil }, true).and_return("{\n \"one\": \"1\"\n}\n") } - it { is_expected.to run.with_params(['one', 'two', nil, 'three'], true).and_return("[\n \"one\",\n \"two\",\n \"three\"\n]\n") } - it { is_expected.to run.with_params(['one', 'two', nil, 'three'], true, 'indent' => '@@@@').and_return("[\n@@@@\"one\",\n@@@@\"two\",\n@@@@\"three\"\n]\n") } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/to_json_spec.rb --- a/modules/stdlib/spec/functions/to_json_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe 'to_json' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params('').and_return('""') } - it { is_expected.to run.with_params(true).and_return('true') } - it { is_expected.to run.with_params('one').and_return('"one"') } - it { is_expected.to run.with_params([]).and_return('[]') } - it { is_expected.to run.with_params(['one']).and_return('["one"]') } - it { is_expected.to run.with_params(['one', 'two']).and_return('["one","two"]') } - it { is_expected.to run.with_params({}).and_return('{}') } - it { is_expected.to run.with_params('key' => 'value').and_return('{"key":"value"}') } - it { - is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) - .and_return('{"one":{"oneA":"A","oneB":{"oneB1":"1","oneB2":"2"}},"two":["twoA","twoB"]}') - } - - it { is_expected.to run.with_params('‰').and_return('"‰"') } - it { is_expected.to run.with_params('竹').and_return('"竹"') } - it { is_expected.to run.with_params('Ü').and_return('"Ü"') } - it { is_expected.to run.with_params('∇').and_return('"∇"') } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/to_yaml_spec.rb --- a/modules/stdlib/spec/functions/to_yaml_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'to_yaml' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params('').and_return("--- ''\n") } - it { is_expected.to run.with_params(true).and_return(%r{--- true\n}) } - it { is_expected.to run.with_params('one').and_return(%r{--- one\n}) } - it { is_expected.to run.with_params([]).and_return("--- []\n") } - it { is_expected.to run.with_params(['one']).and_return("---\n- one\n") } - it { is_expected.to run.with_params(['one', 'two']).and_return("---\n- one\n- two\n") } - it { is_expected.to run.with_params({}).and_return("--- {}\n") } - it { is_expected.to run.with_params('key' => 'value').and_return("---\nkey: value\n") } - it { - is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) - .and_return("---\none:\n oneA: A\n oneB:\n oneB1: '1'\n oneB2: '2'\ntwo:\n- twoA\n- twoB\n") - } - - it { is_expected.to run.with_params('‰').and_return("--- \"‰\"\n") } - it { is_expected.to run.with_params('∇').and_return("--- \"∇\"\n") } -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/try_get_value_spec.rb --- a/modules/stdlib/spec/functions/try_get_value_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -require 'spec_helper' - -describe 'try_get_value' do - let(:data) do - { - 'a' => { - 'g' => '2', - 'e' => [ - 'f0', - 'f1', - { - 'x' => { - 'y' => 'z', - }, - }, - 'f3', - ], - }, - 'b' => true, - 'c' => false, - 'd' => '1', - } - end - - context 'with single values' do - it 'exists' do - is_expected.not_to eq(nil) - end - - it 'is able to return a single value' do - is_expected.to run.with_params('test').and_return('test') - end - - it 'uses the default value if data is a single value and path is present' do - is_expected.to run.with_params('test', 'path', 'default').and_return('default') - end - - it 'returns default if there is no data' do - is_expected.to run.with_params(nil, nil, 'default').and_return('default') - end - - it 'is able to use data structures as default values' do - is_expected.to run.with_params('test', 'path', data).and_return(data) - end - end - - context 'with structure values' do - it 'is able to extracts a single hash value' do - is_expected.to run.with_params(data, 'd', 'default').and_return('1') - end - - it 'is able to extract a deeply nested hash value' do - is_expected.to run.with_params(data, 'a/g', 'default').and_return('2') - end - - it 'returns the default value if the path is not found' do - is_expected.to run.with_params(data, 'missing', 'default').and_return('default') - end - - it 'returns the default value if the path is too long' do - is_expected.to run.with_params(data, 'a/g/c/d', 'default').and_return('default') - end - - it 'supports an array index in the path' do - is_expected.to run.with_params(data, 'a/e/1', 'default').and_return('f1') - end - - it 'returns the default value if an array index is not a number' do - is_expected.to run.with_params(data, 'a/b/c', 'default').and_return('default') - end - - it 'returns the default value if and index is out of array length' do - is_expected.to run.with_params(data, 'a/e/5', 'default').and_return('default') - end - - it 'is able to path though both arrays and hashes' do - is_expected.to run.with_params(data, 'a/e/2/x/y', 'default').and_return('z') - end - - it 'is able to return "true" value: default' do - is_expected.to run.with_params(data, 'b', 'default').and_return(true) - end - - it 'is able to return "true" value' do - is_expected.to run.with_params(data, 'm', true).and_return(true) - end - - it 'is able to return "false" value: default' do - is_expected.to run.with_params(data, 'c', 'default').and_return(false) - end - - it 'is able to return "false" value' do - is_expected.to run.with_params(data, 'm', false).and_return(false) - end - - it 'returns "nil" if value is not found and no default value is provided' do - is_expected.to run.with_params(data, 'a/1').and_return(nil) - end - - it 'is able to use a custom path separator' do - is_expected.to run.with_params(data, 'a::g', 'default', '::').and_return('2') - end - - it 'is able to use a custom path separator: default' do - is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default') - end - - it 'is able to throw an error with incorrect params' do - is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}i) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/type3x_spec.rb --- a/modules/stdlib/spec/functions/type3x_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe 'type3x' do - it 'exists' do - expect(Puppet::Parser::Functions.function('type3x')).to eq('function_type3x') - end - - it 'raises a ParseError if there is less than 1 arguments' do - expect { scope.function_type3x([]) }.to(raise_error(Puppet::ParseError)) - end - - it 'returns string when given a string' do - result = scope.function_type3x(['aaabbbbcccc']) - expect(result).to(eq('string')) - end - - it 'returns array when given an array' do - result = scope.function_type3x([['aaabbbbcccc', 'asdf']]) - expect(result).to(eq('array')) - end - - it 'returns hash when given a hash' do - result = scope.function_type3x([{ 'a' => 1, 'b' => 2 }]) - expect(result).to(eq('hash')) - end - - it 'returns integer when given an integer' do - result = scope.function_type3x(['1']) - expect(result).to(eq('integer')) - end - - it 'returns float when given a float' do - result = scope.function_type3x(['1.34']) - expect(result).to(eq('float')) - end - - it 'returns boolean when given a boolean' do - result = scope.function_type3x([true]) - expect(result).to(eq('boolean')) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/type_of_spec.rb --- a/modules/stdlib/spec/functions/type_of_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -require 'spec_helper' - -if ENV['FUTURE_PARSER'] == 'yes' - describe 'type_of' do - pending 'teach rspec-puppet to load future-only functions under 3.7.5' do - it { is_expected.not_to eq(nil) } - end - end -end - -if Puppet.version.to_f >= 4.0 - describe 'type_of' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) } - - it 'gives the type of a string' do - expect(subject.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType) - end - - it 'gives the type of an integer' do - expect(subject.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/type_spec.rb --- a/modules/stdlib/spec/functions/type_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -require 'spec_helper' - -describe 'type' do - it 'exists' do - expect(Puppet::Parser::Functions.function('type')).to eq('function_type') - end - - it 'gives a deprecation warning when called' do - expect(scope).to receive(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Unable to reduce to required length - scope.function_type(['aoeu']) - end - - it 'returns string when given a string' do - result = scope.function_type(['aaabbbbcccc']) - expect(result).to(eq('string')) - end - - it 'returns array when given an array' do - result = scope.function_type([['aaabbbbcccc', 'asdf']]) - expect(result).to(eq('array')) - end - - it 'returns hash when given a hash' do - result = scope.function_type([{ 'a' => 1, 'b' => 2 }]) - expect(result).to(eq('hash')) - end - - it 'returns integer when given an integer' do - result = scope.function_type(['1']) - expect(result).to(eq('integer')) - end - - it 'returns float when given a float' do - result = scope.function_type(['1.34']) - expect(result).to(eq('float')) - end - - it 'returns boolean when given a boolean' do - result = scope.function_type([true]) - expect(result).to(eq('boolean')) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/union_spec.rb --- a/modules/stdlib/spec/functions/union_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -require 'spec_helper' - -describe 'union' do - describe 'argument checking' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{Every parameter must be an array}) } - end - - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one'], []).and_return(['one']) } - it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one'], ['two']).and_return(['one', 'two']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) } - it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) } - it { is_expected.to run.with_params(['ốńə', 'ţשׂợ'], ['ŧĥяếệ', 'ƒởųŗ'], ['ốńə', 'ţשׂợ', 'ŧĥяếệ'], ['ƒởųŗ']).and_return(['ốńə', 'ţשׂợ', 'ŧĥяếệ', 'ƒởųŗ']) } - it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/unique_spec.rb --- a/modules/stdlib/spec/functions/unique_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -describe 'unique' do - if Puppet.version.to_f < 5.0 - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - end - - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } - it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } - end - - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaba').and_return('ab') } - it { is_expected.to run.with_params('ããъã').and_return('ãъ') } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/unix2dos_spec.rb --- a/modules/stdlib/spec/functions/unix2dos_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'unix2dos' do - context 'when checking parameter validity' do - it { is_expected.not_to eq(nil) } - it do - is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) - end - it do - is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments}) - end - it do - is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) - end - it do - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) - end - end - - context 'when converting from unix to dos format' do - sample_text = "Hello\nWorld\n" - desired_output = "Hello\r\nWorld\r\n" - - it 'outputs dos format' do - is_expected.to run.with_params(sample_text).and_return(desired_output) - end - end - - context 'when converting from dos to dos format' do - sample_text = "Hello\r\nWorld\r\n" - desired_output = "Hello\r\nWorld\r\n" - - it 'outputs dos format' do - is_expected.to run.with_params(sample_text).and_return(desired_output) - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/upcase_spec.rb --- a/modules/stdlib/spec/functions/upcase_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -require 'spec_helper' - -describe 'upcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) } - it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) } - end - - describe 'normal string handling' do - it { is_expected.to run.with_params('abc').and_return('ABC') } - it { is_expected.to run.with_params('Abc').and_return('ABC') } - it { is_expected.to run.with_params('ABC').and_return('ABC') } - end - - describe 'handling classes derived from String' do - it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('ABC') } - end - - describe 'strings in arrays handling' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['One', 'twO']).and_return(['ONE', 'TWO']) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/uriescape_spec.rb --- a/modules/stdlib/spec/functions/uriescape_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'uriescape' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } - end - - describe 'handling normal strings' do - it 'calls ruby\'s URI.escape function' do - expect(URI).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once - is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') - end - end - - describe 'handling classes derived from String' do - it 'calls ruby\'s URI.escape function' do - uri_string = AlsoString.new('uri_string') - expect(URI).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once - is_expected.to run.with_params(uri_string).and_return('escaped_uri_string') - end - end - - describe 'strings in arrays handling' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['one}', 'two']).and_return(['one%7D', 'two']) } - it { is_expected.to run.with_params(['one}', 1, true, {}, 'two']).and_return(['one%7D', 1, true, {}, 'two']) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_absolute_path_spec.rb --- a/modules/stdlib/spec/functions/validate_absolute_path_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -require 'spec_helper' - -describe 'validate_absolute_path' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('c:/') - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'valid paths handling' do - ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet'].each do |path| - it { is_expected.to run.with_params(path) } - it { is_expected.to run.with_params(['/tmp', path]) } - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - ].each do |path| - it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - end - end - - context 'with relative paths' do - ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'relative\\windows'].each do |path| - it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_array_spec.rb --- a/modules/stdlib/spec/functions/validate_array_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'validate_array' do - describe 'signature validation' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - it { is_expected.not_to eq(nil) } - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params([]) - end - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params([]) } - it { is_expected.to run.with_params(['one']) } - it { is_expected.to run.with_params([], ['two']) } - it { is_expected.to run.with_params(['one'], ['two']) } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params([], {}).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, %r{is not an Array}) } - it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError, %r{is not an Array}) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_augeas_spec.rb --- a/modules/stdlib/spec/functions/validate_augeas_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -require 'spec_helper' - -describe 'validate_augeas' do - if Puppet.features.augeas? - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) } - end - - describe 'valid inputs' do - inputs = [ - ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns'], - ["proc /proc proc nodev,noexec,nosuid 0 0\n", 'Fstab.lns'], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input) } - end - end - - describe 'valid inputs which fail augeas validation' do - # The intent here is to make sure valid inputs raise exceptions when they - # don't specify an error message to display. This is the behvior in - # 2.2.x and prior. - inputs = [ - ["root:x:0:0:root\n", 'Passwd.lns'], - ["127.0.1.1\n", 'Hosts.lns'], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{validate_augeas.*?matched less than it should}) } - end - end - - describe 'when specifying nice error messages' do - # The intent here is to make sure the function returns the 4th argument - # in the exception thrown - inputs = [ - ["root:x:0:0:root\n", 'Passwd.lns', [], 'Failed to validate passwd content'], - ["127.0.1.1\n", 'Hosts.lns', [], 'Wrong hosts content'], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{#{input[3]}}) } - end - end - - describe 'matching additional tests' do - inputs = [ - ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']], - ["root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input) } - end - end - - describe 'failing additional tests' do - inputs = [ - ["foobar:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']], - ["root:x:0:0:root:/root:/bin/sh\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']], - ] - - inputs.each do |input| - it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, %r{testing path}) } - end - end - else - skip 'ruby-augeas not installed' - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_bool_spec.rb --- a/modules/stdlib/spec/functions/validate_bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'validate_bool' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(true) - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'acceptable values' do - it { is_expected.to run.with_params(true) } - it { is_expected.to run.with_params(false) } - it { is_expected.to run.with_params(true, false, false, true) } - end - - describe 'validation failures' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('true').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params(true, 'false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('true', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - it { is_expected.to run.with_params('true', false, false, false, false, false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_cmd_spec.rb --- a/modules/stdlib/spec/functions/validate_cmd_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -require 'spec_helper' - -describe 'validate_cmd', :unless => Puppet::Util::Platform.windows? do - let(:touch) { File.exist?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' } - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{content must be a string}) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, %r{checkscript must be a string}) - } - it { - pending('should implement stricter type checking') - is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, %r{custom error message must be a string}) - } - end - - context 'when validation fails' do - context 'with % placeholder' do - it { - is_expected.to run - .with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, %r{Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)}) - } - it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) } - end - context 'without % placeholder' do - it { - is_expected.to run - .with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, %r{Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)}) - } - it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_domain_name_spec.rb --- a/modules/stdlib/spec/functions/validate_domain_name_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe 'validate_domain_name' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('com', 'com.') } - it { is_expected.to run.with_params('x.com', 'x.com.') } - it { is_expected.to run.with_params('foo.example.com', 'foo.example.com.') } - it { is_expected.to run.with_params('2foo.example.com', '2foo.example.com.') } - it { is_expected.to run.with_params('www.2foo.example.com', 'www.2foo.example.com.') } - it { is_expected.to run.with_params('domain.tld', 'puppet.com') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - - it { is_expected.to run.with_params('foo.example.com', []).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('foo.example.com', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('foo.example.com', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('foo.example.com', true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) } - it { is_expected.to run.with_params('invalid domain').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) } - it { is_expected.to run.with_params('-foo.example.com').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) } - it { is_expected.to run.with_params('www.example.2com').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) } - it { is_expected.to run.with_params('192.168.1.1').and_raise_error(Puppet::ParseError, %r{is not a syntactically correct domain name}) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_email_address_spec.rb --- a/modules/stdlib/spec/functions/validate_email_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'validate_email_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('bob@gmail.com') } - it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) } - it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_hash_spec.rb --- a/modules/stdlib/spec/functions/validate_hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe 'validate_hash' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'check for deprecation warning' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('key' => 'value') - end - end - - describe 'valid inputs' do - it { is_expected.to run.with_params({}) } - it { is_expected.to run.with_params('key' => 'value') } - it { is_expected.to run.with_params({}, 'key' => 'value') } - it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - it { is_expected.to run.with_params("{ 'number' => 'one' }").and_raise_error(Puppet::ParseError, %r{is not a Hash}) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_integer_spec.rb --- a/modules/stdlib/spec/functions/validate_integer_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -require 'spec_helper' - -describe 'validate_integer' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(3) - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', 7.0, -7.0, {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x'].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{to be an Integer}) } - it { is_expected.to run.with_params(invalid, 10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) } - it { is_expected.to run.with_params(invalid, 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) } - it { is_expected.to run.with_params([0, 1, 2, invalid, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) } - end - - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be an Integer}) } - end - - context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([0, 1, 2, { 0 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - end - - it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, %r{to be unset or an Integer}) } - it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, %r{to be unset or an Integer}) } - it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, %r{second argument to be larger than third argument}) } - end - - context 'with no range constraints' do - it { is_expected.to run.with_params(1) } - it { is_expected.to run.with_params(-1) } - it { is_expected.to run.with_params('1') } - it { is_expected.to run.with_params('-1') } - it { is_expected.to run.with_params([1, 2, 3, 4]) } - it { is_expected.to run.with_params([1, '2', '3', 4]) } - end - - context 'with a maximum limit of 10' do - describe 'rejects numbers greater than the limit' do - it { is_expected.to run.with_params(11, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(100, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(2**65, 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params([1, 2, 10, 100], 10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - end - - describe 'accepts numbers less or equal to the limit' do - it { is_expected.to run.with_params(10, 10) } - it { is_expected.to run.with_params(1, 10) } - it { is_expected.to run.with_params(-1, 10) } - it { is_expected.to run.with_params('1', 10) } - it { is_expected.to run.with_params('-1', 10) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10) } - end - end - - context 'with a minimum limit of -10' do - describe 'rejects numbers greater than the upper limit' do - it { is_expected.to run.with_params(11, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(100, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(2**65, 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params([1, 2, 10, 100], 10, -10).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - end - - describe 'rejects numbers smaller than the lower limit' do - it { is_expected.to run.with_params(-11, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params(-100, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params(-2**65, 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params([-10, 1, 2, 10, -100], 10, -10).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - end - - describe 'accepts numbers between and including the limits' do - it { is_expected.to run.with_params(10, 10, -10) } - it { is_expected.to run.with_params(-10, 10, -10) } - it { is_expected.to run.with_params(1, 10, -10) } - it { is_expected.to run.with_params(-1, 10, -10) } - it { is_expected.to run.with_params('1', 10, -10) } - it { is_expected.to run.with_params('-1', 10, -10) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10, -10) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10, -10) } - end - end - - it { is_expected.to run.with_params(10, 10, 10) } - - describe 'empty upper limit is interpreted as infinity' do - it { is_expected.to run.with_params(11, '', 10) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_ip_address_spec.rb --- a/modules/stdlib/spec/functions/validate_ip_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -require 'spec_helper' - -describe 'validate_ip_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('0.0.0.0') } - it { is_expected.to run.with_params('8.8.8.8') } - it { is_expected.to run.with_params('127.0.0.1') } - it { is_expected.to run.with_params('10.10.10.10') } - it { is_expected.to run.with_params('194.232.104.150') } - it { is_expected.to run.with_params('244.24.24.24') } - it { is_expected.to run.with_params('255.255.255.255') } - it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') } - it { is_expected.to run.with_params('3ffe:0505:0002::') } - it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } - it { is_expected.to run.with_params('::1/64') } - it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('1.2.3.4') - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params('1.2.3.4') - end - end - - context 'with netmasks' do - it { is_expected.to run.with_params('8.8.8.8/0') } - it { is_expected.to run.with_params('8.8.8.8/16') } - it { is_expected.to run.with_params('8.8.8.8/32') } - it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') } - end - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IP}) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_ipv4_address_spec.rb --- a/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -require 'spec_helper' - -describe 'validate_ipv4_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first) - end - end - - SharedData::IPV4_PATTERNS.each do |value| - it { is_expected.to run.with_params(value) } - end - - SharedData::IPV4_NEGATIVE_PATTERNS.each do |value| - it { is_expected.to run.with_params(value).and_raise_error(Puppet::ParseError, %r{is not a valid IPv4}) } - end - - describe 'invalid inputs' do - [{}, [], 1, true].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) } - end - end - - describe 'multiple inputs' do - it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS[0], SharedData::IPV4_PATTERNS[1]) } - it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS[0], 'invalid ip').and_raise_error(Puppet::ParseError, %r{is not a valid IPv4}) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_ipv6_address_spec.rb --- a/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -require 'spec_helper' - -describe 'validate_ipv6_address' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - end - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('3ffe:0505:0002::') - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params('3ffe:0505:0002::') - end - end - - describe 'valid inputs' do - it { is_expected.to run.with_params('3ffe:0505:0002::') } - it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } - it { is_expected.to run.with_params('::1/64') } - it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } - it { is_expected.to run.with_params('fe80:0000:0000:0000:0204:61ff:fe9d:f156') } - it { is_expected.to run.with_params('fe80:0:0:0:204:61ff:fe9d:f156') } - it { is_expected.to run.with_params('fe80::204:61ff:fe9d:f156') } - it { is_expected.to run.with_params('fe80:0:0:0:0204:61ff:254.157.241.86') } - it { is_expected.to run.with_params('::1') } - it { is_expected.to run.with_params('fe80::') } - it { is_expected.to run.with_params('2001::') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('::ffff:2.3.4').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('::ffff:257.1.2.3').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('::ffff:12345678901234567890.1.26').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid IPv6}) } - context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_legacy_spec.rb --- a/modules/stdlib/spec/functions/validate_legacy_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0 - describe 'validate_legacy' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - - describe 'when passing the type assertion and passing the previous validation' do - it 'passes without notice' do - expect(scope).to receive(:function_validate_foo).with([5]).once - expect(Puppet).to receive(:notice).never - is_expected.to run.with_params('Integer', 'validate_foo', 5) - end - end - - describe 'when passing the type assertion and failing the previous validation' do - it 'passes with a notice about newly accepted value' do - expect(scope).to receive(:function_validate_foo).with([5]).and_raise(Puppet::ParseError, 'foo').once - expect(Puppet).to receive(:notice).with(include('Accepting previously invalid value for target type')) - is_expected.to run.with_params('Integer', 'validate_foo', 5) - end - end - - describe 'when failing the type assertion and passing the previous validation' do - it 'passes with a deprecation message' do - expect(scope).to receive(:function_validate_foo).with(['5']).once - expect(subject.func).to receive(:call_function).with('deprecation', 'validate_legacy', include('Integer')).once - is_expected.to run.with_params('Integer', 'validate_foo', '5') - end - end - - describe 'when failing the type assertion and failing the previous validation' do - it 'fails with a helpful message' do - expect(scope).to receive(:function_validate_foo).with(['5']).and_raise(Puppet::ParseError, 'foo').once - expect(subject.func).to receive(:call_function).with('fail', include('Integer')).once - is_expected.to run.with_params('Integer', 'validate_foo', '5') - end - end - - describe 'when passing in undef' do - it 'works' do - expect(scope).to receive(:function_validate_foo).with([:undef]).once - expect(Puppet).to receive(:notice).never - is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef) - end - end - - describe 'when passing in multiple arguments' do - it 'passes with a deprecation message' do - expect(scope).to receive(:function_validate_foo).with([:undef, 1, 'foo']).once - expect(Puppet).to receive(:notice).never - is_expected.to run.with_params('Optional[Integer]', 'validate_foo', :undef, 1, 'foo') - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_numeric_spec.rb --- a/modules/stdlib/spec/functions/validate_numeric_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -require 'spec_helper' - -describe 'validate_numeric' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params(3) - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x'].each do |invalid| - it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) } - it { is_expected.to run.with_params(invalid, 10.0).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) } - it { is_expected.to run.with_params(invalid, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) } - end - - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, %r{to be a Numeric}) } - end - - context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do - it { is_expected.to run.with_params([0, 1, 2, { 1 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([0, 1, 2, { 0 => 2 }, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) } - end - - it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, %r{to be unset or a Numeric}) } - it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, %r{to be unset or a Numeric}) } - it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, %r{second argument to be larger than third argument}) } - end - - context 'with no range constraints' do - it { is_expected.to run.with_params(1) } - it { is_expected.to run.with_params(-1) } - it { is_expected.to run.with_params('1') } - it { is_expected.to run.with_params('-1') } - it { is_expected.to run.with_params([1, 2, 3, 4]) } - it { is_expected.to run.with_params([1, '2', '3', 4]) } - end - - context 'with a maximum limit of 10.0' do - describe 'rejects numbers greater than the limit' do - it { is_expected.to run.with_params(11, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(100, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(2**65, 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params([1, 2, 10.0, 100], 10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - end - - describe 'accepts numbers less or equal to the limit' do - it { is_expected.to run.with_params(10.0, 10.0) } - it { is_expected.to run.with_params(1, 10.0) } - it { is_expected.to run.with_params(-1, 10.0) } - it { is_expected.to run.with_params('1', 10.0) } - it { is_expected.to run.with_params('-1', 10.0) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10.0) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10.0) } - end - end - - context 'with a minimum limit of -10.0' do - describe 'rejects numbers greater than the upper limit' do - it { is_expected.to run.with_params(11, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(100, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params(2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - it { is_expected.to run.with_params([1, 2, 10.0, 100], 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be smaller or equal}) } - end - - describe 'rejects numbers smaller than the lower limit' do - it { is_expected.to run.with_params(-11, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params(-100, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params(-2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - it { is_expected.to run.with_params([-10.0, 1, 2, 10.0, -100], 10.0, -10.0).and_raise_error(Puppet::ParseError, %r{to be greater or equal}) } - end - - describe 'accepts numbers between and including the limits' do - it { is_expected.to run.with_params(10.0, 10.0, -10.0) } - it { is_expected.to run.with_params(-10.0, 10.0, -10.0) } - it { is_expected.to run.with_params(1, 10.0, -10.0) } - it { is_expected.to run.with_params(-1, 10.0, -10.0) } - it { is_expected.to run.with_params('1', 10.0, -10.0) } - it { is_expected.to run.with_params('-1', 10.0, -10.0) } - it { is_expected.to run.with_params([1, 2, 3, 4], 10.0, -10.0) } - it { is_expected.to run.with_params([1, '2', '3', 4], 10.0, -10.0) } - end - end - - it { is_expected.to run.with_params(10.0, 10.0, 10.0) } - - describe 'empty upper limit is interpreted as infinity' do - it { is_expected.to run.with_params(11, '', 10.0) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_re_spec.rb --- a/modules/stdlib/spec/functions/validate_re_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -require 'spec_helper' - -describe 'validate_re' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('', '') - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('', '') } - it { is_expected.to run.with_params('', ['']) } - it { is_expected.to run.with_params('', [''], 'custom error') } - it { is_expected.to run.with_params('one', '^one') } - it { is_expected.to run.with_params('one', ['^one', '^two']) } - it { is_expected.to run.with_params('one', ['^one', '^two'], 'custom error') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) } - it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('notone', ['^one', '^two']).and_raise_error(Puppet::ParseError, %r{does not match}) } - it { is_expected.to run.with_params('notone', ['^one', '^two'], 'custom error').and_raise_error(Puppet::ParseError, %r{custom error}) } - end - - describe 'non-string inputs' do - [ - 1, # Fixnum - 3.14, # Float - nil, # NilClass - true, # TrueClass - false, # FalseClass - ['10'], # Array - :key, # Symbol - { :key => 'val' }, # Hash - ].each do |input| - it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, %r{needs to be a String}) } - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_slength_spec.rb --- a/modules/stdlib/spec/functions/validate_slength_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -require 'spec_helper' - -describe 'validate_slength' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('1234567890', 10) - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', 2, 3, 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{second argument to be a positive Numeric}) } - it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, %r{second argument to be a positive Numeric}) } - it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, %r{third argument to be unset or a positive Numeric}) } - it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, %r{third argument to be unset or a positive Numeric}) } - it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, %r{argument to be equal to or larger than third argument}) } - end - - context 'with a maximum length of 10' do - describe 'rejects strings longer than the limit' do - it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params(['one', '1234567890abcdef'], 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } - end - - describe 'accepts strings shorter or equal to the limit' do - it { is_expected.to run.with_params('1234567890', 10) } - it { is_expected.to run.with_params('12345', 10) } - it { is_expected.to run.with_params(['one', 'two'], 10) } - end - end - - context 'with a minimum length of 5' do - describe 'rejects strings longer than the upper limit' do - it { is_expected.to run.with_params('1234567890a', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params('1234567890abcdef', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } - end - - describe 'rejects numbers shorter than the lower limit' do - it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } - end - - describe 'accepts strings of length between and including the limits' do - it { is_expected.to run.with_params('12345', 10, 5) } - it { is_expected.to run.with_params('123456', 10, 5) } - it { is_expected.to run.with_params('1234567', 10, 5) } - it { is_expected.to run.with_params('12345678', 10, 5) } - it { is_expected.to run.with_params('123456789', 10, 5) } - it { is_expected.to run.with_params('1234567890', 10, 5) } - it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) } - end - end - - describe 'corner cases' do - it { - pending('this should work') - is_expected.to run.with_params('', 0, 0) - } - it { is_expected.to run.with_params('1234567890', 10, 10) } - end - - describe 'empty upper limit is interpreted as infinity' do - it { - pending('not implemented') - is_expected.to run.with_params('1234567890ab', '', 10) - } - it { - pending('not implemented') - is_expected.to run.with_params('12345678', '', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) - } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_string_spec.rb --- a/modules/stdlib/spec/functions/validate_string_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -describe 'validate_string' do - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - - # Checking for deprecation warning - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('', '') - end - - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'valid inputs' do - it { is_expected.to run.with_params('') } - it { is_expected.to run.with_params(nil) } - it { is_expected.to run.with_params('one') } - it { is_expected.to run.with_params('one', 'two') } - end - - describe 'invalid inputs' do - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } - it { is_expected.to run.with_params('one', 2).and_raise_error(Puppet::ParseError, %r{is not a string}) } - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb --- a/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -require 'spec_helper' - -describe 'validate_x509_rsa_key_pair' do - let(:valid_cert) do - < Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params({}, 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } - it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params('key' => 'value').and_return(['value']) } - it 'returns the array of values' do - result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }]) - expect(result).to match_array(['value1', 'value2', 'value2']) - end - - it 'runs with UTF8 and double byte characters' do - result = subject.call([{ 'かぎ' => '使用', 'ҝĕұ' => '√ẩŀứệ', 'ҝĕұďŭрļǐçằťè' => '√ẩŀứệ' }]) - expect(result).to match_array(['使用', '√ẩŀứệ', '√ẩŀứệ']) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/functions/zip_spec.rb --- a/modules/stdlib/spec/functions/zip_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'zip' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the third.') - is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - it { is_expected.to run.with_params([], []).and_return([]) } - it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6]).and_return([[1, 4], [2, 5], [3, 6]]) } - it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], false).and_return([[1, 4], [2, 5], [3, 6]]) } - it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], true).and_return([1, 4, 2, 5, 3, 6]) } - it { is_expected.to run.with_params([1, 2, 'four'], [true, true, false]).and_return([[1, true], [2, true], ['four', false]]) } - it { is_expected.to run.with_params([1, 2, 3], [4, 5]).and_return([[1, 4], [2, 5], [3, nil]]) } - it { is_expected.to run.with_params('A string', [4, 5]).and_raise_error(Puppet::ParseError, %r{Requires array}i) } - - context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(['ầ', 'ь', 'ć'], ['đ', 'ề', 'ƒ']).and_return([['ầ', 'đ'], ['ь', 'ề'], ['ć', 'ƒ']]) } - it { is_expected.to run.with_params(['ペ', '含', '値'], ['ッ', '文', 'イ']).and_return([['ペ', 'ッ'], ['含', '文'], ['値', 'イ']]) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/monkey_patches/alias_should_to_must.rb --- a/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -require 'rspec' -# class Object -class Object - # This is necessary because the RAL has a 'should' - # method. - alias must should - alias must_not should_not -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/monkey_patches/publicize_methods.rb --- a/modules/stdlib/spec/monkey_patches/publicize_methods.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -# Some monkey-patching to allow us to test private methods. -class Class - def publicize_methods(*methods) - saved_private_instance_methods = methods.empty? ? private_instance_methods : methods - - class_eval { public(*saved_private_instance_methods) } - yield - class_eval { private(*saved_private_instance_methods) } - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/spec_helper.rb --- a/modules/stdlib/spec/spec_helper.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -RSpec.configure do |c| - c.mock_with :rspec -end - -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' - -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) - -include RspecPuppetFacts - -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} - -default_fact_files = [ - File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), -] - -default_fact_files.each do |f| - next unless File.exist?(f) && File.readable?(f) && File.size?(f) - - begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e - RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" - end -end - -# read default_facts and merge them over what is provided by facterdb -default_facts.each do |fact, value| - add_custom_fact fact, value -end - -RSpec.configure do |c| - c.default_facts = default_facts - c.before :each do - # set to strictest setting for testing - # by default Puppet runs at warning level - Puppet.settings[:strict] = :warning - end - c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] - c.after(:suite) do - RSpec::Puppet::Coverage.report!(0) - end -end - -# Ensures that a module is defined -# @param module_name Name of the module -def ensure_module_defined(module_name) - module_name.split('::').reduce(Object) do |last_module, next_module| - last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) - last_module.const_get(next_module, false) - end -end - -# 'spec_overrides' from sync.yml will appear below this line diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/spec_helper_acceptance.rb --- a/modules/stdlib/spec/spec_helper_acceptance.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -# frozen_string_literal: true - -require 'serverspec' -require 'puppet_litmus' -require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) -include PuppetLitmus - -if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost' - puts 'Running tests against this machine !' - if Gem.win_platform? - set :backend, :cmd - else - set :backend, :exec - end -else - # load inventory - inventory_hash = inventory_hash_from_inventory_file - node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) - - if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes') - host = ENV['TARGET_HOST'] - set :backend, :docker - set :docker_container, host - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes') - set :backend, :ssh - options = Net::SSH::Config.for(host) - options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil? - options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil? - options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil? - options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil? - # Support both net-ssh 4 and 5. - # rubocop:disable Metrics/BlockNesting - options[:verify_host_key] = if node_config.dig('ssh', 'host-key-check').nil? - # Fall back to SSH behavior. This variable will only be set in net-ssh 5.3+. - if @strict_host_key_checking.nil? || @strict_host_key_checking - Net::SSH::Verifiers::Always.new - else - # SSH's behavior with StrictHostKeyChecking=no: adds new keys to known_hosts. - # If known_hosts points to /dev/null, then equivalent to :never where it - # accepts any key beacuse they're all new. - Net::SSH::Verifiers::AcceptNewOrLocalTunnel.new - end - elsif node_config.dig('ssh', 'host-key-check') - if defined?(Net::SSH::Verifiers::Always) - Net::SSH::Verifiers::Always.new - else - Net::SSH::Verifiers::Secure.new - end - elsif defined?(Net::SSH::Verifiers::Never) - Net::SSH::Verifiers::Never.new - else - Net::SSH::Verifiers::Null.new - end - # rubocop:enable Metrics/BlockNesting - host = if ENV['TARGET_HOST'].include?(':') - ENV['TARGET_HOST'].split(':').first - else - ENV['TARGET_HOST'] - end - set :host, options[:host_name] || host - set :ssh_options, options - set :request_pty, true - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes') - require 'winrm' - # rubocop:disable Style/HashSyntax - set :backend, :winrm - set :os, family: 'windows' - user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil? - pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil? - endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" - - opts = { - user: user, - password: pass, - endpoint: endpoint, - operation_timeout: 300, - } - # rubocop:enable Style/HashSyntax - winrm = WinRM::Connection.new opts - Specinfra.configuration.winrm = winrm - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/spec_helper_local.rb --- a/modules/stdlib/spec/spec_helper_local.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -# automatically load any shared examples or contexts -Dir['./spec/support/**/*.rb'].sort.each { |f| require f } - -# HACK: to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples -RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers) - -RSpec.configure do |config| - # supply tests with a possibility to test for the future parser - config.add_setting :puppet_future - config.puppet_future = Puppet.version.to_f >= 4.0 - - config.before :each do - # Ensure that we don't accidentally cache facts and environment between - # test cases. This requires each example group to explicitly load the - # facts being exercised with something like - # Facter.collection.loader.load(:ipaddress) - Facter.clear - Facter.clear_messages - - RSpec::Mocks.setup - end - - config.after :each do - RSpec::Mocks.verify - RSpec::Mocks.teardown - end -end - -# Helper class to test handling of arguments which are derived from string -class AlsoString < String -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/support/shared_data.rb --- a/modules/stdlib/spec/support/shared_data.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -module SharedData - IPV4_PATTERNS = [ - '0.0.0.0', - '1.2.3.4', - '10.10.10.10', - '127.0.0.1', - '192.88.99.0', - '194.232.104.150', - '224.0.0.0', - '244.24.24.24', - '255.255.255.255', - '8.8.8.8', - '8.8.8.8/0', - '8.8.8.8/16', - '8.8.8.8/255.255.0.0', - '8.8.8.8/32', - ].freeze - IPV4_NEGATIVE_PATTERNS = [ - '', - '0000', - '0.0.0.0.', - '0.0.0.0./0.0.0.0.', - '0.0.0.0./1', - '0.0.0.0.0', - '0.0.0.0/0.0.0.0.', - '0.0.0.256', - '0.0.0', - '1.2.3.4.5', - '1.2.3', - '10.010.10.10', - '2001:0db8:85a3:0000:0000:8a2e:0370:73342001:0db8:85a3:0000:0000:8a2e:0370:7334', - '4.4.4', - '77', - '9999.9999.9999.9999', - 'affe::beef', - 'nope', - ].freeze -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/absolute_path_spec.rb --- a/modules/stdlib/spec/type_aliases/absolute_path_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Absolute_path' do - describe 'valid paths handling' do - ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet', - '/var/opt//lib/puppet', '/var/ůťƒ8', '/var/ネット'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - - context 'with relative paths' do - ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows', '\\var\\ůťƒ8', '\\var\\ネット'].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/array_spec.rb --- a/modules/stdlib/spec/type_aliases/array_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Array' do - describe 'accepts arrays' do - [ - [], - ['one'], - [1], - [{}], - [[]], - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '', - 'one', - '1', - {}, - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/base32_spec.rb --- a/modules/stdlib/spec/type_aliases/base32_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Base32' do - describe 'valid handling' do - ['ASDASDDASD3453453', 'ASDASDDASD3453453=', 'ASDASDDASD3453453==', 'ASDASDDASD3453453===', 'ASDASDDASD3453453====', 'ASDASDDASD3453453=====', 'ASDASDDASD3453453======', 'asdasddasd3453453', - 'asdasddasd3453453=', 'asdasddasd3453453==', 'asdasddasd3453453===', 'asdasddasd3453453====', 'asdasddasd3453453=====', 'asdasddasd3453453======'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'asdasd!@#$', - '=asdasd9879876876+/', - 'asda=sd9879876876+/', - 'asdaxsd9879876876+/===', - 'asdads asdasd', - 'asdasddasd3453453=======', - 'asdaSddasd', - 'asdasddasd1', - 'asdasddasd9', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/base64_spec.rb --- a/modules/stdlib/spec/type_aliases/base64_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Base64' do - describe 'valid handling' do - ['asdasdASDSADA342386832/746+=', 'asdasdASDSADA34238683274/6+', 'asdasdASDSADA3423868327/46+=='].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'asdasd!@#$', - '=asdasd9879876876+/', - 'asda=sd9879876876+/', - 'asdaxsd9879876876+/===', - 'asdads asdasd', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/bool_spec.rb --- a/modules/stdlib/spec/type_aliases/bool_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Bool' do - describe 'accepts booleans' do - [ - true, - false, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - [1], - [{}], - [true], - 'true', - 'false', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/compat__ip_address.rb --- a/modules/stdlib/spec/type_aliases/compat__ip_address.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Ip_address' do - describe 'accepts ipv4 and ipv6 addresses' do - [ - '224.0.0.0', - '255.255.255.255', - '0.0.0.0', - '192.88.99.0', - '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - describe 'rejects other values' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'nope', - '77', - '4.4.4', - '2001:0db8:85a3:000000:0000:8a2e:0370:7334', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/compat__ipv4_spec.rb --- a/modules/stdlib/spec/type_aliases/compat__ipv4_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Ipv4' do - describe 'accepts ipv4 addresses' do - SharedData::IPV4_PATTERNS.each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - describe 'rejects other values' do - SharedData::IPV4_NEGATIVE_PATTERNS.each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/compat__ipv6_spec.rb --- a/modules/stdlib/spec/type_aliases/compat__ipv6_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Ipv6' do - describe 'accepts ipv6 addresses' do - [ - '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', - 'fe80:0000:0000:0000:0204:61ff:fe9d:f156', - 'fe80:0:0:0:204:61ff:fe9d:f156', - 'fe80::204:61ff:fe9d:f156', - 'fe80:0:0:0:0204:61ff:254.157.241.86', - '::1', - 'fe80::', - '2001::', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - describe 'rejects other values' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'nope', - '77', - '4.4.4', - '2000:7334', - '::ffff:2.3.4', - '::ffff:257.1.2.3', - '::ffff:12345678901234567890.1.26', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/filemode_spec.rb --- a/modules/stdlib/spec/type_aliases/filemode_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -# coding: utf-8 - -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Filemode' do - describe 'valid modes' do - [ - '7', - '12', - '666', - - '0000', - '0644', - '1644', - '2644', - '4644', - '0123', - '0777', - - 'a=,o-r,u+X,g=w', - 'a=Xr,+0', - 'u=rwx,g+rX', - 'u+s,g-s', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid modes' do - context 'with garbage inputs' do - [ - true, - false, - :keyword, - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'ネット', - '55555', - '0x123', - '0649', - - '=8,X', - 'x=r,a=wx', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/filesource_spec.rb --- a/modules/stdlib/spec/type_aliases/filesource_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Filesource' do - describe 'valid handling' do - [ - 'https://hello.com', - 'https://notcreative.org', - 'https://canstillaccepthttps.co.uk', - 'http://anhttp.com', - 'http://runningoutofideas.gov', - 'file:///hello/bla', - 'file:///foo/bar.log', - 'puppet:///modules/foo/bar.log', - 'puppet://pm.example.com/modules/foo/bar.log', - 'puppet://192.0.2.1/modules/foo/bar.log', - '/usr2/username/bin:/usr/local/bin:/usr/bin:.', - 'C:/', - 'C:\\', - 'C:\\WINDOWS\\System32', - 'C:/windows/system32', - 'X:/foo/bar', - 'X:\\foo\\bar', - '\\\\host\\windows', - '//host/windows', - '/var/tmp', - '/var/opt/../lib/puppet', - 'puppet:///a_custom_mount_point/foo/bar/foobar.conf', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - '*/Users//nope', - '\\Users/hc/wksp/stdlib', - 'C:noslashes', - '\\var\\tmp', - 'puppet://bob@pm.example.com/modules/foo/bar.log', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/float_spec.rb --- a/modules/stdlib/spec/type_aliases/float_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Float' do - describe 'accepts floats' do - [ - 3.7, - '3.7', - -3.7, - '-342.2315e-12', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x', 3, '3', -3, '-3'].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/fqdn_spec.rb --- a/modules/stdlib/spec/type_aliases/fqdn_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Fqdn' do - describe 'valid handling' do - ['example', 'example.com', 'www.example.com'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - '2001:DB8::1', - 'www www.example.com', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/hash_spec.rb --- a/modules/stdlib/spec/type_aliases/hash_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Hash' do - describe 'accepts hashes' do - [ - {}, - { 'one' => 'two' }, - { 'wan' => 3 }, - { '001' => 'helly' }, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - describe 'rejects other values' do - [ - '', - 'one', - '1', - [], - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/host_spec.rb --- a/modules/stdlib/spec/type_aliases/host_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Host' do - describe 'valid handling' do - ['example', 'example.com', 'www.example.com', '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', '2001:0db8::1', '224.0.0.0', '255.255.255.255', - '0.0.0.0', '192.88.99.0'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid handling' do - context 'garbage inputs' do - [ - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'www www.example.com', - 'bob@example.com', - '%.example.com', - '2001:0d8', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/httpsurl_spec.rb --- a/modules/stdlib/spec/type_aliases/httpsurl_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::HTTPSUrl' do - describe 'valid handling' do - ['https://hello.com', 'https://notcreative.org', 'https://notexciting.co.uk', 'https://graphemica.com/❤', 'https://graphemica.com/緩', 'HTTPS://FOO.com'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'httds://notquiteright.org', - 'hptts:/nah', - 'https;//notrightbutclose.org', - 'http://graphemica.com/❤', - 'http://graphemica.com/緩', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/httpurl_spec.rb --- a/modules/stdlib/spec/type_aliases/httpurl_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::HTTPUrl' do - describe 'valid handling' do - ['https://hello.com', 'https://notcreative.org', 'https://canstillaccepthttps.co.uk', 'http://anhttp.com', 'http://runningoutofideas.gov', - 'http://', 'http://graphemica.com/❤', 'http://graphemica.com/緩', 'HTTPS://FOO.COM', 'HTTP://BAR.COM'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'httds://notquiteright.org', - 'hptts:/nah', - 'https;//notrightbutclose.org', - 'hts://graphemica.com/❤', - 'https:graphemica.com/緩', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/integer_spec.rb --- a/modules/stdlib/spec/type_aliases/integer_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Integer' do - describe 'accepts integers' do - [ - 3, - '3', - -3, - '-3', - "123\nfoo", - "foo\n123", - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - ["foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', - {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x', 3.7, '3.7', -3.7, '-342.2315e-12'].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_nosubnet_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_nosubnet_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::Nosubnet' do - describe 'accepts ipv4 and ipv6 addresses without subnets' do - [ - '224.0.0.0', - '255.255.255.255', - '0.0.0.0', - '192.88.99.0', - '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', - '127.0.0.1', - '8.8.4.4', - '52.10.10.141', - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - 'FF01:0:0:0:0:0:0:101', - 'FF01::101', - '::', - '12AB::CD30:192.168.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '10.1.240.4/24', - 'FF01:0:0:0:0:0:0:101/32', - 'FF01::101/60', - 'nope', - '77', - '4.4.4', - '2001:0db8:85a3:000000:0000:8a2e:0370:7334', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address' do - describe 'accepts ipv4 and ipv6 addresses' do - [ - '224.0.0.0', - '255.255.255.255', - '0.0.0.0', - '192.88.99.0', - '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', - '127.0.0.1', - '8.8.4.4', - '10.1.240.4/24', - '52.10.10.141', - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - 'FF01:0:0:0:0:0:0:101', - 'FF01::101', - 'FF01:0:0:0:0:0:0:101/32', - 'FF01::101/60', - '::', - '12AB::CD30:192.168.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'nope', - '77', - '4.4.4', - '2001:0db8:85a3:000000:0000:8a2e:0370:7334', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v4_nosubnet_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v4_nosubnet_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V4::Nosubnet' do - describe 'accepts ipv4 addresses without subnets' do - [ - '127.0.0.1', - '8.8.4.4', - '52.10.10.141', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '10.1.240.4/24', - '192.168.1', - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - '12AB::CD30:192.168.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v4_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v4_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V4' do - describe 'accepts ipv4 addresses' do - [ - '127.0.0.1', - '8.8.4.4', - '10.1.240.4/24', - '52.10.10.141', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '192.168.1', - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - '12AB::CD30:192.168.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_alternative_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_alternative_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Alternative' do - describe 'accepts ipv6 addresses in alternative format' do - [ - '0:0:0:0:0:0:13.1.68.3', - '0:0:0:0:0:FFFF:129.144.52.38', - '0:0:0:0:0:FFFF:129.144.52.38/60', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'nope', - '127.0.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_cidr_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_cidr_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ - -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::CIDR' do - describe 'accepts ipv6 addresses in cidr format' do - [ - 'FF01:0:0:0:0:0:0:101/32', - 'FF01::101/60', - '::/0', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - 'FF01:0:0:0:0:0:0:101', - 'FF01::101', - '12AB::CD30:192.168.0.1', - '127.0.0.1', - '10.1.240.4/24', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_compressed_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_compressed_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Compressed' do - describe 'accepts ipv6 addresses in compressed format' do - [ - '1080::8:800:200C:417A', - '1080::8:800:200C:417A/60', - 'FF01::101', - '::1', - '::', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'nope', - '127.0.0.1', - 'FEDC::BA98:7654:3210::3210', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_full_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_full_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Full' do - describe 'accepts ipv6 addresses in full format' do - [ - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60', - '1080:0:0:0:8:800:200C:417A', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'nope', - '127.0.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Nosubnet::Alternative' do - describe 'accepts ipv6 addresses in alternative format without subnets' do - [ - '0:0:0:0:0:0:13.1.68.3', - '0:0:0:0:0:FFFF:129.144.52.38', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '0:0:0:0:0:FFFF:129.144.52.38/60', - 'nope', - '127.0.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Nosubnet::Compressed' do - describe 'accepts ipv6 addresses in compressed format without subnets' do - [ - '1080::8:800:200C:417A', - 'FF01::101', - '::1', - '::', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '1080::8:800:200C:417A/60', - 'nope', - '127.0.0.1', - 'FEDC::BA98:7654:3210::3210', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6::Nosubnet::Full' do - describe 'accepts ipv6 addresses in full format without subnets' do - [ - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - '1080:0:0:0:8:800:200C:417A', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60', - 'nope', - '127.0.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/ip_address_v6_spec.rb --- a/modules/stdlib/spec/type_aliases/ip_address_v6_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::IP::Address::V6' do - describe 'accepts ipv6 addresses' do - [ - 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', - 'FF01:0:0:0:0:0:0:101', - 'FF01::101', - 'FF01:0:0:0:0:0:0:101/32', - 'FF01::101/60', - '::', - '12AB::CD30:192.168.0.1', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '127.0.0.1', - '10.1.240.4/24', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/numeric_spec.rb --- a/modules/stdlib/spec/type_aliases/numeric_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::Numeric' do - describe 'accepts numerics' do - [ - 3, - '3', - -3, - '-3', - 3.7, - '3.7', - -3.7, - '-342.2315e-12', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1 => 2 }, '', :undef, 'x'].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb --- a/modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::ObjectStore::GSUri' do - describe 'accepts case-sensitive google cloud gs uris' do - [ - 'gs://mybucket/myfile.csv', - 'gs://bucket/path/to/file.tar.gz', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '', - 'GS://mybucket/myfile.csv', - 5, - 'gs//mybucket/myfile.csv', - 'gs:/mybucket/myfile.csv', - 'gs:mybucket/myfile.csv', - 'gs-mybucket/myfile.csv', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb --- a/modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::ObjectStore::S3Uri' do - describe 'accepts case-sensitive amazon web services s3 uris' do - [ - 's3://bucket-name/path', - 's3://bucket/path/to/file.txt', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '', - 'S3://bucket-name/path', - 3, - 's3:/bucket-name/path', - 's3//bucket-name/path', - 's3:bucket-name/path', - 's3-bucket-name/path', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/objectstore_spec.rb --- a/modules/stdlib/spec/type_aliases/objectstore_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::ObjectStore' do - describe 'accepts case-sensitive google cloud gs or amazon web services s3 uris' do - [ - 's3://bucket-name/path', - 's3://bucket/path/to/file.txt', - 'gs://mybucket/myfile.csv', - 'gs://bucket/path/to/file.tar.gz', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - '', - 'S3://bucket/path', - 'GS://bucket/path', - 5, - 3, - 'gs//bucket/path/to/file', - 's3//bucket/path/to/file', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/port__privileged_spec.rb --- a/modules/stdlib/spec/type_aliases/port__privileged_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Port::Privileged' do - describe 'valid ports' do - [ - 80, - 443, - 1023, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'https', - '443', - -1, - 1337, - 1024, - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/port__unprivileged_spec.rb --- a/modules/stdlib/spec/type_aliases/port__unprivileged_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Port::Unprivileged' do - describe 'valid unprivilegedport' do - [ - 1024, - 1337, - 65_000, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'https', - '443', - -1, - 80, - 443, - 1023, - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/port_spec.rb --- a/modules/stdlib/spec/type_aliases/port_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Port' do - describe 'valid ports' do - [ - 80, - 443, - 1337, - 65_000, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'https', - '443', - -1, - 65_536, - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/string_spec.rb --- a/modules/stdlib/spec/type_aliases/string_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Compat::String' do - describe 'accepts strings' do - [ - '', - 'one', - nil, - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'rejects other values' do - [ - [], - {}, - 1, - true, - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/unixpath_spec.rb --- a/modules/stdlib/spec/type_aliases/unixpath_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Unixpath' do - describe 'valid handling' do - ['/usr2/username/bin:/usr/local/bin:/usr/bin:.', '/var/tmp', '/Users/helencampbell/workspace/puppetlabs-stdlib', '/var/ůťƒ8', '/var/ネット', '/var//tmp', '/var/../tmp'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'C:/whatever', - '\\var\\tmp', - '\\Users/hc/wksp/stdlib', - '*/Users//nope', - "var\ůťƒ8", - "var\ネット", - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/windowspath_spec.rb --- a/modules/stdlib/spec/type_aliases/windowspath_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' - -if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 - describe 'Stdlib::Windowspath' do - describe 'valid handling' do - ['C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', 'X:/var/ůťƒ8', 'X:/var/ネット'].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid path handling' do - context 'with garbage inputs' do - [ - nil, - [nil], - [nil, nil], - { 'foo' => 'bar' }, - {}, - '', - 'httds://notquiteright.org', - '/usr2/username/bin:/usr/local/bin:/usr/bin:.', - 'C;//notright/here', - 'C:noslashes', - 'C:ネット', - 'C:ůťƒ8', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/type_aliases/yes_no_spec.rb --- a/modules/stdlib/spec/type_aliases/yes_no_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -# coding: utf-8 - -require 'spec_helper' - -describe 'Stdlib::Yes_no' do - describe 'valid types' do - [ - 'yes', - 'no', - 'YES', - 'Yes', - 'NO', - 'No', - ].each do |value| - describe value.inspect do - it { is_expected.to allow_value(value) } - end - end - end - - describe 'invalid types' do - context 'with garbage inputs' do - [ - true, - false, - :keyword, - nil, - ['yes', 'no'], - { 'foo' => 'bar' }, - {}, - '', - 'ネット', - '55555', - '0x123', - 'yess', - 'nooo', - ].each do |value| - describe value.inspect do - it { is_expected.not_to allow_value(value) } - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb --- a/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -require 'spec_helper' -require 'facter/facter_dot_d' - -describe Facter::Util::DotD do # rubocop:disable RSpec/FilePath : Spec path is as it should be - context 'with a simple fact' do - before :each do - allow(Facter).to receive(:version).and_return('1.6.1') - allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/fake_fact.txt']) - allow(File).to receive(:readlines).with('/etc/facter/facts.d/fake_fact.txt').and_return(['fake_fact=fake fact']) - subject.create - end - - it 'returns successfully' do - expect(Facter.fact(:fake_fact).value).to eq('fake fact') - end - end - - context 'with a fact with equals signs' do - before :each do - allow(Facter).to receive(:version).and_return('1.6.1') - allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/foo.txt']) - allow(File).to receive(:readlines).with('/etc/facter/facts.d/foo.txt').and_return(['foo=1+1=2']) - subject.create - end - - it 'returns successfully' do - expect(Facter.fact(:foo).value).to eq('1+1=2') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/package_provider_spec.rb --- a/modules/stdlib/spec/unit/facter/package_provider_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -require 'spec_helper' -require 'puppet/type' -require 'puppet/type/package' - -describe 'package_provider', :type => :fact do - before(:each) { Facter.clear } - after(:each) { Facter.clear } - - ['4.2.2', '3.7.1 (Puppet Enterprise 3.2.1)'].each do |puppetversion| - describe "on puppet ''#{puppetversion}''" do - before :each do - allow(Facter).to receive(:value).and_return(puppetversion) - end - - context 'when darwin' do - it 'returns pkgdmg' do - provider = Puppet::Type.type(:package).provider(:pkgdmg) - allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:package_provider).value).to eq('pkgdmg') - end - end - - context 'when centos 7' do - it 'returns yum' do - provider = Puppet::Type.type(:package).provider(:yum) - allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:package_provider).value).to eq('yum') - end - end - - context 'when ubuntu' do - it 'returns apt' do - provider = Puppet::Type.type(:package).provider(:apt) - allow(Puppet::Type.type(:package)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:package_provider).value).to eq('apt') - end - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/pe_version_spec.rb --- a/modules/stdlib/spec/unit/facter/pe_version_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -require 'spec_helper' - -describe 'PE Version specs' do - before :each do - # Explicitly load the pe_version.rb file which contains generated facts - # that cannot be automatically loaded. Puppet 2.x implements - # Facter.collection.load while Facter 1.x markes Facter.collection.load as - # a private method. - if Facter.collection.respond_to? :load - Facter.collection.load(:pe_version) - else - Facter.collection.loader.load(:pe_version) - end - end - - context 'when puppetversion is nil' do - before :each do - allow(Facter.fact(:puppetversion)).to receive(:value).and_return(nil) - end - - it 'puppetversion is nil' do - expect(Facter.fact(:puppetversion).value).to be_nil - end - - it 'pe_version is nil' do - expect(Facter.fact(:pe_version).value).to be_nil - end - end - - context 'when PE is installed' do - ['2.6.1', '2.10.300'].each do |version| - puppetversion = "2.7.19 (Puppet Enterprise #{version})" - context "puppetversion => #{puppetversion}" do - before :each do - allow(Facter.fact(:puppetversion)).to receive(:value).and_return(puppetversion) - end - - (major, minor, patch) = version.split('.') - - it 'returns true' do - expect(Facter.fact(:is_pe).value).to eq(true) - end - - it "Should have a version of #{version}" do - expect(Facter.fact(:pe_version).value).to eq(version) - end - - it "Should have a major version of #{major}" do - expect(Facter.fact(:pe_major_version).value).to eq(major) - end - - it "Should have a minor version of #{minor}" do - expect(Facter.fact(:pe_minor_version).value).to eq(minor) - end - - it "Should have a patch version of #{patch}" do - expect(Facter.fact(:pe_patch_version).value).to eq(patch) - end - end - end - end - - context 'when PE is not installed' do - before :each do - allow(Facter.fact(:puppetversion)).to receive(:value).and_return('2.7.19') - end - - it 'is_pe is false' do - expect(Facter.fact(:is_pe).value).to eq(false) - end - - it 'pe_version is nil' do - expect(Facter.fact(:pe_version).value).to be_nil - end - - it 'pe_major_version is nil' do - expect(Facter.fact(:pe_major_version).value).to be_nil - end - - it 'pe_minor_version is nil' do - expect(Facter.fact(:pe_minor_version).value).to be_nil - end - - it 'has a patch version' do - expect(Facter.fact(:pe_patch_version).value).to be_nil - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/root_home_spec.rb --- a/modules/stdlib/spec/unit/facter/root_home_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -require 'spec_helper' -require 'facter/root_home' -describe 'Root Home Specs' do - describe Facter::Util::RootHome do - context 'when solaris' do - let(:root_ent) { 'root:x:0:0:Super-User:/:/sbin/sh' } - let(:expected_root_home) { '/' } - - it 'returns /' do - expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent) - expect(described_class.returnt_root_home).to eq(expected_root_home) - end - end - context 'when linux' do - let(:root_ent) { 'root:x:0:0:root:/root:/bin/bash' } - let(:expected_root_home) { '/root' } - - it 'returns /root' do - expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(root_ent) - expect(described_class.returnt_root_home).to eq(expected_root_home) - end - end - context 'when windows' do - it 'is nil on windows' do - expect(Facter::Util::Resolution).to receive(:exec).with('getent passwd root').and_return(nil) - expect(described_class.returnt_root_home).to be_nil - end - end - end - - describe 'root_home', :type => :fact do - before(:each) { Facter.clear } - after(:each) { Facter.clear } - - context 'when macosx' do - before(:each) do - allow(Facter.fact(:kernel)).to receive(:value).and_return('Darwin') - allow(Facter.fact(:osfamily)).to receive(:value).and_return('Darwin') - end - let(:expected_root_home) { '/var/root' } - - sample_dscacheutil = File.read(fixtures('dscacheutil', 'root')) - - it 'returns /var/root' do - allow(Facter::Util::Resolution).to receive(:exec).with('dscacheutil -q user -a name root').and_return(sample_dscacheutil) - expect(Facter.fact(:root_home).value).to eq(expected_root_home) - end - end - - context 'when aix' do - before(:each) do - allow(Facter.fact(:kernel)).to receive(:value).and_return('AIX') - allow(Facter.fact(:osfamily)).to receive(:value).and_return('AIX') - end - let(:expected_root_home) { '/root' } - - sample_lsuser = File.read(fixtures('lsuser', 'root')) - - it 'returns /root' do - allow(Facter::Util::Resolution).to receive(:exec).with('lsuser -c -a home root').and_return(sample_lsuser) - expect(Facter.fact(:root_home).value).to eq(expected_root_home) - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/service_provider_spec.rb --- a/modules/stdlib/spec/unit/facter/service_provider_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -require 'spec_helper' -require 'puppet/type' -require 'puppet/type/service' - -describe 'service_provider', :type => :fact do - before(:each) { Facter.clear } - after(:each) { Facter.clear } - - context 'when macosx' do - it 'returns launchd' do - provider = Puppet::Type.type(:service).provider(:launchd) - allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:service_provider).value).to eq('launchd') - end - end - - context 'when systemd' do - it 'returns systemd' do - provider = Puppet::Type.type(:service).provider(:systemd) - allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:service_provider).value).to eq('systemd') - end - end - - context 'when redhat' do - it 'returns redhat' do - provider = Puppet::Type.type(:service).provider(:redhat) - allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(provider) - - expect(Facter.fact(:service_provider).value).to eq('redhat') - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb --- a/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -require 'spec_helper' -require 'facter/util/puppet_settings' - -describe Facter::Util::PuppetSettings do - describe '#with_puppet' do - context 'without Puppet loaded' do - before(:each) do - allow(Module).to receive(:const_get).with('Puppet').and_raise(NameError) - end - - it 'is nil' do - expect(subject.with_puppet { Puppet[:vardir] }).to be_nil - end - it 'does not yield to the block' do - expect(Puppet).to receive(:[]).never - expect(subject.with_puppet { Puppet[:vardir] }).to be_nil - end - end - context 'with Puppet loaded' do - # module Puppet - module Puppet; end - let(:vardir) { '/var/lib/puppet' } - - before :each do - allow(Puppet).to receive(:[]).with(:vardir).and_return(vardir) - end - - it 'yields to the block' do - subject.with_puppet { Puppet[:vardir] } - end - it 'returns the nodes vardir' do - expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb --- a/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -require 'spec_helper' - -describe 'the enclose_ipv6 function' do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it 'exists' do - expect(Puppet::Parser::Functions.function('enclose_ipv6')).to eq('function_enclose_ipv6') - end - - it 'raises a ParseError if there is less than 1 arguments' do - expect { scope.function_enclose_ipv6([]) }.to(raise_error(Puppet::ParseError)) - end - - it 'raises a ParseError if there is more than 1 arguments' do - expect { scope.function_enclose_ipv6(['argument1', 'argument2']) }.to(raise_error(Puppet::ParseError)) - end - - it 'raises a ParseError when given garbage' do - expect { scope.function_enclose_ipv6(['garbage']) }.to(raise_error(Puppet::ParseError)) - end - - it 'raises a ParseError when given something else than a string or an array' do - expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to(raise_error(Puppet::ParseError)) - end - - it 'does not raise a ParseError when given a single ip string' do - expect { scope.function_enclose_ipv6(['127.0.0.1']) }.not_to raise_error - end - - it 'does not raise a ParseError when given * as ip string' do - expect { scope.function_enclose_ipv6(['*']) }.not_to raise_error - end - - it 'does not raise a ParseError when given an array of ip strings' do - expect { scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1']]) }.not_to raise_error - end - - it 'does not raise a ParseError when given differently notations of ip addresses' do - expect { scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1', '[fe80::1]']]) }.not_to raise_error - end - - it 'raises a ParseError when given a wrong ipv4 address' do - expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to(raise_error(Puppet::ParseError)) - end - - it 'raises a ParseError when given a ipv4 address with square brackets' do - expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to(raise_error(Puppet::ParseError)) - end - - it 'raises a ParseError when given a wrong ipv6 address' do - expect { scope.function_enclose_ipv6(['fe80:::1']) }.to(raise_error(Puppet::ParseError)) - end - - it 'embraces ipv6 adresses within an array of ip addresses' do - result = scope.function_enclose_ipv6([['127.0.0.1', 'fe80::1', '[fe80::2]']]) - expect(result).to(eq(['127.0.0.1', '[fe80::1]', '[fe80::2]'])) - end - - it 'embraces a single ipv6 adresse' do - result = scope.function_enclose_ipv6(['fe80::1']) - expect(result).to(eq(['[fe80::1]'])) - end - - it 'does not embrace a single ipv4 adresse' do - result = scope.function_enclose_ipv6(['127.0.0.1']) - expect(result).to(eq(['127.0.0.1'])) - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb --- a/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -require 'spec_helper' - -describe 'is_absolute_path' do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - let(:function_args) do - [] - end - - let(:function) do - scope.function_is_absolute_path(function_args) - end - - describe 'validate arity' do - let(:function_args) do - [1, 2] - end - - it 'raises a ParseError if there is more than 1 arguments' do - -> { function }.should(raise_error(ArgumentError)) - end - end - - it 'exists' do - Puppet::Parser::Functions.function(subject).should == "function_#{subject}" - end - - # help enforce good function defination - it 'contains arity' do - end - - it 'raises a ParseError if there is less than 1 arguments' do - -> { function }.should(raise_error(ArgumentError)) - end - - describe 'should retrun true' do - let(:return_value) do - true - end - - describe 'windows' do - let(:function_args) do - ['c:\temp\test.txt'] - end - - it 'returns data' do - function.should eq(return_value) - end - end - - describe 'non-windows' do - let(:function_args) do - ['/temp/test.txt'] - end - - it 'returns data' do - function.should eq(return_value) - end - end - end - - describe 'should return false' do - let(:return_value) do - false - end - - describe 'windows' do - let(:function_args) do - ['..\temp\test.txt'] - end - - it 'returns data' do - function.should eq(return_value) - end - end - - describe 'non-windows' do - let(:function_args) do - ['../var/lib/puppet'] - end - - it 'returns data' do - function.should eq(return_value) - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb --- a/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,258 +0,0 @@ -require 'spec_helper' - -provider_class = Puppet::Type.type(:file_line).provider(:ruby) -#  These tests fail on windows when run as part of the rake task. Individually they pass -describe provider_class, :unless => Puppet::Util::Platform.windows? do - include PuppetlabsSpec::Files - - let :tmpfile do - tmpfilename('file_line_test') - end - let :content do - '' - end - let :params do - {} - end - let :resource do - Puppet::Type::File_line.new({ - :name => 'foo', - :path => tmpfile, - :line => 'foo', - }.merge(params)) - end - let :provider do - provider_class.new(resource) - end - - before :each do - File.open(tmpfile, 'w') do |fh| - fh.write(content) - end - end - - describe 'line parameter' do - context 'when line exists' do - let(:content) { 'foo' } - - it 'detects the line' do - expect(provider).to be_exists - end - end - context 'when line does not exist' do - let(:content) { 'foo bar' } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'appends the line' do - provider.create - expect(File.read(tmpfile).chomp).to eq("foo bar\nfoo") - end - end - end - - describe 'match parameter' do - let(:params) { { :match => '^bar' } } - - describe 'does not match line - line does not exist - replacing' do - let(:content) { "foo bar\nbar" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the match' do - provider.create - expect(File.read(tmpfile).chomp).to eq("foo bar\nfoo") - end - end - - describe 'does not match line - line does not exist - appending' do - let(:params) { super().merge(:replace => false) } - let(:content) { "foo bar\nbar" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - - context 'when does not match line - line exists' do - let(:content) { "foo\nbar" } - - it 'detects the line' do - expect(provider).to be_exists - end - end - - context 'when matches line - line exists' do - let(:params) { { :match => '^foo' } } - let(:content) { "foo\nbar" } - - it 'detects the line' do - expect(provider).to be_exists - end - end - - context 'when matches line - line does not exist' do - let(:params) { { :match => '^foo' } } - let(:content) { "foo bar\nbar" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the match' do - provider.create - expect(File.read(tmpfile).chomp).to eq("foo\nbar") - end - end - end - - describe 'append_on_no_match' do - let(:params) do - { - :append_on_no_match => false, - :match => '^foo1$', - } - end - - context 'when matching' do - let(:content) { "foo1\nbar" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the match' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo\nbar") - end - end - context 'when not matching' do - let(:content) { "foo3\nbar" } - - it 'does not affect the file' do - expect(provider).to be_exists - end - end - end - - describe 'replace_all_matches_not_matching_line' do - context 'when replace is false' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :replace => false, - } - end - - it 'raises an error' do - expect { provider.exists? }.to raise_error(Puppet::Error, %r{replace must be true}) - end - end - - context 'when match matches line - when there are more matches than lines' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^foo', - :multiple => true, - } - end - let(:content) { "foo\nfoo bar\nbar\nfoo baz" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the matches' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo\nfoo\nbar\nfoo") - end - end - - context 'when match matches line - when there are the same matches and lines' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^foo', - :multiple => true, - } - end - let(:content) { "foo\nfoo\nbar" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - - context 'when match does not match line - when there are more matches than lines' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^bar', - :multiple => true, - } - end - let(:content) { "foo\nfoo bar\nbar\nbar baz" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the matches' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo\nfoo bar\nfoo\nfoo") - end - end - - context 'when match does not match line - when there are the same matches and lines' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^bar', - :multiple => true, - } - end - let(:content) { "foo\nfoo\nbar\nbar baz" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the matches' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo\nfoo\nfoo\nfoo") - end - end - end - - context 'when match does not match line - when there are no matches' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^bar', - :multiple => true, - } - end - let(:content) { "foo\nfoo bar" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - - context 'when match does not match line - when there are no matches or lines' do - let(:params) do - { - :replace_all_matches_not_matching_line => true, - :match => '^bar', - :multiple => true, - } - end - let(:content) { 'foo bar' } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'appends the line' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo bar\nfoo") - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb --- a/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,374 +0,0 @@ -require 'spec_helper' - -provider_class = Puppet::Type.type(:file_line).provider(:ruby) -#  These tests fail on windows when run as part of the rake task. Individually they pass -describe provider_class, :unless => Puppet::Util::Platform.windows? do - include PuppetlabsSpec::Files - - let :tmpfile do - tmpfilename('file_line_test') - end - let :content do - '' - end - let :params do - {} - end - let :resource do - Puppet::Type::File_line.new({ - :name => 'foo', - :path => tmpfile, - :line => 'foo', - }.merge(params)) - end - let :provider do - provider_class.new(resource) - end - - before :each do - File.open(tmpfile, 'w') do |fh| - fh.write(content) - end - end - - describe '#create' do - context 'when adding' do - pending('To be added.') - end - context 'when replacing' do - let :params do - { - :line => 'foo = bar', - :match => '^foo\s*=.*$', - :replace => false, - } - end - let(:content) { "foo1\nfoo=blah\nfoo2\nfoo3" } - - it "providor 'be_exists'" do - expect(provider).to be_exists - end - it 'does not replace the matching line' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo=blah\nfoo2\nfoo3") - end - it 'appends the line if no matches are found' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2") } - expect(provider.exists?).to be false - provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar") - end - it 'raises an error with invalid values' do - expect { - @resource = Puppet::Type::File_line.new( - :name => 'foo', :path => tmpfile, :line => 'foo = bar', :match => '^foo\s*=.*$', :replace => 'asgadga', - ) - }.to raise_error(Puppet::Error, %r{Invalid value "asgadga"\. Valid values are true, false\.}) - end - end - end - describe '#destroy' do - pending('To be added?') - end - context 'when matching' do - # rubocop:disable RSpec/InstanceVariable : replacing before with let breaks the tests, variables need to be altered within it block : multi - before :each do - @resource = Puppet::Type::File_line.new( - :name => 'foo', - :path => tmpfile, - :line => 'foo = bar', - :match => '^foo\s*=.*$', - ) - @provider = provider_class.new(@resource) - end - describe 'using match' do - it 'raises an error if more than one line matches, and should not have modified the file' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") } - expect { @provider.create }.to raise_error(Puppet::Error, %r{More than one line.*matches}) - expect(File.read(tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz") - end - - it 'replaces all lines that matches' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'foo = bar', :match => '^foo\s*=.*$', :multiple => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") } - @provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar") - end - - it 'replaces all lines that match, even when some lines are correct' do - @resource = Puppet::Type::File_line.new(:name => 'neil', :path => tmpfile, :line => "\thard\tcore\t0\n", :match => '^[ \t]hard[ \t]+core[ \t]+.*', :multiple => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("\thard\tcore\t90\n\thard\tcore\t0\n") } - @provider.create - expect(File.read(tmpfile).chomp).to eql("\thard\tcore\t0\n\thard\tcore\t0") - end - - it 'raises an error with invalid values' do - expect { - @resource = Puppet::Type::File_line.new( - :name => 'foo', :path => tmpfile, :line => 'foo = bar', :match => '^foo\s*=.*$', :multiple => 'asgadga', - ) - }.to raise_error(Puppet::Error, %r{Invalid value "asgadga"\. Valid values are true, false\.}) - end - - it 'replaces a line that matches' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo=blah\nfoo2") } - @provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") - end - it 'adds a new line if no lines match' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2") } - @provider.create - expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n") - end - it 'does nothing if the exact line already exists' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo = bar\nfoo2") } - @provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") - end - end - describe 'using match+append_on_no_match - when there is a match' do - it 'replaces line' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'inserted = line', :match => '^foo3$', :append_on_no_match => false) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz") } - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo = blah\nfoo2\nfoo = baz") - end - end - describe 'using match+append_on_no_match - when there is no match' do - it 'does not add line after no matches found' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'inserted = line', :match => '^foo3$', :append_on_no_match => false) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz") } - expect(File.read(tmpfile).chomp).to eql("foo1\nfoo = blah\nfoo2\nfoo = baz") - end - end - end - context 'when match+replace+append_on_no_match' do - pending('to do') - end - context 'when after' do - let :resource do - Puppet::Type::File_line.new( - :name => 'foo', - :path => tmpfile, - :line => 'inserted = line', - :after => '^foo1', - ) - end - - let :provider do - provider_class.new(resource) - end - - context 'when match and after set' do - shared_context 'when resource_create' do - let(:match) { '^foo2$' } - let(:after) { '^foo1$' } - let(:resource) do - Puppet::Type::File_line.new( - :name => 'foo', - :path => tmpfile, - :line => 'inserted = line', - :after => after, - :match => match, - ) - end - end - before :each do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nfoo = baz") } - end - describe 'inserts at match' do - include_context 'resource_create' - it { - provider.create - expect(File.read(tmpfile).chomp).to eq("foo1\ninserted = line\nfoo = baz") - } - end - describe 'inserts a new line after when no match' do - include_context 'resource_create' do - let(:match) { '^nevergoingtomatch$' } - end - it { - provider.create - expect(File.read(tmpfile).chomp).to eq("foo1\ninserted = line\nfoo2\nfoo = baz") - } - end - describe 'append to end of file if no match for both after and match' do - include_context 'resource_create' do - let(:match) { '^nevergoingtomatch$' } - let(:after) { '^stillneverafter' } - end - it { - provider.create - expect(File.read(tmpfile).chomp).to eq("foo1\nfoo2\nfoo = baz\ninserted = line") - } - end - end - context 'with one line matching the after expression' do - before :each do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz") } - end - - it 'inserts the specified line after the line matching the "after" expression' do - provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") - end - end - context 'with multiple lines matching the after expression' do - before :each do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo = blah\nfoo2\nfoo1\nfoo = baz") } - end - - it 'errors out stating "One or no line must match the pattern"' do - expect { provider.create }.to raise_error(Puppet::Error, %r{One or no line must match the pattern}) - end - - it 'adds the line after all lines matching the after expression' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'inserted = line', :after => '^foo1$', :multiple => true) - @provider = provider_class.new(@resource) - @provider.create - expect(File.read(tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz") - end - end - context 'with no lines matching the after expression' do - let :content do - "foo3\nfoo = blah\nfoo2\nfoo = baz\n" - end - - before :each do - File.open(tmpfile, 'w') { |fh| fh.write(content) } - end - - it 'appends the specified line to the file' do - provider.create - expect(File.read(tmpfile)).to eq(content << resource[:line] << "\n") - end - end - end - context 'when removing with a line' do - before :each do - # TODO: these should be ported over to use the PuppetLabs spec_helper - # file fixtures once the following pull request has been merged: - # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files - @resource = Puppet::Type::File_line.new( - :name => 'foo', - :path => tmpfile, - :line => 'foo', - :ensure => 'absent', - ) - @provider = provider_class.new(@resource) - end - it 'removes the line if it exists' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2") - end - it 'removes the line without touching the last new line' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2\n") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\n") - end - it 'removes any occurence of the line' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\n") - end - it 'example in the docs' do - @resource = Puppet::Type::File_line.new(:name => 'bashrc_proxy', :ensure => 'absent', :path => tmpfile, :line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128') - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=http://squid.puppetlabs.vm:3128\nfoo4\n") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo4\n") - end - end - context 'when removing with a match' do - before :each do - @resource = Puppet::Type::File_line.new( - :name => 'foo', - :path => tmpfile, - :line => 'foo2', - :ensure => 'absent', - :match => 'o$', - :match_for_absence => true, - ) - @provider = provider_class.new(@resource) - end - - it 'finds a line to match' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - expect(@provider.exists?).to be true - end - - it 'removes one line if it matches' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2") - end - - it 'the line parameter is actually not used at all but is silently ignored if here' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'supercalifragilisticexpialidocious', :ensure => 'absent', :match => 'o$', :match_for_absence => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2") - end - - it 'and may not be here and does not need to be here' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :ensure => 'absent', :match => 'o$', :match_for_absence => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2") - end - - it 'raises an error if more than one line matches' do - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") } - expect { @provider.destroy }.to raise_error(Puppet::Error, %r{More than one line}) - end - - it 'removes multiple lines if :multiple is true' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'foo2', :ensure => 'absent', :match => 'o$', :multiple => true, :match_for_absence => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\n") - end - - it 'ignores the match if match_for_absence is not specified' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'foo2', :ensure => 'absent', :match => 'o$') - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo\n") - end - - it 'ignores the match if match_for_absence is false' do - @resource = Puppet::Type::File_line.new(:name => 'foo', :path => tmpfile, :line => 'foo2', :ensure => 'absent', :match => 'o$', :match_for_absence => false) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo\n") - end - - it 'example in the docs' do - @resource = Puppet::Type::File_line.new( - :name => 'bashrc_proxy', :ensure => 'absent', :path => tmpfile, :line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - :match => '^export\ HTTP_PROXY\=', :match_for_absence => true - ) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo4\n") - end - - it 'example in the docs showing line is redundant' do - @resource = Puppet::Type::File_line.new(:name => 'bashrc_proxy', :ensure => 'absent', :path => tmpfile, :match => '^export\ HTTP_PROXY\=', :match_for_absence => true) - @provider = provider_class.new(@resource) - File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") } - @provider.destroy - expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo4\n") - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec_use_cases.rb --- a/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec_use_cases.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -require 'spec_helper' - -provider_class = Puppet::Type.type(:file_line).provider(:ruby) -#  These tests fail on windows when run as part of the rake task. Individually they pass -describe provider_class, :unless => Puppet::Util::Platform.windows? do - include PuppetlabsSpec::Files - - let :tmpfile do - tmpfilename('file_line_test') - end - let :content do - '' - end - let :params do - {} - end - let :resource do - Puppet::Type::File_line.new({ - :name => 'foo', - :path => tmpfile, - :line => 'foo', - }.merge(params)) - end - let :provider do - provider_class.new(resource) - end - - before :each do - File.open(tmpfile, 'w') do |fh| - fh.write(content) - end - end - - describe 'customer use cases - no lines' do - describe 'MODULES-5003' do - let(:params) do - { - :line => "*\thard\tcore\t0", - :match => "^[ \t]*\\*[ \t]+hard[ \t]+core[ \t]+.*", - :multiple => true, - } - end - let(:content) { "* hard core 90\n* hard core 10\n" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the matches' do - provider.create - expect(File.read(tmpfile).chomp).to eq("* hard core 0\n* hard core 0") - end - end - - describe 'MODULES-5003 - one match, one line - just ensure the line exists' do - let(:params) do - { - :line => "*\thard\tcore\t0", - :match => "^[ \t]*\\*[ \t]+hard[ \t]+core[ \t]+.*", - :multiple => true, - } - end - let(:content) { "* hard core 90\n* hard core 0\n" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - - describe 'MODULES-5003 - one match, one line - replace all matches, even when line exists' do - let(:params) do - { - :line => "*\thard\tcore\t0", - :match => "^[ \t]*\\*[ \t]+hard[ \t]+core[ \t]+.*", - :multiple => true, - - }.merge(:replace_all_matches_not_matching_line => true) - end - let(:content) { "* hard core 90\n* hard core 0\n" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the matches' do - provider.create - expect(File.read(tmpfile).chomp).to eq("* hard core 0\n* hard core 0") - end - end - - describe 'MODULES-5651 - match, no line' do - let(:params) do - { - :line => 'LogLevel=notice', - :match => '^#LogLevel$', - } - end - let(:content) { "#LogLevel\nstuff" } - - it 'requests changes' do - expect(provider).not_to be_exists - end - it 'replaces the match' do - provider.create - expect(File.read(tmpfile).chomp).to eq("LogLevel=notice\nstuff") - end - end - - describe 'MODULES-5651 - match, line' do - let(:params) do - { - :line => 'LogLevel=notice', - :match => '^#LogLevel$', - } - end - let(:content) { "#Loglevel\nLogLevel=notice\nstuff" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - - describe 'MODULES-5651 - no match, line' do - let(:params) do - { - :line => 'LogLevel=notice', - :match => '^#LogLevel$', - } - end - let(:content) { "LogLevel=notice\nstuff" } - - it 'does not request changes' do - expect(provider).to be_exists - end - end - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/type/anchor_spec.rb --- a/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -require 'spec_helper' - -anchor = Puppet::Type.type(:anchor).new(:name => 'ntp::begin') - -describe anchor do - it 'stringifies normally' do - expect(anchor.to_s).to eq('Anchor[ntp::begin]') - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/spec/unit/puppet/type/file_line_spec.rb --- a/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb Sun Oct 09 10:34:07 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -require 'spec_helper' -require 'tempfile' -describe Puppet::Type.type(:file_line) do - let :tmp_path do - if Puppet::Util::Platform.windows? - 'C:\tmp\path' - else - '/tmp/path' - end - end - let :my_path do - if Puppet::Util::Platform.windows? - 'C:\my\path' - else - '/my/path' - end - end - let :file_line do - Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => tmp_path) - end - - it 'accepts a line' do - file_line[:line] = 'my_line' - expect(file_line[:line]).to eq('my_line') - end - it 'accepts a path' do - file_line[:path] = my_path - expect(file_line[:path]).to eq(my_path) - end - it 'accepts a match regex' do - file_line[:match] = '^foo.*$' - expect(file_line[:match]).to eq('^foo.*$') - end - - it 'accepts a match regex that does not match the specified line' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'foo', :path => my_path, :line => 'foo=bar', :match => '^bar=blah$', - ) - }.not_to raise_error - end - it 'accepts a match regex that does match the specified line' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'foo', :path => my_path, :line => 'foo=bar', :match => '^\s*foo=.*$', - ) - }.not_to raise_error - end - it 'accepts utf8 characters' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'ƒồỗ', :path => my_path, :line => 'ƒồỗ=ьåя', :match => '^ьåя=βļάħ$', - ) - }.not_to raise_error - end - it 'accepts double byte characters' do - expect { - Puppet::Type.type(:file_line).new( - :name => 'フーバー', :path => my_path, :line => 'この=それ', :match => '^この=ああ$', - ) - }.not_to raise_error - end - it 'accepts posix filenames' do - file_line[:path] = tmp_path - expect(file_line[:path]).to eq(tmp_path) - end - it 'does not accept unqualified path' do - expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, %r{File paths must be fully qualified}) - end - it 'requires that a line is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, %r{line is a required attribute}) - end - it 'does not require that a line is specified when matching for absence' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength - end - it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength - end - it 'requires that a file is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, %r{path is a required attribute}) - end - it 'defaults to ensure => present' do - expect(file_line[:ensure]).to eq :present - end - it 'defaults to replace => true' do - expect(file_line[:replace]).to eq :true - end - it 'defaults to encoding => UTF-8' do - expect(file_line[:encoding]).to eq 'UTF-8' - end - it 'accepts encoding => iso-8859-1' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :present, :encoding => 'iso-8859-1', :line => 'bar') }.not_to raise_error - end - - it 'autorequires the file it manages' do - catalog = Puppet::Resource::Catalog.new - file = Puppet::Type.type(:file).new(:name => tmp_path) - catalog.add_resource file - catalog.add_resource file_line - relationship = file_line.autorequire.find do |rel| - (rel.source.to_s == "File[#{tmp_path}]") && (rel.target.to_s == file_line.to_s) - end - expect(relationship).to be_a Puppet::Relationship - end - - it 'does not autorequire the file it manages if it is not managed' do - catalog = Puppet::Resource::Catalog.new - catalog.add_resource file_line - expect(file_line.autorequire).to be_empty - end -end diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/base32.pp --- a/modules/stdlib/types/base32.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/base32.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,2 +1,2 @@ # Type to match base32 String -type Stdlib::Base32 = Pattern[/^[a-z2-7]+={,6}$/, /^[A-Z2-7]+={,6}$/] +type Stdlib::Base32 = Pattern[/\A[a-z2-7]+={,6}\z/, /\A[A-Z2-7]+={,6}\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/base64.pp --- a/modules/stdlib/types/base64.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/base64.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,2 +1,2 @@ # Type to match base64 String -type Stdlib::Base64 = Pattern[/^[a-zA-Z0-9\/\+]+={,2}$/] +type Stdlib::Base64 = Pattern[/\A[a-zA-Z0-9\/\+]+={,2}\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/datasize.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/datasize.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Datasize = Pattern[/^\d+(?i:[kmgt]b?|b)$/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ensure/file.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/ensure/file.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Ensure::File = Enum['present', 'file', 'directory', 'link', 'absent'] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ensure/file/directory.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/ensure/file/directory.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Ensure::File::Directory = Enum['directory', 'absent'] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ensure/file/file.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/ensure/file/file.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Ensure::File::File = Enum['file', 'absent'] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ensure/file/link.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/ensure/file/link.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Ensure::File::Link = Enum['link', 'absent'] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/filemode.pp --- a/modules/stdlib/types/filemode.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/filemode.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,2 +1,4 @@ # See `man chmod.1` for the regular expression for symbolic mode -type Stdlib::Filemode = Pattern[/^(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))$/] +# lint:ignore:140chars +type Stdlib::Filemode = Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/] +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/filesource.pp --- a/modules/stdlib/types/filesource.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/filesource.pp Sun Oct 09 10:34:32 2022 +0100 @@ -3,7 +3,7 @@ Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[ - /^file:\/\/\/([^\/\0]+(\/)?)+$/, - /^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/, + /\Afile:\/\/\/([^\n\/\0]+(\/)?)+\z/, + /\Apuppet:\/\/(([\w-]+\.?)+)?\/([^\n\/\0]+(\/)?)+\z/, ], ] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/fqdn.pp --- a/modules/stdlib/types/fqdn.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/fqdn.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -type Stdlib::Fqdn = Pattern[/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/] +type Stdlib::Fqdn = Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/httpstatus.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/httpstatus.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::HttpStatus = Integer[100, 599] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/httpsurl.pp --- a/modules/stdlib/types/httpsurl.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/httpsurl.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -type Stdlib::HTTPSUrl = Pattern[/(?i:^https:\/\/)/] +type Stdlib::HTTPSUrl = Pattern[/(?i:\Ahttps:\/\/.*\z)/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/httpurl.pp --- a/modules/stdlib/types/httpurl.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/httpurl.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -type Stdlib::HTTPUrl = Pattern[/(?i:^https?:\/\/)/] +type Stdlib::HTTPUrl = Pattern[/(?i:\Ahttps?:\/\/.*\z)/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ip/address/v4/cidr.pp --- a/modules/stdlib/types/ip/address/v4/cidr.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/ip/address/v4/cidr.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,3 @@ +# lint:ignore:140chars type Stdlib::IP::Address::V4::CIDR = Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/] +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ip/address/v4/nosubnet.pp --- a/modules/stdlib/types/ip/address/v4/nosubnet.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/ip/address/v4/nosubnet.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,3 @@ +# lint:ignore:140chars type Stdlib::IP::Address::V4::Nosubnet = Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ip/address/v6/alternative.pp --- a/modules/stdlib/types/ip/address/v6/alternative.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/ip/address/v6/alternative.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,3 +1,4 @@ +# lint:ignore:140chars type Stdlib::IP::Address::V6::Alternative = Pattern[ /\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, @@ -7,3 +8,4 @@ /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, ] +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ip/address/v6/cidr.pp --- a/modules/stdlib/types/ip/address/v6/cidr.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/ip/address/v6/cidr.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,3 +1,3 @@ - +# lint:ignore:140chars type Stdlib::IP::Address::V6::CIDR = Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/] - +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/ip/address/v6/nosubnet/alternative.pp --- a/modules/stdlib/types/ip/address/v6/nosubnet/alternative.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/ip/address/v6/nosubnet/alternative.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,3 +1,4 @@ +# lint:ignore:140chars type Stdlib::IP::Address::V6::Nosubnet::Alternative = Pattern[ /\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, @@ -7,3 +8,4 @@ /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, ] +# lint:endignore diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/mac.pp --- a/modules/stdlib/types/mac.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/mac.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,5 +1,5 @@ # A type for a MAC address type Stdlib::MAC = Pattern[ - /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/, - /^([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})$/ + /\A([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})\z/, + /\A([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})\z/, ] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/objectstore/gsuri.pp --- a/modules/stdlib/types/objectstore/gsuri.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/objectstore/gsuri.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,2 +1,1 @@ -type Stdlib::ObjectStore::GSUri = Pattern[/^gs:\/\//] - +type Stdlib::ObjectStore::GSUri = Pattern[/\Ags:\/\/.*\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/objectstore/s3uri.pp --- a/modules/stdlib/types/objectstore/s3uri.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/objectstore/s3uri.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -type Stdlib::ObjectStore::S3Uri = Pattern[/^s3:\/\//] +type Stdlib::ObjectStore::S3Uri = Pattern[/\As3:\/\/.*\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/port/dynamic.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/port/dynamic.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Port::Dynamic = Integer[49152, 65535] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/port/ephemeral.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/port/ephemeral.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Port::Ephemeral = Stdlib::Port::Dynamic diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/port/registered.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/port/registered.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Port::Registered = Stdlib::Port::User diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/port/user.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/stdlib/types/port/user.pp Sun Oct 09 10:34:32 2022 +0100 @@ -0,0 +1,1 @@ +type Stdlib::Port::User = Integer[1024, 49151] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/syslogfacility.pp --- a/modules/stdlib/types/syslogfacility.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/syslogfacility.pp Sun Oct 09 10:34:32 2022 +0100 @@ -22,5 +22,5 @@ 'local4', 'local5', 'local6', - 'local7' + 'local7', ] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/unixpath.pp --- a/modules/stdlib/types/unixpath.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/unixpath.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,2 +1,2 @@ # this regex rejects any path component that does not start with "/" or is NUL -type Stdlib::Unixpath = Pattern[/^\/([^\/\0]+\/*)*$/] +type Stdlib::Unixpath = Pattern[/\A\/([^\n\/\0]+\/*)*\z/] diff -r a200bf678bec -r 4a2ee7e3b110 modules/stdlib/types/windowspath.pp --- a/modules/stdlib/types/windowspath.pp Sun Oct 09 10:34:07 2022 +0100 +++ b/modules/stdlib/types/windowspath.pp Sun Oct 09 10:34:32 2022 +0100 @@ -1,1 +1,1 @@ -type Stdlib::Windowspath = Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/] +type Stdlib::Windowspath = Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/]