Skip to content

Commit 8b140c4

Browse files
committed
Merge pull request #22 from TelekomLabs/update-common
updating common files
2 parents f81fd22 + 56d8d06 commit 8b140c4

7 files changed

Lines changed: 17 additions & 40 deletions

File tree

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
source 'https://rubygems.org'
44

55
gem 'rake'
6-
gem 'serverspec'
6+
gem 'serverspec', '~> 2.3.0'
77
gem 'rubocop', '~> 0.23'
8+
gem 'highline', '~> 1.6.0'

default/serverspec/os_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
require 'spec_helper'
1919

20-
RSpec.configure do |c|
21-
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
22-
end
23-
2420

2521
describe command('find / -name \'.rhosts\' | wc -l ') do
2622
its(:stdout) { should match(/^0/) }

default/serverspec/spec_helper.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
require 'net/ssh'
2323
require 'highline/import'
2424

25-
include Serverspec::Helper::Ssh
26-
include Serverspec::Helper::DetectOS
25+
set :backend, :ssh
2726

2827
RSpec.configure do |c|
2928

@@ -42,28 +41,25 @@
4241
end
4342

4443
if ENV['ASK_LOGIN_USERNAME']
45-
user = ask("\nEnter login username: ") { |q| q.echo = false }
44+
options[:user] = ask("\nEnter login username: ") { |q| q.echo = false }
4645
else
47-
user = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
46+
options[:user] = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
4847
end
4948

50-
if user.nil?
49+
if options[:user].nil?
5150
puts 'specify login user env LOGIN_USERNAME= or user='
5251
exit 1
5352
end
5453

55-
c.host = ENV['TARGET_HOST']
56-
options.merge(Net::SSH::Config.for(c.host))
57-
c.ssh = Net::SSH.start(c.host, user, options)
58-
c.os = backend.check_os
54+
c.host = ENV['TARGET_HOST']
55+
c.ssh_options = options.merge(Net::SSH::Config.for(c.host))
5956

6057
end
6158

6259
else
6360
require 'serverspec'
6461

65-
include Serverspec::Helper::Exec
66-
include Serverspec::Helper::DetectOS
62+
set :backend, :exec
6763

6864
RSpec.configure do |c|
6965
c.before :all do

default/serverspec/sysctl_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
require 'spec_helper'
1919

20-
RSpec.configure do |c|
21-
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
22-
end
23-
2420
describe 'IP V4 networking' do
2521

2622

@@ -204,7 +200,7 @@
204200

205201

206202
# check if we find the nx flag
207-
if command('cat /proc/cpuinfo').return_stdout?(/^flags.*?:.*? nx( .*?)?$/)
203+
if command('cat /proc/cpuinfo').stdout =~ /^flags.*?:.*? nx( .*?)?$/
208204
true
209205
else
210206
# if no nx flag is present, we require exec-shield

lockdown/serverspec/os_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
require 'spec_helper'
1919

20-
RSpec.configure do |c|
21-
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
22-
end
23-
2420

2521
describe command('find / -name \'.rhosts\' | wc -l ') do
2622
its(:stdout) { should match(/^0/) }

lockdown/serverspec/spec_helper.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
require 'net/ssh'
2323
require 'highline/import'
2424

25-
include Serverspec::Helper::Ssh
26-
include Serverspec::Helper::DetectOS
25+
set :backend, :ssh
2726

2827
RSpec.configure do |c|
2928

@@ -42,28 +41,25 @@
4241
end
4342

4443
if ENV['ASK_LOGIN_USERNAME']
45-
user = ask("\nEnter login username: ") { |q| q.echo = false }
44+
options[:user] = ask("\nEnter login username: ") { |q| q.echo = false }
4645
else
47-
user = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
46+
options[:user] = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
4847
end
4948

50-
if user.nil?
49+
if options[:user].nil?
5150
puts 'specify login user env LOGIN_USERNAME= or user='
5251
exit 1
5352
end
5453

55-
c.host = ENV['TARGET_HOST']
56-
options.merge(Net::SSH::Config.for(c.host))
57-
c.ssh = Net::SSH.start(c.host, user, options)
58-
c.os = backend.check_os
54+
c.host = ENV['TARGET_HOST']
55+
c.ssh_options = options.merge(Net::SSH::Config.for(c.host))
5956

6057
end
6158

6259
else
6360
require 'serverspec'
6461

65-
include Serverspec::Helper::Exec
66-
include Serverspec::Helper::DetectOS
62+
set :backend, :exec
6763

6864
RSpec.configure do |c|
6965
c.before :all do

lockdown/serverspec/sysctl_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
require 'spec_helper'
1919

20-
RSpec.configure do |c|
21-
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
22-
end
23-
2420
describe 'IP V4 networking' do
2521

2622

0 commit comments

Comments
 (0)