]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #752 from antaflos/apt_auth_conf_support
authorTP Honey <tphoney@users.noreply.github.com>
Thu, 21 Jun 2018 12:25:50 +0000 (13:25 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Jun 2018 12:25:50 +0000 (13:25 +0100)
Support managing login configurations in /etc/apt/auth.conf

1  2 
manifests/init.pp
manifests/params.pp
spec/classes/apt_spec.rb

Simple merge
Simple merge
index 7fdfb775ec31cf38240550b7686513b6001217f5,654af4eb01b5db69020f591687de0be502922120..011286d876bc96fd78cf9a73a81e233a2b160252
@@@ -186,13 -188,59 +188,59 @@@ describe 'apt' d
      }
    end
  
+   context 'with entries for /etc/apt/auth.conf' do
+     let(:params) do
+       {
+         auth_conf_entries: [
+           { machine: 'deb.example.net',
+             login: 'foologin',
+             password: 'secret' },
+           { machine: 'apt.example.com',
+             login: 'aptlogin',
+             password: 'supersecret' },
+         ],
+       }
+     end
+     auth_conf_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
+ "
+     it {
+       is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present',
+                                                              owner: 'root',
+                                                              group: 'root',
+                                                              mode: '0600',
+                                                              notify: 'Class[Apt::Update]',
+                                                              content: auth_conf_content)
+     }
+   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
    context 'with sources defined on valid osfamily' do
      let :facts do
 -      { os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04' } },
 +      { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
          osfamily: 'Debian',
 -        lsbdistcodename: 'precise',
 +        lsbdistcodename: 'xenial',
          lsbdistid: 'Ubuntu',
 -        lsbdistrelease: '12.04',
 +        lsbdistrelease: '16.04',
          puppetversion: Puppet.version }
      end
      let(:params) do