Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f27ea9

Browse files
authored
Merge pull request puppetlabs#1058 from puppetlabs/issue-1057
2 parents 65e0324 + 67dd216 commit 9f27ea9

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

manifests/ppa.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141

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

spec/defines/ppa_spec.rb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,69 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = [])
4444
}
4545
end
4646

47+
[
48+
'ppa:foo/bar',
49+
'ppa:foo/bar1.0',
50+
'ppa:foo10/bar10',
51+
'ppa:foo-/bar_',
52+
].each do |value|
53+
describe 'valid resource names' do
54+
let :facts do
55+
{
56+
os: {
57+
family: 'Debian',
58+
name: 'Ubuntu',
59+
release: {
60+
major: '18',
61+
full: '18.04',
62+
},
63+
distro: {
64+
codename: 'trusty',
65+
id: 'Ubuntu',
66+
},
67+
},
68+
}
69+
end
70+
71+
let(:title) { value }
72+
73+
it { is_expected.not_to raise_error }
74+
it { is_expected.to contain_exec("add-apt-repository-#{value}") }
75+
end
76+
end
77+
78+
[
79+
'ppa:foo!/bar',
80+
'ppa:foo/bar!',
81+
'ppa:foo1.0/bar',
82+
'ppa:foo/bar/foobar',
83+
'|| ls -la ||',
84+
'|| touch /tmp/foo.txt ||',
85+
].each do |value|
86+
describe 'invalid resource names' do
87+
let :facts do
88+
{
89+
os: {
90+
family: 'Debian',
91+
name: 'Ubuntu',
92+
release: {
93+
major: '18',
94+
full: '18.04',
95+
},
96+
distro: {
97+
codename: 'trusty',
98+
id: 'Ubuntu',
99+
},
100+
},
101+
}
102+
end
103+
104+
let(:title) { value }
105+
106+
it { is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid PPA name: #{value}}) }
107+
end
108+
end
109+
47110
describe 'Ubuntu 15.10 sources.list filename' do
48111
let :facts do
49112
{

0 commit comments

Comments
 (0)