winrm-fs 1.3.0 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- *.swp
2
- *.gem
3
- pkg/*
4
- .rvmrc
5
- .idea
6
- .bundle
7
- spec/spec/creds*.json
8
- spec/config.yml
9
- traces/
10
- Gemfile.lock
11
- .vagrant
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,17 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- Naming/FileName:
4
- Exclude:
5
- - 'lib/winrm-fs.rb'
6
-
7
- Style/Encoding:
8
- Enabled: true
9
-
10
- Layout/EndOfLine:
11
- Enabled: false
12
-
13
- Metrics/LineLength:
14
- Max: 120
15
-
16
- Metrics/AbcSize:
17
- Max: 25
@@ -1,65 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2017-12-12 22:48:53 +0100 using RuboCop version 0.52.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: EnforcedStyle.
12
- # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
13
- Layout/IndentHeredoc:
14
- Exclude:
15
- - 'spec/matchers.rb'
16
-
17
- # Offense count: 6
18
- # Configuration parameters: CountComments, ExcludedMethods.
19
- Metrics/BlockLength:
20
- Max: 185
21
-
22
- # Offense count: 3
23
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
24
- # URISchemes: http, https
25
- Metrics/LineLength:
26
- Max: 106
27
-
28
- # Offense count: 4
29
- # Configuration parameters: Blacklist.
30
- # Blacklist: END, (?-mix:EO[A-Z]{1})
31
- Naming/HeredocDelimiterNaming:
32
- Exclude:
33
- - 'lib/winrm-fs/core/file_transporter.rb'
34
- - 'spec/matchers.rb'
35
- - 'winrm-fs.gemspec'
36
-
37
- # Offense count: 1
38
- # Configuration parameters: .
39
- # SupportedStyles: annotated, template, unannotated
40
- Style/FormatStringToken:
41
- EnforcedStyle: unannotated
42
-
43
- # Offense count: 4
44
- # Cop supports --auto-correct.
45
- # Configuration parameters: AutoCorrect, EnforcedStyle.
46
- # SupportedStyles: predicate, comparison
47
- Style/NumericPredicate:
48
- Exclude:
49
- - 'spec/**/*'
50
- - 'lib/winrm-fs/core/file_transporter.rb'
51
- - 'lib/winrm-fs/file_manager.rb'
52
-
53
- # Offense count: 1
54
- # Cop supports --auto-correct.
55
- # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
56
- # SupportedStyles: slashes, percent_r, mixed
57
- Style/RegexpLiteral:
58
- Exclude:
59
- - 'lib/winrm-fs/core/tmp_zip.rb'
60
-
61
- # Offense count: 3
62
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
63
- # URISchemes: http, https
64
- Metrics/LineLength:
65
- Max: 106
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0
4
- - 2.3.4
5
- - 2.4.1
6
-
7
- # This prevents testing branches that are created just for PRs
8
- branches:
9
- only:
10
- - master
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'rb-readline'
data/Rakefile DELETED
@@ -1,27 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'rspec/core/rake_task'
4
- require 'rubocop/rake_task'
5
-
6
- # Change to the directory of this file.
7
- Dir.chdir(File.expand_path(__dir__))
8
-
9
- # For gem creation and bundling
10
- require 'bundler/gem_tasks'
11
-
12
- RSpec::Core::RakeTask.new(:spec) do |task|
13
- task.pattern = 'spec/unit/*_spec.rb'
14
- task.rspec_opts = ['--color', '-f documentation']
15
- end
16
-
17
- # Run the integration test suite
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/integration/*_spec.rb'
20
- task.rspec_opts = ['--color', '-f documentation']
21
- end
22
-
23
- RuboCop::RakeTask.new
24
-
25
- task default: %i[spec rubocop]
26
-
27
- task all: %i[default integration]
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.3.0
@@ -1,8 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- VAGRANTFILE_API_VERSION = '2'.freeze
5
-
6
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
- config.vm.box = 'mwrock/WindowsNano'
8
- end
@@ -1,38 +0,0 @@
1
- version: "master-{build}"
2
-
3
- os: Windows Server 2012 R2
4
- platform:
5
- - x64
6
-
7
- environment:
8
- winrm_user: test_user
9
- winrm_password: Pass@word1
10
-
11
- matrix:
12
- - ruby_version: "22"
13
- winrm_endpoint: http://localhost:5985/wsman
14
-
15
- clone_folder: c:\projects\winrm-fs
16
- clone_depth: 1
17
- branches:
18
- only:
19
- - master
20
-
21
- install:
22
- - ps: net user /add $env:winrm_user $env:winrm_password
23
- - ps: net localgroup administrators $env:winrm_user /add
24
- - ps: winrm set winrm/config/client/auth '@{Basic="true"}'
25
- - ps: winrm set winrm/config/service/auth '@{Basic="true"}'
26
- - ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
27
- - ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
28
- - ps: Write-Host $env:PATH
29
- - ps: ruby --version
30
- - ps: gem --version
31
- - ps: bundler --version
32
-
33
- build_script:
34
- - bundle install || bundle install || bundle install
35
-
36
- test_script:
37
- - SET SPEC_OPTS=--format progress
38
- - bundle exec rake integration
@@ -1,71 +0,0 @@
1
- # WinRM-fs Gem Changelog
2
- # 1.3.0
3
- - Upload from StringIO object
4
- - Add missing winrm/exceptions require in file_transporter
5
- - Use correct way to relativize paths of Zip entries
6
-
7
- # 1.2.1
8
- - Correctly handle unicode filenames
9
-
10
- # 1.2.0
11
- - Add ability to download directories
12
-
13
- # 1.1.1
14
- - Remove empty items from powershell pipeline when extracting zip files
15
-
16
- # 1.1.0
17
- - Convert MD5 hashes to SHA1.
18
-
19
- # 1.0.2
20
- - Fix `Pathname.glob` expansion of shortnames.
21
-
22
- # 1.0.1
23
- - Call ClearScriptBlockCache to prevent OutOfMemoryExceptions ClearScriptBlockCache
24
-
25
- # 1.0.0
26
- - Using winrm v2. File uploads just got a whole lot faster!
27
-
28
- # 0.4.3
29
- - Fix error handling with wmf5, filtering out progress output from inspected stderr.
30
-
31
- # 0.4.2
32
- - Improved Powershell error handling in metadata checking.
33
-
34
- # 0.4.1
35
- - Fixes a regression on Windows 2008 R2/Windows 7 and below where the WinRM service corrupts the check files metadata resulting in malformed destination paths.
36
-
37
- # 0.4.0
38
- - Correct the destination path of individual files. Always assume it is the full destination path unless it is an existing directory. This may potentialy break some callers expecting the remote path to be a directory that winrm-fs will create if missing as the destination of the local file. A new directory will not be created and the local file will be uploaded directly to the remote path.
39
-
40
- # 0.3.2
41
- - Fix re-extraction of cached directories from temp folder when there is more than one "clean" directory deleted from destination
42
-
43
- # 0.3.1
44
- - Widen logging version constraints to include 2.0 (matching WinRM core gem)
45
-
46
- # 0.3.0
47
- - Jetisons `CommandExecutor` now living in the core WinRM gem and swaps in implementation currently used in the winrm-transport gem. These changes should have little visible effect on current consumers of the `FileManager` class with these exceptions:
48
- - BREAKING CHANGE: When uploading a directory and the destination directory exists on the endpoint, the source base directory will be created below the destination directory on the endpoint and the source directory contents will be unzipped to that location. Prior to this release, the contents of the source directory would be unzipped to an existing destination directory without creating the source base directory. This new behavior is more consistent with SCP and other well known shell copy commands.
49
- - `Upload` may now receive an array of source files and directories rather than just a single file or directory path.
50
-
51
- # 0.2.4
52
- - Fix issue 21, downloading files is extremely slow.
53
- - Add zip file creation debug logging.
54
-
55
- # 0.2.3
56
- - Fix yielding progress data, issue #23
57
-
58
- # 0.2.2
59
- - Fix powershell streams leaking to standard error breaking Windows 10, issue #18
60
-
61
- # 0.2.1
62
- - Fixed issue 16 creating zip file on Windows
63
-
64
- # 0.2.0
65
- - Redesigned temp zip file creation system
66
- - Fixed lots of small edge case issues especially with directory uploads
67
- - Simplified file manager upload method API to take only a single source file or directory
68
- - Expanded acceptable username and hostnames for rwinrmcp
69
-
70
- # 0.1.0
71
- - Initial alpha quality release
@@ -1,3 +0,0 @@
1
- endpoint: "http://localhost:55985/wsman"
2
- user: vagrant
3
- password: vagrant
@@ -1,285 +0,0 @@
1
- require 'pathname'
2
-
3
- # rubocop:disable BlockLength
4
- describe WinRM::FS::FileManager do
5
- let(:upload_dir) { "winrm_#{rand(2**16)}" }
6
- let(:dest_dir) { File.join(subject.temp_dir, upload_dir) }
7
- let(:temp_upload_dir) { '$env:TEMP/winrm-upload' }
8
- let(:spec_dir) { File.expand_path(File.dirname(File.dirname(__FILE__))) }
9
- let(:this_file) { Pathname.new(__FILE__) }
10
- let(:service) { winrm_connection }
11
-
12
- subject { WinRM::FS::FileManager.new(service) }
13
-
14
- before(:each) do
15
- expect(subject.delete(dest_dir)).to be true
16
- expect(subject.delete(temp_upload_dir)).to be true
17
- end
18
-
19
- context 'exists?' do
20
- it 'should exist' do
21
- expect(subject.exists?('c:/windows')).to be true
22
- expect(subject.exists?('c:/foobar')).to be false
23
- end
24
- end
25
-
26
- context 'create and delete dir' do
27
- it 'should create the directory recursively' do
28
- subdir = File.join(dest_dir, 'subdir1', 'subdir2')
29
- expect(subject.create_dir(subdir)).to be true
30
- expect(subject.exists?(subdir)).to be true
31
- expect(subject.create_dir(subdir)).to be true
32
- expect(subject.delete(subdir)).to be true
33
- expect(subject.exists?(subdir)).to be false
34
- end
35
- end
36
-
37
- context 'temp_dir' do
38
- it 'should return the remote users temp dir' do
39
- expect(subject.temp_dir).to match(%r{C:/Users/\S+/AppData/Local/Temp})
40
- end
41
- end
42
-
43
- context 'download file' do
44
- let(:download_dir) { File.join(spec_dir, 'temp') }
45
- let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
46
- let(:download_file) { Pathname.new(File.join(download_dir, File.basename(this_file))) }
47
-
48
- before(:each) do
49
- expect(subject.delete(dest_dir)).to be true
50
- FileUtils.rm_rf(Dir.glob("#{download_dir}/*"))
51
- FileUtils.mkdir_p(download_dir)
52
- end
53
-
54
- it 'should download the specified file' do
55
- subject.upload(this_file, dest_file)
56
- subject.download(dest_file, download_file)
57
- expect(File.open(download_file).read).to eq(File.open(this_file).read)
58
- end
59
- end
60
-
61
- context 'download directory' do
62
- let(:download_dir) { File.join(spec_dir, 'temp') }
63
- let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
64
- let(:root_dir) { File.expand_path('../../', File.dirname(__FILE__)) }
65
- let(:winrm_fs_dir) { File.join(root_dir, 'lib/winrm-fs') }
66
-
67
- before(:each) do
68
- expect(subject.delete(dest_dir)).to be true
69
- FileUtils.rm_rf(Dir.glob("#{download_dir}/*"))
70
- FileUtils.mkdir_p(download_dir)
71
- end
72
-
73
- it 'downloads the directory contents recursively' do
74
- subject.upload(winrm_fs_dir, dest_dir)
75
- subject.download(dest_dir, download_dir)
76
-
77
- Dir.glob(winrm_fs_dir + '/**/*.rb').each do |host_file|
78
- host_file_rel = Pathname.new(host_file).relative_path_from(
79
- Pathname.new(winrm_fs_dir)
80
- ).to_s
81
- download_file = File.join(download_dir, upload_dir, host_file_rel)
82
- expect(File.open(download_file).read).to eq(File.open(host_file).read)
83
- end
84
- end
85
- end
86
-
87
- context 'upload file' do
88
- let(:dest_file) { Pathname.new(File.join(dest_dir, File.basename(this_file))) }
89
- let(:from_memory) { StringIO.new('Upload From Memory') }
90
-
91
- before(:each) do
92
- expect(subject.delete(dest_dir)).to be true
93
- end
94
-
95
- it 'should upload a single StringIO object to a remote file' do
96
- subject.upload(from_memory, dest_file)
97
- expect(subject).to have_created(dest_file).with_content(from_memory.string)
98
- end
99
-
100
- it 'should error if multiple StringIO objects passed to upload' do
101
- expect { subject.upload([from_memory, from_memory], dest_file) }
102
- .to raise_error(WinRM::FS::Core::UploadSourceError)
103
- end
104
-
105
- it 'should error if both a StringIO object and a file path passed to upload' do
106
- expect { subject.upload([from_memory, this_file], dest_file) }
107
- .to raise_error(WinRM::FS::Core::UploadSourceError)
108
- end
109
-
110
- it 'should upload the specified file' do
111
- subject.upload(this_file, dest_file)
112
- expect(subject).to have_created(dest_file).with_content(this_file)
113
- end
114
-
115
- it 'should upload to root of the c: drive' do
116
- subject.upload(this_file, 'c:/winrmtest.rb')
117
- expect(subject).to have_created('c:/winrmtest.rb').with_content(this_file)
118
- subject.delete('c:/winrmtest.rb')
119
- end
120
-
121
- it 'should upload just filename' do
122
- subject.upload(this_file, 'winrmtest.rb')
123
- expect(subject).to have_created('winrmtest.rb').with_content(this_file)
124
- subject.delete('winrmtest.rb')
125
- end
126
-
127
- it 'should upload using relative file path' do
128
- subject.upload('./spec/integration/file_manager_spec.rb', dest_file)
129
- expect(subject).to have_created(dest_file).with_content(this_file)
130
- end
131
-
132
- it 'should upload to the specified directory' do
133
- subject.create_dir(dest_dir)
134
- subject.upload(this_file, dest_dir)
135
- expect(subject).to have_created(dest_file).with_content(this_file)
136
- end
137
-
138
- it 'should treat extensionless target as file if not an existing directory' do
139
- subject.upload(this_file, dest_dir)
140
- expect(subject).to have_created(dest_dir).with_content(this_file)
141
- end
142
-
143
- it 'should create extensionless source under target dir if target dir exists' do
144
- subject.create_dir(dest_dir)
145
- src_file = File.expand_path('../../Gemfile', File.dirname(__FILE__))
146
- subject.upload(src_file, dest_dir)
147
- expect(subject).to have_created(File.join(dest_dir, 'Gemfile')).with_content(src_file)
148
- end
149
-
150
- it 'should upload to the specified directory with env var' do
151
- subject.upload(this_file, '$env:Temp')
152
- expected_dest_file = File.join(subject.temp_dir, File.basename(this_file))
153
- expect(subject).to have_created(expected_dest_file).with_content(this_file)
154
- end
155
-
156
- it 'should upload to Program Files sub dir' do
157
- subject.create_dir('$env:ProgramFiles/foo')
158
- subject.upload(this_file, '$env:ProgramFiles/foo')
159
- expect(subject).to have_created('c:/Program Files/foo/file_manager_spec.rb') \
160
- .with_content(this_file)
161
- end
162
-
163
- it 'should upload to the specified nested directory' do
164
- dest_sub_dir = File.join(dest_dir, 'subdir')
165
- subject.create_dir(dest_sub_dir)
166
- dest_sub_dir_file = File.join(dest_sub_dir, File.basename(this_file))
167
- subject.upload(this_file, dest_sub_dir)
168
- expect(subject).to have_created(dest_sub_dir_file).with_content(this_file)
169
- end
170
-
171
- it 'yields progress data' do
172
- block_called = false
173
- total_bytes_copied = 0
174
- total = subject.upload(this_file, dest_file) do |bytes_copied, total_bytes, local_path, remote_path|
175
- expect(total_bytes).to be > 0
176
- total_bytes_copied = bytes_copied
177
- expect(local_path).to eq(this_file.to_s)
178
- expect(remote_path).to eq(dest_file.to_s)
179
- block_called = true
180
- end
181
- expect(total_bytes_copied).to eq(total)
182
- expect(block_called).to be true
183
- expect(total).to be > 0
184
- end
185
-
186
- it 'should not upload when content matches' do
187
- subject.upload(this_file, dest_dir)
188
- bytes_uploaded = subject.upload(this_file, dest_dir)
189
- expect(bytes_uploaded).to eq 0
190
- end
191
-
192
- it 'should upload when content differs' do
193
- matchers_file = File.join(spec_dir, 'matchers.rb')
194
- subject.upload(matchers_file, dest_file)
195
- bytes_uploaded = subject.upload(this_file, dest_file)
196
- expect(bytes_uploaded).to be > 0
197
- end
198
-
199
- it 'raises WinRMUploadError when a bad source path is specified' do
200
- expect { subject.upload('c:/some/non-existant/path/foo', dest_file) }.to raise_error
201
- end
202
- end
203
-
204
- context 'upload empty file' do
205
- let(:empty_src_file) { Tempfile.new('empty') }
206
- let(:dest_file) { File.join(dest_dir, 'emptyfile.txt') }
207
-
208
- it 'creates a new empty file' do
209
- expect(subject.upload(empty_src_file.path, dest_file)).to be 0
210
- expect(subject).to have_created(dest_file).with_content('')
211
- end
212
-
213
- it 'overwrites an existing file' do
214
- expect(subject.upload(this_file, dest_file)).to be > 0
215
- expect(subject.upload(empty_src_file.path, dest_file)).to be 0
216
- expect(subject).to have_created(dest_file).with_content('')
217
- end
218
- end
219
-
220
- context 'upload directory' do
221
- let(:root_dir) { File.expand_path('../../', File.dirname(__FILE__)) }
222
- let(:winrm_fs_dir) { File.join(root_dir, 'lib/winrm-fs') }
223
- let(:core_dir) { File.join(root_dir, 'lib/winrm-fs/core') }
224
- let(:scripts_dir) { File.join(root_dir, 'lib/winrm-fs/scripts') }
225
-
226
- it 'copies the directory contents recursively when directory does not exist' do
227
- bytes_uploaded = subject.upload(winrm_fs_dir, dest_dir)
228
- expect(bytes_uploaded).to be > 0
229
-
230
- Dir.glob(winrm_fs_dir + '/**/*.rb').each do |host_file|
231
- host_file_rel = Pathname.new(host_file).relative_path_from(
232
- Pathname.new(winrm_fs_dir)
233
- ).to_s
234
- remote_file = File.join(dest_dir, host_file_rel)
235
- expect(subject).to have_created(remote_file).with_content(host_file)
236
- end
237
- end
238
-
239
- it 'copies the directory recursively when directory does exist' do
240
- subject.create_dir(dest_dir)
241
- bytes_uploaded = subject.upload(winrm_fs_dir, dest_dir)
242
- expect(bytes_uploaded).to be > 0
243
-
244
- Dir.glob(winrm_fs_dir + '/**/*.rb').each do |host_file|
245
- host_file_rel = Pathname.new(host_file).relative_path_from(
246
- Pathname.new(winrm_fs_dir).dirname
247
- ).to_s
248
- remote_file = File.join(dest_dir, host_file_rel)
249
- expect(subject).to have_created(remote_file).with_content(host_file)
250
- end
251
- end
252
-
253
- it 'does not copy the directory when content is the same' do
254
- subject.upload(winrm_fs_dir, dest_dir)
255
- bytes_uploaded = subject.upload(winrm_fs_dir, dest_dir)
256
- expect(bytes_uploaded).to eq 0
257
- end
258
-
259
- it 'unzips the directory when cached content is the same' do
260
- subject.upload(winrm_fs_dir, dest_dir)
261
- subject.delete(dest_dir)
262
- expect(subject.exists?(dest_dir)).to be false
263
- subject.upload(winrm_fs_dir, dest_dir)
264
- expect(subject.exists?(dest_dir)).to be true
265
- end
266
-
267
- it 'unzips multiple directories when cached content is the same for all' do
268
- subject.create_dir(dest_dir)
269
- subject.upload([core_dir, scripts_dir], dest_dir)
270
- subject.delete(dest_dir)
271
- expect(subject.exists?(dest_dir)).to be false
272
- subject.create_dir(dest_dir)
273
- subject.upload([core_dir, scripts_dir], dest_dir)
274
- expect(subject.exists?(File.join(dest_dir, 'core'))).to be true
275
- expect(subject.exists?(File.join(dest_dir, 'scripts'))).to be true
276
- end
277
-
278
- it 'copies the directory when content differs' do
279
- subject.upload(winrm_fs_dir, dest_dir)
280
- bytes_uploaded = subject.upload(core_dir, dest_dir)
281
- expect(bytes_uploaded).to be > 0
282
- end
283
- end
284
- end
285
- # rubocop:enable BlockLength