]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/keystone/spec/classes/keystone_ldap_spec.rb
088526e8697940a6a3956f7d1dbf66a030f3cb39
[dsa-puppet.git] / 3rdparty / modules / keystone / spec / classes / keystone_ldap_spec.rb
1 require 'spec_helper'
2
3 describe 'keystone::ldap' do
4   describe 'with basic params' do
5     let :params do
6       {
7         :url => 'ldap://foo',
8         :user => 'cn=foo,dc=example,dc=com',
9         :password => 'abcdefg',
10         :suffix => 'dc=example,dc=com',
11         :query_scope => 'sub',
12         :page_size => '50',
13         :user_tree_dn => 'cn=users,dc=example,dc=com',
14         :user_filter => '(memberOf=cn=openstack,cn=groups,cn=accounts,dc=example,dc=com)',
15         :user_objectclass => 'inetUser',
16         :user_id_attribute => 'uid',
17         :user_name_attribute => 'cn',
18         :user_mail_attribute => 'mail',
19         :user_enabled_attribute => 'UserAccountControl',
20         :user_enabled_mask => '2',
21         :user_enabled_default => '512',
22         :user_enabled_invert => 'False',
23         :user_attribute_ignore => '',
24         :user_default_project_id_attribute => 'defaultProject',
25         :user_allow_create => 'False',
26         :user_allow_update => 'False',
27         :user_allow_delete => 'False',
28         :user_pass_attribute => 'krbPassword',
29         :user_enabled_emulation => 'True',
30         :user_enabled_emulation_dn => 'cn=openstack-enabled,cn=groups,cn=accounts,dc=example,dc=com',
31         :user_additional_attribute_mapping => 'description:name, gecos:name',
32         :project_tree_dn => 'ou=projects,ou=openstack,dc=example,dc=com',
33         :project_filter => '',
34         :project_objectclass => 'organizationalUnit',
35         :project_id_attribute => 'ou',
36         :project_member_attribute => 'member',
37         :project_desc_attribute => 'description',
38         :project_name_attribute => 'ou',
39         :project_enabled_attribute => 'enabled',
40         :project_domain_id_attribute => 'businessCategory',
41         :project_attribute_ignore => '',
42         :project_allow_create => 'True',
43         :project_allow_update => 'True',
44         :project_allow_delete => 'True',
45         :project_enabled_emulation => 'False',
46         :project_enabled_emulation_dn => 'True',
47         :project_additional_attribute_mapping => 'cn=enabled,ou=openstack,dc=example,dc=com',
48         :role_tree_dn => 'ou=roles,ou=openstack,dc=example,dc=com',
49         :role_filter => '',
50         :role_objectclass => 'organizationalRole',
51         :role_id_attribute => 'cn',
52         :role_name_attribute => 'ou',
53         :role_member_attribute => 'roleOccupant',
54         :role_attribute_ignore => 'description',
55         :role_allow_create => 'True',
56         :role_allow_update => 'True',
57         :role_allow_delete => 'True',
58         :role_additional_attribute_mapping => '',
59         :group_tree_dn => 'ou=groups,ou=openstack,dc=example,dc=com',
60         :group_filter => 'cn=enabled-groups,cn=groups,cn=accounts,dc=example,dc=com',
61         :group_objectclass => 'organizationalRole',
62         :group_id_attribute => 'cn',
63         :group_name_attribute => 'cn',
64         :group_member_attribute => 'roleOccupant',
65         :group_desc_attribute => 'description',
66         :group_attribute_ignore => '',
67         :group_allow_create => 'False',
68         :group_allow_update => 'False',
69         :group_allow_delete => 'False',
70         :group_additional_attribute_mapping => '',
71         :use_tls => 'False',
72         :tls_cacertdir => '/etc/ssl/certs/',
73         :tls_cacertfile => '/etc/ssl/certs/ca-certificates.crt',
74         :tls_req_cert => 'demand',
75         :identity_driver => 'keystone.identity.backends.ldap.Identity',
76         :assignment_driver => 'keystone.assignment.backends.ldap.Assignment',
77         :use_pool => 'True',
78         :pool_size => 20,
79         :pool_retry_max => 2,
80         :pool_retry_delay => 0.2,
81         :pool_connection_timeout => 222,
82         :pool_connection_lifetime => 222,
83         :use_auth_pool => 'True',
84         :auth_pool_size => 20,
85         :auth_pool_connection_lifetime => 200,
86       }
87     end
88     it { should contain_package('python-ldap') }
89     it { should contain_package('python-ldappool') }
90     it 'should have basic params' do
91       # basic params
92       should contain_keystone_config('ldap/url').with_value('ldap://foo')
93       should contain_keystone_config('ldap/user').with_value('cn=foo,dc=example,dc=com')
94       should contain_keystone_config('ldap/password').with_value('abcdefg').with_secret(true)
95       should contain_keystone_config('ldap/suffix').with_value('dc=example,dc=com')
96       should contain_keystone_config('ldap/query_scope').with_value('sub')
97       should contain_keystone_config('ldap/page_size').with_value('50')
98
99       # users
100       should contain_keystone_config('ldap/user_tree_dn').with_value('cn=users,dc=example,dc=com')
101       should contain_keystone_config('ldap/user_filter').with_value('(memberOf=cn=openstack,cn=groups,cn=accounts,dc=example,dc=com)')
102       should contain_keystone_config('ldap/user_objectclass').with_value('inetUser')
103       should contain_keystone_config('ldap/user_id_attribute').with_value('uid')
104       should contain_keystone_config('ldap/user_name_attribute').with_value('cn')
105       should contain_keystone_config('ldap/user_mail_attribute').with_value('mail')
106       should contain_keystone_config('ldap/user_enabled_attribute').with_value('UserAccountControl')
107       should contain_keystone_config('ldap/user_enabled_mask').with_value('2')
108       should contain_keystone_config('ldap/user_enabled_default').with_value('512')
109       should contain_keystone_config('ldap/user_enabled_invert').with_value('False')
110       should contain_keystone_config('ldap/user_attribute_ignore').with_value('')
111       should contain_keystone_config('ldap/user_default_project_id_attribute').with_value('defaultProject')
112       should contain_keystone_config('ldap/user_tree_dn').with_value('cn=users,dc=example,dc=com')
113       should contain_keystone_config('ldap/user_allow_create').with_value('False')
114       should contain_keystone_config('ldap/user_allow_update').with_value('False')
115       should contain_keystone_config('ldap/user_allow_delete').with_value('False')
116       should contain_keystone_config('ldap/user_pass_attribute').with_value('krbPassword')
117       should contain_keystone_config('ldap/user_enabled_emulation').with_value('True')
118       should contain_keystone_config('ldap/user_enabled_emulation_dn').with_value('cn=openstack-enabled,cn=groups,cn=accounts,dc=example,dc=com')
119       should contain_keystone_config('ldap/user_additional_attribute_mapping').with_value('description:name, gecos:name')
120
121       # projects/tenants
122       should contain_keystone_config('ldap/project_tree_dn').with_value('ou=projects,ou=openstack,dc=example,dc=com')
123       should contain_keystone_config('ldap/project_filter').with_value('')
124       should contain_keystone_config('ldap/project_objectclass').with_value('organizationalUnit')
125       should contain_keystone_config('ldap/project_id_attribute').with_value('ou')
126       should contain_keystone_config('ldap/project_member_attribute').with_value('member')
127       should contain_keystone_config('ldap/project_desc_attribute').with_value('description')
128       should contain_keystone_config('ldap/project_name_attribute').with_value('ou')
129       should contain_keystone_config('ldap/project_enabled_attribute').with_value('enabled')
130       should contain_keystone_config('ldap/project_domain_id_attribute').with_value('businessCategory')
131       should contain_keystone_config('ldap/project_attribute_ignore').with_value('')
132       should contain_keystone_config('ldap/project_allow_create').with_value('True')
133       should contain_keystone_config('ldap/project_allow_update').with_value('True')
134       should contain_keystone_config('ldap/project_allow_delete').with_value('True')
135       should contain_keystone_config('ldap/project_enabled_emulation').with_value('False')
136       should contain_keystone_config('ldap/project_enabled_emulation_dn').with_value('True')
137       should contain_keystone_config('ldap/project_additional_attribute_mapping').with_value('cn=enabled,ou=openstack,dc=example,dc=com')
138
139       # roles
140       should contain_keystone_config('ldap/role_tree_dn').with_value('ou=roles,ou=openstack,dc=example,dc=com')
141       should contain_keystone_config('ldap/role_filter').with_value('')
142       should contain_keystone_config('ldap/role_objectclass').with_value('organizationalRole')
143       should contain_keystone_config('ldap/role_id_attribute').with_value('cn')
144       should contain_keystone_config('ldap/role_name_attribute').with_value('ou')
145       should contain_keystone_config('ldap/role_member_attribute').with_value('roleOccupant')
146       should contain_keystone_config('ldap/role_attribute_ignore').with_value('description')
147       should contain_keystone_config('ldap/role_allow_create').with_value('True')
148       should contain_keystone_config('ldap/role_allow_update').with_value('True')
149       should contain_keystone_config('ldap/role_allow_delete').with_value('True')
150       should contain_keystone_config('ldap/role_additional_attribute_mapping').with_value('')
151
152       # groups
153       should contain_keystone_config('ldap/group_tree_dn').with_value('ou=groups,ou=openstack,dc=example,dc=com')
154       should contain_keystone_config('ldap/group_filter').with_value('cn=enabled-groups,cn=groups,cn=accounts,dc=example,dc=com')
155       should contain_keystone_config('ldap/group_objectclass').with_value('organizationalRole')
156       should contain_keystone_config('ldap/group_id_attribute').with_value('cn')
157       should contain_keystone_config('ldap/group_member_attribute').with_value('roleOccupant')
158       should contain_keystone_config('ldap/group_desc_attribute').with_value('description')
159       should contain_keystone_config('ldap/group_name_attribute').with_value('cn')
160       should contain_keystone_config('ldap/group_attribute_ignore').with_value('')
161       should contain_keystone_config('ldap/group_allow_create').with_value('False')
162       should contain_keystone_config('ldap/group_allow_update').with_value('False')
163       should contain_keystone_config('ldap/group_allow_delete').with_value('False')
164       should contain_keystone_config('ldap/group_additional_attribute_mapping').with_value('')
165
166       # tls
167       should contain_keystone_config('ldap/use_tls').with_value('False')
168       should contain_keystone_config('ldap/tls_cacertdir').with_value('/etc/ssl/certs/')
169       should contain_keystone_config('ldap/tls_cacertfile').with_value('/etc/ssl/certs/ca-certificates.crt')
170       should contain_keystone_config('ldap/tls_req_cert').with_value('demand')
171
172       # ldap pooling
173       should contain_keystone_config('ldap/use_pool').with_value('True')
174       should contain_keystone_config('ldap/pool_size').with_value('20')
175       should contain_keystone_config('ldap/pool_retry_max').with_value('2')
176       should contain_keystone_config('ldap/pool_retry_delay').with_value('0.2')
177       should contain_keystone_config('ldap/pool_connection_timeout').with_value('222')
178       should contain_keystone_config('ldap/pool_connection_lifetime').with_value('222')
179       should contain_keystone_config('ldap/use_auth_pool').with_value('True')
180       should contain_keystone_config('ldap/auth_pool_size').with_value('20')
181       should contain_keystone_config('ldap/auth_pool_connection_lifetime').with_value('200')
182
183       # drivers
184       should contain_keystone_config('identity/driver').with_value('keystone.identity.backends.ldap.Identity')
185       should contain_keystone_config('assignment/driver').with_value('keystone.assignment.backends.ldap.Assignment')
186     end
187   end
188
189   describe 'with deprecated params' do
190     let :params do
191       {
192         :tenant_tree_dn => 'ou=projects,ou=openstack,dc=example,dc=com',
193         :tenant_filter => '',
194         :tenant_objectclass => 'organizationalUnit',
195         :tenant_id_attribute => 'ou',
196         :tenant_member_attribute => 'member',
197         :tenant_desc_attribute => 'description',
198         :tenant_name_attribute => 'ou',
199         :tenant_enabled_attribute => 'enabled',
200         :tenant_domain_id_attribute => 'businessCategory',
201         :tenant_attribute_ignore => '',
202         :tenant_allow_create => 'True',
203         :tenant_allow_update => 'True',
204         :tenant_allow_delete => 'True',
205         :tenant_enabled_emulation => 'False',
206         :tenant_enabled_emulation_dn => 'True',
207         :tenant_additional_attribute_mapping => 'cn=enabled,ou=openstack,dc=example,dc=com',
208       }
209     end
210     it 'should work with deprecated params' do
211       should contain_keystone_config('ldap/project_tree_dn').with_value('ou=projects,ou=openstack,dc=example,dc=com')
212       should contain_keystone_config('ldap/project_filter').with_value('')
213       should contain_keystone_config('ldap/project_objectclass').with_value('organizationalUnit')
214       should contain_keystone_config('ldap/project_id_attribute').with_value('ou')
215       should contain_keystone_config('ldap/project_member_attribute').with_value('member')
216       should contain_keystone_config('ldap/project_desc_attribute').with_value('description')
217       should contain_keystone_config('ldap/project_name_attribute').with_value('ou')
218       should contain_keystone_config('ldap/project_enabled_attribute').with_value('enabled')
219       should contain_keystone_config('ldap/project_domain_id_attribute').with_value('businessCategory')
220       should contain_keystone_config('ldap/project_attribute_ignore').with_value('')
221       should contain_keystone_config('ldap/project_allow_create').with_value('True')
222       should contain_keystone_config('ldap/project_allow_update').with_value('True')
223       should contain_keystone_config('ldap/project_allow_delete').with_value('True')
224       should contain_keystone_config('ldap/project_enabled_emulation').with_value('False')
225       should contain_keystone_config('ldap/project_enabled_emulation_dn').with_value('True')
226       should contain_keystone_config('ldap/project_additional_attribute_mapping').with_value('cn=enabled,ou=openstack,dc=example,dc=com')
227     end
228   end
229
230   describe 'with deprecated and new params both set' do
231     let :params do
232       {
233         :tenant_tree_dn  => 'ou=projects,ou=old-openstack,dc=example,dc=com',
234         :project_tree_dn => 'ou=projects,ou=new-openstack,dc=example,dc=com',
235       }
236     end
237     it 'should fail with deprecated and new params both set' do
238         expect {
239             should compile
240         }.to raise_error Puppet::Error, /tenant_tree_dn and project_tree_dn are both set. results may be unexpected/
241     end
242   end
243 end