specinfra 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/specinfra/backend/ssh.rb +8 -5
- data/lib/specinfra/configuration.rb +10 -1
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/ssh/build_command_spec.rb +35 -0
- metadata +82 -60
- checksums.yaml +0 -7
@@ -84,13 +84,16 @@ module SpecInfra
|
|
84
84
|
|
85
85
|
def sudo
|
86
86
|
sudo_path = SpecInfra.configuration.sudo_path
|
87
|
-
if sudo_path
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
sudo_path += '/' if sudo_path
|
88
|
+
|
89
|
+
sudo_options = SpecInfra.configuration.sudo_options
|
90
|
+
if sudo_options
|
91
|
+
sudo_options = sudo_options.join(' ') if sudo_options.is_a?(Array)
|
92
|
+
sudo_options = ' ' + sudo_options
|
91
93
|
end
|
92
|
-
end
|
93
94
|
|
95
|
+
"#{sudo_path}sudo#{sudo_options}"
|
96
|
+
end
|
94
97
|
end
|
95
98
|
end
|
96
99
|
end
|
@@ -1,7 +1,16 @@
|
|
1
1
|
module SpecInfra
|
2
2
|
module Configuration
|
3
3
|
class << self
|
4
|
-
VALID_OPTIONS_KEYS = [
|
4
|
+
VALID_OPTIONS_KEYS = [
|
5
|
+
:path,
|
6
|
+
:pre_command,
|
7
|
+
:stdout,
|
8
|
+
:stderr,
|
9
|
+
:sudo_path,
|
10
|
+
:disable_sudo,
|
11
|
+
:pass_prompt,
|
12
|
+
:sudo_options
|
13
|
+
].freeze
|
5
14
|
|
6
15
|
def defaults
|
7
16
|
VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
|
data/lib/specinfra/version.rb
CHANGED
@@ -96,3 +96,38 @@ describe 'build command without sudo' do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
sudo_options = ['-p', '"[sudo] password for"']
|
101
|
+
sudo_options_string = ' -p "[sudo] password for"'
|
102
|
+
|
103
|
+
describe 'build command with sudo on alternate path' do
|
104
|
+
before :each do
|
105
|
+
RSpec.configure do |c|
|
106
|
+
ssh.stub(:options) { { :user => 'foo' } }
|
107
|
+
c.ssh = ssh
|
108
|
+
c.sudo_options = sudo_options
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
context 'command pattern 1a' do
|
114
|
+
subject { backend.build_command('test -f /etc/passwd') }
|
115
|
+
it { should eq "sudo#{sudo_options_string} test -f /etc/passwd" }
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'command pattern 2a' do
|
119
|
+
subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
|
120
|
+
it { should eq "sudo#{sudo_options_string} test ! -f /etc/selinux/config || (sudo#{sudo_options_string} getenforce | grep -i -- disabled && sudo#{sudo_options_string} grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'command pattern 3a' do
|
124
|
+
subject { backend.build_command("dpkg -s apache2 && ! dpkg -s apache2 | grep -E '^Status: .+ not-installed$'") }
|
125
|
+
it { should eq "sudo#{sudo_options_string} dpkg -s apache2 && ! sudo#{sudo_options_string} dpkg -s apache2 | grep -E '^Status: .+ not-installed$'" }
|
126
|
+
end
|
127
|
+
|
128
|
+
after :each do
|
129
|
+
RSpec.configure do |c|
|
130
|
+
c.sudo_options = nil
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
metadata
CHANGED
@@ -1,64 +1,76 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Gosuke Miyashita
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-01-10 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
14
22
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
23
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
24
27
|
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
version: "1.3"
|
34
34
|
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
35
38
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
48
|
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
49
52
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
55
64
|
description: Common layer for serverspec and configspec
|
56
|
-
email:
|
65
|
+
email:
|
57
66
|
- gosukenator@gmail.com
|
58
67
|
executables: []
|
68
|
+
|
59
69
|
extensions: []
|
70
|
+
|
60
71
|
extra_rdoc_files: []
|
61
|
-
|
72
|
+
|
73
|
+
files:
|
62
74
|
- .gitignore
|
63
75
|
- .travis.yml
|
64
76
|
- Gemfile
|
@@ -115,31 +127,41 @@ files:
|
|
115
127
|
- spec/helper/properties_spec.rb
|
116
128
|
- spec/spec_helper.rb
|
117
129
|
- specinfra.gemspec
|
118
|
-
|
119
|
-
|
130
|
+
has_rdoc: true
|
131
|
+
homepage: ""
|
132
|
+
licenses:
|
120
133
|
- MIT
|
121
|
-
metadata: {}
|
122
134
|
post_install_message:
|
123
135
|
rdoc_options: []
|
124
|
-
|
136
|
+
|
137
|
+
require_paths:
|
125
138
|
- lib
|
126
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
136
157
|
requirements: []
|
158
|
+
|
137
159
|
rubyforge_project:
|
138
|
-
rubygems_version:
|
160
|
+
rubygems_version: 1.6.2
|
139
161
|
signing_key:
|
140
|
-
specification_version:
|
162
|
+
specification_version: 3
|
141
163
|
summary: Common layer for serverspec and configspec
|
142
|
-
test_files:
|
164
|
+
test_files:
|
143
165
|
- spec/backend/ssh/build_command_spec.rb
|
144
166
|
- spec/configuration_spec.rb
|
145
167
|
- spec/helper/backend_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 1daab8e0c532a3aefde28e5b3112866ed64263a0
|
4
|
-
data.tar.gz: c7280e34053256ca4edc0593aad49aff63c2695c
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: ceb475126ef0a1811966621577e3217305f55972e3c82eec621ab82c789a42922afa3c46a24ed19ed98cb64f3e0f2a49ecc86f1f150b921a8705139dcb9afdd2
|
7
|
-
data.tar.gz: 5609f02da64a4d96876d2381a2befe657bd10e79f5036b245816e58c1f4c130b1891067bf3d314b03325794ed912825e91061a0cd828a20fbe297ed62efb83eb
|