norad_spec_runner 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699bf53dab967b2672f83af168026b4666797755
|
4
|
+
data.tar.gz: 89f712129ebcd1674576825e4329a46507c57384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d53ecab4146ecf3d2cd059b3fdbf21aa18c0f70f0f4311fe288557c917a667cbb59af153ec362373e04d1b4c3ffdf61970d47247252bd891bd31a0b8c89ea4
|
7
|
+
data.tar.gz: 79a75e89560e54dbf2182bc46ca2aec2d8bee3803150d1b742637f41fde15f067272d18f428eb35babeaa2eacdaeddbe87db6457f6dd42d15d67791ab585b779
|
data/.gitlab-ci.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
stages:
|
2
|
+
- behavior_test
|
2
3
|
- release
|
3
4
|
|
4
5
|
image: ruby:2.4.0
|
@@ -6,6 +7,11 @@ image: ruby:2.4.0
|
|
6
7
|
before_script:
|
7
8
|
- bundle install --jobs=4 --with development
|
8
9
|
|
10
|
+
rspec:
|
11
|
+
stage: behavior_test
|
12
|
+
script:
|
13
|
+
- bundle exec rspec --order rand spec
|
14
|
+
|
9
15
|
publish:
|
10
16
|
stage: release
|
11
17
|
script:
|
@@ -18,7 +18,7 @@ module NoradSpecRunner
|
|
18
18
|
method_option :tests, :aliases => '-t', :desc => 'Rspec tests to execute'
|
19
19
|
method_option :sub_tests, :aliases => '-s', :desc => 'Specific test from given RSpec file', :default => '\'\''
|
20
20
|
method_option :results_file, :aliases => '-r', :desc => 'File to store the results'
|
21
|
-
method_option :port, :aliases => '-p', :desc => 'Port to connect on', :default => 22
|
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
24
|
|
@@ -2,12 +2,13 @@ require 'rspec'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'net/ssh'
|
4
4
|
require 'specinfra'
|
5
|
+
require 'norad_spec_runner/sec_test'
|
6
|
+
require 'norad_spec_runner/linux_sec_test'
|
5
7
|
|
6
8
|
module NoradSpecRunner
|
7
9
|
# Class to run Rspec tests over SSH
|
8
10
|
class RemoteTask < Task
|
9
11
|
SSH_TIMEOUT = 10
|
10
|
-
DEFAULT_LINUX_SPEC = 'default_linux_spec.rb'
|
11
12
|
|
12
13
|
attr_reader :host, :username, :sshkey, :ssh_port, :obj, :platform, :results_file, :cisco_enable_pw, :tests_parent_dir
|
13
14
|
|
@@ -81,19 +82,20 @@ module NoradSpecRunner
|
|
81
82
|
|
82
83
|
def autodetect_test_pattern(tests)
|
83
84
|
pattern = select_spec_for_os(tests)
|
84
|
-
pattern = "#{tests}/#{DEFAULT_LINUX_SPEC}" unless File.exist?("#{tests_parent_dir}/#{pattern}")
|
85
85
|
puts "Trying to run #{pattern}"
|
86
86
|
pattern
|
87
87
|
end
|
88
88
|
|
89
|
-
def select_spec_for_os(
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
def select_spec_for_os(test_name)
|
90
|
+
# Explicitly need this test case first
|
91
|
+
if target_is_ios_device?(start_ssh_session)
|
92
|
+
test_klass = SecTest
|
93
|
+
elsif target_is_linux?(start_ssh_session)
|
94
|
+
test_klass = LinuxSecTest
|
93
95
|
else
|
94
|
-
|
95
|
-
"#{File.expand_path(File.dirname(__FILE__))}/support/os_not_supported_spec.rb"
|
96
|
+
test_klass = SecTest
|
96
97
|
end
|
98
|
+
test_klass.new(tests_parent_dir, test_name, platform).test_to_run
|
97
99
|
end
|
98
100
|
|
99
101
|
def target_is_ios_device?(ssh_session)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module NoradSpecRunner
|
2
|
+
class SecTest
|
3
|
+
UNSUPPORTED_SPEC_FILE = "#{File.expand_path(File.dirname(__FILE__))}/support/os_not_supported_spec.rb"
|
4
|
+
attr_reader :tests_parent_dir, :test_name, :platform
|
5
|
+
|
6
|
+
def initialize(tests_parent_dir, test_name, platform)
|
7
|
+
@tests_parent_dir = tests_parent_dir
|
8
|
+
@test_name = test_name
|
9
|
+
@platform = platform
|
10
|
+
print_detection_message
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_to_run
|
14
|
+
suggested_test_file_exists? ? suggested_test_file : default_test_file
|
15
|
+
end
|
16
|
+
|
17
|
+
def suggested_test_file_exists?
|
18
|
+
File.exist?("#{tests_parent_dir}/#{suggested_test_file}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def suggested_test_file
|
22
|
+
"#{test_name}/#{platform}_spec.rb"
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_test_file
|
26
|
+
UNSUPPORTED_SPEC_FILE
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def print_detection_message
|
32
|
+
platform ? puts("Platform #{platform} detected!") : puts("Unable to detect OS!")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.
|
4
|
+
version: 0.4.1
|
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-
|
13
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: serverspec
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
- bin/norad_spec_runner
|
131
131
|
- lib/norad_spec_runner.rb
|
132
132
|
- lib/norad_spec_runner/cli.rb
|
133
|
+
- lib/norad_spec_runner/linux_sec_test.rb
|
133
134
|
- lib/norad_spec_runner/remote_task.rb
|
135
|
+
- lib/norad_spec_runner/sec_test.rb
|
134
136
|
- lib/norad_spec_runner/support/os_not_supported_spec.rb
|
135
137
|
- lib/norad_spec_runner/task.rb
|
136
138
|
- lib/norad_spec_runner/version.rb
|