1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
# frozen_string_literal: true
require 'spec_helper_acceptance'
require 'uri'
context 'authenticated download' do
let(:source) do
parser = URI::RFC2396_Parser.new
parser.escape("http://httpbin.org/basic-auth/user/#{password}")
end
let(:pp) do
<<-EOS
package { 'wget':
ensure => 'installed',
}
archive { '/tmp/testfile':
source => '#{source.gsub("'") { "\\'" }}',
username => 'user',
password => '#{password.gsub("'") { "\\'" }}',
provider => #{provider},
}
EOS
end
%w[curl wget ruby].each do |provider|
context "with provider #{provider}" do
let(:provider) { provider }
[
'hunter2',
'pass word with spaces',
'y^%88_',
"passwordwithsinglequote'!",
].each do |password|
context "with password '#{password}'" do
let(:password) { password }
it 'applies idempotently with no errors' do
shell('/bin/rm -f /tmp/testfile')
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file('/tmp/testfile') do
it { is_expected.to be_file }
its(:content_as_json) { is_expected.to include('authenticated' => true, 'user' => 'user') }
end
end
end
end
end
end
|