winrm-elevated 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm-elevated
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Neal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-03 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: winrm
@@ -39,49 +39,55 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.2'
47
+ version: '10.3'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '13'
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
- version: '3.2'
57
+ version: '10.3'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '13'
55
61
  - !ruby/object:Gem::Dependency
56
- name: rake
62
+ name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '10.3'
67
+ version: '3.2'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '10.3'
74
+ version: '3.2'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rubocop
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0.28'
81
+ version: 0.51.0
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0.28'
83
- description: " Ruby library for running commands via WinRM as elevated through
84
- a scheduled task\n"
88
+ version: 0.51.0
89
+ description: Ruby library for running commands via WinRM as elevated through a scheduled
90
+ task
85
91
  email:
86
92
  - sneal@sneal.net
87
93
  executables: []
@@ -90,42 +96,24 @@ extra_rdoc_files:
90
96
  - README.md
91
97
  - LICENSE
92
98
  files:
93
- - ".gitignore"
94
- - ".rspec"
95
- - ".rubocop.yml"
96
- - ".travis.yml"
97
- - Gemfile
98
99
  - LICENSE
99
100
  - README.md
100
- - Rakefile
101
- - VERSION
102
- - appveyor.yml
103
- - changelog.md
104
101
  - lib/winrm-elevated.rb
105
102
  - lib/winrm-elevated/scripts/elevated_shell.ps1
106
103
  - lib/winrm/shells/elevated.rb
107
- - spec/config-example.yml
108
- - spec/matchers.rb
109
- - spec/powershell_elevated_spec.rb
110
- - spec/spec_helper.rb
111
- - winrm-elevated.gemspec
112
104
  homepage: https://github.com/WinRb/winrm-elevated
113
105
  licenses:
114
106
  - Apache-2.0
115
107
  metadata: {}
116
108
  post_install_message:
117
- rdoc_options:
118
- - "-x"
119
- - test/
120
- - "-x"
121
- - examples/
109
+ rdoc_options: []
122
110
  require_paths:
123
111
  - lib
124
112
  required_ruby_version: !ruby/object:Gem::Requirement
125
113
  requirements:
126
114
  - - ">="
127
115
  - !ruby/object:Gem::Version
128
- version: 1.9.0
116
+ version: 2.2.0
129
117
  required_rubygems_version: !ruby/object:Gem::Requirement
130
118
  requirements:
131
119
  - - ">="
@@ -133,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
121
  version: '0'
134
122
  requirements: []
135
123
  rubyforge_project:
136
- rubygems_version: 2.6.6
124
+ rubygems_version: 2.7.6
137
125
  signing_key:
138
126
  specification_version: 4
139
127
  summary: Ruby library for running commands as elevated
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- *.swp
2
- *.gem
3
- pkg/*
4
- .rvmrc
5
- .idea
6
- .bundle
7
- spec/config.yml
8
- Gemfile.lock
9
- .vagrant
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format nested
3
- --require spec_helper
@@ -1,17 +0,0 @@
1
- Style/FileName:
2
- Enabled: false
3
-
4
- Style/Encoding:
5
- Enabled: true
6
-
7
- Metrics/LineLength:
8
- Max: 120
9
-
10
- Metrics/MethodLength:
11
- Max: 20
12
-
13
- ClassLength:
14
- Max: 250
15
-
16
- Metrics/AbcSize:
17
- Max: 25
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
-
7
- # This prevents testing branches that are created just for PRs
8
- branches:
9
- only:
10
- - master
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- # encoding: UTF-8
2
- source 'https://rubygems.org'
3
- gemspec
4
-
5
- group :development do
6
- # Use a tighter specification until rubocop issues are fixed.
7
- # Then remove this
8
- gem 'rubocop', '~> 0.28.0'
9
- end
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
- require 'bundler/gem_tasks'
7
-
8
- # Change to the directory of this file.
9
- Dir.chdir(File.expand_path('../', __FILE__))
10
-
11
- RSpec::Core::RakeTask.new(:spec) do |task|
12
- task.pattern = 'spec/*_spec.rb'
13
- task.rspec_opts = ['--color', '-f documentation']
14
- task.rspec_opts << '-tunit'
15
- end
16
-
17
- # Run the integration test suite
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/*_spec.rb'
20
- task.rspec_opts = ['--color', '-f documentation']
21
- task.rspec_opts << '-tintegration'
22
- end
23
-
24
- RuboCop::RakeTask.new
25
-
26
- task default: [:spec, :rubocop]
27
-
28
- task all: [:default, :integration]
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0
@@ -1,39 +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: Pa$$word1
10
-
11
- matrix:
12
- - ruby_version: "21"
13
- winrm_endpoint: http://localhost:5985/wsman
14
-
15
- clone_folder: c:\projects\winrm-elevated
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: gem install bundler --quiet --no-ri --no-rdoc
32
- - ps: bundler --version
33
-
34
- build_script:
35
- - bundle install || bundle install || bundle install
36
-
37
- test_script:
38
- - SET SPEC_OPTS=--format progress
39
- - bundle exec rake integration
@@ -1,31 +0,0 @@
1
- # WinRM-Elevated Gem Changelog
2
-
3
- # 1.1.0
4
- - Allow tasks to be configured for interactive logon
5
- - Fix broken credentials when they contain dollar signs
6
- - Do not fail when temporary files cannot be deleted
7
-
8
- # 1.0.1
9
- - Fix to avoid profile conflicts
10
- - Fix inadequate Execution Policy errors
11
-
12
- # 1.0.0
13
- - Adjust to comply with winrm v2 APIs
14
- - Expose implementation as a class of `WinRM::Shells`
15
-
16
- # 0.4.0
17
- - Initialize `Elevated::Runner` with a `CommandExecutor` instead of a `WinrmService` client
18
- - Run commands from newer winrm executor
19
- - Use latest winrm-fs 0.4.2
20
- - Allow task to run as a service account
21
- - Provide an artificially long timeout to the task to keep the task from dying after 60 seconds
22
-
23
- # 0.3.0
24
- - [Name Powershell Script and Log Files Uniquely](https://github.com/WinRb/winrm-elevated/pull/6)
25
-
26
- # 0.2.0
27
- - [Only upload the elevated runner script once per winrm session](https://github.com/WinRb/winrm-elevated/pull/3)
28
- - Bump WinRM (1.5) and WinRM-fs (0.3.0) gem constraints
29
-
30
- # 0.1.0
31
- - Initial Release
@@ -1,3 +0,0 @@
1
- endpoint: "http://localhost:55985/wsman"
2
- user: vagrant
3
- password: vagrant
@@ -1,50 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rspec/expectations'
3
-
4
- # rspec matchers
5
- RSpec::Matchers.define :have_stdout_match do |expected_stdout|
6
- match do |actual_output|
7
- !expected_stdout.match(actual_output.stdout).nil?
8
- end
9
- failure_message do |actual_output|
10
- "expected that '#{actual_output.stdout}' would match #{expected_stdout}"
11
- end
12
- end
13
-
14
- RSpec::Matchers.define :have_stderr_match do |expected_stderr|
15
- match do |actual_output|
16
- !expected_stderr.match(actual_output.stderr).nil?
17
- end
18
- failure_message do |actual_output|
19
- "expected that '#{actual_output.stderr}' would match #{expected_stderr}"
20
- end
21
- end
22
-
23
- RSpec::Matchers.define :have_no_stdout do
24
- match do |actual_output|
25
- stdout = actual_output.stdout
26
- stdout == '\r\n' || stdout == ''
27
- end
28
- failure_message do |actual_output|
29
- "expected that '#{actual_output.stdout}' would have no stdout"
30
- end
31
- end
32
-
33
- RSpec::Matchers.define :have_no_stderr do
34
- match do |actual_output|
35
- stderr = actual_output.stderr
36
- stderr == '\r\n' || stderr == ''
37
- end
38
- failure_message do |actual_output|
39
- "expected that '#{actual_output.stderr}' would have no stderr"
40
- end
41
- end
42
-
43
- RSpec::Matchers.define :have_exit_code do |expected_exit_code|
44
- match do |actual_output|
45
- expected_exit_code == actual_output.exitcode
46
- end
47
- failure_message do |actual_output|
48
- "expected exit code #{expected_exit_code}, but got #{actual_output.exitcode}"
49
- end
50
- end
@@ -1,87 +0,0 @@
1
- # encoding: UTF-8
2
- describe 'powershell elevated runner', integration: true do
3
- describe 'ipconfig' do
4
- subject(:output) { elevated_shell.run('ipconfig') }
5
- it { should have_exit_code 0 }
6
- it { should have_stdout_match(/Windows IP Configuration/) }
7
- it { should have_no_stderr }
8
- end
9
-
10
- describe 'ipconfig as Service' do
11
- subject(:output) do
12
- elevated_shell.username = 'System'
13
- elevated_shell.password = nil
14
- elevated_shell.run('ipconfig')
15
- end
16
- it { should have_exit_code 0 }
17
- it { should have_stdout_match(/Windows IP Configuration/) }
18
- it { should have_no_stderr }
19
- end
20
-
21
- describe 'echo \'hello world\' using apostrophes' do
22
- subject(:output) { elevated_shell.run("echo 'hello world'") }
23
- it { should have_exit_code 0 }
24
- it { should have_stdout_match(/hello world/) }
25
- it { should have_no_stderr }
26
- end
27
-
28
- describe 'ipconfig with incorrect argument -z' do
29
- subject(:output) { elevated_shell.run('ipconfig 127.0.0.1 -z') }
30
- it { should have_exit_code 1 }
31
- end
32
-
33
- describe 'Math area calculation' do
34
- subject(:output) do
35
- cmd = <<-EOH
36
- $diameter = 4.5
37
- $area = [Math]::pow([Math]::PI * ($diameter/2), 2)
38
- Write-Host $area
39
- EOH
40
- elevated_shell.run(cmd)
41
- end
42
- it { should have_exit_code 0 }
43
- it { should have_stdout_match(/49.9648722805149/) }
44
- it { should have_no_stderr }
45
- end
46
-
47
- describe 'ipconfig with a block' do
48
- subject(:stdout) do
49
- outvar = ''
50
- elevated_shell.run('ipconfig') do |stdout, _stderr|
51
- outvar << stdout
52
- end
53
- outvar
54
- end
55
- it { should match(/Windows IP Configuration/) }
56
- end
57
-
58
- describe 'capturing output from Write-Host and Write-Error' do
59
- subject(:output) do
60
- script = <<-eos
61
- Write-Host 'Hello'
62
- $host.ui.WriteErrorLine(', world!')
63
- eos
64
-
65
- @captured_stdout = ''
66
- @captured_stderr = ''
67
- elevated_shell.run(script) do |stdout, stderr|
68
- @captured_stdout << stdout if stdout
69
- @captured_stderr << stderr if stderr
70
- end
71
- end
72
-
73
- it 'should have stdout' do
74
- expect(output.stdout).to eq("Hello\r\n")
75
- expect(output.stdout).to eq(@captured_stdout)
76
- end
77
-
78
- it 'should have stderr' do
79
- expect(output.stderr).to eq(", world!\r\n")
80
- expect(output.stderr).to eq(@captured_stderr)
81
- end
82
-
83
- it 'should have output' do
84
- expect(output.output).to eq("Hello\r\n, world!\r\n")
85
- end
86
- end
87
- end
@@ -1,58 +0,0 @@
1
- # encoding: UTF-8
2
- require 'winrm'
3
- require 'winrm-elevated'
4
- require_relative 'matchers'
5
-
6
- # Creates a WinRM connection for integration tests
7
- module ConnectionHelper
8
- def winrm_connection
9
- WinRM::Connection.new(winrm_config)
10
- end
11
-
12
- def elevated_shell
13
- @elevated_shell ||= winrm_connection.shell(:elevated)
14
- end
15
-
16
- def winrm_config
17
- unless @winrm_config
18
- path = File.expand_path("#{File.dirname(__FILE__)}/config.yml")
19
- unless File.exist?(path)
20
- path = File.expand_path("#{File.dirname(__FILE__)}/config-example.yml")
21
- end
22
- @winrm_config = symbolize_keys(YAML.load(File.read(path)))
23
- @winrm_config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint']
24
- @winrm_config[:user] = ENV['winrm_user'] if ENV['winrm_user']
25
- @winrm_config[:password] = ENV['winrm_password'] if ENV['winrm_password']
26
- end
27
- @winrm_config
28
- end
29
-
30
- def username
31
- winrm_config[:user]
32
- end
33
-
34
- def password
35
- winrm_config[:password]
36
- end
37
-
38
- # rubocop:disable Metrics/MethodLength
39
- def symbolize_keys(hash)
40
- hash.each_with_object({}) do |(key, value), result|
41
- new_key = case key
42
- when String then key.to_sym
43
- else key
44
- end
45
- new_value = case value
46
- when Hash then symbolize_keys(value)
47
- else value
48
- end
49
- result[new_key] = new_value
50
- result
51
- end
52
- end
53
- # rubocop:enable Metrics/MethodLength
54
- end
55
-
56
- RSpec.configure do |config|
57
- config.include(ConnectionHelper)
58
- end