Skip to content

Instantly share code, notes, and snippets.

@retr0h
Created April 2, 2012 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retr0h/2288122 to your computer and use it in GitHub Desktop.
Save retr0h/2288122 to your computer and use it in GitHub Desktop.
source "http://rubygems.org"
group :test, :development do
gem "rake", "~> 0.9.2.2"
gem "rye", "~> 0.9.5"
end
require "test_helper"
describe "setup_chef" do
it "has config" do
topic = Rbox.execute "ls /etc/chef/client.rb"
topic.exit_status.must_equal 0
end
it "has first-boot json" do
topic = Rbox.execute "ls /etc/chef/first-boot.json"
topic.exit_status.must_equal 0
end
it "has proper initial role" do
topic = Rbox.execute "cat /etc/chef/first-boot.json |grep run_list"
topic.to_s.must_equal '{"run_list":["role[booted]"]}'
end
it "has initial chef-client crontab" do
topic = Rbox.execute "crontab -l |grep chef-client"
topic.to_s.must_match %r{0,30.*chef-client}
end
describe "validation.pem" do
before { @file = "/etc/chef/validation.pem" }
it "exists" do
topic = Rbox.execute "ls #{@file}"
topic.exit_status.must_equal 0
end
it "has proper modes" do
topic = Rbox.sudo "perl -e'printf \"%o\n\",(stat shift)[2] & 07777' #{@file}"
topic.stdout.to_s.to_i.must_equal 600
end
end
describe "data bag secret" do
before { @file = "/etc/chef/encrypted_data_bag_secret" }
it "exists" do
topic = Rbox.execute "ls #{@file}"
topic.exit_status.must_equal 0
end
it "has proper modes" do
topic = Rbox.sudo "perl -e'printf \"%o\n\",(stat shift)[2] & 07777' #{@file}"
topic.stdout.to_s.to_i.must_equal 600
end
end
end
require "rubygems"
require "bundler"
Bundler.setup :default, :test
require "rye"
require "minitest/spec"
MiniTest::Unit.autorun
Rbox = Rye::Box.new(ENV['TEST_HOST'],
:via => Rye::Hop.new("jumphost.example.com"),
:user => ENV['TEST_USER']
)
Rbox.disable_safe_mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment