Skip to content

Commit

Permalink
add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
chr4 committed Nov 14, 2013
1 parent 6a0a337 commit 5f6b8c5
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true

platforms:
- name: ubuntu-13.04
driver_config:
box: opscode-ubuntu-13.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box

- name: ubuntu-12.10
driver_config:
box: opscode-ubuntu-12.10
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.10_provisionerless.box

- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box

- name: debian-7.1.0
driver_config:
box: opscode-debian-7.1.0
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_debian-7.1.0_provisionerless.box

- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box

- name: centos-5.9
driver_config:
box: opscode-centos-5.9
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box


suites:
- name: custom_port
run_list:
- recipe[minitest-handler]
- recipe[sshd::default]
attributes:
sshd:
sshd_config:
Port: 1234

- name: conditional_block
run_list:
- recipe[minitest-handler]
- recipe[sshd::default]
attributes:
sshd:
sshd_config:
Port: 1234
7 changes: 7 additions & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
site :opscode

metadata

group :integration do
cookbook 'minitest-handler'
end
41 changes: 41 additions & 0 deletions files/default/tests/minitest/default_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Cookbook Name:: sshd
# Test:: default
#
# Copyright 2013, Chris Aumann
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

require File.expand_path('../support/helpers', __FILE__)

describe 'sshd::default' do
include Helpers::TestHelper

it 'should install openssh-server' do
package(node['sshd']['package']).must_be_installed
end

it 'should create sshd_config according to specifications' do
file(node['sshd']['config_file']).must_include('Port 1234')
end

it 'should start openssh-server service' do
service(node['sshd']['service_name']).must_be_running
end

it 'should enable openssh-server service' do
service(node['sshd']['service_name']).must_be_enabled
end
end
27 changes: 27 additions & 0 deletions files/default/tests/minitest/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Cookbook Name:: sshd
#
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Helpers
module TestHelper
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources
end
end

0 comments on commit 5f6b8c5

Please sign in to comment.