2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
20 describe 'keystone::resource::service_identity' do
22 let (:title) { 'neutron' }
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' }
32 shared_examples 'keystone::resource::service_identity examples' do
34 context 'with only required parameters' do
39 it { is_expected.to contain_keystone_user(title).with(
41 :password => 'secrete',
42 :email => 'neutron@localhost',
43 :tenant => 'services',
46 it { is_expected.to contain_keystone_user_role("#{title}@services").with(
51 it { is_expected.to contain_keystone_service(title).with(
54 :description => 'neutron service',
57 it { is_expected.to contain_keystone_endpoint("RegionOne/#{title}").with(
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',
65 context 'when omitting a required parameter password' do
67 required_params.delete(:password)
69 it { expect { is_expected.to raise_error(Puppet::Error) } }
72 context 'with user domain' do
74 required_params.merge({:user_domain => 'userdomain'})
76 it { is_expected.to contain_keystone_domain('userdomain').with(
79 it { is_expected.to contain_keystone_user(title).with(
81 :password => 'secrete',
82 :email => 'neutron@localhost',
83 :tenant => 'services',
84 :domain => 'userdomain',
86 it { is_expected.to contain_keystone_user_role("#{title}@services").with(
91 context 'with user and project domain' do
93 required_params.merge({
94 :user_domain => 'userdomain',
95 :project_domain => 'projdomain',
98 it { is_expected.to contain_keystone_user(title).with(
100 :password => 'secrete',
101 :email => 'neutron@localhost',
102 :tenant => 'services',
103 :domain => 'userdomain',
105 it { is_expected.to contain_keystone_domain('userdomain').with(
106 :ensure => 'present',
108 it { is_expected.to contain_keystone_user_role("#{title}@services").with(
109 :ensure => 'present',
113 context 'with default domain only' do
115 required_params.merge({
116 :default_domain => 'defaultdomain',
119 it { is_expected.to contain_keystone_user(title).with(
120 :ensure => 'present',
121 :password => 'secrete',
122 :email => 'neutron@localhost',
123 :tenant => 'services',
124 :domain => 'defaultdomain',
126 it { is_expected.to contain_keystone_domain('defaultdomain').with(
127 :ensure => 'present',
129 it { is_expected.to contain_keystone_user_role("#{title}@services").with(
130 :ensure => 'present',
137 context 'on a Debian osfamily' do
139 { :osfamily => "Debian" }
142 include_examples 'keystone::resource::service_identity examples'
145 context 'on a RedHat osfamily' do
147 { :osfamily => 'RedHat' }
150 include_examples 'keystone::resource::service_identity examples'