Skip to content

Commit 326a027

Browse files
test: acceptance validation of certificate configuration
test: fix linter test: fix zabbix_host with the right tls options refactor: more concise test case Co-authored-by: Christos Papageorgiou <[email protected]> test: remove duplicated tests from tls related node test: fix syntax and linter for resource
1 parent 7c9b431 commit 326a027

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

spec/acceptance/zabbix_host_spec.rb

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,36 @@ class { 'zabbix':
132132
end
133133
end
134134

135+
it_behaves_like 'an idempotent resource' do
136+
let(:manifest) do
137+
<<-EOS
138+
zabbix_host { 'test5.example.com':
139+
ipaddress => '127.0.0.5',
140+
use_ip => false,
141+
port => 1051,
142+
groups => ['Virtual machines'],
143+
templates => #{template},
144+
macros => [],
145+
tls_accept => 'cert',
146+
tls_connect => 'cert',
147+
tls_issuer => 'Zabbix.com',
148+
tls_subject => 'MyClientCertificate',
149+
}
150+
EOS
151+
end
152+
end
153+
135154
let(:result_hosts) do
136-
zabbixapi('localhost', 'Admin', 'zabbix', 'host.get', selectParentTemplates: ['host'], selectInterfaces: %w[dns ip main port type useip details], selectGroups: ['name'], output: ['host', '']).result
155+
zabbixapi(
156+
'localhost',
157+
'Admin',
158+
'zabbix',
159+
'host.get',
160+
selectParentTemplates: ['host'],
161+
selectInterfaces: %w[dns ip main port type useip details],
162+
selectGroups: ['name'],
163+
output: ['host', 'tls_accept', 'tls_connect', 'tls_issuer', 'tls_subject', '']
164+
).result
137165
end
138166

139167
context 'test1.example.com' do
@@ -308,6 +336,30 @@ class { 'zabbix':
308336
end
309337

310338
end
339+
340+
context 'test5.example.com' do
341+
let(:test5) { result_hosts.select { |h| h['host'] == 'test5.example.com' }.first }
342+
343+
it 'is created' do
344+
expect(test5['host']).to eq('test5.example.com')
345+
end
346+
347+
it 'has a correct tls_accept configured' do
348+
expect(test5['tls_accept']).to eq('4')
349+
end
350+
351+
it 'has a correct tls_connect configured' do
352+
expect(test5['tls_connect']).to eq('4')
353+
end
354+
355+
it 'has a correct tls_issuer configured' do
356+
expect(test5['tls_issuer']).to eq('Zabbix.com')
357+
end
358+
359+
it 'has a correct tls_subject configured' do
360+
expect(test5['tls_subject']).to eq('MyClientCertificate')
361+
end
362+
end
311363
end
312364
end
313365
end

0 commit comments

Comments
 (0)