norad_spec_runner 0.4.1 → 0.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 699bf53dab967b2672f83af168026b4666797755
4
- data.tar.gz: 89f712129ebcd1674576825e4329a46507c57384
3
+ metadata.gz: 5b73ddcb59e0e2fce7fa32f4f00473aab8ba2bbc
4
+ data.tar.gz: 321f8f8c755bca498d18200fb311f034b36c26d6
5
5
  SHA512:
6
- metadata.gz: d9d53ecab4146ecf3d2cd059b3fdbf21aa18c0f70f0f4311fe288557c917a667cbb59af153ec362373e04d1b4c3ffdf61970d47247252bd891bd31a0b8c89ea4
7
- data.tar.gz: 79a75e89560e54dbf2182bc46ca2aec2d8bee3803150d1b742637f41fde15f067272d18f428eb35babeaa2eacdaeddbe87db6457f6dd42d15d67791ab585b779
6
+ metadata.gz: 9900761058380e65ad9de155ffee4bfac7c5e93690eb93cb313069d9d3c7eac1cbff25f4ba0a0a376101b8a0bb95a51d14a31d92c981ea9ea6b2f862677b0168
7
+ data.tar.gz: d5aea3728b0147c55cd014c1487644ba9fc51d0b87c6738b7f7bc2589bad1bce9b97f13f439ce019405f75f2742df0fed28af997d8d53be78316370400b5b367
@@ -21,6 +21,8 @@ module NoradSpecRunner
21
21
  method_option :port, :aliases => '-p', :desc => 'Port to connect on', :default => '22'
22
22
  method_option :cisco_enable_pw, :desc => 'Password to enter Enable mode in Cisco IOS', :default => ''
23
23
  method_option :detect_os, :desc => 'Whether or not to perform OS detection', :type => :boolean, :default => false
24
+ method_option :disable_sudo, :desc => 'Whether or not to use sudo', :type => :boolean, :default => true
25
+ method_option :tags, :desc => 'rspec --tag options', :default => '\'\''
24
26
 
25
27
  def remote(encoded_key)
26
28
  spectask = NoradSpecRunner::RemoteTask.new(encoded_key, options)
@@ -10,12 +10,13 @@ module NoradSpecRunner
10
10
  class RemoteTask < Task
11
11
  SSH_TIMEOUT = 10
12
12
 
13
- attr_reader :host, :username, :sshkey, :ssh_port, :obj, :platform, :results_file, :cisco_enable_pw, :tests_parent_dir
13
+ attr_reader :host, :username, :sshkey, :ssh_port, :obj, :platform, :results_file, :cisco_enable_pw, :tests_parent_dir, :disable_sudo
14
14
 
15
15
  def initialize(encoded_key, options)
16
16
  @host = options.fetch(:host)
17
17
  @sshkey = options.fetch(:sshkey)
18
18
  @cisco_enable_pw = options.fetch(:cisco_enable_pw, '')
19
+ @disable_sudo = options.fetch(:disable_sudo, 'true')
19
20
  # Decode the key and store
20
21
  File.open(@sshkey, "w") do |f|
21
22
  f.write Base64.decode64(encoded_key)
@@ -32,7 +33,7 @@ module NoradSpecRunner
32
33
 
33
34
  @results_file = options.fetch(:results_file)
34
35
  @obj.pattern = detect_os ? autodetect_test_pattern(tests) : tests
35
- @obj.rspec_opts = "-e #{sub_tests} --format json -o #{@results_file}"
36
+ @obj.rspec_opts = build_rspec_opts(options)
36
37
  end
37
38
 
38
39
  def run
@@ -46,6 +47,7 @@ module NoradSpecRunner
46
47
  ENV['AUDIT_SSHKEY'] = sshkey
47
48
  ENV['AUDIT_SSH_PORT'] = ssh_port
48
49
  ENV['AUDIT_CISCO_ENABLE_PASSWORD'] = cisco_enable_pw
50
+ ENV['AUDIT_DISABLE_SUDO'] = disable_sudo.to_s
49
51
 
50
52
  # Capture STDERR for SSH related errors
51
53
  STDERR.reopen(ftmp)
@@ -134,5 +136,18 @@ module NoradSpecRunner
134
136
  write_error_to_results_file e.message
135
137
  true
136
138
  end
139
+
140
+ def build_rspec_opts(options)
141
+ rspec_opts = [ '--format json', "-o #{@results_file}"]
142
+ options.fetch(:tags).split(',').each do |tag|
143
+ rspec_opts << "--tag=#{tag}"
144
+ end
145
+ # --tag and --example do not work together so
146
+ # if there is a tag disable example option
147
+ if options.fetch(:tags) == ''
148
+ rspec_opts << "-e #{sub_tests}"
149
+ end
150
+ rspec_opts.join(' ')
151
+ end
137
152
  end
138
153
  end
@@ -1,3 +1,3 @@
1
1
  module NoradSpecRunner
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_spec_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Manifold
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-12 00:00:00.000000000 Z
13
+ date: 2017-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: serverspec