Skip to content

Commit 12f236d

Browse files
committed
(FM-7602) Update acceptance tests
1 parent b08a380 commit 12f236d

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

lib/puppet/util/task_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class Puppet::Util::TaskHelper
66
def initialize(transport_name)
77
@transport_name = transport_name
8+
@transport = {}
89

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

16-
Puppet::ResourceApi::Transport.connect(@transport_name, credentials)
17+
@transport[@transport_name] ||= Puppet::ResourceApi::Transport.connect(@transport_name, credentials)
1718
end
1819

1920
def params

spec/acceptance/basic_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
context 'when it gets the current running config' do
2626
it 'will get the current running config and store to file' do
2727
params = {
28-
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
2928
'config_file' => 'spec/fixtures/config-acceptance.xml',
3029
}
3130

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

spec/acceptance/tasks/config_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
describe 'Config task' do
55
before(:each) do
66
params = {
7-
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
7+
'_target' => {
8+
'host' => RSpec.configuration.host,
9+
'user' => RSpec.configuration.user,
10+
'password' => RSpec.configuration.password,
11+
},
812
'config_file' => config,
913
'apply' => apply,
1014
}
@@ -21,7 +25,11 @@
2125

2226
after(:all) do
2327
params = {
24-
'credentials_file' => "file://#{Dir.getwd}/spec/fixtures/acceptance-credentials.conf",
28+
'_target' => {
29+
'host' => RSpec.configuration.host,
30+
'user' => RSpec.configuration.user,
31+
'password' => RSpec.configuration.password,
32+
},
2533
'config_file' => 'spec/fixtures/config-reset.xml',
2634
'apply' => true,
2735
}
@@ -35,8 +43,8 @@
3543
let(:apply) { false }
3644

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

4856
it 'will upload the configuration file and load it' do
49-
expect(stdout_str).to match %r{Loading Config}
50-
expect(stdout_str).to match %r{Importing configuration}
57+
expect(stdout_str).to match %r{\{\}}
58+
expect(stdout_str).not_to match %r{_error}
5159
puts stdout_str if debug_output?
5260
expect(status.exitstatus).to eq 0
5361
end
@@ -74,8 +82,8 @@
7482
let(:apply) { true }
7583

7684
it 'will upload the configuration file and load it' do
77-
expect(stdout_str).to match %r{Loading Config}
78-
expect(stdout_str).to match %r{Importing configuration}
85+
expect(stdout_str).to match %r{\{\}}
86+
expect(stdout_str).not_to match %r{_error}
7987
puts stdout_str if debug_output?
8088
expect(status.exitstatus).to eq 0
8189
end

spec/spec_helper_acceptance.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ def debug_output?
4545

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

48+
c.add_setting :host, default: @hostname
49+
c.add_setting :user, default: (ENV['PANOS_TEST_USER'] || 'admin')
50+
c.add_setting :password, default: (ENV['PANOS_TEST_PASSWORD'] || 'admin')
51+
4852
File.open('spec/fixtures/acceptance-credentials.conf', 'w') do |file|
4953
file.puts <<CREDENTIALS
50-
address: #{@hostname}
51-
username: #{ENV['PANOS_TEST_USER'] || 'admin'}
52-
password: #{ENV['PANOS_TEST_PASSWORD'] || 'admin'}
54+
host: #{RSpec.configuration.host}
55+
user: #{RSpec.configuration.user}
56+
password: #{RSpec.configuration.password}
5357
CREDENTIALS
5458
end
5559

0 commit comments

Comments
 (0)