1 # frozen_string_literal: true
12 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } },
13 lsbdistrelease: '14.04',
14 lsbdistcodename: 'trusty',
15 operatingsystem: 'Ubuntu',
21 let(:title) { 'ppa:needs/such.substitution/wow+type' }
23 it { is_expected.not_to contain_package('python-software-properties') }
25 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [],
26 command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Layout/LineLength
27 unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Layout/LineLength
29 logoutput: 'on_failure')
33 describe 'Ubuntu 15.10 sources.list filename' do
36 os: { family: 'Debian', name: 'Ubuntu', release: { major: '15', full: '15.10' } },
37 lsbdistrelease: '15.10',
38 lsbdistcodename: 'wily',
39 operatingsystem: 'Ubuntu',
45 let(:title) { 'ppa:user/foo' }
48 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
49 command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Layout/LineLength
50 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Layout/LineLength
52 logoutput: 'on_failure')
56 describe 'package_name => software-properties-common' do
62 package_name: 'software-properties-common',
68 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
69 lsbdistrelease: '14.04',
70 lsbdistcodename: 'trusty',
71 operatingsystem: 'Ubuntu',
77 let(:title) { 'ppa:needs/such.substitution/wow' }
79 it { is_expected.to contain_package('software-properties-common') }
81 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
82 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength
83 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength
85 'logoutput' => 'on_failure')
89 is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
93 describe 'package_manage => false' do
99 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
100 lsbdistrelease: '14.04',
101 lsbdistcodename: 'trusty',
102 operatingsystem: 'Ubuntu',
109 package_manage: false,
113 let(:title) { 'ppa:needs/such.substitution/wow' }
115 it { is_expected.not_to contain_package('python-software-properties') }
117 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
118 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength
119 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength
121 'logoutput' => 'on_failure')
125 is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
129 describe 'apt included, no proxy' do
130 let :pre_condition do
132 apt::ppa { "ppa:user/foo2": }
137 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
138 lsbdistrelease: '14.04',
139 lsbdistcodename: 'trusty',
140 operatingsystem: 'Ubuntu',
148 package_manage: true,
149 require: 'Apt::Ppa[ppa:user/foo2]',
152 let(:title) { 'ppa:user/foo' }
154 it { is_expected.to compile.with_all_deps }
155 it { is_expected.to contain_package('software-properties-common') }
157 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
158 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
159 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
161 logoutput: 'on_failure')
165 describe 'apt included, proxy host' do
166 let :pre_condition do
168 proxy => { "host" => "localhost" },
173 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
174 lsbdistrelease: '14.04',
175 lsbdistcodename: 'trusty',
176 operatingsystem: 'Ubuntu',
184 'package_manage' => true,
187 let(:title) { 'ppa:user/foo' }
189 it { is_expected.to contain_package('software-properties-common') }
191 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8080'],
192 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
193 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
195 logoutput: 'on_failure')
199 describe 'apt included, proxy host and port' do
200 let :pre_condition do
202 proxy => { "host" => "localhost", "port" => 8180 },
207 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
208 lsbdistrelease: '14.04',
209 lsbdistcodename: 'trusty',
210 operatingsystem: 'Ubuntu',
218 package_manage: true,
221 let(:title) { 'ppa:user/foo' }
223 it { is_expected.to contain_package('software-properties-common') }
225 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180'],
226 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
227 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
229 logoutput: 'on_failure')
233 describe 'apt included, proxy host and port and https' do
234 let :pre_condition do
236 proxy => { "host" => "localhost", "port" => 8180, "https" => true },
241 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
242 lsbdistrelease: '14.04',
243 lsbdistcodename: 'trusty',
244 operatingsystem: 'Ubuntu',
252 package_manage: true,
255 let(:title) { 'ppa:user/foo' }
257 it { is_expected.to contain_package('software-properties-common') }
259 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
260 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
261 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
263 logoutput: 'on_failure')
267 describe 'ensure absent' do
268 let :pre_condition do
273 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
274 lsbdistrelease: '14.04',
275 lsbdistcodename: 'trusty',
276 operatingsystem: 'Ubuntu',
281 let(:title) { 'ppa:user/foo' }
289 is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
293 context 'with validation' do
294 describe 'no release' do
297 os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
298 lsbdistrelease: '14.04',
299 operatingsystem: 'Ubuntu',
302 lsbdistcodeanme: nil,
305 let(:title) { 'ppa:user/foo' }
308 is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required})
312 describe 'not ubuntu' do
315 os: { family: 'Debian', name: 'Debian', release: { major: '6', full: '6.0.7' } },
316 lsbdistrelease: '6.0.7',
317 lsbdistcodename: 'wheezy',
318 operatingsystem: 'Debian',
323 let(:title) { 'ppa:user/foo' }
326 is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian})