Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-1057) Regex fix to allow dotted resources #1058

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

# Validate the resource name
if $name !~ /^ppa:([a-zA-Z0-9\-_]+)\/([a-zA-z0-9\-_]+)$/ {
if $name !~ /^ppa:([a-zA-Z0-9\-_]+)\/([a-zA-z0-9\-_\.]+)$/ {
fail("Invalid PPA name: ${name}")
}

Expand Down
63 changes: 63 additions & 0 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,69 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = [])
}
end

[
'ppa:foo/bar',
'ppa:foo/bar1.0',
'ppa:foo10/bar10',
'ppa:foo-/bar_',
].each do |value|
describe 'valid resource names' do
let :facts do
{
os: {
family: 'Debian',
name: 'Ubuntu',
release: {
major: '18',
full: '18.04',
},
distro: {
codename: 'trusty',
id: 'Ubuntu',
},
},
}
end

let(:title) { value }

it { is_expected.not_to raise_error }
LukasAud marked this conversation as resolved.
Show resolved Hide resolved
it { is_expected.to contain_exec("add-apt-repository-#{value}") }
end
end

[
'ppa:foo!/bar',
'ppa:foo/bar!',
'ppa:foo1.0/bar',
'ppa:foo/bar/foobar',
'|| ls -la ||',
'|| touch /tmp/foo.txt ||',
].each do |value|
describe 'invalid resource names' do
let :facts do
{
os: {
family: 'Debian',
name: 'Ubuntu',
release: {
major: '18',
full: '18.04',
},
distro: {
codename: 'trusty',
id: 'Ubuntu',
},
},
}
end

let(:title) { value }

it { is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid PPA name: #{value}}) }
end
end

describe 'Ubuntu 15.10 sources.list filename' do
let :facts do
{
Expand Down