2 describe 'apt', :type => :class do
3 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
6 :disable_keys => :undef,
7 :always_apt_update => false,
8 :purge_sources_list => false,
9 :purge_sources_list_d => false,
15 :disable_keys => true,
16 :always_apt_update => true,
18 :proxy_port => '3128',
19 :purge_sources_list => true,
20 :purge_sources_list_d => true,
23 :purge_preferences => true,
24 :purge_preferences_d => true,
27 :disable_keys => false
30 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
32 default_params.merge(param_set)
39 let :refresh_only_apt_update do
40 if param_hash[:always_apt_update]
47 it { should contain_class("apt::params") }
50 if param_hash[:purge_sources_list]
51 should contain_file("sources.list").with({
52 'path' => "/etc/apt/sources.list",
53 'ensure' => "present",
57 "content" => "# Repos managed by puppet.\n"
60 should contain_file("sources.list").with({
61 'path' => "/etc/apt/sources.list",
62 'ensure' => "present",
71 if param_hash[:purge_sources_list_d]
72 should create_file("sources.list.d").with({
73 'path' => "/etc/apt/sources.list.d",
74 'ensure' => "directory",
79 'notify' => 'Exec[apt_update]'
82 should create_file("sources.list.d").with({
83 'path' => "/etc/apt/sources.list.d",
84 'ensure' => "directory",
89 'notify' => 'Exec[apt_update]'
94 if param_hash[:purge_preferences]
95 should create_file('apt-preferences').with({
97 :path => '/etc/apt/preferences',
100 should_not contain_file('apt-preferences')
105 if param_hash[:purge_preferences_d]
106 should create_file("preferences.d").with({
107 'path' => "/etc/apt/preferences.d",
108 'ensure' => "directory",
115 should create_file("preferences.d").with({
116 'path' => "/etc/apt/preferences.d",
117 'ensure' => "directory",
127 should contain_exec("apt_update").with({
128 'command' => "/usr/bin/apt-get update",
129 'refreshonly' => refresh_only_apt_update
134 if param_hash[:disable_keys] == true
135 should create_file("99unauth").with({
136 'content' => "APT::Get::AllowUnauthenticated 1;\n",
137 'ensure' => "present",
138 'path' => "/etc/apt/apt.conf.d/99unauth"
140 elsif param_hash[:disable_keys] == false
141 should create_file("99unauth").with({
142 'ensure' => "absent",
143 'path' => "/etc/apt/apt.conf.d/99unauth"
145 elsif param_hash[:disable_keys] != :undef
146 should_not create_file("99unauth").with({
147 'path' => "/etc/apt/apt.conf.d/99unauth"
151 describe 'when setting a proxy' do
153 if param_hash[:proxy_host]
154 should contain_file('01proxy').with(
155 'path' => '/etc/apt/apt.conf.d/01proxy',
156 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n",
157 'notify' => "Exec[apt_update]"
160 should contain_file('01proxy').with(
161 'path' => '/etc/apt/apt.conf.d/01proxy',
162 'notify' => 'Exec[apt_update]',