2 describe 'apt', :type => :class do
5 :disable_keys => false,
6 :always_apt_update => false,
13 :disable_keys => true,
14 :always_apt_update => true,
16 :proxy_port => '3128',
20 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
22 default_params.merge(param_set)
29 let :refresh_only_apt_update do
30 if param_hash[:always_apt_update]
37 it { should include_class("apt::params") }
39 it { should contain_package("python-software-properties") }
43 should contain_file("sources.list").with({
44 'path' => "/etc/apt/sources.list",
45 'ensure' => "present",
49 "content" => "# Repos managed by puppet.\n"
52 should contain_file("sources.list").with({
53 'path' => "/etc/apt/sources.list",
54 'ensure' => "present",
64 should create_file("sources.list.d").with({
65 'path' => "/etc/apt/sources.list.d",
66 'ensure' => "directory",
73 should create_file("sources.list.d").with({
74 'path' => "/etc/apt/sources.list.d",
75 'ensure' => "directory",
85 should contain_exec("apt_update").with({
86 'command' => "/usr/bin/apt-get update",
87 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
88 'refreshonly' => refresh_only_apt_update
93 if param_hash[:disable_keys]
94 should contain_exec("make-apt-insecure").with({
95 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
96 'creates' => '/etc/apt/apt.conf.d/99unauth'
99 should_not contain_exec("make-apt-insecure").with({
100 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
101 'creates' => '/etc/apt/apt.conf.d/99unauth'
105 describe 'when setting a proxy' do
107 if param_hash[:proxy_host]
108 should contain_file('configure-apt-proxy').with(
109 'path' => '/etc/apt/apt.conf.d/proxy',
110 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";"
113 should_not contain_file('configure_apt_proxy')