|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'awscli::profile', :type => :define do |
| 4 | + context 'supported OS ' do |
| 5 | + ['darwin', 'debian', 'redhat'].each do |osfamily| |
| 6 | + describe "#{osfamily} installation" do |
| 7 | + let(:facts) { { |
| 8 | + :osfamily => osfamily, |
| 9 | + :concat_basedir => '/var/lib/puppet/concat/' |
| 10 | + } } |
| 11 | + |
| 12 | + let(:title) { 'test_profile' } |
| 13 | + |
| 14 | + let(:params) { { } } |
| 15 | + |
| 16 | + it 'should report an error if no aws_access_key_id is given' do |
| 17 | + is_expected.to raise_error(Puppet::Error, /no aws_access_key_id provided/) |
| 18 | + end |
| 19 | + |
| 20 | + it 'should report an error if no aws_secret_access_key is given' do |
| 21 | + params.merge!({ 'aws_access_key_id' => 'TESTAWSACCESSKEYID' }) |
| 22 | + is_expected.to raise_error(Puppet::Error, /no aws_secret_access_key provided/) |
| 23 | + end |
| 24 | + |
| 25 | + it 'should create profile for root if no user is given' do |
| 26 | + params.merge!({ |
| 27 | + 'aws_access_key_id' => 'TESTAWSACCESSKEYID', |
| 28 | + 'aws_secret_access_key' => 'TESTSECRETACCESSKEY' |
| 29 | + }) |
| 30 | + is_expected.to contain_file('/root/.aws').with_ensure('directory') |
| 31 | + is_expected.to contain_concat('/root/.aws/credentials') |
| 32 | + is_expected.to contain_concat__fragment( 'test_profile' ).with |
| 33 | + ({ |
| 34 | + :target => '/root/.aws/credentials' |
| 35 | + }) |
| 36 | + end |
| 37 | + |
| 38 | + it 'should create profile for user test' do |
| 39 | + params.merge!({ |
| 40 | + 'user' => 'test', |
| 41 | + 'aws_access_key_id' => 'TESTAWSACCESSKEYID', |
| 42 | + 'aws_secret_access_key' => 'TESTSECRETACCESSKEY' |
| 43 | + }) |
| 44 | + is_expected.to contain_file('/home/test/.aws').with_ensure('directory') |
| 45 | + is_expected.to contain_concat('/home/test/.aws/credentials') |
| 46 | + is_expected.to contain_concat__fragment( 'test_profile' ).with |
| 47 | + ({ |
| 48 | + :target => '/home/test/.aws/credentials' |
| 49 | + }) |
| 50 | + end |
| 51 | + |
| 52 | + |
| 53 | + end |
| 54 | + end |
| 55 | + end |
| 56 | +end |
0 commit comments