Skip to content

Commit 12b7f80

Browse files
committed
issues/1196
In response to @smortex comment: #1199 (review) * Trickled up the checksum-related parameters for `apt::source` * Modified test for source, all green.
1 parent 53e717f commit 12b7f80

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

manifests/source.pp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,27 @@
1414
# extension. Absence of extension will result in file formation with just name and no extension.
1515
# apt::source { 'puppetlabs':
1616
# location => 'http://apt.puppetlabs.com',
17-
# comment => 'Puppet8',
17+
# repos => 'puppet8'
18+
# comment => 'Puppet 8 release',
1819
# key => {
19-
# 'name' => 'puppetlabs.gpg',
20+
# 'name' => 'puppetlabs-keyring.gpg',
2021
# 'source' => 'https://apt.puppetlabs.com/keyring.gpg',
2122
# },
2223
# }
2324
#
25+
# @example Deploy the apt source and associated keyring file with checksum
26+
# apt::source { 'puppetlabs':
27+
# location => 'http://apt.puppetlabs.com',
28+
# repos => 'puppet8',
29+
# comment => 'Puppet 8 release',
30+
# key => {
31+
# name => 'puppetlabs-keyring.gpg',
32+
# source => 'https://apt.puppetlabs.com/keyring.gpg'
33+
# checksum => 'sha256',
34+
# checksum_value => '9d7a61ab06b18454e9373edec4fc7c87f9a91bacfc891893ba0da37a33069771',
35+
# }
36+
# }
37+
#
2438
# @param location
2539
# Required, unless ensure is set to 'absent'. Specifies an Apt repository. Valid options: a string containing a repository URL.
2640
#
@@ -47,7 +61,7 @@
4761
#
4862
# @param key
4963
# Creates an `apt::keyring` in `/etc/apt/keyrings` (or anywhere on disk given `filename`) Valid options:
50-
# * a hash of `parameter => value` pairs to be passed to `file`: `name` (title), `content`, `source`, `filename`
64+
# * a hash of `parameter => value` pairs to be passed to `file`: `name` (title), `content`, `source`, `filename`, `checksum`, `checksum_value`.
5165
#
5266
# The following inputs are valid for the (deprecated) `apt::key` defined type. Valid options:
5367
# * a string to be passed to the `id` parameter of the `apt::key` defined type
@@ -177,13 +191,15 @@
177191
# Modern apt keyrings
178192
elsif $_key =~ Hash and $_key['name'] {
179193
apt::keyring { $_key['name']:
180-
ensure => $_key_ensure,
181-
content => $_key['content'],
182-
source => $_key['source'],
183-
dir => $_key['dir'],
184-
filename => $_key['filename'],
185-
mode => $_key['mode'],
186-
before => $_before,
194+
ensure => $_key_ensure,
195+
content => $_key['content'],
196+
source => $_key['source'],
197+
dir => $_key['dir'],
198+
filename => $_key['filename'],
199+
mode => $_key['mode'],
200+
checksum => $_key['checksum'],
201+
checksum_value => $_key['checksum_value'],
202+
before => $_before,
187203
}
188204

189205
$_list_keyring = if $_key['dir'] and $_key['filename'] {

spec/defines/source_spec.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,20 @@
103103
release: 'sid',
104104
repos: 'testing',
105105
key: {
106-
'ensure' => 'refreshed',
107-
'id' => id,
108-
'server' => 'pgp.mit.edu',
109-
'content' => 'GPG key content',
110-
'source' => 'http://apt.puppetlabs.com/pubkey.gpg',
111-
'weak_ssl' => true
106+
'name' => 'puppetlabs-keyring.gpg',
107+
'ensure' => 'present',
108+
'source' => 'https://apt.puppetlabs.com/pubkey.gpg',
109+
'checksum' => 'sha256',
110+
'checksum_value' => '050e8c0c43d4b43449ea89ffbea8a1c912a1bb3d008a70ad9623912024933e01',
112111
},
113112
pin: '10',
114113
architecture: 'x86_64',
115-
allow_unsigned: true
114+
allow_insecure: true
116115
}
117116
end
118117

119118
it {
120-
expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
119+
expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 allow-insecure=yes signed-by=/etc/apt/keyrings/puppetlabs-keyring.gpg\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
121120
.without_content(%r{deb-src})
122121
}
123122

@@ -128,12 +127,11 @@
128127
}
129128

130129
it {
131-
expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed',
132-
id: id,
133-
server: 'pgp.mit.edu',
134-
content: 'GPG key content',
135-
source: 'http://apt.puppetlabs.com/pubkey.gpg',
136-
weak_ssl: true)
130+
expect(subject).to contain_apt__keyring("puppetlabs-keyring.gpg").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
131+
name: 'puppetlabs-keyring.gpg',
132+
source: 'https://apt.puppetlabs.com/pubkey.gpg',
133+
checksum: 'sha256',
134+
checksum_value: '050e8c0c43d4b43449ea89ffbea8a1c912a1bb3d008a70ad9623912024933e01')
137135
}
138136
end
139137
end

0 commit comments

Comments
 (0)