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 :disable_keys => false
25 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
27 default_params.merge(param_set)
34 let :refresh_only_apt_update do
35 if param_hash[:always_apt_update]
42 it { should include_class("apt::params") }
44 it { should contain_package("python-software-properties") }
47 if param_hash[:purge_sources_list]
48 should contain_file("sources.list").with({
49 'path' => "/etc/apt/sources.list",
50 'ensure' => "present",
54 "content" => "# Repos managed by puppet.\n"
57 should contain_file("sources.list").with({
58 'path' => "/etc/apt/sources.list",
59 'ensure' => "present",
68 if param_hash[:purge_sources_list_d]
69 should create_file("sources.list.d").with({
70 'path' => "/etc/apt/sources.list.d",
71 'ensure' => "directory",
78 should create_file("sources.list.d").with({
79 'path' => "/etc/apt/sources.list.d",
80 'ensure' => "directory",
90 should contain_exec("apt_update").with({
91 'command' => "/usr/bin/apt-get update",
92 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
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_not contain_file('configure_apt_proxy')
131 describe "it should not error if package['python-software-properties'] is already defined" do
132 let(:pre_condition) { 'package { "python-software-properties": }->Class["Apt"]' }
133 it { should contain_package("python-software-properties") }