From ecb9bfe4edcb4c285c8c86e39ff047641b814b8e Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Thu, 7 Dec 2017 09:55:21 +0000 Subject: [PATCH] Addressing Rubocop Errors --- lib/puppet/provider/apt_key/apt_key.rb | 2 +- lib/puppet/type/apt_key.rb | 36 +++--- spec/acceptance/apt_key_provider_spec.rb | 154 +++++++++++------------ spec/acceptance/apt_spec.rb | 10 +- spec/acceptance/class_spec.rb | 6 +- spec/classes/apt_backports_spec.rb | 28 ++--- spec/classes/apt_spec.rb | 24 ++-- spec/classes/apt_update_spec.rb | 12 +- spec/defines/key_compat_spec.rb | 36 +++--- spec/defines/key_spec.rb | 36 +++--- spec/defines/pin_spec.rb | 22 ++-- spec/defines/ppa_spec.rb | 2 +- spec/defines/source_compat_spec.rb | 12 +- spec/defines/source_spec.rb | 20 +-- spec/spec_helper_acceptance.rb | 3 +- spec/unit/puppet/type/apt_key_spec.rb | 4 +- 16 files changed, 204 insertions(+), 203 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 49b1afd..fc0d206 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -72,7 +72,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do def self.prefetch(resources) apt_keys = instances - resources.keys.each do |name| + resources.each_key do |name| if name.length == 40 provider = apt_keys.find { |key| key.fingerprint == name } resources[name].provider = provider if provider diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index a9273e2..d8b224f 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -1,7 +1,7 @@ require 'pathname' Puppet::Type.newtype(:apt_key) do - @doc = <<-EOS + @doc = <<-MANIFEST This type provides Puppet with the capabilities to manage GPG keys needed by apt to perform package validation. Apt has it's own GPG keyring that can be manipulated through the `apt-key` command. @@ -14,7 +14,7 @@ Puppet::Type.newtype(:apt_key) do If Puppet is given the location of a key file which looks like an absolute path this type will autorequire that file. - EOS + MANIFEST ensurable @@ -69,66 +69,66 @@ Puppet::Type.newtype(:apt_key) do end newproperty(:fingerprint) do - desc <<-EOS + desc <<-MANIFEST The 40-digit hexadecimal fingerprint of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:long) do - desc <<-EOS + desc <<-MANIFEST The 16-digit hexadecimal id of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:short) do - desc <<-EOS + desc <<-MANIFEST The 8-digit hexadecimal id of the specified GPG key. This property is read-only. - EOS + MANIFEST end newproperty(:expired) do - desc <<-EOS + desc <<-MANIFEST Indicates if the key has expired. This property is read-only. - EOS + MANIFEST end newproperty(:expiry) do - desc <<-EOS + desc <<-MANIFEST The date the key will expire, or nil if it has no expiry date. This property is read-only. - EOS + MANIFEST end newproperty(:size) do - desc <<-EOS + desc <<-MANIFEST The key size, usually a multiple of 1024. This property is read-only. - EOS + MANIFEST end newproperty(:type) do - desc <<-EOS + desc <<-MANIFEST The key type, one of: rsa, dsa, ecc, ecdsa This property is read-only. - EOS + MANIFEST end newproperty(:created) do - desc <<-EOS + desc <<-MANIFEST Date the key was created. This property is read-only. - EOS + MANIFEST end end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 0644cb5..0e1ba63 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -22,12 +22,12 @@ TIMEOUT_RETRY_WAIT = 5 TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found} def populate_default_options_pp(value) - default_options_pp = <<-EOS + default_options_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{value}', ensure => 'present', } - EOS + MANIFEST default_options_pp end @@ -43,27 +43,27 @@ def apply_manifest_twice(manifest_pp) apply_manifest(manifest_pp, catch_changes: true) end -invalid_key_length_pp = <<-EOS +invalid_key_length_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '8280EF8D349F', } - EOS + MANIFEST -ensure_absent_pp = <<-EOS +ensure_absent_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } - EOS + MANIFEST -ensure_absent_long_key_pp = <<-EOS +ensure_absent_long_key_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'absent', } - EOS + MANIFEST -gpg_key_pp = <<-EOS +gpg_key_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', @@ -120,9 +120,9 @@ gpg_key_pp = <<-EOS =mMjt -----END PGP PUBLIC KEY BLOCK-----", } - EOS + MANIFEST -multiple_keys_pp = <<-EOS +multiple_keys_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', @@ -373,183 +373,183 @@ multiple_keys_pp = <<-EOS =TREp -----END PGP PUBLIC KEY BLOCK----- ", } - EOS + MANIFEST -bogus_key_pp = <<-EOS +bogus_key_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', content => 'For posterity: such content, much bogus, wow', } - EOS + MANIFEST -hkps_pool_pp = <<-EOS +hkps_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'hkps.pool.sks-keyservers.net', } - EOS + MANIFEST -hkp_pool_pp = <<-EOS +hkp_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', server => 'hkp://hkps.pool.sks-keyservers.net:80', } - EOS + MANIFEST -nonexistant_key_server_pp = <<-EOS +nonexistant_key_server_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'nonexistant.key.server', } - EOS + MANIFEST -dot_server_pp = <<-EOS +dot_server_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => '.pgp.key.server', } - EOS + MANIFEST -http_works_pp = <<-EOS +http_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST -http_works_userinfo_pp = <<-EOS +http_works_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST -four_oh_four_pp = <<-EOS +four_oh_four_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - EOS + MANIFEST -socket_error_pp = <<-EOS +socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } - EOS + MANIFEST -ftp_works_pp = <<-EOS +ftp_works_pp = <<-MANIFEST apt_key { 'CentOS 6': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } - EOS + MANIFEST -ftp_550_pp = <<-EOS +ftp_550_pp = <<-MANIFEST apt_key { 'CentOS 6': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } - EOS + MANIFEST -ftp_socket_error_pp = <<-EOS +ftp_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } - EOS + MANIFEST -https_works_pp = <<-EOS +https_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST -https_userinfo_pp = <<-EOS +https_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST -https_404_pp = <<-EOS +https_404_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - EOS + MANIFEST -https_socket_error_pp = <<-EOS +https_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } - EOS + MANIFEST -path_exists_pp = <<-EOS +path_exists_pp = <<-MANIFEST apt_key { 'puppetlabs': id => 'EF8D349F', ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } - EOS + MANIFEST -path_does_not_exist_pp = <<-EOS +path_does_not_exist_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/totally_bogus.file', } - EOS + MANIFEST -path_bogus_content_pp = <<-EOS +path_bogus_content_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/fake-key.gpg', } - EOS + MANIFEST -debug_works_pp = <<-EOS +debug_works_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', options => 'debug', } - EOS + MANIFEST -fingerprint_match_pp = <<-EOS +fingerprint_match_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST -fingerprint_does_not_match_pp = <<-EOS +fingerprint_does_not_match_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '6F6B15509CF8E59E6E469F327F438280EF8D9999', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - EOS + MANIFEST describe 'apt_key' do before(:each) do @@ -577,8 +577,8 @@ describe 'apt_key' do '0x formatted 160bit lowercase key fingerprint' => "0x#{PUPPETLABS_GPG_KEY_FINGERPRINT.downcase}", } - key_versions.each do |key, value| - context key.to_s do + key_versions.each do |key, value| # rubocop:disable Lint/UnusedBlockArgument, Performance/HashEachMethods + context 'when key.to_s' do it 'works' do apply_manifest_twice(populate_default_options_pp(value)) shell(PUPPETLABS_KEY_CHECK_COMMAND) @@ -586,7 +586,7 @@ describe 'apt_key' do end end - context 'invalid length key id' do + context 'with invalid length key id' do it 'fails' do apply_manifest(invalid_key_length_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{Valid values match}) @@ -596,7 +596,7 @@ describe 'apt_key' do end describe 'ensure =>' do - context 'absent' do + context 'when absent' do it 'is removed' do # Install the key first (retry because key pool may timeout) install_key(CENTOS_GPG_KEY_FINGERPRINT) @@ -612,7 +612,7 @@ describe 'apt_key' do end end - context 'absent, added with long key', unless: (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '6') do + context 'when absent, added with long key', unless: (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '6') do it 'is removed' do # Install the key first (retry because key pool may timeout) install_key(PUPPETLABS_GPG_KEY_LONG_ID) @@ -627,7 +627,7 @@ describe 'apt_key' do end describe 'content =>' do - context 'puppetlabs gpg key' do + context 'with puppetlabs gpg key' do it 'works' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do @@ -639,14 +639,14 @@ describe 'apt_key' do end end - context 'multiple keys' do + context 'with multiple keys' do it 'runs without errors' do apply_manifest_twice(multiple_keys_pp) shell(PUPPETLABS_KEY_CHECK_COMMAND) end end - context 'bogus key' do + context 'with bogus key' do it 'fails' do apply_manifest(bogus_key_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) @@ -656,7 +656,7 @@ describe 'apt_key' do end describe 'server =>' do - context 'hkps.pool.sks-keyservers.net' do + context 'with hkps.pool.sks-keyservers.net' do it 'works' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do @@ -668,7 +668,7 @@ describe 'apt_key' do end end - context 'hkp://hkps.pool.sks-keyservers.net:80' do + context 'with hkp://hkps.pool.sks-keyservers.net:80' do it 'works' do retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do apply_manifest(hkp_pool_pp, catch_failures: true) @@ -679,7 +679,7 @@ describe 'apt_key' do end end - context 'nonexistant.key.server' do + context 'with nonexistant.key.server' do it 'fails' do apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host)}) @@ -687,7 +687,7 @@ describe 'apt_key' do end end - context 'key server start with dot' do + context 'with key server start with dot' do it 'fails' do apply_manifest(dot_server_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{Invalid value ".pgp.key.server"}) @@ -697,7 +697,7 @@ describe 'apt_key' do end describe 'source =>' do - context 'http://' do + context 'with http://' do it 'works' do apply_manifest_twice(http_works_pp) shell(PUPPETLABS_KEY_CHECK_COMMAND) @@ -721,7 +721,7 @@ describe 'apt_key' do end end - context 'ftp://' do + context 'with ftp://' do before(:each) do shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", acceptable_exit_codes: [0, 1, 2]) @@ -745,7 +745,7 @@ describe 'apt_key' do end end - context 'https://' do + context 'with https://' do it 'works' do apply_manifest_twice(https_works_pp) shell(PUPPETLABS_KEY_CHECK_COMMAND) @@ -769,7 +769,7 @@ describe 'apt_key' do end end - context '/path/that/exists' do + context 'with /path/that/exists' do before(:each) do shell("curl -o /tmp/puppetlabs-pubkey.gpg \ http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}") @@ -785,7 +785,7 @@ describe 'apt_key' do end end - context '/path/that/does/not/exist' do + context 'with /path/that/does/not/exist' do it 'fails' do apply_manifest(path_does_not_exist_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{does not exist}) @@ -793,7 +793,7 @@ describe 'apt_key' do end end - context '/path/that/exists/with/bogus/content' do + context 'with /path/that/exists/with/bogus/content' do before(:each) do shell('echo "here be dragons" > /tmp/fake-key.gpg') end @@ -810,7 +810,7 @@ describe 'apt_key' do end describe 'options =>' do - context 'debug' do + context 'with debug' do it 'works' do apply_manifest_twice(debug_works_pp) shell(PUPPETLABS_KEY_CHECK_COMMAND) @@ -819,13 +819,13 @@ describe 'apt_key' do end describe 'fingerprint validation against source/content' do - context 'fingerprint in id matches fingerprint from remote key' do + context 'with fingerprint in id matches fingerprint from remote key' do it 'works' do apply_manifest_twice(fingerprint_match_pp) end end - context 'fingerprint in id does NOT match fingerprint from remote key' do + context 'with fingerprint in id does NOT match fingerprint from remote key' do it 'works' do apply_manifest(fingerprint_does_not_match_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{don't match}) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 04f5540..5505748 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -4,7 +4,7 @@ MAX_TIMEOUT_RETRY = 3 TIMEOUT_RETRY_WAIT = 5 TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found} -everything_everything_pp = <<-EOS +everything_everything_pp = <<-MANIFEST if $::lsbdistcodename == 'lucid' { $sources = undef } else { @@ -34,16 +34,16 @@ everything_everything_pp = <<-EOS }, sources => $sources, } - EOS + MANIFEST describe 'apt class' do - context 'reset' do + context 'with reset' do it 'fixes the sources.list' do shell('cp /etc/apt/sources.list /tmp') end end - context 'all the things' do + context 'with all the things' do it 'works with no errors' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do @@ -58,7 +58,7 @@ describe 'apt class' do end end - context 'reset' do + context 'with reset' do it 'fixes the sources.list' do shell('cp /tmp/sources.list /etc/apt') end diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index d970794..53d75f6 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper_acceptance' describe 'apt class' do - context 'default parameters' do + context 'with default parameters' do # Using puppet_apply as a helper it 'works with no errors' do - pp = <<-EOS + pp = <<-MANIFEST class { 'apt': } - EOS + MANIFEST # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index b8e1424..33022b9 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -4,7 +4,7 @@ describe 'apt::backports', type: :class do let(:pre_condition) { "class{ '::apt': }" } describe 'debian/ubuntu tests' do - context 'defaults on deb' do + context 'with defaults on deb' do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -23,7 +23,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'wheezy-backports' }) } end - context 'defaults on ubuntu' do + context 'with defaults on ubuntu' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, @@ -43,7 +43,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end - context 'set everything' do + context 'with everything set' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, @@ -72,7 +72,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 90, 'release' => 'vivid' }) } end - context 'set things with hashes' do + context 'when set things with hashes' do let(:facts) do { os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, @@ -111,7 +111,7 @@ describe 'apt::backports', type: :class do } end - context 'sets all the needed things' do + context 'with all the needed things set' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', @@ -129,7 +129,7 @@ describe 'apt::backports', type: :class do pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end - context 'missing location' do + context 'with missing location' do let(:params) do { release: 'trusty-backports', @@ -142,7 +142,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end - context 'missing release' do + context 'with missing release' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', @@ -155,7 +155,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end - context 'missing repos' do + context 'with missing repos' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', @@ -168,7 +168,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end - context 'missing key' do + context 'with missing key' do let(:params) do { location: 'http://archive.ubuntu.com/ubuntu', @@ -194,7 +194,7 @@ describe 'apt::backports', type: :class do } end - context 'invalid location' do + context 'with invalid location' do let(:params) do { location: true, @@ -205,7 +205,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end - context 'invalid release' do + context 'with invalid release' do let(:params) do { release: true, @@ -216,7 +216,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end - context 'invalid repos' do + context 'with invalid repos' do let(:params) do { repos: true, @@ -227,7 +227,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end - context 'invalid key' do + context 'with invalid key' do let(:params) do { key: true, @@ -238,7 +238,7 @@ describe 'apt::backports', type: :class do is_expected.to raise_error(Puppet::Error, %r{expects a}) end end - context 'invalid pin' do + context 'with invalid pin' do let(:params) do { pin: true, diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index fb84c51..0c6333b 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -43,7 +43,7 @@ describe 'apt' do } end - context 'defaults' do + context 'with defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list) } @@ -76,7 +76,7 @@ describe 'apt' do end describe 'proxy=' do - context 'host=localhost' do + context 'when host=localhost' do let(:params) { { proxy: { 'host' => 'localhost' } } } it { @@ -88,7 +88,7 @@ describe 'apt' do } end - context 'host=localhost and port=8180' do + context 'when host=localhost and port=8180' do let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } } it { @@ -100,7 +100,7 @@ describe 'apt' do } end - context 'host=localhost and https=true' do + context 'when host=localhost and https=true' do let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } } it { @@ -112,7 +112,7 @@ describe 'apt' do } end - context 'host=localhost and direct=true' do + context 'when host=localhost and direct=true' do let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } } it { @@ -124,7 +124,7 @@ describe 'apt' do } end - context 'host=localhost and https=true and direct=true' do + context 'when host=localhost and https=true and direct=true' do let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } } it { @@ -143,7 +143,7 @@ describe 'apt' do } end - context 'ensure=absent' do + context 'when ensure=absent' do let(:params) { { proxy: { 'ensure' => 'absent' } } } it { @@ -152,7 +152,7 @@ describe 'apt' do } end end - context 'lots of non-defaults' do + context 'with lots of non-defaults' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, @@ -352,7 +352,7 @@ describe 'apt' do end describe 'failing tests' do - context "purge['sources.list']=>'banana'" do + context "with purge['sources.list']=>'banana'" do let(:params) { { purge: { 'sources.list' => 'banana' } } } it do @@ -360,7 +360,7 @@ describe 'apt' do end end - context "purge['sources.list.d']=>'banana'" do + context "with purge['sources.list.d']=>'banana'" do let(:params) { { purge: { 'sources.list.d' => 'banana' } } } it do @@ -368,7 +368,7 @@ describe 'apt' do end end - context "purge['preferences']=>'banana'" do + context "with purge['preferences']=>'banana'" do let(:params) { { purge: { 'preferences' => 'banana' } } } it do @@ -376,7 +376,7 @@ describe 'apt' do end end - context "purge['preferences.d']=>'banana'" do + context "with purge['preferences.d']=>'banana'" do let(:params) { { purge: { 'preferences.d' => 'banana' } } } it do diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 9f91d04..675bbd2 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe 'apt::update', type: :class do - context "and apt::update['frequency']='always'" do + context "when apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do + context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -46,13 +46,13 @@ describe 'apt::update', type: :class do end end end - context "and apt::update['frequency']='reluctantly'" do + context "when apt::update['frequency']='reluctantly'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do + context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -90,9 +90,9 @@ describe 'apt::update', type: :class do end end %w[daily weekly].each do |update_frequency| - context "and apt::update['frequency'] has the value of #{update_frequency}" do + context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do + context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 0a450ec..43ccbbc 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -112,7 +112,7 @@ describe 'apt::key', type: :define do end end - context 'domain with dash' do + context 'when domain has dash' do let(:params) do { server: 'p-gp.m-it.edu', @@ -125,7 +125,7 @@ describe 'apt::key', type: :define do end end - context 'url' do + context 'with url' do let :params do { server: 'hkp://pgp.mit.edu', @@ -137,7 +137,7 @@ describe 'apt::key', type: :define do server: 'hkp://pgp.mit.edu') end end - context 'url with port number' do + context 'with url and port number' do let :params do { server: 'hkp://pgp.mit.edu:80', @@ -152,7 +152,7 @@ describe 'apt::key', type: :define do end describe 'validation' do - context 'domain begin with dash' do + context 'when domain begins with a dash' do let(:params) do { server: '-pgp.mit.edu', @@ -164,7 +164,7 @@ describe 'apt::key', type: :define do end end - context 'domain begin with dot' do + context 'when domain begins with dot' do let(:params) do { server: '.pgp.mit.edu', @@ -176,7 +176,7 @@ describe 'apt::key', type: :define do end end - context 'domain end with dot' do + context 'when domain ends with dot' do let(:params) do { server: 'pgp.mit.edu.', @@ -187,7 +187,7 @@ describe 'apt::key', type: :define do is_expected .to raise_error(%r{expects a match}) end end - context 'exceed character url' do + context 'when url character limit is exceeded' do let :params do { server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', @@ -198,7 +198,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'incorrect port number url' do + context 'with incorrect port number url' do let :params do { server: 'hkp://pgp.mit.edu:8008080', @@ -209,7 +209,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'incorrect protocol for url' do + context 'with incorrect protocol for url' do let :params do { server: 'abc://pgp.mit.edu:80', @@ -220,7 +220,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'missing port number url' do + context 'with missing port number url' do let :params do { server: 'hkp://pgp.mit.edu:', @@ -231,7 +231,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'url ending with a dot' do + context 'with url ending with a dot' do let :params do { server: 'hkp://pgp.mit.edu.', @@ -242,7 +242,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'url begin with a dash' do + context 'with url begin with a dash' do let(:params) do { server: 'hkp://-pgp.mit.edu', @@ -253,7 +253,7 @@ describe 'apt::key', type: :define do is_expected.to raise_error(%r{expects a match}) end end - context 'invalid key' do + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end @@ -263,7 +263,7 @@ describe 'apt::key', type: :define do end end - context 'invalid source' do + context 'with invalid source' do let :params do { source: 'afp://puppetlabs.com/key.gpg', @@ -275,7 +275,7 @@ describe 'apt::key', type: :define do end end - context 'invalid content' do + context 'with invalid content' do let :params do { content: [], @@ -287,7 +287,7 @@ describe 'apt::key', type: :define do end end - context 'invalid server' do + context 'with invalid server' do let :params do { server: 'two bottles of rum', @@ -299,7 +299,7 @@ describe 'apt::key', type: :define do end end - context 'invalid keyserver_options' do + context 'with invalid keyserver_options' do let :params do { options: {}, @@ -311,7 +311,7 @@ describe 'apt::key', type: :define do end end - context 'invalid ensure' do + context 'with invalid ensure' do let :params do { ensure: 'foo', diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index d668780..6a5a89f 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -117,7 +117,7 @@ describe 'apt::key' do end end - context 'domain with dash' do + context 'when domain with dash' do let(:params) do { server: 'p-gp.m-it.edu', @@ -130,7 +130,7 @@ describe 'apt::key' do end end - context 'url' do + context 'with url' do let :params do { server: 'hkp://pgp.mit.edu', @@ -142,7 +142,7 @@ describe 'apt::key' do server: 'hkp://pgp.mit.edu') end end - context 'url with port number' do + context 'when url with port number' do let :params do { server: 'hkp://pgp.mit.edu:80', @@ -157,7 +157,7 @@ describe 'apt::key' do end describe 'validation' do - context 'domain begin with dash' do + context 'when domain begin with dash' do let(:params) do { server: '-pgp.mit.edu', @@ -169,7 +169,7 @@ describe 'apt::key' do end end - context 'domain begin with dot' do + context 'when domain begin with dot' do let(:params) do { server: '.pgp.mit.edu', @@ -181,7 +181,7 @@ describe 'apt::key' do end end - context 'domain end with dot' do + context 'when domain end with dot' do let(:params) do { server: 'pgp.mit.edu.', @@ -192,7 +192,7 @@ describe 'apt::key' do is_expected .to raise_error(%r{expects a match}) end end - context 'exceed character url' do + context 'when character url exceeded' do let :params do { server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', @@ -203,7 +203,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'incorrect port number url' do + context 'with incorrect port number url' do let :params do { server: 'hkp://pgp.mit.edu:8008080', @@ -214,7 +214,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'incorrect protocol for url' do + context 'with incorrect protocol for url' do let :params do { server: 'abc://pgp.mit.edu:80', @@ -225,7 +225,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'missing port number url' do + context 'with missing port number url' do let :params do { server: 'hkp://pgp.mit.edu:', @@ -236,7 +236,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'url ending with a dot' do + context 'with url ending with a dot' do let :params do { server: 'hkp://pgp.mit.edu.', @@ -247,7 +247,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'url begin with a dash' do + context 'when url begins with a dash' do let(:params) do { server: 'hkp://-pgp.mit.edu', @@ -258,7 +258,7 @@ describe 'apt::key' do is_expected.to raise_error(%r{expects a match}) end end - context 'invalid key' do + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' end @@ -268,7 +268,7 @@ describe 'apt::key' do end end - context 'invalid source' do + context 'with invalid source' do let :params do { source: 'afp://puppetlabs.com/key.gpg', @@ -280,7 +280,7 @@ describe 'apt::key' do end end - context 'invalid content' do + context 'with invalid content' do let :params do { content: [], @@ -292,7 +292,7 @@ describe 'apt::key' do end end - context 'invalid server' do + context 'with invalid server' do let :params do { server: 'two bottles of rum', @@ -304,7 +304,7 @@ describe 'apt::key' do end end - context 'invalid options' do + context 'with invalid options' do let :params do { options: {}, @@ -316,7 +316,7 @@ describe 'apt::key' do end end - context 'invalid ensure' do + context 'with invalid ensure' do %w[foo aabsent absenta apresent presenta].each do |param| let :params do { diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 52ecb97..2329e9a 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -14,11 +14,11 @@ describe 'apt::pin', type: :define do end let(:title) { 'my_pin' } - context 'defaults' do + context 'with defaults' do it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n}) } end - context 'set version' do + context 'with set version' do let :params do { 'packages' => 'vim', @@ -29,7 +29,7 @@ describe 'apt::pin', type: :define do it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n}) } end - context 'set origin' do + context 'with set origin' do let :params do { 'packages' => 'vim', @@ -40,7 +40,7 @@ describe 'apt::pin', type: :define do it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n}) } end - context 'not defaults' do + context 'without defaults' do let :params do { 'explanation' => 'foo', @@ -61,7 +61,7 @@ describe 'apt::pin', type: :define do } end - context 'ensure absent' do + context 'with ensure absent' do let :params do { 'ensure' => 'absent', @@ -73,14 +73,14 @@ describe 'apt::pin', type: :define do } end - context 'bad characters' do + context 'with bad characters' do let(:title) { 'such bad && wow!' } it { is_expected.to contain_apt__setting('pref-such__bad____wow_') } end describe 'validation' do - context 'invalid order' do + context 'with invalid order' do let :params do { 'order' => 'foo', @@ -92,7 +92,7 @@ describe 'apt::pin', type: :define do end end - context 'packages == * and version' do + context 'with packages == * and version' do let :params do { 'version' => '1', @@ -104,7 +104,7 @@ describe 'apt::pin', type: :define do end end - context 'packages == * and release and origin' do + context 'with packages == * and release and origin' do let :params do { 'origin' => 'test', @@ -117,7 +117,7 @@ describe 'apt::pin', type: :define do end end - context 'specific form with release and origin' do + context 'with specific release and origin' do let :params do { 'release' => 'foo', @@ -131,7 +131,7 @@ describe 'apt::pin', type: :define do end end - context 'specific form with version and origin' do + context 'with specific version and origin' do let :params do { 'version' => '1', diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7a11811..b534186 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -337,7 +337,7 @@ describe 'apt::ppa' do } end - context 'validation' do + context 'with validation' do describe 'no release' do let :facts do { diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 23f9549..f89f4be 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -7,7 +7,7 @@ describe 'apt::source', type: :define do 'my_source' end - context 'mostly defaults' do + context 'with mostly defaults' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -30,7 +30,7 @@ describe 'apt::source', type: :define do } end - context 'no defaults' do + context 'with no defaults' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -71,7 +71,7 @@ describe 'apt::source', type: :define do } end - context 'allow_unsigned true' do + context 'when allow_unsigned true' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -92,7 +92,7 @@ describe 'apt::source', type: :define do it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ wheezy main\n}) } end - context 'architecture equals x86_64' do + context 'with architecture equals x86_64' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -114,7 +114,7 @@ describe 'apt::source', type: :define do } end - context 'ensure => absent' do + context 'with ensure => absent' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -136,7 +136,7 @@ describe 'apt::source', type: :define do end describe 'validation' do - context 'no release' do + context 'with no release' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 9cec580..a9077e9 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -11,7 +11,7 @@ describe 'apt::source' do 'my_source' end - context 'defaults' do + context 'with defaults' do context 'without location' do let :facts do { @@ -180,7 +180,7 @@ describe 'apt::source' do end end - context 'allow_unsigned true' do + context 'with allow_unsigned true' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -202,7 +202,7 @@ describe 'apt::source' do } end - context 'architecture equals x86_64' do + context 'with architecture equals x86_64' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -248,7 +248,7 @@ describe 'apt::source' do } end - context 'include_src => true' do + context 'with include_src => true' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -270,7 +270,7 @@ describe 'apt::source' do } end - context 'include deb => false' do + context 'with include deb => false' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -293,7 +293,7 @@ describe 'apt::source' do it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } end - context 'include src => true and include deb => false' do + context 'with include src => true and include deb => false' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -316,7 +316,7 @@ describe 'apt::source' do it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } end - context 'ensure => absent' do + context 'with ensure => absent' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -338,7 +338,7 @@ describe 'apt::source' do end describe 'validation' do - context 'no release' do + context 'with no release' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -354,7 +354,7 @@ describe 'apt::source' do end end - context 'release is empty string' do + context 'with release is empty string' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, @@ -368,7 +368,7 @@ describe 'apt::source' do it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) } end - context 'invalid pin' do + context 'with invalid pin' do let :facts do { os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 67bf096..2ec2dba 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -27,7 +27,8 @@ def puppet_version (on default, puppet('--version')).output.chomp end -def run_puppet_access_login(user:, password: '~!@#$%^*-/ aZ', lifetime: '5y') +def run_puppet_access_login(user:, password: + '~!@#$%^*-/ aZ', lifetime: '5y') on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password) end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index 0428040..a25d827 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'puppet' describe Puppet::Type.type(:apt_key) do - context 'only namevar 32bit key id' do + context 'with only namevar 32bit key id' do let(:resource) do Puppet::Type.type(:apt_key).new( id: 'EF8D349F', @@ -129,7 +129,7 @@ describe Puppet::Type.type(:apt_key) do end end - context 'validation' do + context 'with validation' do it 'raises an error if content and source are set' do expect { Puppet::Type.type(:apt_key).new(id: 'EF8D349F', -- 2.32.3