2 describe 'apt', :type => :class do
5 :disable_keys => :undef,
6 :always_apt_update => false,
13 :disable_keys => true,
14 :always_apt_update => true,
16 :proxy_port => '3128',
20 :disable_keys => false
23 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
25 default_params.merge(param_set)
32 let :refresh_only_apt_update do
33 if param_hash[:always_apt_update]
40 it { should include_class("apt::params") }
42 it { should contain_package("python-software-properties") }
46 should contain_file("sources.list").with({
47 'path' => "/etc/apt/sources.list",
48 'ensure' => "present",
52 "content" => "# Repos managed by puppet.\n"
55 should contain_file("sources.list").with({
56 'path' => "/etc/apt/sources.list",
57 'ensure' => "present",
67 should create_file("sources.list.d").with({
68 'path' => "/etc/apt/sources.list.d",
69 'ensure' => "directory",
76 should create_file("sources.list.d").with({
77 'path' => "/etc/apt/sources.list.d",
78 'ensure' => "directory",
88 should contain_exec("apt_update").with({
89 'command' => "/usr/bin/apt-get update",
90 'subscribe' => ["File[sources.list]", "File[sources.list.d]"],
91 'refreshonly' => refresh_only_apt_update
96 if param_hash[:disable_keys] == true
97 should create_file("99unauth").with({
98 'content' => "APT::Get::AllowUnauthenticated 1;\n",
99 'ensure' => "present",
100 'path' => "/etc/apt/apt.conf.d/99unauth"
102 elsif param_hash[:disable_keys] == false
103 should create_file("99unauth").with({
104 'ensure' => "absent",
105 'path' => "/etc/apt/apt.conf.d/99unauth"
107 elsif param_hash[:disable_keys] != :undef
108 should_not create_file("99unauth").with({
109 'path' => "/etc/apt/apt.conf.d/99unauth"
113 describe 'when setting a proxy' do
115 if param_hash[:proxy_host]
116 should contain_file('configure-apt-proxy').with(
117 'path' => '/etc/apt/apt.conf.d/proxy',
118 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";"
121 should_not contain_file('configure_apt_proxy')
128 describe "it should not error if package['python-software-properties'] is already defined" do
129 let(:pre_condition) { 'package { "python-software-properties": }->Class["Apt"]' }
130 it { should contain_package("python-software-properties") }