| 1 |
# |
| 2 |
# Copyright (C) 2014 Catalyst IT Limited. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
# |
| 16 |
# Author: Ricardo Rocha <[email protected]> |
| 17 |
# |
| 18 |
|
| 19 |
require 'spec_helper' |
| 20 |
|
| 21 |
describe 'ceph::key' do |
| 22 |
let (:pre_condition) do |
| 23 |
"class { 'ceph': fsid => 'foo' }" |
| 24 |
end |
| 25 |
|
| 26 |
shared_examples 'ceph key' do |
| 27 |
describe "with custom params" do |
| 28 |
let :title do |
| 29 |
'client.admin' |
| 30 |
end |
| 31 |
|
| 32 |
let :params do |
| 33 |
{ |
| 34 |
:secret => 'supersecret', |
| 35 |
:user => 'nobody', |
| 36 |
:group => 'nogroup', |
| 37 |
:cap_mon => 'allow *', |
| 38 |
:cap_osd => 'allow rw', |
| 39 |
:cap_mgr => 'allow *', |
| 40 |
:inject => true, |
| 41 |
} |
| 42 |
end |
| 43 |
|
| 44 |
it { |
| 45 |
should contain_exec('ceph-key-client.admin').with( |
| 46 |
'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph-authtool /etc/ceph/ceph.client.admin.keyring --name 'client.admin' --add-key 'supersecret' --cap mon 'allow *' --cap osd 'allow rw' --cap mgr 'allow *' " |
| 47 |
) |
| 48 |
should contain_file('/etc/ceph/ceph.client.admin.keyring').with( |
| 49 |
'owner' => 'nobody', |
| 50 |
'group' => 'nogroup', |
| 51 |
'mode' => '0600', |
| 52 |
'selinux_ignore_defaults' => true, |
| 53 |
) |
| 54 |
should contain_exec('ceph-injectkey-client.admin').with( |
| 55 |
'command' => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph auth import -i /etc/ceph/ceph.client.admin.keyring" |
| 56 |
) |
| 57 |
} |
| 58 |
end |
| 59 |
end |
| 60 |
|
| 61 |
on_supported_os({ |
| 62 |
:supported_os => OSDefaults.get_supported_os |
| 63 |
}).each do |os,facts| |
| 64 |
context "on #{os}" do |
| 65 |
let (:facts) do |
| 66 |
facts.merge!(OSDefaults.get_facts()) |
| 67 |
end |
| 68 |
|
| 69 |
it_behaves_like 'ceph key' |
| 70 |
end |
| 71 |
end |
| 72 |
end |