]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/spec/defines/keystone_resource_service_identity_spec.rb
d7d0a62c5ac771ad5705e2c5fe883545c5249c67
[dsa-puppet.git] / 3rdparty / modules / keystone / spec / defines / keystone_resource_service_identity_spec.rb
1 #
2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17
18 require 'spec_helper'
19
20 describe 'keystone::resource::service_identity' do
21
22   let (:title) { 'neutron' }
23
24   let :required_params do
25     { :password     => 'secrete',
26       :service_type => 'network',
27       :admin_url    => 'http://192.168.0.1:9696',
28       :internal_url => 'http://10.0.0.1:9696',
29       :public_url   => 'http://7.7.7.7:9696' }
30   end
31
32   shared_examples 'keystone::resource::service_identity examples' do
33
34     context 'with only required parameters' do
35       let :params do
36         required_params
37       end
38
39       it { should contain_keystone_user(title).with(
40         :ensure   => 'present',
41         :password => 'secrete',
42         :email    => 'neutron@localhost',
43         :tenant   => 'services',
44       )}
45
46       it { should contain_keystone_user_role("#{title}@services").with(
47         :ensure => 'present',
48         :roles  => 'admin',
49       )}
50
51       it { should contain_keystone_service(title).with(
52         :ensure      => 'present',
53         :type        => 'network',
54         :description => 'neutron service',
55       )}
56
57       it { should contain_keystone_endpoint("RegionOne/#{title}").with(
58         :ensure       => 'present',
59         :public_url   => 'http://7.7.7.7:9696',
60         :internal_url => 'http://10.0.0.1:9696',
61         :admin_url    => 'http://192.168.0.1:9696',
62       )}
63     end
64
65     context 'when omitting a required parameter password' do
66       let :params do
67         required_params.delete(:password)
68       end
69       it { expect { should raise_error(Puppet::Error) } }
70     end
71
72   end
73
74   context 'on a Debian osfamily' do
75     let :facts do
76       { :osfamily => "Debian" }
77     end
78
79     include_examples 'keystone::resource::service_identity examples'
80   end
81
82   context 'on a RedHat osfamily' do
83     let :facts do
84       { :osfamily => 'RedHat' }
85     end
86
87     include_examples 'keystone::resource::service_identity examples'
88   end
89 end