train 0.29.1 → 0.29.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/train/file/local/unix.rb +23 -0
- data/lib/train/file/remote/linux.rb +1 -1
- data/lib/train/version.rb +1 -1
- data/test/integration/bootstrap.sh +2 -0
- data/test/integration/cookbooks/test/recipes/prep_files.rb +4 -0
- data/test/integration/tests/path_file_test.rb +7 -0
- data/test/unit/file/local/unix_test.rb +37 -3
- data/test/unit/file/remote/linux_test.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91f83eccb563ed719ca19fd8be06d9616afc4eae
|
4
|
+
data.tar.gz: 740ba4a80a9b4690b36dec69dd2e752659032033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96eda4528ad55102f10ff705b13a639dec7405f693f67f72d6d8d1b11c35439210ca92ee172d3f18ae564097271de3aa88671f2c8528a8a5b84604dd1ec0344d
|
7
|
+
data.tar.gz: b4260ea407f3cf12614d222d5304a85091830972aade03e10491f1b897f5e01c99e3dc7ff45a7314cdd30e7224d46cd0b460538d34a0454f0601136ff8343db8
|
@@ -54,6 +54,16 @@ module Train
|
|
54
54
|
group == sth
|
55
55
|
end
|
56
56
|
|
57
|
+
def unix_mode_mask(owner, type)
|
58
|
+
o = UNIX_MODE_OWNERS[owner.to_sym]
|
59
|
+
return nil if o.nil?
|
60
|
+
|
61
|
+
t = UNIX_MODE_TYPES[type.to_sym]
|
62
|
+
return nil if t.nil?
|
63
|
+
|
64
|
+
t & o
|
65
|
+
end
|
66
|
+
|
57
67
|
private
|
58
68
|
|
59
69
|
def pw_username(uid)
|
@@ -67,6 +77,19 @@ module Train
|
|
67
77
|
rescue ArgumentError => _
|
68
78
|
nil
|
69
79
|
end
|
80
|
+
|
81
|
+
UNIX_MODE_OWNERS = {
|
82
|
+
all: 00777,
|
83
|
+
owner: 00700,
|
84
|
+
group: 00070,
|
85
|
+
other: 00007,
|
86
|
+
}.freeze
|
87
|
+
|
88
|
+
UNIX_MODE_TYPES = {
|
89
|
+
r: 00444,
|
90
|
+
w: 00222,
|
91
|
+
x: 00111,
|
92
|
+
}.freeze
|
70
93
|
end
|
71
94
|
end
|
72
95
|
end
|
@@ -8,7 +8,7 @@ module Train
|
|
8
8
|
class Linux < Train::File::Remote::Unix
|
9
9
|
def content
|
10
10
|
return @content if defined?(@content)
|
11
|
-
@content = @backend.run_command("cat #{@
|
11
|
+
@content = @backend.run_command("cat #{@spath} || echo -n").stdout
|
12
12
|
return @content unless @content.empty?
|
13
13
|
@content = nil if directory? or size.nil? or size > 0
|
14
14
|
@content
|
data/lib/train/version.rb
CHANGED
@@ -5,7 +5,7 @@ require 'train/transports/local'
|
|
5
5
|
|
6
6
|
describe Train::File::Local::Unix do
|
7
7
|
let(:cls) { Train::File::Local::Unix }
|
8
|
-
|
8
|
+
|
9
9
|
let(:backend) {
|
10
10
|
backend = Train::Transports::Mock.new.connection
|
11
11
|
backend.mock_os({ family: 'linux' })
|
@@ -86,8 +86,8 @@ describe Train::File::Local::Unix do
|
|
86
86
|
it 'grouped_into' do
|
87
87
|
meta_stub :stat, statres do
|
88
88
|
connection.file(rand.to_s).grouped_into?('group').must_equal true
|
89
|
-
end
|
90
|
-
end
|
89
|
+
end
|
90
|
+
end
|
91
91
|
|
92
92
|
it 'recognizes selinux label' do
|
93
93
|
meta_stub :stat, statres do
|
@@ -109,4 +109,38 @@ describe Train::File::Local::Unix do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
describe '#unix_mode_mask' do
|
114
|
+
let(:file_tester) do
|
115
|
+
Class.new(cls) do
|
116
|
+
define_method :type do
|
117
|
+
:file
|
118
|
+
end
|
119
|
+
end.new(nil, nil, false)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'check owner mode calculation' do
|
123
|
+
file_tester.unix_mode_mask('owner', 'x').must_equal 0100
|
124
|
+
file_tester.unix_mode_mask('owner', 'w').must_equal 0200
|
125
|
+
file_tester.unix_mode_mask('owner', 'r').must_equal 0400
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'check group mode calculation' do
|
129
|
+
file_tester.unix_mode_mask('group', 'x').must_equal 0010
|
130
|
+
file_tester.unix_mode_mask('group', 'w').must_equal 0020
|
131
|
+
file_tester.unix_mode_mask('group', 'r').must_equal 0040
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'check other mode calculation' do
|
135
|
+
file_tester.unix_mode_mask('other', 'x').must_equal 0001
|
136
|
+
file_tester.unix_mode_mask('other', 'w').must_equal 0002
|
137
|
+
file_tester.unix_mode_mask('other', 'r').must_equal 0004
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'check all mode calculation' do
|
141
|
+
file_tester.unix_mode_mask('all', 'x').must_equal 0111
|
142
|
+
file_tester.unix_mode_mask('all', 'w').must_equal 0222
|
143
|
+
file_tester.unix_mode_mask('all', 'r').must_equal 0444
|
144
|
+
end
|
145
|
+
end
|
112
146
|
end
|
@@ -42,6 +42,12 @@ describe Train::File::Remote::Linux do
|
|
42
42
|
cls.new(backend, 'path').content.must_be_nil
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'reads file contents' do
|
46
|
+
out = rand.to_s
|
47
|
+
backend.mock_command('cat /spaced\\ path || echo -n', out)
|
48
|
+
cls.new(backend, '/spaced path').content.must_equal out
|
49
|
+
end
|
50
|
+
|
45
51
|
it 'checks for file existance' do
|
46
52
|
backend.mock_command('test -e path', true)
|
47
53
|
cls.new(backend, 'path').exist?.must_equal true
|
@@ -164,4 +170,4 @@ describe Train::File::Remote::Linux do
|
|
164
170
|
f.selinux_label.must_equal 'labels'
|
165
171
|
end
|
166
172
|
end
|
167
|
-
end
|
173
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.29.
|
4
|
+
version: 0.29.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|