|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
| 3 | +shared_examples 'old debianoid' do |
| 4 | + it do |
| 5 | + is_expected.to contain_file('/usr/share/keyrings/datadog-archive-keyring.gpg') |
| 6 | + is_expected.to contain_file('/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg') |
| 7 | + is_expected.to contain_exec('ensure key DATADOG_APT_KEY_CURRENT.public is imported in APT keyring') |
| 8 | + is_expected.to contain_exec('ensure key D75CEA17048B9ACBF186794B32637D44F14F620E is imported in APT keyring') |
| 9 | + is_expected.to contain_exec('ensure key A2923DFF56EDA6E76E55E492D3A80E30382E94DE is imported in APT keyring') |
| 10 | + end |
| 11 | +end |
| 12 | + |
| 13 | +shared_examples 'new debianoid' do |
| 14 | + it do |
| 15 | + is_expected.to contain_file('/usr/share/keyrings/datadog-archive-keyring.gpg') |
| 16 | + is_expected.not_to contain_file('/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg') |
| 17 | + is_expected.to contain_exec('ensure key DATADOG_APT_KEY_CURRENT.public is imported in APT keyring') |
| 18 | + is_expected.to contain_exec('ensure key D75CEA17048B9ACBF186794B32637D44F14F620E is imported in APT keyring') |
| 19 | + is_expected.to contain_exec('ensure key A2923DFF56EDA6E76E55E492D3A80E30382E94DE is imported in APT keyring') |
| 20 | + end |
| 21 | +end |
| 22 | + |
3 | 23 | describe 'datadog_agent::ubuntu' do |
4 | 24 | context 'agent 5' do |
5 | 25 | if RSpec::Support::OS.windows? |
|
23 | 43 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list') |
24 | 44 | .with_ensure('absent') |
25 | 45 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ |
26 | | - .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+main}) |
| 46 | + .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+main}) |
27 | 47 | end |
28 | 48 |
|
29 | 49 | # it should install the mirror |
30 | 50 | it { is_expected.not_to contain_apt__key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') } |
31 | | - it do |
32 | | - is_expected.to contain_apt__key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') |
33 | | - is_expected.to contain_apt__key('D75CEA17048B9ACBF186794B32637D44F14F620E') |
34 | | - end |
35 | | - |
36 | | - context 'overriding keyserver' do |
37 | | - let(:params) do |
38 | | - { |
39 | | - apt_keyserver: 'hkp://pool.sks-keyservers.net:80', |
40 | | - } |
41 | | - end |
42 | | - |
43 | | - it do |
44 | | - is_expected.to contain_apt__key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\ |
45 | | - .with_server('hkp://pool.sks-keyservers.net:80') |
46 | | - is_expected.to contain_apt__key('D75CEA17048B9ACBF186794B32637D44F14F620E')\ |
47 | | - .with_server('hkp://pool.sks-keyservers.net:80') |
48 | | - end |
49 | | - end |
50 | 51 |
|
51 | 52 | it do |
52 | 53 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ |
|
87 | 88 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list') |
88 | 89 | .with_ensure('absent') |
89 | 90 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ |
90 | | - .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) |
| 91 | + .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+6}) |
91 | 92 | end |
92 | 93 |
|
93 | 94 | # it should install the mirror |
94 | 95 | it { is_expected.not_to contain_apt__key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') } |
95 | | - it do |
96 | | - is_expected.to contain_apt__key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') |
97 | | - is_expected.to contain_apt__key('D75CEA17048B9ACBF186794B32637D44F14F620E') |
98 | | - end |
99 | 96 |
|
100 | 97 | it do |
101 | 98 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list')\ |
|
136 | 133 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list') |
137 | 134 | .with_ensure('absent') |
138 | 135 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ |
139 | | - .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+7}) |
| 136 | + .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+7}) |
140 | 137 | end |
141 | 138 |
|
142 | | - # it should install the mirror |
143 | | - it { is_expected.not_to contain_apt__key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') } |
144 | | - it { is_expected.to contain_apt__key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') } |
145 | | - |
146 | 139 | it do |
147 | 140 | is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list')\ |
148 | 141 | .that_notifies('exec[apt_update]') |
|
161 | 154 | .that_requires('exec[apt_update]') |
162 | 155 | end |
163 | 156 | end |
| 157 | + |
| 158 | + context 'ubuntu < 16' do |
| 159 | + let(:params) do |
| 160 | + { |
| 161 | + agent_major_version: 7, |
| 162 | + } |
| 163 | + end |
| 164 | + |
| 165 | + let(:facts) do |
| 166 | + { |
| 167 | + osfamily: 'debian', |
| 168 | + operatingsystem: 'Ubuntu', |
| 169 | + operatingsystemrelease: '14.04', |
| 170 | + } |
| 171 | + end |
| 172 | + |
| 173 | + include_examples 'old debianoid' |
| 174 | + end |
| 175 | + |
| 176 | + context 'ubuntu >= 16' do |
| 177 | + let(:params) do |
| 178 | + { |
| 179 | + agent_major_version: 7, |
| 180 | + } |
| 181 | + end |
| 182 | + |
| 183 | + let(:facts) do |
| 184 | + { |
| 185 | + osfamily: 'debian', |
| 186 | + operatingsystem: 'Ubuntu', |
| 187 | + operatingsystemrelease: '16.04', |
| 188 | + } |
| 189 | + end |
| 190 | + |
| 191 | + include_examples 'new debianoid' |
| 192 | + end |
| 193 | + |
| 194 | + context 'debian < 9' do |
| 195 | + let(:params) do |
| 196 | + { |
| 197 | + agent_major_version: 7, |
| 198 | + } |
| 199 | + end |
| 200 | + |
| 201 | + let(:facts) do |
| 202 | + { |
| 203 | + osfamily: 'debian', |
| 204 | + operatingsystem: 'Debian', |
| 205 | + operatingsystemrelease: '8.0', |
| 206 | + } |
| 207 | + end |
| 208 | + |
| 209 | + include_examples 'old debianoid' |
| 210 | + end |
| 211 | + |
| 212 | + context 'debian >= 9' do |
| 213 | + let(:params) do |
| 214 | + { |
| 215 | + agent_major_version: 7, |
| 216 | + } |
| 217 | + end |
| 218 | + |
| 219 | + let(:facts) do |
| 220 | + { |
| 221 | + osfamily: 'debian', |
| 222 | + operatingsystem: 'Debian', |
| 223 | + operatingsystemrelease: '9.0', |
| 224 | + } |
| 225 | + end |
| 226 | + |
| 227 | + include_examples 'new debianoid' |
| 228 | + end |
164 | 229 | end |
0 commit comments