Skip to content

Commit

Permalink
add specs to debian, gentoo and solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
studio3104 committed May 1, 2013
1 parent 96cf040 commit 9ce0e1c
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/debian/commands_spec.rb
Expand Up @@ -113,6 +113,26 @@
it { should eq "id root | awk '{print $3}' | grep wheel" }
end

describe 'have_gid', :os => :debian do
subject { commands.check_gid('root', 0) }
it { should eq "getent group | grep -w ^root | cut -f 3 -d ':' | grep -w 0" }
end

describe 'have_uid', :os => :debian do
subject { commands.check_uid('root', 0) }
it { should eq "id root | grep uid=0(" }
end

describe 'have_login_shell', :os => :debian do
subject { commands.check_login_shell('root', '/bin/bash') }
it { should eq "grep -w ^root /etc/passwd | cut -f 7 -d ':' | grep -w /bin/bash" }
end

describe 'have_home_directory', :os => :debian do
subject { commands.check_home_directory('root', '/root') }
it { should eq "grep -w ^root /etc/passwd | cut -f 6 -d ':' | grep -w /root" }
end

describe 'check_ipatbles', :os => :debian do
context 'check a rule without a table and a chain' do
subject { commands.check_iptables_rule('-P INPUT ACCEPT') }
Expand Down
4 changes: 4 additions & 0 deletions spec/debian/matchers_spec.rb
Expand Up @@ -31,6 +31,10 @@
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'

it_behaves_like 'support belong_to_group matcher', 'root', 'root'
it_behaves_like 'support have_gid matcher', 'root', 0
it_behaves_like 'support have_uid matcher', 'root', 0
it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
it_behaves_like 'support have_home_directory matcher', 'root', '/root'

it_behaves_like 'support have_iptables_rule matcher', '-P INPUT ACCEPT'
it_behaves_like 'support have_iptables_rule.with_table.with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
Expand Down
20 changes: 20 additions & 0 deletions spec/gentoo/commands_spec.rb
Expand Up @@ -112,6 +112,26 @@
it { should eq "id root | awk '{print $3}' | grep wheel" }
end

describe 'have_gid', :os => :gentoo do
subject { commands.check_gid('root', 0) }
it { should eq "getent group | grep -w ^root | cut -f 3 -d ':' | grep -w 0" }
end

describe 'have_uid', :os => :gentoo do
subject { commands.check_uid('root', 0) }
it { should eq "id root | grep uid=0(" }
end

describe 'have_login_shell', :os => :gentoo do
subject { commands.check_login_shell('root', '/bin/bash') }
it { should eq "grep -w ^root /etc/passwd | cut -f 7 -d ':' | grep -w /bin/bash" }
end

describe 'have_home_directory', :os => :gentoo do
subject { commands.check_home_directory('root', '/root') }
it { should eq "grep -w ^root /etc/passwd | cut -f 6 -d ':' | grep -w /root" }
end

describe 'check_ipatbles', :os => :gentoo do
context 'check a rule without a table and a chain' do
subject { commands.check_iptables_rule('-P INPUT ACCEPT') }
Expand Down
4 changes: 4 additions & 0 deletions spec/gentoo/matchers_spec.rb
Expand Up @@ -32,6 +32,10 @@
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'

it_behaves_like 'support belong_to_group matcher', 'root', 'root'
it_behaves_like 'support have_gid matcher', 'root', 0
it_behaves_like 'support have_uid matcher', 'root', 0
it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
it_behaves_like 'support have_home_directory matcher', 'root', '/root'

it_behaves_like 'support have_iptables_rule matcher', '-P INPUT ACCEPT'
it_behaves_like 'support have_iptables_rule.with_table.with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
Expand Down
20 changes: 20 additions & 0 deletions spec/solaris/commands_spec.rb
Expand Up @@ -112,6 +112,26 @@
it { should eq "id root | awk '{print $3}' | grep wheel" }
end

describe 'have_gid', :os => :solaris do
subject { commands.check_gid('root', 0) }
it { should eq "getent group | grep -w ^root | cut -f 3 -d ':' | grep -w 0" }
end

describe 'have_uid', :os => :solaris do
subject { commands.check_uid('root', 0) }
it { should eq "id root | grep uid=0(" }
end

describe 'have_login_shell', :os => :solaris do
subject { commands.check_login_shell('root', '/bin/bash') }
it { should eq "grep -w ^root /etc/passwd | cut -f 7 -d ':' | grep -w /bin/bash" }
end

describe 'have_home_directory', :os => :solaris do
subject { commands.check_home_directory('root', '/root') }
it { should eq "grep -w ^root /etc/passwd | cut -f 6 -d ':' | grep -w /root" }
end


describe 'check_zfs', :os => :solaris do
context 'check without properties' do
Expand Down
4 changes: 4 additions & 0 deletions spec/solaris/matchers_spec.rb
Expand Up @@ -32,6 +32,10 @@
it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'

it_behaves_like 'support belong_to_group matcher', 'root', 'root'
it_behaves_like 'support have_gid matcher', 'root', 0
it_behaves_like 'support have_uid matcher', 'root', 0
it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
it_behaves_like 'support have_home_directory matcher', 'root', '/root'

it_behaves_like 'support be_zfs matcher', 'rpool'
it_behaves_like 'support be_zfs.property matcher', 'rpool', { 'mountpoint' => '/rpool' }
Expand Down

0 comments on commit 9ce0e1c

Please sign in to comment.