cem_win_spec 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -12
- data/cem_win_spec.gemspec +0 -1
- data/exe/cem-win-spec +20 -0
- data/lib/cem_win_spec/iap_tunnel.rb +11 -2
- data/lib/cem_win_spec/rspec_test_cmds.rb +12 -7
- data/lib/cem_win_spec/test_runner.rb +15 -10
- data/lib/cem_win_spec/version.rb +1 -1
- data/lib/cem_win_spec/win_exec/cmd/base_cmd.rb +96 -0
- data/lib/cem_win_spec/win_exec/{local_exec.rb → cmd/local_cmd.rb} +13 -13
- data/lib/cem_win_spec/win_exec/{winrm_exec.rb → cmd/winrm_cmd.rb} +21 -8
- data/lib/cem_win_spec/win_exec/connection_opts.rb +5 -5
- data/lib/cem_win_spec/win_exec/exec.rb +196 -0
- data/lib/cem_win_spec/win_exec/factory.rb +123 -0
- data/lib/cem_win_spec/win_exec.rb +2 -228
- data/lib/cem_win_spec.rb +12 -15
- metadata +8 -21
- data/lib/cem_win_spec/remote_command.rb +0 -47
- data/lib/cem_win_spec/win_exec/base_exec.rb +0 -42
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cem_win_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heston Snodgrass
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: tty-spinner
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.9'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.9'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: puppet_forge
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,16 +105,17 @@ files:
|
|
119
105
|
- lib/cem_win_spec/logging/formatter.rb
|
120
106
|
- lib/cem_win_spec/module_archive_builder.rb
|
121
107
|
- lib/cem_win_spec/rake_tasks.rb
|
122
|
-
- lib/cem_win_spec/remote_command.rb
|
123
108
|
- lib/cem_win_spec/rspec_test_cmds.rb
|
124
109
|
- lib/cem_win_spec/test_runner.rb
|
125
110
|
- lib/cem_win_spec/version.rb
|
126
111
|
- lib/cem_win_spec/win_exec.rb
|
127
|
-
- lib/cem_win_spec/win_exec/
|
112
|
+
- lib/cem_win_spec/win_exec/cmd/base_cmd.rb
|
113
|
+
- lib/cem_win_spec/win_exec/cmd/local_cmd.rb
|
114
|
+
- lib/cem_win_spec/win_exec/cmd/winrm_cmd.rb
|
128
115
|
- lib/cem_win_spec/win_exec/connection_opts.rb
|
129
|
-
- lib/cem_win_spec/win_exec/
|
116
|
+
- lib/cem_win_spec/win_exec/exec.rb
|
117
|
+
- lib/cem_win_spec/win_exec/factory.rb
|
130
118
|
- lib/cem_win_spec/win_exec/output.rb
|
131
|
-
- lib/cem_win_spec/win_exec/winrm_exec.rb
|
132
119
|
- sig/cem_win_spec.rbs
|
133
120
|
homepage: https://github.com/hsnodgrass/cem_win_spec
|
134
121
|
licenses:
|
@@ -152,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
139
|
- !ruby/object:Gem::Version
|
153
140
|
version: '0'
|
154
141
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.4.10
|
156
143
|
signing_key:
|
157
144
|
specification_version: 4
|
158
145
|
summary: Write a short summary, because RubyGems requires one.
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'iap_tunnel'
|
4
|
-
require_relative 'win_exec'
|
5
|
-
|
6
|
-
module CemWinSpec
|
7
|
-
# Class for running a command on a remote Windows host
|
8
|
-
class RemoteCommand
|
9
|
-
attr_reader :title, :result
|
10
|
-
|
11
|
-
def initialize(title, iap_tunnel: nil, reuse_tunnel: true, winrm_opts: {}, &block)
|
12
|
-
@title = title
|
13
|
-
@iap_tunnel = iap_tunnel || IapTunnel.new
|
14
|
-
@reuse_tunnel = reuse_tunnel
|
15
|
-
@winrm_opts = winrm_opts
|
16
|
-
@block = block
|
17
|
-
@win_exec = WinExec.new('localhost', @iap_tunnel.port, winrm_opts: winrm_opts)
|
18
|
-
@result = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def ran?
|
22
|
-
!@result.nil?
|
23
|
-
end
|
24
|
-
|
25
|
-
def success?
|
26
|
-
@result.is_a? WinRM::Output
|
27
|
-
end
|
28
|
-
|
29
|
-
def run
|
30
|
-
puts "Running #{@title}"
|
31
|
-
@result = if @reuse_tunnel
|
32
|
-
@iap_tunnel.start # ensure tunnel is running
|
33
|
-
@block.call @win_exec
|
34
|
-
else
|
35
|
-
@iap_tunnel.stop # ensure tunnel is stopped
|
36
|
-
@iap_tunnel.with do # start tunnel for this block
|
37
|
-
@block.call @win_exec
|
38
|
-
end
|
39
|
-
end
|
40
|
-
@result
|
41
|
-
rescue StandardError => e
|
42
|
-
puts "Error running #{@title}: #{e}"
|
43
|
-
@result = e
|
44
|
-
raise @result
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../logging'
|
4
|
-
|
5
|
-
module CemWinSpec
|
6
|
-
module WinExec
|
7
|
-
class BaseExec
|
8
|
-
include CemWinSpec::Logging
|
9
|
-
|
10
|
-
attr_accessor :working_dir
|
11
|
-
|
12
|
-
def initialize(working_dir = nil)
|
13
|
-
@working_dir = working_dir
|
14
|
-
end
|
15
|
-
|
16
|
-
def available?
|
17
|
-
raise NotImplementedError
|
18
|
-
end
|
19
|
-
|
20
|
-
def exec(cmd, *_args, **_kwargs)
|
21
|
-
raise NotImplementedError
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def cd_working_dir(cmd)
|
27
|
-
return cmd if working_dir.nil?
|
28
|
-
|
29
|
-
"cd #{working_dir}; #{cmd}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def cmd_prefix_msg
|
33
|
-
prefix = 'Executing command'
|
34
|
-
working_dir.nil? ? "#{prefix}:\n" : "#{prefix} in #{working_dir}:\n"
|
35
|
-
end
|
36
|
-
|
37
|
-
def puts_cmd(cmd)
|
38
|
-
logger.debug "#{cmd_prefix_msg}#{cmd.split(%r{\n|\r\n|;\s*}).map { |c| " #> #{c}" }.join("\n")}"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|