6 { 'secret_key' => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
15 File.expand_path(File.join(__FILE__, '..', '..', 'fixtures'))
19 { :concat_basedir => '/var/lib/puppet/concat',
20 :fqdn => 'some.host.tld'
24 shared_examples 'horizon' do
26 context 'with default parameters' do
28 should contain_package('python-lesscpy').with_ensure('present')
29 should contain_package('horizon').with_ensure('present')
31 it { should contain_exec('refresh_horizon_django_cache').with({
32 :command => '/usr/share/openstack-dashboard/manage.py compress',
35 it { should contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
37 it 'configures apache' do
38 should contain_class('horizon::wsgi::apache').with({
39 :servername => 'some.host.tld',
41 :servername => 'some.host.tld',
46 it 'generates local_settings.py' do
47 verify_contents(subject, platforms_params[:config_file], [
49 "ALLOWED_HOSTS = ['*', ]",
50 "SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'",
51 'OPENSTACK_KEYSTONE_URL = "http://127.0.0.1:5000/v2.0"',
52 'OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_"',
53 " 'can_set_mount_point': True,",
54 " 'can_set_password': False,",
55 " 'enable_lb': False,",
56 " 'enable_firewall': False,",
57 " 'enable_quotas': True,",
58 " 'enable_security_group': True,",
59 " 'enable_vpn': False,",
60 'API_RESULT_LIMIT = 1000',
61 "LOGIN_URL = '#{platforms_params[:root_url]}/auth/login/'",
62 "LOGOUT_URL = '#{platforms_params[:root_url]}/auth/logout/'",
63 "LOGIN_REDIRECT_URL = '#{platforms_params[:root_url]}'",
64 'COMPRESS_OFFLINE = True',
65 "FILE_UPLOAD_TEMP_DIR = '/tmp'"
68 # From internals of verify_contents, get the contents to check for absence of a line
69 content = subject.resource('file', platforms_params[:config_file]).send(:parameters)[:content]
71 # With default options, should _not_ have a line to configure SESSION_ENGINE
72 content.should_not match(/^SESSION_ENGINE/)
75 it { should_not contain_file(params[:file_upload_temp_dir]) }
78 context 'with overridden parameters' do
81 :cache_server_ip => '10.0.0.1',
82 :django_session_engine => 'django.contrib.sessions.backends.cache',
83 :keystone_default_role => 'SwiftOperator',
84 :keystone_url => 'https://keystone.example.com:4682',
85 :openstack_endpoint_type => 'internalURL',
86 :secondary_endpoint_type => 'ANY-VALUE',
87 :django_debug => true,
88 :api_result_limit => 4682,
89 :compress_offline => false,
90 :hypervisor_options => {'can_set_mount_point' => false, 'can_set_password' => true },
91 :cinder_options => {'enable_backup' => true },
92 :neutron_options => {'enable_lb' => true, 'enable_firewall' => true, 'enable_quotas' => false, 'enable_security_group' => false, 'enable_vpn' => true, 'profile_support' => 'cisco' },
93 :file_upload_temp_dir => '/var/spool/horizon',
94 :secure_cookies => true
98 it 'generates local_settings.py' do
99 verify_contents(subject, platforms_params[:config_file], [
101 "ALLOWED_HOSTS = ['*', ]",
102 'CSRF_COOKIE_SECURE = True',
103 'SESSION_COOKIE_SECURE = True',
104 "SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'",
105 " 'LOCATION': '10.0.0.1:11211',",
106 'SESSION_ENGINE = "django.contrib.sessions.backends.cache"',
107 'OPENSTACK_KEYSTONE_URL = "https://keystone.example.com:4682"',
108 'OPENSTACK_KEYSTONE_DEFAULT_ROLE = "SwiftOperator"',
109 " 'can_set_mount_point': False,",
110 " 'can_set_password': True,",
111 " 'enable_backup': True,",
112 " 'enable_lb': True,",
113 " 'enable_firewall': True,",
114 " 'enable_quotas': False,",
115 " 'enable_security_group': False,",
116 " 'enable_vpn': True,",
117 " 'profile_support': 'cisco',",
118 'OPENSTACK_ENDPOINT_TYPE = "internalURL"',
119 'SECONDARY_ENDPOINT_TYPE = "ANY-VALUE"',
120 'API_RESULT_LIMIT = 4682',
121 'COMPRESS_OFFLINE = False',
122 "FILE_UPLOAD_TEMP_DIR = '/var/spool/horizon'"
126 it { should_not contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
128 it { should contain_file(params[:file_upload_temp_dir]) }
131 context 'with overridden parameters and cache_server_ip array' do
134 :cache_server_ip => ['10.0.0.1','10.0.0.2'],
138 it 'generates local_settings.py' do
139 verify_contents(subject, platforms_params[:config_file], [
140 " 'LOCATION': [ '10.0.0.1:11211','10.0.0.2:11211', ],",
144 it { should contain_exec('refresh_horizon_django_cache') }
147 context 'with deprecated parameters' do
150 :keystone_host => 'keystone.example.com',
151 :keystone_port => 4682,
152 :keystone_scheme => 'https',
153 :can_set_mount_point => true,
157 it 'generates local_settings.py' do
158 verify_contents(subject, platforms_params[:config_file], [
159 'OPENSTACK_KEYSTONE_URL = "https://keystone.example.com:4682/v2.0"',
160 " 'can_set_mount_point': True,"
165 context 'with vhost_extra_params' do
168 :vhost_extra_params => { 'add_listen' => false },
172 it 'configures apache' do
173 should contain_class('horizon::wsgi::apache').with({
174 :extra_params => { 'add_listen' => false },
180 context 'with ssl enabled' do
184 :servername => 'some.host.tld',
185 :horizon_cert => '/etc/pki/tls/certs/httpd.crt',
186 :horizon_key => '/etc/pki/tls/private/httpd.key',
187 :horizon_ca => '/etc/pki/tls/certs/ca.crt',
191 it 'configures apache' do
192 should contain_class('horizon::wsgi::apache').with({
193 :bind_address => nil,
195 :horizon_cert => '/etc/pki/tls/certs/httpd.crt',
196 :horizon_key => '/etc/pki/tls/private/httpd.key',
197 :horizon_ca => '/etc/pki/tls/certs/ca.crt',
202 context 'without apache' do
204 params.merge!({ :configure_apache => false })
207 it 'does not configure apache' do
208 should_not contain_class('horizon::wsgi::apache')
212 context 'with available_regions parameter' do
215 :available_regions => [
216 ['http://region-1.example.com:5000/v2.0', 'Region-1'],
217 ['http://region-2.example.com:5000/v2.0', 'Region-2']
222 it 'AVAILABLE_REGIONS is configured' do
223 verify_contents(subject, platforms_params[:config_file], [
224 "AVAILABLE_REGIONS = [",
225 " ('http://region-1.example.com:5000/v2.0', 'Region-1'),",
226 " ('http://region-2.example.com:5000/v2.0', 'Region-2'),",
232 context 'with policy parameters' do
235 :policy_files_path => '/opt/openstack-dashboard',
237 'compute' => 'nova_policy.json',
238 'identity' => 'keystone_policy.json',
239 'network' => 'neutron_policy.json',
244 it 'POLICY_FILES_PATH and POLICY_FILES are configured' do
245 verify_contents(subject, platforms_params[:config_file], [
246 "POLICY_FILES_PATH = '/opt/openstack-dashboard'",
248 " 'compute': 'nova_policy.json',",
249 " 'identity': 'keystone_policy.json',",
250 " 'network': 'neutron_policy.json',",
256 context 'with overriding local_settings_template' do
259 :django_debug => 'True',
260 :help_url => 'https://docs.openstack.org',
261 :local_settings_template => fixtures_path + '/override_local_settings.py.erb'
265 it 'uses the custom local_settings.py template' do
266 verify_contents(subject, platforms_params[:config_file], [
267 '# Custom local_settings.py',
269 "HORIZON_CONFIG = {",
270 " 'dashboards': ('project', 'admin', 'settings',),",
271 " 'default_dashboard': 'project',",
272 " 'user_home': 'openstack_dashboard.views.get_user_home',",
273 " 'ajax_queue_limit': 10,",
274 " 'auto_fade_alerts': {",
276 " 'fade_duration': 1500,",
277 " 'types': ['alert-success', 'alert-info']",
279 " 'help_url': \"https://docs.openstack.org\",",
280 " 'exceptions': {'recoverable': exceptions.RECOVERABLE,",
281 " 'not_found': exceptions.NOT_FOUND,",
282 " 'unauthorized': exceptions.UNAUTHORIZED},",
288 context 'with /var/tmp as upload temp dir' do
291 :file_upload_temp_dir => '/var/tmp'
295 it { should_not contain_file(params[:file_upload_temp_dir]) }
299 context 'on RedHat platforms' do
302 :osfamily => 'RedHat',
303 :operatingsystemrelease => '6.0'
307 let :platforms_params do
308 { :config_file => '/etc/openstack-dashboard/local_settings',
309 :package_name => 'openstack-dashboard',
310 :root_url => '/dashboard' }
313 it_behaves_like 'horizon'
316 context 'on Debian platforms' do
319 :osfamily => 'Debian',
320 :operatingsystemrelease => '6.0'
324 let :platforms_params do
325 { :config_file => '/etc/openstack-dashboard/local_settings.py',
326 :package_name => 'openstack-dashboard-apache',
327 :root_url => '/horizon' }
330 it_behaves_like 'horizon'