Skip to content

Commit

Permalink
Merge pull request #1075 from xepa/xepa-patch-1
Browse files Browse the repository at this point in the history
Updated mark as title can contain dot (fixes #1074)
  • Loading branch information
LukasAud authored Jan 18, 2023
2 parents f12c74c + 6958dc5 commit fad371f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifests/mark.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
define apt::mark (
Enum['auto','manual','hold','unhold'] $setting,
) {
if $title !~ /^[a-zA-Z0-9\-_]+$/ {
if $title !~ /^[a-z0-9][a-z0-9.+\-]+$/ {
fail("Invalid package name: ${title}")
}

Expand Down
18 changes: 14 additions & 4 deletions spec/defines/mark_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe 'apt::mark', type: :define do
let :title do
'my_source'
'mysource'
end

let :facts do
Expand Down Expand Up @@ -32,7 +32,7 @@
end

it {
is_expected.to contain_exec('apt-mark manual my_source')
is_expected.to contain_exec('apt-mark manual mysource')
}
end

Expand All @@ -51,8 +51,12 @@
[
'package',
'package1',
'package_name',
'package.name',
'package-name',
'package+name',
'p.ackagename',
'p+ackagename',
'p+',
].each do |value|
describe 'with a valid resource title' do
let :title do
Expand All @@ -71,13 +75,19 @@
end
end

# packagenames starting with + are not valid as the title according to puppet
# good thing this is also an illegal name for debian packages
[
'|| ls -la ||',
'packakge with space',
'package<>|',
'|| touch /tmp/foo.txt ||',
'package_name',
'PackageName',
'.p',
'p',
].each do |value|
describe 'with an invalid resource title' do
describe "with an invalid resource title [#{value}]" do
let :title do
value
end
Expand Down

0 comments on commit fad371f

Please sign in to comment.