require 'spec_helper'
describe 'apt::key' do
- let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
- GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+
+ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
+
+ GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
let :title do
GPG_KEY_ID
:id => title,
:ensure => 'present',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:options => nil,
})
:id => GPG_KEY_ID,
:ensure => 'present',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:options => nil,
})
:id => title,
:ensure => 'absent',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:keyserver => nil,
})
:server => '-pgp.mit.edu',
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject.call } .to raise_error(/does not match/)
end
end
:server => '.pgp.mit.edu',
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject.call } .to raise_error(/does not match/)
end
end
:server => "pgp.mit.edu.",
} end
it 'fails' do
- expect { subject } .to raise_error(/does not match/)
+ expect { subject.call } .to raise_error(/does not match/)
end
end
context "exceed character url" do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context "incorrect port number url" do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context "incorrect protocol for url" do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context "missing port number url" do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context "url ending with a dot" do
}
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context "url begin with a dash" do
:server => "hkp://-pgp.mit.edu",
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
context 'invalid key' do
'Out of rum. Why? Why are we out of rum?'
end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
:source => 'afp://puppetlabs.com/key.gpg',
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
:content => [],
} end
it 'fails' do
- expect { subject }.to raise_error(/is not a string/)
+ expect { subject.call }.to raise_error(/is not a string/)
end
end
:server => 'two bottles of rum',
} end
it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ expect { subject.call }.to raise_error(/does not match/)
end
end
:options => {},
} end
it 'fails' do
- expect { subject }.to raise_error(/is not a string/)
+ expect { subject.call }.to raise_error(/is not a string/)
end
end
context 'invalid ensure' do
- let :params do
- {
- :ensure => 'foo',
- }
- end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
+ %w(foo aabsent absenta apresent presenta).each do |param|
+ let :params do
+ {
+ :ensure => param,
+ }
+ end
+ it 'fails' do
+ expect { subject.call }.to raise_error(/does not match/)
+ end
end
end
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
- "apt::key { 'duplicate': id => '#{title}', }"
+ "class { 'apt': }
+ apt::key { 'duplicate': id => '#{title}', }"
end
it 'contains two apt::key resources' do
:id => title,
:ensure => 'present',
:source => nil,
- :server => nil,
+ :server => 'keyserver.ubuntu.com',
:content => nil,
:options => nil,
})
context 'two apt::key resources, different ensure' do
let :pre_condition do
- "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
+ "class { 'apt': }
+ apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
- expect { subject }.to raise_error(/already ensured as absent/)
+ expect { subject.call }.to raise_error(/already ensured as absent/)
end
end
end