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
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.
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
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
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
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',
=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',
=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
'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)
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})
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)
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)
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
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})
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
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)
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)})
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"})
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)
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])
end
end
- context 'https://' do
+ context 'with https://' do
it 'works' do
apply_manifest_twice(https_works_pp)
shell(PUPPETLABS_KEY_CHECK_COMMAND)
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}")
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})
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
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)
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})
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 {
},
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
end
end
- context 'reset' do
+ context 'with reset' do
it 'fixes the sources.list' do
shell('cp /tmp/sources.list /etc/apt')
end
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)
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' } },
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' } },
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' } },
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' } },
}
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',
pin: { 'priority' => 200, 'release' => 'trusty-backports' })
}
end
- context 'missing location' do
+ context 'with missing location' do
let(:params) do
{
release: 'trusty-backports',
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',
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',
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',
}
end
- context 'invalid location' do
+ context 'with invalid location' do
let(:params) do
{
location: true,
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,
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,
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,
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,
}
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)
}
end
describe 'proxy=' do
- context 'host=localhost' do
+ context 'when host=localhost' do
let(:params) { { proxy: { 'host' => 'localhost' } } }
it {
}
end
- context 'host=localhost and port=8180' do
+ context 'when host=localhost and port=8180' do
let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } }
it {
}
end
- context 'host=localhost and https=true' do
+ context 'when host=localhost and https=true' do
let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } }
it {
}
end
- context 'host=localhost and direct=true' do
+ context 'when host=localhost and direct=true' do
let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } }
it {
}
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 {
}
end
- context 'ensure=absent' do
+ context 'when ensure=absent' do
let(:params) { { proxy: { 'ensure' => 'absent' } } }
it {
}
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 },
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
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
end
end
- context "purge['preferences']=>'banana'" do
+ context "with purge['preferences']=>'banana'" do
let(:params) { { purge: { 'preferences' => 'banana' } } }
it do
end
end
- context "purge['preferences.d']=>'banana'" do
+ context "with purge['preferences.d']=>'banana'" do
let(:params) { { purge: { 'preferences.d' => 'banana' } } }
it do
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' } },
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' } },
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' } },
end
end
- context 'domain with dash' do
+ context 'when domain has dash' do
let(:params) do
{
server: 'p-gp.m-it.edu',
end
end
- context 'url' do
+ context 'with url' do
let :params do
{
server: 'hkp://pgp.mit.edu',
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',
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',
end
end
- context 'domain begin with dot' do
+ context 'when domain begins with dot' do
let(:params) do
{
server: '.pgp.mit.edu',
end
end
- context 'domain end with dot' do
+ context 'when domain ends with dot' do
let(:params) do
{
server: 'pgp.mit.edu.',
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',
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',
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',
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:',
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.',
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',
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
end
end
- context 'invalid source' do
+ context 'with invalid source' do
let :params do
{
source: 'afp://puppetlabs.com/key.gpg',
end
end
- context 'invalid content' do
+ context 'with invalid content' do
let :params do
{
content: [],
end
end
- context 'invalid server' do
+ context 'with invalid server' do
let :params do
{
server: 'two bottles of rum',
end
end
- context 'invalid keyserver_options' do
+ context 'with invalid keyserver_options' do
let :params do
{
options: {},
end
end
- context 'invalid ensure' do
+ context 'with invalid ensure' do
let :params do
{
ensure: 'foo',
end
end
- context 'domain with dash' do
+ context 'when domain with dash' do
let(:params) do
{
server: 'p-gp.m-it.edu',
end
end
- context 'url' do
+ context 'with url' do
let :params do
{
server: 'hkp://pgp.mit.edu',
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',
end
describe 'validation' do
- context 'domain begin with dash' do
+ context 'when domain begin with dash' do
let(:params) do
{
server: '-pgp.mit.edu',
end
end
- context 'domain begin with dot' do
+ context 'when domain begin with dot' do
let(:params) do
{
server: '.pgp.mit.edu',
end
end
- context 'domain end with dot' do
+ context 'when domain end with dot' do
let(:params) do
{
server: 'pgp.mit.edu.',
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',
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',
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',
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:',
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.',
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',
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
end
end
- context 'invalid source' do
+ context 'with invalid source' do
let :params do
{
source: 'afp://puppetlabs.com/key.gpg',
end
end
- context 'invalid content' do
+ context 'with invalid content' do
let :params do
{
content: [],
end
end
- context 'invalid server' do
+ context 'with invalid server' do
let :params do
{
server: 'two bottles of rum',
end
end
- context 'invalid options' do
+ context 'with invalid options' do
let :params do
{
options: {},
end
end
- context 'invalid ensure' do
+ context 'with invalid ensure' do
%w[foo aabsent absenta apresent presenta].each do |param|
let :params 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',
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',
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',
}
end
- context 'ensure absent' do
+ context 'with ensure absent' do
let :params do
{
'ensure' => 'absent',
}
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',
end
end
- context 'packages == * and version' do
+ context 'with packages == * and version' do
let :params do
{
'version' => '1',
end
end
- context 'packages == * and release and origin' do
+ context 'with packages == * and release and origin' do
let :params do
{
'origin' => 'test',
end
end
- context 'specific form with release and origin' do
+ context 'with specific release and origin' do
let :params do
{
'release' => 'foo',
end
end
- context 'specific form with version and origin' do
+ context 'with specific version and origin' do
let :params do
{
'version' => '1',
}
end
- context 'validation' do
+ context 'with validation' do
describe 'no release' do
let :facts 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' } },
}
end
- context 'no defaults' do
+ context 'with no defaults' do
let :facts do
{
os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
}
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' } },
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' } },
}
end
- context 'ensure => absent' do
+ context 'with ensure => absent' do
let :facts do
{
os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
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' } },
'my_source'
end
- context 'defaults' do
+ context 'with defaults' do
context 'without location' do
let :facts 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' } },
}
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' } },
}
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' } },
}
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' } },
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' } },
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' } },
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' } },
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' } },
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' } },
(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
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',
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',