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.
@@ -1,26 +0,0 @@
1
- require_relative '../../lib/winrm-fs/core/tmp_zip'
2
-
3
- describe WinRM::FS::Core::TmpZip do
4
- let(:winrm_fs_dir) { File.expand_path('../../lib/winrm-fs', File.dirname(__FILE__)) }
5
-
6
- subject { WinRM::FS::Core::TmpZip.new(winrm_fs_dir) }
7
-
8
- context 'temp file creation' do
9
- it 'should create a temp file on disk' do
10
- path = subject.path
11
- expect(File.exist?(path)).to be true
12
- subject.unlink
13
- expect(File.exist?(path)).to be false
14
- end
15
- end
16
-
17
- context 'create zip' do
18
- it 'should add all files in directory to the zip recursively' do
19
- expect(subject).to contain_zip_entries([
20
- 'exceptions.rb',
21
- 'core/tmp_zip.rb',
22
- 'scripts/checksum.ps1.erb'
23
- ])
24
- end
25
- end
26
- end
@@ -1,57 +0,0 @@
1
- require 'rspec/expectations'
2
-
3
- RSpec::Matchers.define :have_created do |remote_file|
4
- match do |file_manager|
5
- if @expected_content
6
- downloaded_file = Tempfile.new('downloaded')
7
- downloaded_file.close
8
-
9
- subject.download(remote_file, downloaded_file.path)
10
- @actual_content = File.read(downloaded_file.path)
11
- downloaded_file.delete
12
-
13
- file_manager.exists?(remote_file) && \
14
- @actual_content == @expected_content
15
- else
16
- file_manager.exists?(remote_file)
17
- end
18
- end
19
- chain :with_content do |expected_content|
20
- expected_content = File.read(expected_content) if File.file?(expected_content)
21
- @expected_content = expected_content
22
- end
23
- failure_message do
24
- if @expected_content
25
- <<-EOH
26
- Expected file '#{remote_file}' to exist with content:
27
-
28
- #{@expected_content}
29
-
30
- but instead got content:
31
-
32
- #{@actual_content}
33
- EOH
34
- else
35
- "Expected file '#{remote_file}' to exist"
36
- end
37
- end
38
- end
39
-
40
- RSpec::Matchers.define :contain_zip_entries do |zip_entries|
41
- match do |temp_zip_file|
42
- zip_entries = [zip_entries] if zip_entries.is_a? String
43
- @zip_file = Zip::File.open(temp_zip_file.path)
44
- @missing_entries = []
45
- zip_entries.each do |entry|
46
- @missing_entries << entry unless @zip_file.find_entry(entry)
47
- end
48
- @missing_entries.empty?
49
- end
50
- failure_message do |temp_zip_file|
51
- msg = "Expected #{temp_zip_file.path} to contain zip entries: #{@missing_entries}\n Got: "
52
- @zip_file.each do |entry|
53
- msg << entry.name << ', '
54
- end
55
- msg
56
- end
57
- end
@@ -1,66 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'winrm-fs'
4
- require 'json'
5
- require_relative 'matchers'
6
-
7
- # Creates a WinRM connection for integration tests
8
- module ConnectionHelper
9
- def winrm_connection
10
- WinRM::Connection.new(config)
11
- end
12
-
13
- def config
14
- @config ||= begin
15
- cfg = symbolize_keys(YAML.safe_load(File.read(winrm_config_path)))
16
- cfg[:basic_auth_only] = true unless cfg[:transport].eql? :kerberos
17
- merge_environment!(cfg)
18
- cfg
19
- end
20
- end
21
-
22
- def merge_environment!(config)
23
- merge_config_option_from_environment(config, 'user')
24
- merge_config_option_from_environment(config, 'password')
25
- merge_config_option_from_environment(config, 'no_ssl_peer_verification')
26
- config[:options][:ssl_peer_fingerprint] = ENV['winrm_cert'] if ENV['use_ssl_peer_fingerprint']
27
- config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint']
28
- config[:transport] = ENV['winrm_transport'] if ENV['winrm_transport']
29
- end
30
-
31
- def merge_config_option_from_environment(config, key)
32
- env_key = 'winrm_' + key
33
- config[key.to_sym] = ENV[env_key] if ENV[env_key]
34
- end
35
-
36
- def winrm_config_path
37
- # Copy config-example.yml to config.yml and edit for your local configuration
38
- path = File.expand_path("#{File.dirname(__FILE__)}/config.yml")
39
- unless File.exist?(path)
40
- # user hasn't done this, so use sane defaults for unit tests
41
- path = File.expand_path("#{File.dirname(__FILE__)}/config-example.yml")
42
- end
43
- path
44
- end
45
-
46
- # rubocop:disable Metrics/MethodLength
47
- def symbolize_keys(hash)
48
- hash.each_with_object({}) do |(key, value), result|
49
- new_key = case key
50
- when String then key.to_sym
51
- else key
52
- end
53
- new_value = case value
54
- when Hash then symbolize_keys(value)
55
- else value
56
- end
57
- result[new_key] = new_value
58
- result
59
- end
60
- end
61
- # rubocop:enable Metrics/MethodLength
62
- end
63
-
64
- RSpec.configure do |config|
65
- config.include(ConnectionHelper)
66
- end
@@ -1,78 +0,0 @@
1
- #
2
- # Author:: Fletcher (<fnichol@nichol.ca>)
3
- #
4
- # Copyright (C) 2015, Fletcher Nichol
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the 'License');
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an 'AS IS' BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'winrm-fs/core/tmp_zip'
19
-
20
- describe WinRM::FS::Core::TmpZip do
21
- let(:src_dir) do
22
- tmpdir = Pathname.new(Dir.mktmpdir)
23
- @tmpdirs << tmpdir
24
- src_dir = tmpdir.join('src')
25
- sub_dir = src_dir.join('veggies')
26
-
27
- src_dir.mkpath
28
- create_local_file(src_dir.join('apple.txt'), 'appleapple')
29
- create_local_file(src_dir.join('banana.txt'), 'bananabanana')
30
- create_local_file(src_dir.join('cherry.txt'), 'cherrycherry')
31
- sub_dir.mkpath
32
- create_local_file(sub_dir.join('carrot.txt'), 'carrotcarrot')
33
- src_dir
34
- end
35
-
36
- let(:tmp_zip) { WinRM::FS::Core::TmpZip.new(src_dir) }
37
-
38
- before { @tmpdirs = [] }
39
-
40
- after do
41
- @tmpdirs.each(&:rmtree)
42
- tmp_zip.unlink if tmp_zip.path
43
- end
44
-
45
- it '#path returns path to created zip file' do
46
- expect(tmp_zip.path.file?).to eq true
47
- end
48
-
49
- it '#unlink removes the file' do
50
- path = tmp_zip.path
51
- expect(path.file?).to eq true
52
-
53
- tmp_zip.unlink
54
-
55
- expect(path.file?).to eq false
56
- expect(tmp_zip.path).to eq nil
57
- end
58
-
59
- describe 'for a zip file containing the base directory' do
60
- let(:tmp_zip) { WinRM::FS::Core::TmpZip.new(src_dir) }
61
-
62
- it 'contains the input entries' do
63
- zip = Zip::File.new(tmp_zip.path)
64
-
65
- expect(zip.map(&:name).sort).to eq(
66
- ['apple.txt', 'banana.txt', 'cherry.txt', 'veggies/carrot.txt']
67
- )
68
- expect(zip.read('apple.txt')).to eq 'appleapple'
69
- expect(zip.read('banana.txt')).to eq 'bananabanana'
70
- expect(zip.read('cherry.txt')).to eq 'cherrycherry'
71
- expect(zip.read('veggies/carrot.txt')).to eq 'carrotcarrot'
72
- end
73
- end
74
-
75
- def create_local_file(path, content)
76
- path.open('wb') { |file| file.write(content) }
77
- end
78
- end
@@ -1,36 +0,0 @@
1
- require 'date'
2
-
3
- version = File.read(File.expand_path('VERSION', __dir__)).strip
4
-
5
- Gem::Specification.new do |s|
6
- s.platform = Gem::Platform::RUBY
7
- s.name = 'winrm-fs'
8
- s.version = version
9
- s.date = Date.today.to_s
10
-
11
- s.author = ['Shawn Neal', 'Matt Wrock']
12
- s.email = ['sneal@sneal.net', 'matt@mattwrock.com']
13
- s.homepage = 'http://github.com/WinRb/winrm-fs'
14
-
15
- s.summary = 'WinRM File System'
16
- s.description = <<-EOF
17
- Ruby library for file system operations via Windows Remote Management
18
- EOF
19
-
20
- s.files = `git ls-files`.split(/\n/)
21
- s.require_path = 'lib'
22
- s.rdoc_options = %w[-x test/ -x examples/]
23
- s.extra_rdoc_files = %w[README.md LICENSE]
24
-
25
- s.bindir = 'bin'
26
- s.executables = ['rwinrmcp']
27
- s.required_ruby_version = '>= 2.2.0'
28
- s.add_runtime_dependency 'erubis', '~> 2.7'
29
- s.add_runtime_dependency 'logging', ['>= 1.6.1', '< 3.0']
30
- s.add_runtime_dependency 'rubyzip', '~> 1.1'
31
- s.add_runtime_dependency 'winrm', '~> 2.0'
32
- s.add_development_dependency 'pry'
33
- s.add_development_dependency 'rake', '~> 10.3'
34
- s.add_development_dependency 'rspec', '~> 3.0'
35
- s.add_development_dependency 'rubocop', '~> 0.51'
36
- end