2 describe 'apt', :type => :class do
5 :disable_keys => false,
6 :always_apt_update => false
12 :disable_keys => true,
13 :always_apt_update => true,
18 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
20 default_params.merge(param_set)
27 let :refresh_only_apt_update do
28 if param_hash[:always_apt_update]
35 it { should include_class("apt::params") }
37 it { should contain_package("python-software-properties") }
40 should contain_file("sources.list").with({
41 'path' => "/etc/apt/sources.list",
42 'ensure' => "present",
50 should create_file("sources.list.d").with({
51 "path" => "/etc/apt/sources.list.d",
52 "ensure" => "directory",
59 should contain_exec("apt_update").with({
60 'command' => "/usr/bin/apt-get update",
61 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
62 'refreshonly' => refresh_only_apt_update
67 if param_hash[:disable_keys]
68 should contain_exec("make-apt-insecure").with({
69 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
70 'creates' => '/etc/apt/apt.conf.d/99unauth'
73 should_not contain_exec("make-apt-insecure").with({
74 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth',
75 'creates' => '/etc/apt/apt.conf.d/99unauth'
79 describe 'when setting a proxy' do
81 if param_hash[:proxy_host]
82 should contain_file('configure-apt-proxy').with(
83 'path' => '/etc/apt/apt.conf.d/proxy',
84 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";"
87 should_not contain_file('configure_apt_proxy')