OSDN Git Service

openldap-grid-0.2.1
[metasearch/grid-chef-repo.git] / cookbooks / openldap-grid / spec / recipes / client_spec.rb
1 #
2 # Cookbook Name:: openldap
3 # Recipe Spec:: client_spec
4 #
5 # Copyright 2015, whitestar
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 require_relative '../spec_helper'
21
22 describe 'openldap::client' do
23   let(:chef_run_on_debian) {
24     ChefSpec::SoloRunner.new(platform: 'debian', version: '7.6') {|node|
25       node.set['openldap']['client']['URI'] = 'ldap://ldap.example.com'
26       node.set['openldap']['client']['BASE'] = 'dc=example,dc=com'
27     }.converge(described_recipe)
28   }
29
30   it 'installs ldap-utils package on debian family.' do
31     expect(chef_run_on_debian).to install_package('ldap-utils')
32   end
33
34   it 'renders /etc/ldap/ldap.conf on debian family.' do
35     expected = expect(chef_run_on_debian)
36     expected.to render_file('/etc/ldap/ldap.conf')
37       .with_content(%r{^URI\s+ldap://ldap\.example\.com$})
38     expected.to render_file('/etc/ldap/ldap.conf')
39       .with_content(/^BASE\s+dc=example,dc=com$/)
40   end
41
42   let(:chef_run_on_rhel) {
43     ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0') {|node|
44       node.set['openldap']['client']['URI'] = 'ldap://ldap.example.com'
45       node.set['openldap']['client']['BASE'] = 'dc=example,dc=com'
46     }.converge(described_recipe)
47   }
48
49   it 'installs openldap-clients on rhel family.' do
50     expect(chef_run_on_rhel).to install_package('openldap-clients')
51   end
52
53   it 'renders /etc/openldap/ldap.conf on rhel family.' do
54     expected = expect(chef_run_on_rhel)
55     expected.to render_file('/etc/openldap/ldap.conf')
56       .with_content(%r{^URI\s+ldap://ldap\.example\.com$})
57     expected.to render_file('/etc/openldap/ldap.conf')
58       .with_content(/^BASE\s+dc=example,dc=com$/)
59   end
60 end