2 describe 'apt', :type => :class do
5 :disable_keys => :undef,
6 :always_apt_update => false,
7 :purge_sources_list => false,
8 :purge_sources_list_d => false,
14 :disable_keys => true,
15 :always_apt_update => true,
17 :proxy_port => '3128',
18 :purge_sources_list => true,
19 :purge_sources_list_d => true,
22 :purge_preferences => true,
23 :purge_preferences_d => true,
26 :disable_keys => false
29 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
31 default_params.merge(param_set)
38 let :refresh_only_apt_update do
39 if param_hash[:always_apt_update]
46 it { should contain_class("apt::params") }
49 if param_hash[:purge_sources_list]
50 should contain_file("sources.list").with({
51 'path' => "/etc/apt/sources.list",
52 'ensure' => "present",
56 "content" => "# Repos managed by puppet.\n"
59 should contain_file("sources.list").with({
60 'path' => "/etc/apt/sources.list",
61 'ensure' => "present",
70 if param_hash[:purge_sources_list_d]
71 should create_file("sources.list.d").with({
72 'path' => "/etc/apt/sources.list.d",
73 'ensure' => "directory",
78 'notify' => 'Exec[apt_update]'
81 should create_file("sources.list.d").with({
82 'path' => "/etc/apt/sources.list.d",
83 'ensure' => "directory",
88 'notify' => 'Exec[apt_update]'
93 if param_hash[:purge_preferences]
94 should create_file('apt-preferences').with({
96 :path => '/etc/apt/preferences',
100 :content => /Explanation/,
103 should create_file('apt-preferences').with({
104 :ensure => 'present',
105 :path => '/etc/apt/preferences',
115 if param_hash[:purge_preferences_d]
116 should create_file("preferences.d").with({
117 'path' => "/etc/apt/preferences.d",
118 'ensure' => "directory",
125 should create_file("preferences.d").with({
126 'path' => "/etc/apt/preferences.d",
127 'ensure' => "directory",
137 should contain_exec("apt_update").with({
138 'command' => "/usr/bin/apt-get update",
139 'refreshonly' => refresh_only_apt_update
144 if param_hash[:disable_keys] == true
145 should create_file("99unauth").with({
146 'content' => "APT::Get::AllowUnauthenticated 1;\n",
147 'ensure' => "present",
148 'path' => "/etc/apt/apt.conf.d/99unauth"
150 elsif param_hash[:disable_keys] == false
151 should create_file("99unauth").with({
152 'ensure' => "absent",
153 'path' => "/etc/apt/apt.conf.d/99unauth"
155 elsif param_hash[:disable_keys] != :undef
156 should_not create_file("99unauth").with({
157 'path' => "/etc/apt/apt.conf.d/99unauth"
161 describe 'when setting a proxy' do
163 if param_hash[:proxy_host]
164 should contain_file('configure-apt-proxy').with(
165 'path' => '/etc/apt/apt.conf.d/proxy',
166 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";",
167 'notify' => "Exec[apt_update]"
170 should contain_file('configure-apt-proxy').with(
171 'path' => '/etc/apt/apt.conf.d/proxy',
172 'notify' => 'Exec[apt_update]',