serverspec 0.6.17 → 0.6.18

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -121,6 +121,30 @@ end
121
121
 
122
122
  You can select **Serverspec::Helper::RedHat**, **Serverspec::Helper::Debian**, **Serverspec::Helper::Gentoo** , **Serverspec::Helper::Solaris** or **Serverspec::Helper::Darwin**.
123
123
 
124
+ ## Vagrant support
125
+
126
+ Serverspec now has Vagrant support, and can be automatically configured from a Vagrantfile
127
+
128
+ ```
129
+ $ serverspec-init
130
+ Select a backend type:
131
+
132
+ 1) SSH
133
+ 2) Exec (local)
134
+
135
+ Select number:1
136
+
137
+ Vagrant instance y/n: y
138
+ Auto-configure Vagrant from Vagrantfile? y/n: y
139
+ 0) web
140
+ 1) db
141
+ 1
142
+ + spec/db/
143
+ + spec/db/httpd_spec.rb
144
+ + spec/spec_helper.rb
145
+ + Rakefile
146
+ ```
147
+
124
148
  See details on [serverspec.org](http://serverspec.org)
125
149
 
126
150
  ----
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
4
4
  task :spec => 'spec:all'
5
5
 
6
6
  namespace :spec do
7
- oses = %w( darwin debian gentoo redhat solaris )
7
+ oses = %w( darwin debian gentoo redhat solaris solaris10 smartos )
8
8
 
9
9
  task :all => [ oses.map {|os| "spec:#{os}" }, :helpers, :exec, :ssh ].flatten
10
10
 
data/lib/serverspec.rb CHANGED
@@ -12,6 +12,7 @@ require 'serverspec/commands/redhat'
12
12
  require 'serverspec/commands/debian'
13
13
  require 'serverspec/commands/gentoo'
14
14
  require 'serverspec/commands/solaris'
15
+ require 'serverspec/commands/solaris10'
15
16
  require 'serverspec/commands/smartos'
16
17
  require 'serverspec/commands/darwin'
17
18
  require 'serverspec/configuration'
@@ -29,12 +30,13 @@ end
29
30
 
30
31
  RSpec.configure do |c|
31
32
  c.include(Serverspec::Helper::Configuration)
32
- c.include(Serverspec::Helper::RedHat, :os => :redhat)
33
- c.include(Serverspec::Helper::Debian, :os => :debian)
34
- c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
35
- c.include(Serverspec::Helper::Solaris, :os => :solaris)
36
- c.include(Serverspec::Helper::SmartOS, :os => :smartos)
37
- c.include(Serverspec::Helper::Darwin, :os => :darwin)
33
+ c.include(Serverspec::Helper::RedHat, :os => :redhat)
34
+ c.include(Serverspec::Helper::Debian, :os => :debian)
35
+ c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
36
+ c.include(Serverspec::Helper::Solaris, :os => :solaris)
37
+ c.include(Serverspec::Helper::Solaris10, :os => :solaris10)
38
+ c.include(Serverspec::Helper::SmartOS, :os => :smartos)
39
+ c.include(Serverspec::Helper::Darwin, :os => :darwin)
38
40
  c.add_setting :os, :default => nil
39
41
  c.add_setting :host, :default => nil
40
42
  c.add_setting :ssh, :default => nil
@@ -197,8 +197,10 @@ module Serverspec
197
197
  'Debian'
198
198
  elsif run_command('ls /etc/gentoo-release')[:exit_status] == 0
199
199
  'Gentoo'
200
- elsif run_command('uname -s')[:stdout] =~ /SunOS/i
201
- if run_command('grep -q SmartOS /etc/release')
200
+ elsif os = run_command('uname -sr')[:stdout] && os =~ /SunOS/i
201
+ if os =~ /5.10/
202
+ 'Solaris10'
203
+ elsif run_command('grep -q SmartOS /etc/release')
202
204
  'SmartOS'
203
205
  else
204
206
  'Solaris'
@@ -0,0 +1,7 @@
1
+ module Serverspec
2
+ module Commands
3
+ class Solaris10 < Solaris
4
+ # Please implement Solaris 10 specific commands
5
+ end
6
+ end
7
+ end
@@ -10,6 +10,7 @@ require 'serverspec/helper/redhat'
10
10
  require 'serverspec/helper/debian'
11
11
  require 'serverspec/helper/gentoo'
12
12
  require 'serverspec/helper/solaris'
13
+ require 'serverspec/helper/solaris10'
13
14
  require 'serverspec/helper/smartos'
14
15
  require 'serverspec/helper/darwin'
15
16
  require 'serverspec/helper/detect_os'
@@ -0,0 +1,9 @@
1
+ module Serverspec
2
+ module Helper
3
+ module Solaris10
4
+ def commands
5
+ Serverspec::Commands::Solaris10.new
6
+ end
7
+ end
8
+ end
9
+ end
@@ -21,15 +21,22 @@ EOF
21
21
  @vagrant = gets.chomp
22
22
  if @vagrant =~ (/(true|t|yes|y|1)$/i)
23
23
  @vagrant = true
24
+ print "Auto-configure Vagrant from Vagrantfile? y/n: "
25
+ auto_config = gets.chomp
26
+ if auto_config =~ (/(true|t|yes|y|1)$/i)
27
+ auto_vagrant_configuration
28
+ else
29
+ print("Input vagrant instance name: ")
30
+ @hostname = gets.chomp
31
+ end
24
32
  else
25
33
  @vagrant = false
34
+ print("Input target host name: ")
35
+ @hostname = gets.chomp
26
36
  end
27
- @vagrant ? print("Input vagrant instance name: ") : print("Input target host name: ")
28
- @hostname = gets.chomp
29
- else
37
+ else
30
38
  @hostname = 'localhost'
31
39
  end
32
-
33
40
  [ 'spec', "spec/#{@hostname}" ].each { |dir| safe_mkdir(dir) }
34
41
  safe_create_spec
35
42
  safe_create_spec_helper
@@ -128,7 +135,8 @@ EOF
128
135
  end")
129
136
  if @vagrant
130
137
  content.gsub!(/### include vagrant conf ###/,"
131
- config = `vagrant ssh-config --host \#{host}`
138
+ vagrant_up = `vagrant up #{@hostname}`
139
+ config = `vagrant ssh-config #{@hostname}`
132
140
  if config != ''
133
141
  config.each_line do |line|
134
142
  if match = /HostName (.*)/.match(line)
@@ -189,5 +197,34 @@ EOF
189
197
  puts ' + Rakefile'
190
198
  end
191
199
  end
200
+
201
+ def self.auto_vagrant_configuration
202
+ if File.exists?("Vagrantfile")
203
+ vagrant_list = `vagrant status`
204
+ list_of_vms = []
205
+ if vagrant_list != ''
206
+ vagrant_list.each_line do |line|
207
+ if match = /([a-z]+[\s]+)(created|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\))/.match(line)
208
+ list_of_vms << match[1].strip!
209
+ end
210
+ end
211
+ if list_of_vms.length == 1
212
+ @hostname = list_of_vms[0]
213
+ else
214
+ list_of_vms.each_with_index { |vm, index | puts "#{index}) #{vm}\n" }
215
+ print "Choose a VM from the Vagrantfile: "
216
+ chosen_vm = gets.chomp
217
+ @hostname = list_of_vms[chosen_vm.to_i]
218
+ end
219
+ else
220
+ $stderr.puts "Vagrant status error - Check your Vagrantfile or .vagrant"
221
+ exit 1
222
+ end
223
+ else
224
+ $stderr.puts "Vagrantfile not found in directory!"
225
+ exit 1
226
+ end
227
+ end
228
+
192
229
  end
193
230
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.6.17"
2
+ VERSION = "0.6.18"
3
3
  end
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Darwin family' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -2,11 +2,57 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Darwin
4
4
 
5
- describe 'Serverspec package matchers of Darwin family' do
6
- it_behaves_like 'support package installed by gem matcher', 'jekyll'
7
- it_behaves_like 'support package installed by gem with version matcher', 'jekyll', '1.1.1'
8
- it_behaves_like 'support package installed by npm matcher', 'bower'
9
- it_behaves_like 'support package installed by npm with version matcher', 'bower', '0.9.2'
10
- it_behaves_like 'support package installed by pecl matcher', 'mongo'
11
- it_behaves_like 'support package installed by pecl with version matcher', 'mongo', '1.4.1'
5
+ describe package('jekyll') do
6
+ it { should be_installed.by('gem') }
7
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll" }
8
+ end
9
+
10
+ describe package('invalid-gem') do
11
+ it { should_not be_installed.by('gem') }
12
+ end
13
+
14
+ describe package('jekyll') do
15
+ it { should be_installed.by('gem').with_version('1.1.1') }
16
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll | grep -w -- 1.1.1" }
17
+ end
18
+
19
+ describe package('jekyll') do
20
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
21
+ end
22
+
23
+ describe package('bower') do
24
+ it { should be_installed.by('npm') }
25
+ its(:command) { should eq "npm ls bower -g" }
26
+ end
27
+
28
+ describe package('invalid-npm-package') do
29
+ it { should_not be_installed.by('npm') }
30
+ end
31
+
32
+ describe package('bower') do
33
+ it { should be_installed.by('npm').with_version('0.9.2') }
34
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
35
+ end
36
+
37
+ describe package('bower') do
38
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
39
+ end
40
+
41
+
42
+ describe package('mongo') do
43
+ it { should be_installed.by('pecl') }
44
+ its(:command) { should eq "pecl list | grep -w -- ^mongo" }
45
+ end
46
+
47
+ describe package('invalid-pecl') do
48
+ it { should_not be_installed.by('pecl') }
49
+ end
50
+
51
+ describe package('mongo') do
52
+ it { should be_installed.by('pecl').with_version('1.4.1') }
53
+ its(:command) { should eq "pecl list | grep -w -- ^mongo | grep -w -- 1.4.1" }
54
+ end
55
+
56
+ describe package('mongo') do
57
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
12
58
  end
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Debian family' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -69,11 +60,6 @@ describe 'check_enabled with run level 5' do
69
60
  it { should eq "ls /etc/rc5.d/ | grep -- httpd || grep 'start on' /etc/init/httpd.conf" }
70
61
  end
71
62
 
72
- describe 'check_installed' do
73
- subject { commands.check_installed('httpd') }
74
- it { should eq "dpkg -s httpd && ! dpkg -s httpd | grep -E '^Status: .+ not-installed$'" }
75
- end
76
-
77
63
  describe 'check_running' do
78
64
  subject { commands.check_running('httpd') }
79
65
  it { should eq "service httpd status | grep 'running'" }
@@ -2,12 +2,66 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Debian
4
4
 
5
- describe 'Serverspec package matchers of Debian family' do
6
- it_behaves_like 'support package installed matcher', 'httpd'
7
- it_behaves_like 'support package installed by gem matcher', 'jekyll'
8
- it_behaves_like 'support package installed by gem with version matcher', 'jekyll', '1.1.1'
9
- it_behaves_like 'support package installed by npm matcher', 'bower'
10
- it_behaves_like 'support package installed by npm with version matcher', 'bower', '0.9.2'
11
- it_behaves_like 'support package installed by pecl matcher', 'mongo'
12
- it_behaves_like 'support package installed by pecl with version matcher', 'mongo', '1.4.1'
5
+ describe package('apache2') do
6
+ it { should be_installed }
7
+ its(:command) { should eq "dpkg -s apache2 && ! dpkg -s apache2 | grep -E '^Status: .+ not-installed$'" }
8
+ end
9
+
10
+ describe package('invalid-package') do
11
+ it { should_not be_installed }
12
+ end
13
+
14
+ describe package('jekyll') do
15
+ it { should be_installed.by('gem') }
16
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll" }
17
+ end
18
+
19
+ describe package('invalid-gem') do
20
+ it { should_not be_installed.by('gem') }
21
+ end
22
+
23
+ describe package('jekyll') do
24
+ it { should be_installed.by('gem').with_version('1.1.1') }
25
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll | grep -w -- 1.1.1" }
26
+ end
27
+
28
+ describe package('jekyll') do
29
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
30
+ end
31
+
32
+ describe package('bower') do
33
+ it { should be_installed.by('npm') }
34
+ its(:command) { should eq "npm ls bower -g" }
35
+ end
36
+
37
+ describe package('invalid-npm-package') do
38
+ it { should_not be_installed.by('npm') }
39
+ end
40
+
41
+ describe package('bower') do
42
+ it { should be_installed.by('npm').with_version('0.9.2') }
43
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
44
+ end
45
+
46
+ describe package('bower') do
47
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
48
+ end
49
+
50
+
51
+ describe package('mongo') do
52
+ it { should be_installed.by('pecl') }
53
+ its(:command) { should eq "pecl list | grep -w -- ^mongo" }
54
+ end
55
+
56
+ describe package('invalid-pecl') do
57
+ it { should_not be_installed.by('pecl') }
58
+ end
59
+
60
+ describe package('mongo') do
61
+ it { should be_installed.by('pecl').with_version('1.4.1') }
62
+ its(:command) { should eq "pecl list | grep -w -- ^mongo | grep -w -- 1.4.1" }
63
+ end
64
+
65
+ describe package('mongo') do
66
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
13
67
  end
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Gentoo family' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -60,11 +51,6 @@ describe 'check_enabled' do
60
51
  it { should eq "rc-update show | grep -- \\^\\\\s\\*httpd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" }
61
52
  end
62
53
 
63
- describe 'check_installed' do
64
- subject { commands.check_installed('httpd') }
65
- it { should eq 'eix httpd --installed' }
66
- end
67
-
68
54
  describe 'check_running' do
69
55
  subject { commands.check_running('httpd') }
70
56
  it { should eq '/etc/init.d/httpd status' }
@@ -2,12 +2,66 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Gentoo
4
4
 
5
- describe 'Serverspec package matchers of Gentoo family' do
6
- it_behaves_like 'support package installed matcher', 'httpd'
7
- it_behaves_like 'support package installed by gem matcher', 'jekyll'
8
- it_behaves_like 'support package installed by gem with version matcher', 'jekyll', '1.1.1'
9
- it_behaves_like 'support package installed by npm matcher', 'bower'
10
- it_behaves_like 'support package installed by npm with version matcher', 'bower', '0.9.2'
11
- it_behaves_like 'support package installed by pecl matcher', 'mongo'
12
- it_behaves_like 'support package installed by pecl with version matcher', 'mongo', '1.4.1'
5
+ describe package('apache') do
6
+ it { should be_installed }
7
+ its(:command) { should eq "eix apache --installed" }
8
+ end
9
+
10
+ describe package('invalid-package') do
11
+ it { should_not be_installed }
12
+ end
13
+
14
+ describe package('jekyll') do
15
+ it { should be_installed.by('gem') }
16
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll" }
17
+ end
18
+
19
+ describe package('invalid-gem') do
20
+ it { should_not be_installed.by('gem') }
21
+ end
22
+
23
+ describe package('jekyll') do
24
+ it { should be_installed.by('gem').with_version('1.1.1') }
25
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll | grep -w -- 1.1.1" }
26
+ end
27
+
28
+ describe package('jekyll') do
29
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
30
+ end
31
+
32
+ describe package('bower') do
33
+ it { should be_installed.by('npm') }
34
+ its(:command) { should eq "npm ls bower -g" }
35
+ end
36
+
37
+ describe package('invalid-npm-package') do
38
+ it { should_not be_installed.by('npm') }
39
+ end
40
+
41
+ describe package('bower') do
42
+ it { should be_installed.by('npm').with_version('0.9.2') }
43
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
44
+ end
45
+
46
+ describe package('bower') do
47
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
48
+ end
49
+
50
+
51
+ describe package('mongo') do
52
+ it { should be_installed.by('pecl') }
53
+ its(:command) { should eq "pecl list | grep -w -- ^mongo" }
54
+ end
55
+
56
+ describe package('invalid-pecl') do
57
+ it { should_not be_installed.by('pecl') }
58
+ end
59
+
60
+ describe package('mongo') do
61
+ it { should be_installed.by('pecl').with_version('1.4.1') }
62
+ its(:command) { should eq "pecl list | grep -w -- ^mongo | grep -w -- 1.4.1" }
63
+ end
64
+
65
+ describe package('mongo') do
66
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
13
67
  end
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Red Hat' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -77,16 +68,6 @@ describe 'check_yumrepo_enabled' do
77
68
  it { should eq 'yum repolist all -C | grep ^epel | grep enabled' }
78
69
  end
79
70
 
80
- describe 'check_installed' do
81
- subject { commands.check_installed('httpd') }
82
- it { should eq 'rpm -q httpd' }
83
- end
84
-
85
- describe 'check_installed' do
86
- subject { commands.check_installed('httpd','2.2') }
87
- it { should eq 'rpm -q httpd | grep -w -- 2.2' }
88
- end
89
-
90
71
  describe 'check_running' do
91
72
  subject { commands.check_running('httpd') }
92
73
  it { should eq 'service httpd status' }
@@ -2,13 +2,75 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::RedHat
4
4
 
5
- describe 'Serverspec package matchers of Red Hat family' do
6
- it_behaves_like 'support package installed matcher', 'httpd'
7
- it_behaves_like 'support package installed with version matcher', 'httpd', '2.2'
8
- it_behaves_like 'support package installed by gem matcher', 'jekyll'
9
- it_behaves_like 'support package installed by gem with version matcher', 'jekyll', '1.1.1'
10
- it_behaves_like 'support package installed by npm matcher', 'bower'
11
- it_behaves_like 'support package installed by npm with version matcher', 'bower', '0.9.2'
12
- it_behaves_like 'support package installed by pecl matcher', 'mongo'
13
- it_behaves_like 'support package installed by pecl with version matcher', 'mongo', '1.4.1'
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ its(:command) { should eq "rpm -q httpd" }
8
+ end
9
+
10
+ describe package('invalid-package') do
11
+ it { should_not be_installed }
12
+ end
13
+
14
+ describe package('httpd') do
15
+ it { should be_installed.with_version('2.2.15-28.el6') }
16
+ its(:command) { should eq "rpm -q httpd | grep -w -- 2.2.15-28.el6" }
17
+ end
18
+
19
+ describe package('httpd') do
20
+ it { should_not be_installed.with_version('invalid-version') }
21
+ end
22
+
23
+ describe package('jekyll') do
24
+ it { should be_installed.by('gem') }
25
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll" }
26
+ end
27
+
28
+ describe package('invalid-gem') do
29
+ it { should_not be_installed.by('gem') }
30
+ end
31
+
32
+ describe package('jekyll') do
33
+ it { should be_installed.by('gem').with_version('1.1.1') }
34
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll | grep -w -- 1.1.1" }
35
+ end
36
+
37
+ describe package('jekyll') do
38
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
39
+ end
40
+
41
+ describe package('bower') do
42
+ it { should be_installed.by('npm') }
43
+ its(:command) { should eq "npm ls bower -g" }
44
+ end
45
+
46
+ describe package('invalid-npm-package') do
47
+ it { should_not be_installed.by('npm') }
48
+ end
49
+
50
+ describe package('bower') do
51
+ it { should be_installed.by('npm').with_version('0.9.2') }
52
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
53
+ end
54
+
55
+ describe package('bower') do
56
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
57
+ end
58
+
59
+
60
+ describe package('mongo') do
61
+ it { should be_installed.by('pecl') }
62
+ its(:command) { should eq "pecl list | grep -w -- ^mongo" }
63
+ end
64
+
65
+ describe package('invalid-pecl') do
66
+ it { should_not be_installed.by('pecl') }
67
+ end
68
+
69
+ describe package('mongo') do
70
+ it { should be_installed.by('pecl').with_version('1.4.1') }
71
+ its(:command) { should eq "pecl list | grep -w -- ^mongo | grep -w -- 1.4.1" }
72
+ end
73
+
74
+ describe package('mongo') do
75
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
14
76
  end
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Solaris family specified SmartOS' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -7,15 +7,6 @@ describe 'Serverspec commands of Solaris family' do
7
7
  it_behaves_like 'support command check_directory', '/var/log'
8
8
  it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
9
 
10
- it_behaves_like 'support command check_installed_by_gem', 'jekyll'
11
- it_behaves_like 'support command check_installed_by_gem with_version', 'jekyll', '1.0.2'
12
-
13
- it_behaves_like 'support command check_installed_by_npm', 'hubot'
14
- it_behaves_like 'support command check_installed_by_npm with_version', 'hubot', '1.0.2'
15
-
16
- it_behaves_like 'support command check_installed_by_pecl', 'mongo'
17
- it_behaves_like 'support command check_installed_by_pecl with_version', 'mongo', '1.4.1'
18
-
19
10
  it_behaves_like 'support command check_mounted', '/'
20
11
 
21
12
  it_behaves_like 'support command check_user', 'root'
@@ -50,16 +41,6 @@ describe 'check_enabled' do
50
41
  it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" }
51
42
  end
52
43
 
53
- describe 'check_installed' do
54
- subject { commands.check_installed('httpd') }
55
- it { should eq 'pkg list -H httpd 2> /dev/null' }
56
- end
57
-
58
- describe 'check_installed' do
59
- subject { commands.check_installed('httpd', '2.2') }
60
- it { should eq 'pkg list -H httpd 2> /dev/null | grep -qw -- 2.2' }
61
- end
62
-
63
44
  describe 'check_file_contain_within' do
64
45
  context 'contain a pattern in the file' do
65
46
  subject { commands.check_file_contain_within('Gemfile', 'rspec') }
@@ -2,13 +2,75 @@ require 'spec_helper'
2
2
 
3
3
  include Serverspec::Helper::Solaris
4
4
 
5
- describe 'Serverspec package matchers of Solaris family' do
6
- it_behaves_like 'support package installed matcher', 'httpd'
7
- it_behaves_like 'support package installed with version matcher', 'httpd', '2.2'
8
- it_behaves_like 'support package installed by gem matcher', 'jekyll'
9
- it_behaves_like 'support package installed by gem with version matcher', 'jekyll', '1.1.1'
10
- it_behaves_like 'support package installed by npm matcher', 'bower'
11
- it_behaves_like 'support package installed by npm with version matcher', 'bower', '0.9.2'
12
- it_behaves_like 'support package installed by pecl matcher', 'mongo'
13
- it_behaves_like 'support package installed by pecl with version matcher', 'mongo', '1.4.1'
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ its(:command) { should eq "pkg list -H httpd 2> /dev/null" }
8
+ end
9
+
10
+ describe package('invalid-package') do
11
+ it { should_not be_installed }
12
+ end
13
+
14
+ describe package('httpd') do
15
+ it { should be_installed.with_version('2.2') }
16
+ its(:command) { should eq "pkg list -H httpd 2> /dev/null | grep -qw -- 2.2" }
17
+ end
18
+
19
+ describe package('httpd') do
20
+ it { should_not be_installed.with_version('invalid-version') }
21
+ end
22
+
23
+ describe package('jekyll') do
24
+ it { should be_installed.by('gem') }
25
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll" }
26
+ end
27
+
28
+ describe package('invalid-gem') do
29
+ it { should_not be_installed.by('gem') }
30
+ end
31
+
32
+ describe package('jekyll') do
33
+ it { should be_installed.by('gem').with_version('1.1.1') }
34
+ its(:command) { should eq "gem list --local | grep -w -- ^jekyll | grep -w -- 1.1.1" }
35
+ end
36
+
37
+ describe package('jekyll') do
38
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
39
+ end
40
+
41
+ describe package('bower') do
42
+ it { should be_installed.by('npm') }
43
+ its(:command) { should eq "npm ls bower -g" }
44
+ end
45
+
46
+ describe package('invalid-npm-package') do
47
+ it { should_not be_installed.by('npm') }
48
+ end
49
+
50
+ describe package('bower') do
51
+ it { should be_installed.by('npm').with_version('0.9.2') }
52
+ its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
53
+ end
54
+
55
+ describe package('bower') do
56
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
57
+ end
58
+
59
+
60
+ describe package('mongo') do
61
+ it { should be_installed.by('pecl') }
62
+ its(:command) { should eq "pecl list | grep -w -- ^mongo" }
63
+ end
64
+
65
+ describe package('invalid-pecl') do
66
+ it { should_not be_installed.by('pecl') }
67
+ end
68
+
69
+ describe package('mongo') do
70
+ it { should be_installed.by('pecl').with_version('1.4.1') }
71
+ its(:command) { should eq "pecl list | grep -w -- ^mongo | grep -w -- 1.4.1" }
72
+ end
73
+
74
+ describe package('mongo') do
75
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
14
76
  end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris10
4
+
5
+ describe 'Serverspec commands of Solaris family' do
6
+ it_behaves_like 'support command check_file', '/etc/passwd'
7
+ it_behaves_like 'support command check_directory', '/var/log'
8
+ it_behaves_like 'support command check_socket', '/var/run/unicorn.sock'
9
+
10
+ it_behaves_like 'support command check_mounted', '/'
11
+
12
+ it_behaves_like 'support command check_user', 'root'
13
+ it_behaves_like 'support command check_user', 'wheel'
14
+
15
+ it_behaves_like 'support command check_file_md5checksum', '/etc/passewd', '96c8c50f81a29965f7af6de371ab4250'
16
+
17
+ it_behaves_like 'support command check_running_under_supervisor', 'httpd'
18
+ it_behaves_like 'support command check_monitored_by_monit', 'unicorn'
19
+ it_behaves_like 'support command check_process', 'httpd'
20
+
21
+ it_behaves_like 'support command check_file_contain', '/etc/passwd', 'root'
22
+
23
+ it_behaves_like 'support command check_mode', '/etc/sudoers', 440
24
+ it_behaves_like 'support command check_owner', '/etc/sudoers', 'root'
25
+ it_behaves_like 'support command check_grouped', '/etc/sudoers', 'wheel'
26
+
27
+ it_behaves_like 'support command check_link', '/etc/system-release', '/etc/redhat-release'
28
+
29
+ it_behaves_like 'support command check_uid', 'root', 0
30
+
31
+ it_behaves_like 'support command check_login_shell', 'root', '/bin/bash'
32
+ it_behaves_like 'support command check_home_directory', 'root', '/root'
33
+
34
+ it_behaves_like 'support command check_authorized_key'
35
+
36
+ it_behaves_like 'support command get_mode'
37
+ end
38
+
39
+ describe 'check_enabled' do
40
+ subject { commands.check_enabled('httpd') }
41
+ it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" }
42
+ end
43
+
44
+ describe 'check_file_contain_within' do
45
+ context 'contain a pattern in the file' do
46
+ subject { commands.check_file_contain_within('Gemfile', 'rspec') }
47
+ it { should eq "sed -n 1,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
48
+ end
49
+
50
+ context 'contain a pattern after a line in a file' do
51
+ subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/') }
52
+ it { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin" }
53
+ end
54
+
55
+ context 'contain a pattern before a line in a file' do
56
+ subject {commands.check_file_contain_within('Gemfile', 'rspec', nil, '/^end/') }
57
+ it { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
58
+ end
59
+
60
+ context 'contain a pattern from within a line and another line in a file' do
61
+ subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/', '/^end/') }
62
+ it { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" }
63
+ end
64
+ end
65
+
66
+ describe 'check_running' do
67
+ subject { commands.check_running('httpd') }
68
+ it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" }
69
+ end
70
+
71
+ describe 'check_belonging_group' do
72
+ subject { commands.check_belonging_group('root', 'wheel') }
73
+ it { should eq "id -Gn root | grep -- wheel" }
74
+ end
75
+
76
+ describe 'check_gid' do
77
+ subject { commands.check_gid('root', 0) }
78
+ it { should eq "getent group | grep -- \\^root: | cut -f 3 -d ':' | grep -w -- 0" }
79
+ end
80
+
81
+ describe 'check_zfs' do
82
+ context 'check without properties' do
83
+ subject { commands.check_zfs('rpool') }
84
+ it { should eq "zfs list -H rpool" }
85
+ end
86
+
87
+ context 'check with a property' do
88
+ subject { commands.check_zfs('rpool', { 'mountpoint' => '/rpool' }) }
89
+ it { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" }
90
+ end
91
+
92
+ context 'check with multiple properties' do
93
+ subject { commands.check_zfs('rpool', { 'mountpoint' => '/rpool', 'compression' => 'off' }) }
94
+ it { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" }
95
+ end
96
+ end
97
+
98
+ describe 'check_ip_filter_rule' do
99
+ subject { commands.check_ipfilter_rule('pass in quick on lo0 all') }
100
+ it { should eq "ipfstat -io 2> /dev/null | grep -- pass\\ in\\ quick\\ on\\ lo0\\ all" }
101
+ end
102
+
103
+ describe 'check_ipnat_rule' do
104
+ subject { commands.check_ipnat_rule('map net1 192.168.0.0/24 -> 0.0.0.0/32') }
105
+ it { should eq "ipnat -l 2> /dev/null | grep -- \\^map\\ net1\\ 192.168.0.0/24\\ -\\>\\ 0.0.0.0/32\\$" }
106
+ end
107
+
108
+ describe 'check_svcprop' do
109
+ subject { commands.check_svcprop('svc:/network/http:apache22', 'httpd/enable_64bit','false') }
110
+ it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$" }
111
+ end
112
+
113
+ describe 'check_svcprops' do
114
+ subject {
115
+ commands.check_svcprops('svc:/network/http:apache22', {
116
+ 'httpd/enable_64bit' => 'false',
117
+ 'httpd/server_type' => 'worker',
118
+ })
119
+ }
120
+ it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$ && svcprop -p httpd/server_type svc:/network/http:apache22 | grep -- \\^worker\\$" }
121
+ end
122
+
123
+ describe 'check_access_by_user' do
124
+ context 'read access' do
125
+ subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'}
126
+ it { should eq 'su dummyuser1 -c "test -r /tmp/something"' }
127
+ end
128
+
129
+ context 'write access' do
130
+ subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'}
131
+ it { should eq 'su dummyuser2 -c "test -w /tmp/somethingw"' }
132
+ end
133
+
134
+ context 'execute access' do
135
+ subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'}
136
+ it { should eq 'su dummyuser3 -c "test -x /tmp/somethingx"' }
137
+ end
138
+ end
@@ -1,33 +1,3 @@
1
- shared_examples_for 'support command check_installed_by_gem' do |package|
2
- subject { commands.check_installed_by_gem(package) }
3
- it { should eq "gem list --local | grep -w -- ^#{package}" }
4
- end
5
-
6
- shared_examples_for 'support command check_installed_by_gem with_version' do |package, version|
7
- subject { commands.check_installed_by_gem(package, version) }
8
- it { should eq "gem list --local | grep -w -- ^#{package} | grep -w -- #{version}" }
9
- end
10
-
11
- shared_examples_for 'support command check_installed_by_npm' do |package|
12
- subject { commands.check_installed_by_npm(package) }
13
- it { should eq "npm ls #{package} -g" }
14
- end
15
-
16
- shared_examples_for 'support command check_installed_by_npm with_version' do |package, version|
17
- subject { commands.check_installed_by_npm(package, version) }
18
- it { should eq "npm ls #{package} -g | grep -w -- #{version}" }
19
- end
20
-
21
- shared_examples_for 'support command check_installed_by_pecl' do |package|
22
- subject { commands.check_installed_by_pecl(package) }
23
- it { should eq "pecl list | grep -w -- ^#{package}" }
24
- end
25
-
26
- shared_examples_for 'support command check_installed_by_pecl with_version' do |package, version|
27
- subject { commands.check_installed_by_pecl(package, version) }
28
- it { should eq "pecl list | grep -w -- ^#{package} | grep -w -- #{version}" }
29
- end
30
-
31
1
  shared_examples_for 'support command check_file' do |file|
32
2
  subject { commands.check_file(file) }
33
3
  it { should eq "test -f #{file}" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.17
4
+ version: 0.6.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -152,6 +152,7 @@ files:
152
152
  - lib/serverspec/commands/redhat.rb
153
153
  - lib/serverspec/commands/smartos.rb
154
154
  - lib/serverspec/commands/solaris.rb
155
+ - lib/serverspec/commands/solaris10.rb
155
156
  - lib/serverspec/configuration.rb
156
157
  - lib/serverspec/helper.rb
157
158
  - lib/serverspec/helper/attributes.rb
@@ -166,6 +167,7 @@ files:
166
167
  - lib/serverspec/helper/redhat.rb
167
168
  - lib/serverspec/helper/smartos.rb
168
169
  - lib/serverspec/helper/solaris.rb
170
+ - lib/serverspec/helper/solaris10.rb
169
171
  - lib/serverspec/helper/ssh.rb
170
172
  - lib/serverspec/helper/type.rb
171
173
  - lib/serverspec/matchers.rb
@@ -295,12 +297,12 @@ files:
295
297
  - spec/solaris/svcprop_spec.rb
296
298
  - spec/solaris/user_spec.rb
297
299
  - spec/solaris/zfs_spec.rb
300
+ - spec/solaris10/commands_spec.rb
298
301
  - spec/spec_helper.rb
299
302
  - spec/support/shared_commands_examples.rb
300
303
  - spec/support/shared_file_examples.rb
301
304
  - spec/support/shared_group_examples.rb
302
305
  - spec/support/shared_kernel_module_examples.rb
303
- - spec/support/shared_package_examples.rb
304
306
  - spec/support/shared_selinux_examples.rb
305
307
  - spec/support/shared_service_examples.rb
306
308
  - spec/support/shared_user_examples.rb
@@ -325,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
327
  version: '0'
326
328
  requirements: []
327
329
  rubyforge_project:
328
- rubygems_version: 1.8.25
330
+ rubygems_version: 1.8.23
329
331
  signing_key:
330
332
  specification_version: 3
331
333
  summary: RSpec tests for your servers configured by Puppet, Chef or anything else
@@ -414,12 +416,12 @@ test_files:
414
416
  - spec/solaris/svcprop_spec.rb
415
417
  - spec/solaris/user_spec.rb
416
418
  - spec/solaris/zfs_spec.rb
419
+ - spec/solaris10/commands_spec.rb
417
420
  - spec/spec_helper.rb
418
421
  - spec/support/shared_commands_examples.rb
419
422
  - spec/support/shared_file_examples.rb
420
423
  - spec/support/shared_group_examples.rb
421
424
  - spec/support/shared_kernel_module_examples.rb
422
- - spec/support/shared_package_examples.rb
423
425
  - spec/support/shared_selinux_examples.rb
424
426
  - spec/support/shared_service_examples.rb
425
427
  - spec/support/shared_user_examples.rb
@@ -1,95 +0,0 @@
1
- shared_examples_for 'support package installed matcher' do |name|
2
- describe 'be_installed' do
3
- describe package(name) do
4
- it { should be_installed }
5
- end
6
-
7
- describe package('invalid-package') do
8
- it { should_not be_installed }
9
- end
10
- end
11
- end
12
-
13
- shared_examples_for 'support package installed with version matcher' do |name,version|
14
- describe 'installed with version' do
15
- describe package(name) do
16
- it { should be_installed.with_version(version) }
17
- end
18
-
19
- describe package('invalid-package') do
20
- it { should_not be_installed.with_version(version) }
21
- end
22
- end
23
- end
24
-
25
- shared_examples_for 'support package installed by gem matcher' do |name|
26
- describe 'installed by gem' do
27
- describe package(name) do
28
- it { should be_installed.by('gem') }
29
- end
30
-
31
- describe package('invalid-gem') do
32
- it { should_not be_installed.by('gem') }
33
- end
34
- end
35
- end
36
-
37
- shared_examples_for 'support package installed by gem with version matcher' do |name, version|
38
- describe 'installed by gem with version' do
39
- describe package(name) do
40
- it { should be_installed.by('gem').with_version(version) }
41
- end
42
-
43
- describe package('invalid-gem-package') do
44
- it { should_not be_installed.by('gem').with_version('invalid-version') }
45
- end
46
- end
47
- end
48
-
49
- shared_examples_for 'support package installed by npm matcher' do |name|
50
- describe 'installed by npm' do
51
- describe package(name) do
52
- it { should be_installed.by('npm') }
53
- end
54
-
55
- describe package('invalid-npm-package') do
56
- it { should_not be_installed.by('npm') }
57
- end
58
- end
59
- end
60
-
61
- shared_examples_for 'support package installed by npm with version matcher' do |name, version|
62
- describe 'installed by npm with version' do
63
- describe package(name) do
64
- it { should be_installed.by('npm').with_version(version) }
65
- end
66
-
67
- describe package('invalid-npm-package') do
68
- it { should_not be_installed.by('npm').with_version('invalid-version') }
69
- end
70
- end
71
- end
72
-
73
- shared_examples_for 'support package installed by pecl matcher' do |name|
74
- describe 'installed by pecl' do
75
- describe package(name) do
76
- it { should be_installed.by('pecl') }
77
- end
78
-
79
- describe package('invalid-pecl') do
80
- it { should_not be_installed.by('pecl') }
81
- end
82
- end
83
- end
84
-
85
- shared_examples_for 'support package installed by pecl with version matcher' do |name, version|
86
- describe 'installed by pecl with version' do
87
- describe package(name) do
88
- it { should be_installed.by('pecl').with_version(version) }
89
- end
90
-
91
- describe package('invalid-pecl-package') do
92
- it { should_not be_installed.by('pecl').with_version('invalid-version') }
93
- end
94
- end
95
- end