specinfra 2.66.5 → 2.66.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -1
- data/lib/specinfra/processor.rb +17 -8
- data/lib/specinfra/version.rb +1 -1
- data/spec/processor_spec.rb +63 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3ab4b42d73fe5ddbe2f8a7b7b15dbf9c4cab08
|
4
|
+
data.tar.gz: f55c8d33ef771d0d3d37788fae05115090b18ed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7e4c706519eb56e678fbfc3745723884d65a335d9346f7eab94488093b773c35af336d82a27ac87176755784b8203c6ba614440a7f8c41a44f1da0cd56df50
|
7
|
+
data.tar.gz: d2b036de0e6b96fac03a9ad50d14f76ae2cdf04e91c29f029546884516603d232e8a97e146c02c6fde5b4051cd11b5c85b7915ee53dd27ff1819efaa5f2d31c7
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ if defined?(RSpec)
|
|
10
10
|
task :default => 'spec:all'
|
11
11
|
|
12
12
|
namespace :spec do
|
13
|
-
task :all => [ :helper, :backend, :configuration, :command, :host_inventory ]
|
13
|
+
task :all => [ :helper, :backend, :configuration, :processor, :command, :host_inventory ]
|
14
14
|
|
15
15
|
RSpec::Core::RakeTask.new(:helper) do |t|
|
16
16
|
t.pattern = "spec/helper/*_spec.rb"
|
@@ -33,6 +33,10 @@ if defined?(RSpec)
|
|
33
33
|
t.pattern = "spec/configuration_spec.rb"
|
34
34
|
end
|
35
35
|
|
36
|
+
RSpec::Core::RakeTask.new(:processor) do |t|
|
37
|
+
t.pattern = "spec/processor_spec.rb"
|
38
|
+
end
|
39
|
+
|
36
40
|
RSpec::Core::RakeTask.new(:command) do |t|
|
37
41
|
t.pattern = "spec/command/**/*.rb"
|
38
42
|
end
|
data/lib/specinfra/processor.rb
CHANGED
@@ -89,14 +89,23 @@ module Specinfra
|
|
89
89
|
end
|
90
90
|
|
91
91
|
mount = ret.stdout.scan(/\S+/)
|
92
|
-
actual_attr
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
92
|
+
actual_attr = { }
|
93
|
+
actual_attr[:device] = mount[0]
|
94
|
+
# Output of mount depends on os:
|
95
|
+
# a) proc on /proc type proc (rw,noexec,nosuid,nodev)
|
96
|
+
# b) procfs on /proc (procfs, local)
|
97
|
+
actual_attr[:type] = mount[4] if mount[3] == 'type' # case a.
|
98
|
+
if match = ret.stdout.match(/\((.*)\)/)
|
99
|
+
options = match[1].split(',')
|
100
|
+
actual_attr[:type] ||= options.shift # case b.
|
101
|
+
options.each do |option|
|
102
|
+
name, val = option.split('=')
|
103
|
+
if val.nil?
|
104
|
+
actual_attr[name.strip.to_sym] = true
|
105
|
+
else
|
106
|
+
val = val.to_i if val.match(/^\d+$/)
|
107
|
+
actual_attr[name.strip.to_sym] = val
|
108
|
+
end
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
data/lib/specinfra/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Specinfra::Processor do
|
4
|
+
describe 'check_file_is_mounted' do
|
5
|
+
let(:path) { '/proc' }
|
6
|
+
let(:cmd) { Specinfra.command.get(:check_file_is_mounted, path) }
|
7
|
+
|
8
|
+
def mock_output(stdout)
|
9
|
+
Specinfra::CommandResult.new :stdout => stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'freebsd' do
|
13
|
+
before do
|
14
|
+
allow(Specinfra.backend).to receive(:run_command).with(cmd) { mock_output 'procfs on /proc (procfs, local)' }
|
15
|
+
end
|
16
|
+
it 'true when fs type matches' do
|
17
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'procfs'}, false)).to eq(true)
|
18
|
+
end
|
19
|
+
it 'false when fs type is different' do
|
20
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'ufs'}, false)).to eq(false)
|
21
|
+
end
|
22
|
+
it 'true when option matches' do
|
23
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:local => true}, false)).to eq(true)
|
24
|
+
end
|
25
|
+
it 'false when option is different' do
|
26
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:async => true}, false)).to eq(false)
|
27
|
+
end
|
28
|
+
context 'only_with' do
|
29
|
+
it 'false when extra options present' do
|
30
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:local => true, :async => true}, true)).to eq(false)
|
31
|
+
end
|
32
|
+
it 'true when all options met' do
|
33
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:device => "procfs", :type => "procfs", :local => true}, true)).to eq(true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
context 'linux' do
|
38
|
+
before do
|
39
|
+
allow(Specinfra.backend).to receive(:run_command).with(cmd) { mock_output 'proc on /proc type proc (rw,noexec,nosuid,nodev)' }
|
40
|
+
end
|
41
|
+
it 'true when fs type matches' do
|
42
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'proc'}, false)).to eq(true)
|
43
|
+
end
|
44
|
+
it 'false when fs type is different' do
|
45
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:type => 'ufs'}, false)).to eq(false)
|
46
|
+
end
|
47
|
+
it 'true when option matches' do
|
48
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true}, false)).to eq(true)
|
49
|
+
end
|
50
|
+
it 'false when option is different' do
|
51
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :unknown => true}, false)).to eq(false)
|
52
|
+
end
|
53
|
+
context 'only_with' do
|
54
|
+
it 'false when extra options present' do
|
55
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true}, true)).to eq(false)
|
56
|
+
end
|
57
|
+
it 'true when all options are same' do
|
58
|
+
expect(Specinfra::Processor.check_file_is_mounted(path, {:noexec => true, :nosuid => true, :nodev => true, :rw => true, :device => "proc", :type => "proc"}, true)).to eq(true)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.66.
|
4
|
+
version: 2.66.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -601,6 +601,7 @@ files:
|
|
601
601
|
- spec/host_inventory/openbsd/virtualization_spec.rb
|
602
602
|
- spec/host_inventory/solaris/filesystem_spec.rb
|
603
603
|
- spec/host_inventory/solaris/virtualization_spec.rb
|
604
|
+
- spec/processor_spec.rb
|
604
605
|
- spec/spec_helper.rb
|
605
606
|
- specinfra.gemspec
|
606
607
|
homepage: https://github.com/mizzy/specinfra
|
@@ -721,4 +722,5 @@ test_files:
|
|
721
722
|
- spec/host_inventory/openbsd/virtualization_spec.rb
|
722
723
|
- spec/host_inventory/solaris/filesystem_spec.rb
|
723
724
|
- spec/host_inventory/solaris/virtualization_spec.rb
|
725
|
+
- spec/processor_spec.rb
|
724
726
|
- spec/spec_helper.rb
|