require 'spec_helper'
# TODO: test handlers-setup.rb
# TODO: test beaver service, assert /etc/beaver/beaver.conf

installed_packages = []

# yum_repos = ['base', 'epel', 'extras', 'snort', 'third-party', 'updates']
yum_repos = %w(base epel extras updates)

file_items = [
  '/etc/cron.daily/logrotate',
  # '/etc/cron.daily/tmpwatch',
  # '/etc/cron.d/sa-update',
  # '/etc/cron.d/snort',
  # '/etc/cron.hourly/snort',
  '/root/.cshrc',
  '/usr/local/bin/check_http',
  '/etc/modprobe.d/ECS.conf',
  '/etc/sysconfig/clock'
]

# Services should not start, therefore ports should not be listening
# listening_ports = [22, 25, 5666, 68, 631, 123, 783]
# listening_ports.each { |listening_port|
#   describe port(listening_port) do
#     it { should be_listening }
#   end
# }

# TODO: not working, verify kitchen syntax

# describe user('root') do
#   it { should be_locked  }
# end

# describe user('vagrant') do
#   it { should be_nopasswd  }
# end

# drwxrwxrwt.  5 root    root     4096 Jan 15 14:16 /tmp
# describe file('/tmp') do
#   it { should have_mode(01777) }
# end

# installed_services = ['sshd','collectd','crond','ip6tables','ntpd','snortd','salt-minion','opsview-agent']
# installed_services.each { |installed_service|
#   describe service(installed_service) do
#     it { should be_installed }
#   end
# }

# stopped_services = ['cupsd','nfs','nfslock','spamassassin']
# stopped_services.each { |stopped_service|
#   describe service(stopped_service) do
#     it { should be_stopped  }
#   end
# }

# running_services = ['rsyslogd']
# running_services.each { |running_service|
#   describe service(running_service) do
#     it { should be_running  }
#   end
# }

describe file('/etc/aliases') do
  it { should contain('root@alias.com') }
end

describe file('/etc/redhat-release') do
  it { should contain('7.0') }
end

installed_packages.each do |installed_package|
  describe package(installed_package) do
    it { should be_installed }
  end
end

yum_repos.each do |yum_repo|
  describe yumrepo(yum_repo) do
    it { should be_enabled }
  end
end

file_items.each do |file_item|
  describe file(file_item) do
    it { should be_file }
  end
end
