2014-01-15 20:16:49 +01:00
|
|
|
require 'spec_helper_acceptance'
|
2013-08-08 17:44:31 +02:00
|
|
|
|
|
|
|
describe 'basic concat test' do
|
|
|
|
|
2013-11-02 02:20:41 +01:00
|
|
|
shared_examples 'successfully_applied' do |pp|
|
2014-01-15 20:16:49 +01:00
|
|
|
it 'applies the manifest twice with no stderr' do
|
|
|
|
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
|
|
|
|
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
|
|
|
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 755 }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/bin") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_directory }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 755 }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
#it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 755 }
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 750 }
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_directory }
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 750 }
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do
|
2013-08-08 17:44:31 +02:00
|
|
|
it { should be_file }
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2013-10-30 05:44:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'owner/group root' do
|
2013-11-14 04:28:27 +01:00
|
|
|
pp = <<-EOS
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/file':
|
2013-10-30 05:44:14 +01:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '1':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '2':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '2',
|
|
|
|
order => '02',
|
|
|
|
}
|
2013-11-14 04:28:27 +01:00
|
|
|
EOS
|
2013-10-30 05:44:14 +01:00
|
|
|
|
2013-11-02 02:20:41 +01:00
|
|
|
it_behaves_like 'successfully_applied', pp
|
|
|
|
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/file') do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 644 }
|
|
|
|
it { should contain '1' }
|
|
|
|
it { should contain '2' }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
|
|
|
end
|
2013-10-30 05:44:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'owner/group non-root' do
|
|
|
|
before(:all) do
|
2014-02-14 21:54:48 +01:00
|
|
|
shell "groupadd -g 64444 bob"
|
|
|
|
shell "useradd -u 42 -g 64444 bob"
|
2013-10-30 05:44:14 +01:00
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
after(:all) do
|
|
|
|
shell "userdel bob"
|
|
|
|
end
|
2013-10-30 05:44:14 +01:00
|
|
|
|
|
|
|
pp="
|
2013-11-06 04:40:03 +01:00
|
|
|
concat { '/tmp/concat/file':
|
2013-10-30 05:44:14 +01:00
|
|
|
owner => 'bob',
|
|
|
|
group => 'bob',
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '1':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
|
|
|
|
concat::fragment { '2':
|
2013-11-06 04:40:03 +01:00
|
|
|
target => '/tmp/concat/file',
|
2013-10-30 05:44:14 +01:00
|
|
|
content => '2',
|
|
|
|
order => '02',
|
|
|
|
}
|
|
|
|
"
|
2013-08-08 17:44:31 +02:00
|
|
|
|
2013-11-02 02:20:41 +01:00
|
|
|
it_behaves_like 'successfully_applied', pp
|
|
|
|
|
2013-11-06 04:40:03 +01:00
|
|
|
describe file('/tmp/concat/file') do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'bob' }
|
|
|
|
it { should be_grouped_into 'bob' }
|
|
|
|
it { should be_mode 644 }
|
|
|
|
it { should contain '1' }
|
|
|
|
it { should contain '2' }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
|
|
|
it { should contain '1' }
|
|
|
|
end
|
2014-01-15 20:16:49 +01:00
|
|
|
describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do
|
2013-11-02 02:20:41 +01:00
|
|
|
it { should be_file }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
it { should be_mode 640 }
|
|
|
|
it { should contain '2' }
|
|
|
|
end
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|
2014-01-21 22:28:42 +01:00
|
|
|
|
|
|
|
context 'ensure' do
|
|
|
|
context 'works when set to present with path set' do
|
|
|
|
pp="
|
|
|
|
concat { 'file':
|
|
|
|
ensure => present,
|
|
|
|
path => '/tmp/concat/file',
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
|
|
|
target => 'file',
|
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
it_behaves_like 'successfully_applied', pp
|
|
|
|
|
|
|
|
describe file('/tmp/concat/file') do
|
|
|
|
it { should be_file }
|
|
|
|
it { should be_mode 644 }
|
|
|
|
it { should contain '1' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'works when set to absent with path set' do
|
|
|
|
pp="
|
|
|
|
concat { 'file':
|
|
|
|
ensure => absent,
|
|
|
|
path => '/tmp/concat/file',
|
|
|
|
mode => '0644',
|
|
|
|
}
|
|
|
|
concat::fragment { '1':
|
|
|
|
target => 'file',
|
|
|
|
content => '1',
|
|
|
|
order => '01',
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
# Can't used shared examples as this will always trigger the exec when
|
|
|
|
# absent is set.
|
|
|
|
it 'applies the manifest twice with no stderr' do
|
|
|
|
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
|
|
|
|
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/tmp/concat/file') do
|
|
|
|
it { should_not be_file }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-08-08 17:44:31 +02:00
|
|
|
end
|