+ context 'with non defaults for sources_list_force' do
+ let :params do
+ {
+ update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+ purge: { 'sources.list' => true },
+ sources_list_force: true
+ }
+ end
+
+ it {
+ expect(subject).to contain_file('sources.list').with(ensure: 'absent')
+ }
+ end
+
+ context 'with entries for /etc/apt/auth.conf' do
+ facts_hash = {
+ 'Ubuntu 18.04' => {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '18',
+ full: '18.04'
+ },
+ distro: {
+ codename: 'bionic',
+ id: 'Ubuntu'
+ }
+ }
+ },
+ 'Debian 9.0' => {
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '9',
+ full: '9.0'
+ },
+ distro: {
+ codename: 'stretch',
+ id: 'Debian'
+ }
+ }
+ },
+ 'Debian 10.0' => {
+ os: {
+ family: 'Debian',
+ name: 'Debian',
+ release: {
+ major: '10',
+ full: '10.0'
+ },
+ distro: {
+ codename: 'buster',
+ id: 'Debian'
+ }
+ }
+ }
+ }
+
+ facts_hash.each do |os, facts|
+ context "when on #{os}" do
+ let(:facts) do
+ facts
+ end
+ let(:params) do
+ {
+ auth_conf_entries: [
+ {
+ machine: 'deb.example.net',
+ login: 'foologin',
+ password: 'secret'
+ },
+ {
+ machine: 'apt.example.com',
+ login: 'aptlogin',
+ password: 'supersecret'
+ },
+ ]
+ }
+ end
+
+ context 'with manage_auth_conf => true' do
+ let(:params) do
+ super().merge(manage_auth_conf: true)
+ end
+
+ auth_conf_content = <<~CONTENT
+ // This file is managed by Puppet. DO NOT EDIT.
+ machine deb.example.net login foologin password secret
+ machine apt.example.com login aptlogin password supersecret
+ CONTENT
+
+ it {
+ expect(subject).to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
+ owner: '_apt',
+ group: 'root',
+ mode: '0600',
+ notify: 'Class[Apt::Update]',
+ content: sensitive(auth_conf_content))
+ }
+ end
+
+ context 'with manage_auth_conf => false' do
+ let(:params) do
+ super().merge(manage_auth_conf: false)
+ end
+
+ it {
+ expect(subject).not_to contain_file('/etc/apt/auth.conf')
+ }
+ end
+ end
+
+ context 'with improperly specified entries for /etc/apt/auth.conf' do
+ let(:params) do
+ {
+ auth_conf_entries: [
+ {
+ machinn: 'deb.example.net',
+ username: 'foologin',
+ password: 'secret'
+ },
+ {
+ machine: 'apt.example.com',
+ login: 'aptlogin',
+ password: 'supersecret'
+ },
+ ]
+ }
+ end
+
+ it { is_expected.to raise_error(Puppet::Error) }
+ end
+ end
+ end
+
+ context 'with sources defined on valid os.family' do