winrm-elevated 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -17
- data/.travis.yml +10 -10
- data/README.md +86 -86
- data/VERSION +1 -1
- data/appveyor.yml +39 -39
- data/changelog.md +26 -18
- data/lib/winrm-elevated.rb +18 -18
- data/lib/winrm-elevated/scripts/elevated_shell.ps1 +108 -108
- data/lib/winrm/shells/elevated.rb +99 -99
- data/spec/config-example.yml +3 -3
- data/spec/matchers.rb +50 -50
- data/spec/powershell_elevated_spec.rb +87 -87
- data/spec/spec_helper.rb +58 -58
- data/winrm-elevated.gemspec +33 -33
- metadata +2 -2
data/spec/spec_helper.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
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
|
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
|
data/winrm-elevated.gemspec
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.platform = Gem::Platform::RUBY
|
8
|
-
s.name = 'winrm-elevated'
|
9
|
-
s.version = version
|
10
|
-
s.date = Date.today.to_s
|
11
|
-
|
12
|
-
s.author = ['Shawn Neal']
|
13
|
-
s.email = ['sneal@sneal.net']
|
14
|
-
s.homepage = 'https://github.com/WinRb/winrm-elevated'
|
15
|
-
|
16
|
-
s.summary = 'Ruby library for running commands as elevated'
|
17
|
-
s.description = <<-EOF
|
18
|
-
Ruby library for running commands via WinRM as elevated through a scheduled task
|
19
|
-
EOF
|
20
|
-
s.license = 'Apache-2.0'
|
21
|
-
|
22
|
-
s.files = `git ls-files`.split(/\n/)
|
23
|
-
s.require_path = 'lib'
|
24
|
-
s.rdoc_options = %w(-x test/ -x examples/)
|
25
|
-
s.extra_rdoc_files = %w(README.md LICENSE)
|
26
|
-
|
27
|
-
s.required_ruby_version = '>= 1.9.0'
|
28
|
-
s.add_runtime_dependency 'winrm', '~> 2.0'
|
29
|
-
s.add_runtime_dependency 'winrm-fs', '~> 1.0'
|
30
|
-
s.add_development_dependency 'rspec', '~> 3.2'
|
31
|
-
s.add_development_dependency 'rake', '~> 10.3'
|
32
|
-
s.add_development_dependency 'rubocop', '~> 0.28'
|
33
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.name = 'winrm-elevated'
|
9
|
+
s.version = version
|
10
|
+
s.date = Date.today.to_s
|
11
|
+
|
12
|
+
s.author = ['Shawn Neal']
|
13
|
+
s.email = ['sneal@sneal.net']
|
14
|
+
s.homepage = 'https://github.com/WinRb/winrm-elevated'
|
15
|
+
|
16
|
+
s.summary = 'Ruby library for running commands as elevated'
|
17
|
+
s.description = <<-EOF
|
18
|
+
Ruby library for running commands via WinRM as elevated through a scheduled task
|
19
|
+
EOF
|
20
|
+
s.license = 'Apache-2.0'
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split(/\n/)
|
23
|
+
s.require_path = 'lib'
|
24
|
+
s.rdoc_options = %w(-x test/ -x examples/)
|
25
|
+
s.extra_rdoc_files = %w(README.md LICENSE)
|
26
|
+
|
27
|
+
s.required_ruby_version = '>= 1.9.0'
|
28
|
+
s.add_runtime_dependency 'winrm', '~> 2.0'
|
29
|
+
s.add_runtime_dependency 'winrm-fs', '~> 1.0'
|
30
|
+
s.add_development_dependency 'rspec', '~> 3.2'
|
31
|
+
s.add_development_dependency 'rake', '~> 10.3'
|
32
|
+
s.add_development_dependency 'rubocop', '~> 0.28'
|
33
|
+
end
|
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.0.
|
4
|
+
version: 1.0.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-
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|