Skip to content

Commit

Permalink
(FM-7602) Update acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
da-ar committed Mar 13, 2019
1 parent b08a380 commit daba8c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/puppet/util/task_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Puppet::Util::TaskHelper
def initialize(transport_name)
@transport_name = transport_name
@transport = {}

return unless params.key? '_installdir'
add_plugin_paths(params['_installdir'])
Expand All @@ -13,7 +14,7 @@ def initialize(transport_name)
def transport
require 'puppet/resource_api/transport'

Puppet::ResourceApi::Transport.connect(@transport_name, credentials)
@transport[@transport_name] ||= Puppet::ResourceApi::Transport.connect(@transport_name, credentials)
end

def params
Expand Down
2 changes: 0 additions & 2 deletions spec/acceptance/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
context 'when it gets the current running config' do
it 'will get the current running config and store to file' do
params = {
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
'config_file' => 'spec/fixtures/config-acceptance.xml',
}

Expand Down Expand Up @@ -68,7 +67,6 @@
context 'when it gets the current running config' do
it 'will get the current running config and store to file' do
params = {
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
'config_file' => 'spec/fixtures/config-reset.xml',
}

Expand Down
24 changes: 16 additions & 8 deletions spec/acceptance/tasks/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
describe 'Config task' do
before(:each) do
params = {
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
'_target' => {
'host' => RSpec.configuration.host,
'user' => RSpec.configuration.user,
'password' => RSpec.configuration.password,
},
'config_file' => config,
'apply' => apply,
}
Expand All @@ -21,7 +25,11 @@

after(:all) do
params = {
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
'_target' => {
'host' => RSpec.configuration.host,
'user' => RSpec.configuration.user,
'password' => RSpec.configuration.password,
},
'config_file' => 'spec/fixtures/config-reset.xml',
'apply' => true,
}
Expand All @@ -35,8 +43,8 @@
let(:apply) { false }

it 'will upload the configuration file but not load it' do
expect(stdout_str).not_to match %r{Loading Config}
expect(stdout_str).to match %r{Importing configuration}
expect(stdout_str).to match %r{\{\}}
expect(stdout_str).not_to match %r{_error}
puts stdout_str if debug_output?
expect(status.exitstatus).to eq 0
end
Expand All @@ -46,8 +54,8 @@
let(:apply) { true }

it 'will upload the configuration file and load it' do
expect(stdout_str).to match %r{Loading Config}
expect(stdout_str).to match %r{Importing configuration}
expect(stdout_str).to match %r{\{\}}
expect(stdout_str).not_to match %r{_error}
puts stdout_str if debug_output?
expect(status.exitstatus).to eq 0
end
Expand All @@ -74,8 +82,8 @@
let(:apply) { true }

it 'will upload the configuration file and load it' do
expect(stdout_str).to match %r{Loading Config}
expect(stdout_str).to match %r{Importing configuration}
expect(stdout_str).to match %r{\{\}}
expect(stdout_str).not_to match %r{_error}
puts stdout_str if debug_output?
expect(status.exitstatus).to eq 0
end
Expand Down
10 changes: 7 additions & 3 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ def debug_output?

puts "Detected #{@platform} config for #{@hostname}"

c.add_setting :host, :default => @hostname
c.add_setting :user, :default => (ENV['PANOS_TEST_USER'] || 'admin')
c.add_setting :password, :default => (ENV['PANOS_TEST_PASSWORD'] || 'admin')

File.open('spec/fixtures/acceptance-credentials.conf', 'w') do |file|
file.puts <<CREDENTIALS
address: #{@hostname}
username: #{ENV['PANOS_TEST_USER'] || 'admin'}
password: #{ENV['PANOS_TEST_PASSWORD'] || 'admin'}
host: #{RSpec.configuration.host}
user: #{RSpec.configuration.user}
password: #{RSpec.configuration.password}
CREDENTIALS
end

Expand Down

0 comments on commit daba8c5

Please sign in to comment.