2 describe 'apt', :type => :class do
3 let(:facts) { { :lsbdistid => '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 :disable_keys => false
26 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
28 default_params.merge(param_set)
35 let :refresh_only_apt_update do
36 if param_hash[:always_apt_update]
43 it { should contain_class("apt::params") }
46 if param_hash[:purge_sources_list]
47 should contain_file("sources.list").with({
48 'path' => "/etc/apt/sources.list",
49 'ensure' => "present",
53 "content" => "# Repos managed by puppet.\n"
56 should contain_file("sources.list").with({
57 'path' => "/etc/apt/sources.list",
58 'ensure' => "present",
67 if param_hash[:purge_sources_list_d]
68 should create_file("sources.list.d").with({
69 'path' => "/etc/apt/sources.list.d",
70 'ensure' => "directory",
75 'notify' => 'Exec[apt_update]'
78 should create_file("sources.list.d").with({
79 'path' => "/etc/apt/sources.list.d",
80 'ensure' => "directory",
85 'notify' => 'Exec[apt_update]'
91 should contain_exec("apt_update").with({
92 'command' => "/usr/bin/apt-get update",
93 'refreshonly' => refresh_only_apt_update
98 if param_hash[:disable_keys] == true
99 should create_file("99unauth").with({
100 'content' => "APT::Get::AllowUnauthenticated 1;\n",
101 'ensure' => "present",
102 'path' => "/etc/apt/apt.conf.d/99unauth"
104 elsif param_hash[:disable_keys] == false
105 should create_file("99unauth").with({
106 'ensure' => "absent",
107 'path' => "/etc/apt/apt.conf.d/99unauth"
109 elsif param_hash[:disable_keys] != :undef
110 should_not create_file("99unauth").with({
111 'path' => "/etc/apt/apt.conf.d/99unauth"
115 describe 'when setting a proxy' do
117 if param_hash[:proxy_host]
118 should contain_file('configure-apt-proxy').with(
119 'path' => '/etc/apt/apt.conf.d/proxy',
120 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";",
121 'notify' => "Exec[apt_update]"
124 should contain_file('configure-apt-proxy').with(
125 'path' => '/etc/apt/apt.conf.d/proxy',
126 'notify' => 'Exec[apt_update]',