From cbc7e9712343aefb5664655a6bff13cbb42b80c0 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Wed, 14 Aug 2024 15:43:15 +0000 Subject: [PATCH 1/3] check default bash user exists --- spec/configuration/users_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/configuration/users_spec.rb diff --git a/spec/configuration/users_spec.rb b/spec/configuration/users_spec.rb new file mode 100644 index 0000000..6ac080d --- /dev/null +++ b/spec/configuration/users_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'set' +require 'spec_helper' +set :os, family: 'redhat', release: '9', arch: 'x86_64' + +# TODO: Change it to 'redborder' +describe user('redBorder') do + it { should exist } + it { should have_login_shell '/bin/bash' } +end From 3a16aeaf4718e8e3809f4412e6b23c071a61aba4 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Fri, 16 Aug 2024 10:25:36 +0000 Subject: [PATCH 2/3] skip instead of fail because segment could not be applied just after installation --- spec/configuration/barnyard2_spec.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/configuration/barnyard2_spec.rb b/spec/configuration/barnyard2_spec.rb index c008d30..a2c31b1 100644 --- a/spec/configuration/barnyard2_spec.rb +++ b/spec/configuration/barnyard2_spec.rb @@ -7,10 +7,15 @@ describe 'Barnyard2 config' do instances_group.each do |group| - describe file("/etc/snort/#{group}/barnyard2.conf") do - it { should exist } - it { should be_file } - it { should be_readable } + file_path = "/etc/snort/#{group}/barnyard2.conf" + describe file(file_path) do + if File.exist?(file_path) + it { should exist } + it { should be_file } + it { should be_readable } + else + skip("File #{file_path} does not exist, but is expected to exist on running state") + end end end end From e547610ca63b7d8ed96d12bde651bb0286985eea Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Fri, 16 Aug 2024 11:37:15 +0000 Subject: [PATCH 3/3] just skip if first segment not configured --- spec/configuration/barnyard2_spec.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/configuration/barnyard2_spec.rb b/spec/configuration/barnyard2_spec.rb index a2c31b1..6131b8d 100644 --- a/spec/configuration/barnyard2_spec.rb +++ b/spec/configuration/barnyard2_spec.rb @@ -6,15 +6,16 @@ instances_group = %w[0] # This is the default name of the first instances group describe 'Barnyard2 config' do - instances_group.each do |group| - file_path = "/etc/snort/#{group}/barnyard2.conf" - describe file(file_path) do - if File.exist?(file_path) + file_path = '/etc/snort/0/barnyard2.conf' + if File.exist?(file_path) + skip("File #{file_path} does not exist, but is expected to exist on running state") + else + instances_group.each do |group| + file_path = "/etc/snort/#{group}/barnyard2.conf" + describe file(file_path) do it { should exist } it { should be_file } it { should be_readable } - else - skip("File #{file_path} does not exist, but is expected to exist on running state") end end end