starting rocky development patch

Change-Id: I8319b6d356c2233237e7308823e7899b09edf413
This commit is contained in:
Samuel Cassiba 2018-08-03 06:23:26 -07:00
parent 1852e73c10
commit 7c1cf9c575
7 changed files with 140 additions and 119 deletions

View File

@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml
AllCops: AllCops:
Include: Include:
- metadata.rb - metadata.rb

19
.rubocop_todo.yml Normal file
View File

@ -0,0 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-08-03 05:25:55 -0700 using RuboCop version 0.55.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 3
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'recipes/apache2-server.rb'
# Offense count: 260
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 249

View File

@ -9,6 +9,6 @@ source 'https://supermarket.chef.io'
end end
cookbook 'openstackclient', cookbook 'openstackclient',
github: 'cloudbau/cookbook-openstackclient' git: 'https://git.openstack.org/openstack/cookbook-openstackclient'
metadata metadata

View File

@ -4,14 +4,14 @@ maintainer_email 'openstack-dev@lists.openstack.org'
license 'Apache-2.0' license 'Apache-2.0'
description 'Installs/Configures the OpenStack Dashboard (Horizon)' description 'Installs/Configures the OpenStack Dashboard (Horizon)'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '17.0.0' version '18.0.0'
%w(ubuntu redhat centos).each do |os| %w(ubuntu redhat centos).each do |os|
supports os supports os
end end
depends 'openstack-common', '>= 17.0.0' depends 'openstack-common', '>= 18.0.0'
depends 'openstack-identity', '>= 17.0.0' depends 'openstack-identity', '>= 18.0.0'
depends 'apache2' depends 'apache2'
depends 'poise-python' depends 'poise-python'

View File

@ -38,7 +38,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'does not mess with certs if ssl not enabled' do it 'does not mess with certs if ssl not enabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem')
expect(chef_run).not_to create_file('/etc/pki/tls/private/horizon.key') expect(chef_run).not_to create_file('/etc/pki/tls/private/horizon.key')
end end

View File

@ -4,7 +4,7 @@ require_relative 'spec_helper'
shared_examples 'virtualhost port configurator' do |port_attribute_name, port_attribute_value| shared_examples 'virtualhost port configurator' do |port_attribute_name, port_attribute_value|
let(:virtualhost_directive) { "<VirtualHost 0.0.0.0:#{port_attribute_value}>" } let(:virtualhost_directive) { "<VirtualHost 0.0.0.0:#{port_attribute_value}>" }
before do before do
node.set['openstack']['endpoints'][port_attribute_name]['port'] = port_attribute_value node.override['openstack']['endpoints'][port_attribute_name]['port'] = port_attribute_value
end end
it 'does not set NameVirtualHost directives when apache 2.4' do it 'does not set NameVirtualHost directives when apache 2.4' do
@ -17,26 +17,26 @@ shared_examples 'virtualhost port configurator' do |port_attribute_name, port_at
context 'server_hostname' do context 'server_hostname' do
it 'sets the value if the server_hostname is present' do it 'sets the value if the server_hostname is present' do
node.set['openstack']['dashboard']['server_hostname'] = 'server_hostname_value' node.override['openstack']['dashboard']['server_hostname'] = 'server_hostname_value'
expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerName server_hostname_value$/) expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerName server_hostname_value$/)
end end
it 'does not set the value if the server_hostname is not present' do it 'does not set the value if the server_hostname is not present' do
node.set['openstack']['dashboard']['server_hostname'] = nil node.override['openstack']['dashboard']['server_hostname'] = nil
expect(chef_run).not_to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerName$/) expect(chef_run).not_to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerName$/)
end end
end end
context 'server_aliases' do context 'server_aliases' do
it 'sets the value if the server_aliases is present' do it 'sets the value if the server_aliases is present' do
node.set['openstack']['dashboard']['server_aliases'] = %w(server_aliases_value) node.override['openstack']['dashboard']['server_aliases'] = %w(server_aliases_value)
expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias server_aliases_value$/) expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias server_aliases_value$/)
end end
it 'sets the value if multiple server_aliases is present' do it 'sets the value if multiple server_aliases is present' do
node.set['openstack']['dashboard']['server_aliases'] = %w(server_aliases_value1 server_aliases_value2) node.override['openstack']['dashboard']['server_aliases'] = %w(server_aliases_value1 server_aliases_value2)
expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias server_aliases_value1 server_aliases_value2$/) expect(chef_run).to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias server_aliases_value1 server_aliases_value2$/)
end end
it 'does not set the value if the server_aliases is not present' do it 'does not set the value if the server_aliases is not present' do
node.set['openstack']['dashboard']['server_hostname'] = [] node.override['openstack']['dashboard']['server_hostname'] = []
expect(chef_run).not_to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias$/) expect(chef_run).not_to render_file(file.name).with_content(/^#{virtualhost_directive}\s*ServerAlias$/)
end end
end end
@ -51,7 +51,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
let(:chef_run_session_sql) do let(:chef_run_session_sql) do
node.set['openstack']['dashboard']['session_backend'] = 'sql' node.override['openstack']['dashboard']['session_backend'] = 'sql'
runner.converge(described_recipe) runner.converge(described_recipe)
end end
include_context 'non_redhat_stubs' include_context 'non_redhat_stubs'
@ -77,7 +77,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'does not include the apache mod_ssl package when ssl disabled' do it 'does not include the apache mod_ssl package when ssl disabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
expect(chef_run).not_to include_recipe('apache2::mod_ssl') expect(chef_run).not_to include_recipe('apache2::mod_ssl')
end end
@ -110,7 +110,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
context 'set ssl chain' do context 'set ssl chain' do
before do before do
node.set['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem'
end end
let(:chain) { chef_run.file('/etc/ssl/certs/horizon-chain.pem') } let(:chain) { chef_run.file('/etc/ssl/certs/horizon-chain.pem') }
@ -128,7 +128,7 @@ describe 'openstack-dashboard::apache2-server' do
let(:key) { chef_run.file('/etc/ssl/private/horizon.pem') } let(:key) { chef_run.file('/etc/ssl/private/horizon.pem') }
before do before do
node.set['openstack']['dashboard']['ssl'].tap do |ssl| node.override['openstack']['dashboard']['ssl'].tap do |ssl|
ssl['cert_dir'] = ssl['key_dir'] = '/etc/ssl/private' ssl['cert_dir'] = ssl['key_dir'] = '/etc/ssl/private'
ssl['cert'] = ssl['key'] = 'horizon.pem' ssl['cert'] = ssl['key'] = 'horizon.pem'
end end
@ -155,8 +155,8 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'does not mess with certs if ssl not enabled' do it 'does not mess with certs if ssl not enabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
node.set['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem'
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem')
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.key') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.key')
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon-chain.pem') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon-chain.pem')
@ -168,17 +168,17 @@ describe 'openstack-dashboard::apache2-server' do
let(:key) { chef_run.file('/etc/anypath/any.key') } let(:key) { chef_run.file('/etc/anypath/any.key') }
before do before do
node.set['openstack']['dashboard']['ssl']['cert_dir'] = '/etc/anypath' node.override['openstack']['dashboard']['ssl']['cert_dir'] = '/etc/anypath'
node.set['openstack']['dashboard']['ssl']['key_dir'] = '/etc/anypath' node.override['openstack']['dashboard']['ssl']['key_dir'] = '/etc/anypath'
node.set['openstack']['dashboard']['ssl']['cert'] = 'any.pem' node.override['openstack']['dashboard']['ssl']['cert'] = 'any.pem'
node.set['openstack']['dashboard']['ssl']['key'] = 'any.key' node.override['openstack']['dashboard']['ssl']['key'] = 'any.key'
allow_any_instance_of(Chef::Recipe).to receive(:secret) allow_any_instance_of(Chef::Recipe).to receive(:secret)
.with('certs', 'any.pem') .with('certs', 'any.pem')
.and_return('any_pem_value') .and_return('any_pem_value')
allow_any_instance_of(Chef::Recipe).to receive(:secret) allow_any_instance_of(Chef::Recipe).to receive(:secret)
.with('certs', 'any.key') .with('certs', 'any.key')
.and_return('any_key_value') .and_return('any_key_value')
node.set['openstack']['dashboard'] node.override['openstack']['dashboard']
end end
it 'create files and restarts apache' do it 'create files and restarts apache' do
expect(chef_run).to create_file('/etc/anypath/any.pem').with( expect(chef_run).to create_file('/etc/anypath/any.pem').with(
@ -199,7 +199,7 @@ describe 'openstack-dashboard::apache2-server' do
context 'set ssl chain' do context 'set ssl chain' do
let(:chain) { chef_run.file('/etc/anypath/any-chain.pem') } let(:chain) { chef_run.file('/etc/anypath/any-chain.pem') }
before do before do
node.set['openstack']['dashboard']['ssl']['chain'] = 'any-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'any-chain.pem'
allow_any_instance_of(Chef::Recipe).to receive(:secret) allow_any_instance_of(Chef::Recipe).to receive(:secret)
.with('certs', 'any-chain.pem') .with('certs', 'any-chain.pem')
.and_return('any_chain_pem_value') .and_return('any_chain_pem_value')
@ -215,14 +215,14 @@ describe 'openstack-dashboard::apache2-server' do
end end
end end
it 'does not mess with certs if ssl not enabled' do it 'does not mess with certs if ssl not enabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
expect(chef_run).not_to create_file('/etc/anypath/any.key') expect(chef_run).not_to create_file('/etc/anypath/any.key')
expect(chef_run).not_to create_file('/etc/anypath/any.pem') expect(chef_run).not_to create_file('/etc/anypath/any.pem')
expect(chef_run).not_to create_file('/etc/anypath/any-chain.pem') expect(chef_run).not_to create_file('/etc/anypath/any-chain.pem')
end end
it 'does not create certs if certs data bag is disabled' do it 'does not create certs if certs data bag is disabled' do
node.set['openstack']['dashboard']['ssl']['use_data_bag'] = false node.override['openstack']['dashboard']['ssl']['use_data_bag'] = false
node.set['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem'
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.pem')
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.key') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon.key')
expect(chef_run).not_to create_file('/etc/ssl/certs/horizon-chain.pem') expect(chef_run).not_to create_file('/etc/ssl/certs/horizon-chain.pem')
@ -252,7 +252,7 @@ describe 'openstack-dashboard::apache2-server' do
let(:default_rewrite_rule) { %r(^\s*RewriteRule \^\(\.\*\)\$ https\://%\{HTTP_HOST\}%\{REQUEST_URI\} \[L,R\]$) } let(:default_rewrite_rule) { %r(^\s*RewriteRule \^\(\.\*\)\$ https\://%\{HTTP_HOST\}%\{REQUEST_URI\} \[L,R\]$) }
it 'has the default banner' do it 'has the default banner' do
node.set['openstack']['dashboard']['custom_template_banner'] = 'custom_template_banner_value' node.override['openstack']['dashboard']['custom_template_banner'] = 'custom_template_banner_value'
expect(chef_run).to render_file(file.name).with_content(/^custom_template_banner_value$/) expect(chef_run).to render_file(file.name).with_content(/^custom_template_banner_value$/)
end end
@ -264,7 +264,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'allows html page caching' do it 'allows html page caching' do
node.set['openstack']['dashboard']['cache_html'] = true node.override['openstack']['dashboard']['cache_html'] = true
expect(chef_run).not_to render_file(file.name).with_content(%r{^\s*SetEnvIfExpr "req\('accept'\) =~/html/" NO_CACHE$}) expect(chef_run).not_to render_file(file.name).with_content(%r{^\s*SetEnvIfExpr "req\('accept'\) =~/html/" NO_CACHE$})
expect(chef_run).not_to render_file(file.name).with_content(/^\s*Header merge Cache-Control no-cache env=NO_CACHE$/) expect(chef_run).not_to render_file(file.name).with_content(/^\s*Header merge Cache-Control no-cache env=NO_CACHE$/)
expect(chef_run).not_to render_file(file.name).with_content(/^\s*Header merge Cache-Control no-store env=NO_CACHE$/) expect(chef_run).not_to render_file(file.name).with_content(/^\s*Header merge Cache-Control no-store env=NO_CACHE$/)
@ -275,7 +275,7 @@ describe 'openstack-dashboard::apache2-server' do
context 'with use_ssl enabled' do context 'with use_ssl enabled' do
before do before do
node.set['openstack']['dashboard']['use_ssl'] = true node.override['openstack']['dashboard']['use_ssl'] = true
end end
it_should_behave_like 'virtualhost port configurator', 'dashboard-https-bind', 443 it_should_behave_like 'virtualhost port configurator', 'dashboard-https-bind', 443
@ -286,23 +286,23 @@ describe 'openstack-dashboard::apache2-server' do
context 'rewrite rule' do context 'rewrite rule' do
it 'shows the default SSL rewrite rule when http_port is 80 and https_port is 443' do it 'shows the default SSL rewrite rule when http_port is 80 and https_port is 443' do
node.set['openstack']['bind_service']['dashboard_http']['port'] = 80 node.override['openstack']['bind_service']['dashboard_http']['port'] = 80
node.set['openstack']['bind_service']['dashboard_https']['port'] = 443 node.override['openstack']['bind_service']['dashboard_https']['port'] = 443
expect(chef_run).to render_file(file.name).with_content(default_rewrite_rule) expect(chef_run).to render_file(file.name).with_content(default_rewrite_rule)
end end
it 'shows the parameterized SSL rewrite rule when http_port is different from 80' do it 'shows the parameterized SSL rewrite rule when http_port is different from 80' do
https_port_value = 443 https_port_value = 443
node.set['openstack']['bind_service']['dashboard_http']['port'] = 81 node.override['openstack']['bind_service']['dashboard_http']['port'] = 81
node.set['openstack']['bind_service']['dashboard_https']['port'] = https_port_value node.override['openstack']['bind_service']['dashboard_https']['port'] = https_port_value
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(%r{^\s*RewriteRule \^\(\.\*\)\$ https://%\{SERVER_NAME\}:#{https_port_value}%\{REQUEST_URI\} \[L,R\]$}) .with_content(%r{^\s*RewriteRule \^\(\.\*\)\$ https://%\{SERVER_NAME\}:#{https_port_value}%\{REQUEST_URI\} \[L,R\]$})
end end
it 'shows the parameterized SSL rewrite rule when https_port is different from 443' do it 'shows the parameterized SSL rewrite rule when https_port is different from 443' do
https_port_value = 444 https_port_value = 444
node.set['openstack']['bind_service']['dashboard_http']['port'] = 80 node.override['openstack']['bind_service']['dashboard_http']['port'] = 80
node.set['openstack']['bind_service']['dashboard_https']['port'] = https_port_value node.override['openstack']['bind_service']['dashboard_https']['port'] = https_port_value
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(%r{^\s*RewriteRule \^\(\.\*\)\$ https://%\{SERVER_NAME\}:#{https_port_value}%\{REQUEST_URI\} \[L,R\]$}) .with_content(%r{^\s*RewriteRule \^\(\.\*\)\$ https://%\{SERVER_NAME\}:#{https_port_value}%\{REQUEST_URI\} \[L,R\]$})
end end
@ -320,14 +320,14 @@ describe 'openstack-dashboard::apache2-server' do
end end
context 'set ssl chain' do context 'set ssl chain' do
it 'shows chain directive' do it 'shows chain directive' do
node.set['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem'
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(%r{^\s*SSLCertificateChainFile /etc/ssl/certs/horizon-chain.pem$}) .with_content(%r{^\s*SSLCertificateChainFile /etc/ssl/certs/horizon-chain.pem$})
end end
end end
context 'set use_data_bag to false' do context 'set use_data_bag to false' do
it 'shows ssl certificate related directives defaults' do it 'shows ssl certificate related directives defaults' do
node.set['openstack']['dashboard']['ssl']['use_data_bag'] = false node.override['openstack']['dashboard']['ssl']['use_data_bag'] = false
[/^\s*SSLEngine on$/, [/^\s*SSLEngine on$/,
%r{^\s*SSLCertificateFile /etc/ssl/certs/horizon.pem$}, %r{^\s*SSLCertificateFile /etc/ssl/certs/horizon.pem$},
%r{^\s*SSLCertificateKeyFile /etc/ssl/private/horizon.key$}, %r{^\s*SSLCertificateKeyFile /etc/ssl/private/horizon.key$},
@ -339,8 +339,8 @@ describe 'openstack-dashboard::apache2-server' do
end end
context 'set ssl chain' do context 'set ssl chain' do
it 'shows chain directive' do it 'shows chain directive' do
node.set['openstack']['dashboard']['ssl']['use_data_bag'] = false node.override['openstack']['dashboard']['ssl']['use_data_bag'] = false
node.set['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem' node.override['openstack']['dashboard']['ssl']['chain'] = 'horizon-chain.pem'
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(%r{^\s*SSLCertificateChainFile /etc/ssl/certs/horizon-chain.pem$}) .with_content(%r{^\s*SSLCertificateChainFile /etc/ssl/certs/horizon-chain.pem$})
end end
@ -358,12 +358,12 @@ describe 'openstack-dashboard::apache2-server' do
allow_any_instance_of(Chef::Recipe).to receive(:secret) allow_any_instance_of(Chef::Recipe).to receive(:secret)
.with('certs', 'ssl.key') .with('certs', 'ssl.key')
.and_return('ssl_key_value') .and_return('ssl_key_value')
node.set['openstack']['dashboard']['ssl']['cert'] = 'ssl.cert' node.override['openstack']['dashboard']['ssl']['cert'] = 'ssl.cert'
node.set['openstack']['dashboard']['ssl']['key'] = 'ssl.key' node.override['openstack']['dashboard']['ssl']['key'] = 'ssl.key'
node.set['openstack']['dashboard']['ssl']['cert_dir'] = 'ssl_dir_value/certs' node.override['openstack']['dashboard']['ssl']['cert_dir'] = 'ssl_dir_value/certs'
node.set['openstack']['dashboard']['ssl']['key_dir'] = 'ssl_dir_value/private' node.override['openstack']['dashboard']['ssl']['key_dir'] = 'ssl_dir_value/private'
node.set['openstack']['dashboard']['ssl']['protocol'] = 'ssl_protocol_value' node.override['openstack']['dashboard']['ssl']['protocol'] = 'ssl_protocol_value'
node.set['openstack']['dashboard']['ssl']['ciphers'] = 'ssl_ciphers_value' node.override['openstack']['dashboard']['ssl']['ciphers'] = 'ssl_ciphers_value'
end end
it 'shows ssl related directives overrides' do it 'shows ssl related directives overrides' do
[/^\s*SSLEngine on$/, [/^\s*SSLEngine on$/,
@ -380,7 +380,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
context 'with use_ssl disabled' do context 'with use_ssl disabled' do
before do before do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
end end
it 'does not show rewrite ssl directive' do it 'does not show rewrite ssl directive' do
@ -388,8 +388,8 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'does not show the default rewrite rule' do it 'does not show the default rewrite rule' do
node.set['openstack']['endpoints']['dashboard-http-bind']['port'] = 80 node.override['openstack']['endpoints']['dashboard-http-bind']['port'] = 80
node.set['openstack']['endpoints']['dashboard-https-bind']['port'] = 443 node.override['openstack']['endpoints']['dashboard-https-bind']['port'] = 443
expect(chef_run).not_to render_file(file.name).with_content(default_rewrite_rule) expect(chef_run).not_to render_file(file.name).with_content(default_rewrite_rule)
end end
@ -405,7 +405,7 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'shows the ServerAdmin' do it 'shows the ServerAdmin' do
node.set['apache']['contact'] = 'apache_contact_value' node.override['apache']['contact'] = 'apache_contact_value'
expect(chef_run).to render_file(file.name).with_content(/\s*ServerAdmin apache_contact_value$/) expect(chef_run).to render_file(file.name).with_content(/\s*ServerAdmin apache_contact_value$/)
end end
@ -414,40 +414,40 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'sets the WSGI script alias' do it 'sets the WSGI script alias' do
node.set['openstack']['dashboard']['wsgi_path'] = 'wsgi_path_value' node.override['openstack']['dashboard']['wsgi_path'] = 'wsgi_path_value'
node.set['openstack']['dashboard']['webroot'] = 'root' node.override['openstack']['dashboard']['webroot'] = 'root'
expect(chef_run).to render_file(file.name).with_content(/^\s*WSGIScriptAlias root wsgi_path_value$/) expect(chef_run).to render_file(file.name).with_content(/^\s*WSGIScriptAlias root wsgi_path_value$/)
end end
it 'sets the WSGI daemon process' do it 'sets the WSGI daemon process' do
node.set['openstack']['dashboard']['horizon_user'] = 'horizon_user_value' node.override['openstack']['dashboard']['horizon_user'] = 'horizon_user_value'
node.set['openstack']['dashboard']['horizon_group'] = 'horizon_group_value' node.override['openstack']['dashboard']['horizon_group'] = 'horizon_group_value'
node.set['openstack']['dashboard']['dash_path'] = 'dash_path_value' node.override['openstack']['dashboard']['dash_path'] = 'dash_path_value'
expect(chef_run).to render_file(file.name).with_content( expect(chef_run).to render_file(file.name).with_content(
/^\s*WSGIDaemonProcess dashboard user=horizon_user_value group=horizon_group_value processes=3 threads=10 python-path=dash_path_value$/ /^\s*WSGIDaemonProcess dashboard user=horizon_user_value group=horizon_group_value processes=3 threads=10 python-path=dash_path_value$/
) )
end end
it 'has the default DocRoot' do it 'has the default DocRoot' do
node.set['openstack']['dashboard']['dash_path'] = 'dash_path_value' node.override['openstack']['dashboard']['dash_path'] = 'dash_path_value'
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(%r{\s*DocumentRoot dash_path_value/.blackhole/$}) .with_content(%r{\s*DocumentRoot dash_path_value/.blackhole/$})
end end
it 'has TraceEnable set' do it 'has TraceEnable set' do
node.set['openstack']['dashboard']['traceenable'] = 'value' node.override['openstack']['dashboard']['traceenable'] = 'value'
expect(chef_run).to render_file(file.name) expect(chef_run).to render_file(file.name)
.with_content(/^ TraceEnable value$/) .with_content(/^ TraceEnable value$/)
end end
it 'sets the right Alias path for /static' do it 'sets the right Alias path for /static' do
node.set['openstack']['dashboard']['static_path'] = 'static_path_value' node.override['openstack']['dashboard']['static_path'] = 'static_path_value'
expect(chef_run).to render_file(file.name).with_content(%r{^\s+Alias /static static_path_value$}) expect(chef_run).to render_file(file.name).with_content(%r{^\s+Alias /static static_path_value$})
end end
%w(dash_path static_path).each do |dir_attribute| %w(dash_path static_path).each do |dir_attribute|
it "sets the #{dir_attribute} directory directive" do it "sets the #{dir_attribute} directory directive" do
node.set['openstack']['dashboard'][dir_attribute] = "#{dir_attribute}_value" node.override['openstack']['dashboard'][dir_attribute] = "#{dir_attribute}_value"
expect(chef_run).to render_file(file.name).with_content(/^\s*<Directory #{dir_attribute}_value>$/) expect(chef_run).to render_file(file.name).with_content(/^\s*<Directory #{dir_attribute}_value>$/)
end end
end end
@ -460,27 +460,27 @@ describe 'openstack-dashboard::apache2-server' do
context 'log directives' do context 'log directives' do
before do before do
node.set['apache']['log_dir'] = 'log_dir_value' node.override['apache']['log_dir'] = 'log_dir_value'
end end
it 'sets de ErrorLog directive' do it 'sets de ErrorLog directive' do
node.set['openstack']['dashboard']['error_log'] = 'error_log_value' node.override['openstack']['dashboard']['error_log'] = 'error_log_value'
expect(chef_run).to render_file(file.name).with_content(%r{^\s*ErrorLog log_dir_value/error_log_value$}) expect(chef_run).to render_file(file.name).with_content(%r{^\s*ErrorLog log_dir_value/error_log_value$})
end end
it 'sets de CustomLog directive' do it 'sets de CustomLog directive' do
node.set['openstack']['dashboard']['access_log'] = 'access_log_value' node.override['openstack']['dashboard']['access_log'] = 'access_log_value'
expect(chef_run).to render_file(file.name).with_content(%r{^\s*CustomLog log_dir_value/access_log_value combined$}) expect(chef_run).to render_file(file.name).with_content(%r{^\s*CustomLog log_dir_value/access_log_value combined$})
end end
end end
it 'sets wsgi socket prefix if wsgi_socket_prefix attribute is preset' do it 'sets wsgi socket prefix if wsgi_socket_prefix attribute is preset' do
node.set['openstack']['dashboard']['wsgi_socket_prefix'] = '/var/run/wsgi' node.override['openstack']['dashboard']['wsgi_socket_prefix'] = '/var/run/wsgi'
expect(chef_run).to render_file(file.name).with_content(%r{^WSGISocketPrefix /var/run/wsgi$}) expect(chef_run).to render_file(file.name).with_content(%r{^WSGISocketPrefix /var/run/wsgi$})
end end
it 'omits wsgi socket prefix if wsgi_socket_prefix attribute is not preset' do it 'omits wsgi socket prefix if wsgi_socket_prefix attribute is not preset' do
node.set['openstack']['dashboard']['wsgi_socket_prefix'] = nil node.override['openstack']['dashboard']['wsgi_socket_prefix'] = nil
expect(chef_run).not_to render_file(file.name).with_content(/^WSGISocketPrefix $/) expect(chef_run).not_to render_file(file.name).with_content(/^WSGISocketPrefix $/)
end end
end end
@ -508,9 +508,9 @@ describe 'openstack-dashboard::apache2-server' do
end end
it 'has configurable path and ownership settings' do it 'has configurable path and ownership settings' do
node.set['openstack']['dashboard']['secret_key_path'] = 'somerandompath' node.override['openstack']['dashboard']['secret_key_path'] = 'somerandompath'
node.set['openstack']['dashboard']['horizon_user'] = 'somerandomuser' node.override['openstack']['dashboard']['horizon_user'] = 'somerandomuser'
node.set['openstack']['dashboard']['horizon_group'] = 'somerandomgroup' node.override['openstack']['dashboard']['horizon_group'] = 'somerandomgroup'
file = chef_run.file('somerandompath') file = chef_run.file('somerandompath')
expect(file.owner).to eq('somerandomuser') expect(file.owner).to eq('somerandomuser')
expect(file.group).to eq('somerandomgroup') expect(file.group).to eq('somerandomgroup')
@ -518,7 +518,7 @@ describe 'openstack-dashboard::apache2-server' do
describe 'secret_key_content set' do describe 'secret_key_content set' do
before do before do
node.set['openstack']['dashboard']['secret_key_content'] = 'somerandomcontent' node.override['openstack']['dashboard']['secret_key_content'] = 'somerandomcontent'
end end
it 'has configurable secret_key_content setting' do it 'has configurable secret_key_content setting' do

View File

@ -10,7 +10,7 @@ describe 'openstack-dashboard::horizon' do
end end
let(:chef_run_session_sql) do let(:chef_run_session_sql) do
node.set['openstack']['dashboard']['session_backend'] = 'sql' node.override['openstack']['dashboard']['session_backend'] = 'sql'
runner.converge(described_recipe) runner.converge(described_recipe)
end end
@ -41,13 +41,13 @@ describe 'openstack-dashboard::horizon' do
context 'template contents' do context 'template contents' do
it 'has the customer banner' do it 'has the customer banner' do
node.set['openstack']['dashboard']['custom_template_banner'] = 'custom_template_banner_value' node.override['openstack']['dashboard']['custom_template_banner'] = 'custom_template_banner_value'
expect(chef_run).to render_file(file.name).with_content(/^custom_template_banner_value$/) expect(chef_run).to render_file(file.name).with_content(/^custom_template_banner_value$/)
end end
context 'misc settings' do context 'misc settings' do
before do before do
node.set['openstack']['dashboard']['misc_local_settings'] = { node.override['openstack']['dashboard']['misc_local_settings'] = {
'CUSTOM_CONFIG_A' => { 'CUSTOM_CONFIG_A' => {
'variable1' => 'value1', 'variable1' => 'value1',
'variable2' => 'value2', 'variable2' => 'value2',
@ -78,7 +78,7 @@ describe 'openstack-dashboard::horizon' do
context 'debug setting' do context 'debug setting' do
context 'set to true' do context 'set to true' do
before do before do
node.set['openstack']['dashboard']['debug'] = true node.override['openstack']['dashboard']['debug'] = true
end end
it 'has a true value for the DEBUG attribute' do it 'has a true value for the DEBUG attribute' do
@ -92,7 +92,7 @@ describe 'openstack-dashboard::horizon' do
context 'set to false' do context 'set to false' do
before do before do
node.set['openstack']['dashboard']['debug'] = false node.override['openstack']['dashboard']['debug'] = false
end end
it 'has a false value for the DEBUG attribute' do it 'has a false value for the DEBUG attribute' do
@ -114,7 +114,7 @@ describe 'openstack-dashboard::horizon' do
context 'set to False' do context 'set to False' do
before do before do
node.set['openstack']['dashboard']['ssl_no_verify'] = 'False' node.override['openstack']['dashboard']['ssl_no_verify'] = 'False'
end end
it 'has a False value for the OPENSTACK_SSL_NO_VERIFY attribute' do it 'has a False value for the OPENSTACK_SSL_NO_VERIFY attribute' do
@ -124,25 +124,25 @@ describe 'openstack-dashboard::horizon' do
context 'not set when ssl disabled' do context 'not set when ssl disabled' do
it 'has a True value for the OPENSTACK_SSL_NO_VERIFY attribute' do it 'has a True value for the OPENSTACK_SSL_NO_VERIFY attribute' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
expect(chef_run).not_to render_file(file.name).with_content(/^OPENSTACK_SSL_NO_VERIFY = True$/) expect(chef_run).not_to render_file(file.name).with_content(/^OPENSTACK_SSL_NO_VERIFY = True$/)
end end
end end
end end
it 'config ssl_cacert' do it 'config ssl_cacert' do
node.set['openstack']['dashboard']['ssl_cacert'] = '/path_to_cacert.pem' node.override['openstack']['dashboard']['ssl_cacert'] = '/path_to_cacert.pem'
expect(chef_run).to render_file(file.name).with_content(%r{^OPENSTACK_SSL_CACERT = '/path_to_cacert.pem'$}) expect(chef_run).to render_file(file.name).with_content(%r{^OPENSTACK_SSL_CACERT = '/path_to_cacert.pem'$})
end end
it 'does not config ssl_cacert when ssl disabled' do it 'does not config ssl_cacert when ssl disabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
node.set['openstack']['dashboard']['ssl_cacert'] = '/path_to_cacert.pem' node.override['openstack']['dashboard']['ssl_cacert'] = '/path_to_cacert.pem'
expect(chef_run).not_to render_file(file.name).with_content(%r{^OPENSTACK_SSL_CACERT = '/path_to_cacert.pem'$}) expect(chef_run).not_to render_file(file.name).with_content(%r{^OPENSTACK_SSL_CACERT = '/path_to_cacert.pem'$})
end end
it 'has some allowed hosts set' do it 'has some allowed hosts set' do
node.set['openstack']['dashboard']['allowed_hosts'] = ['dashboard.example.net'] node.override['openstack']['dashboard']['allowed_hosts'] = ['dashboard.example.net']
expect(chef_run).to render_file(file.name).with_content(/^ALLOWED_HOSTS = \["dashboard.example.net"\]$/) expect(chef_run).to render_file(file.name).with_content(/^ALLOWED_HOSTS = \["dashboard.example.net"\]$/)
end end
@ -155,7 +155,7 @@ describe 'openstack-dashboard::horizon' do
context 'set to sha256' do context 'set to sha256' do
before do before do
node.set['openstack']['dashboard']['hash_algorithm'] = 'sha256' node.override['openstack']['dashboard']['hash_algorithm'] = 'sha256'
end end
it 'has a sha256 value for the OPENSTACK_TOKEN_HASH_ALGORITHM attribute' do it 'has a sha256 value for the OPENSTACK_TOKEN_HASH_ALGORITHM attribute' do
@ -167,12 +167,12 @@ describe 'openstack-dashboard::horizon' do
context 'ssl offload' do context 'ssl offload' do
let(:secure_proxy_string) { 'SECURE_PROXY_SSL_HEADER = \(\'HTTP_X_FORWARDED_PROTOCOL\', \'https\'\)' } let(:secure_proxy_string) { 'SECURE_PROXY_SSL_HEADER = \(\'HTTP_X_FORWARDED_PROTOCOL\', \'https\'\)' }
it 'does not configure ssl proxy when ssl_offload is false' do it 'does not configure ssl proxy when ssl_offload is false' do
node.set['openstack']['dashboard']['ssl_offload'] = false node.override['openstack']['dashboard']['ssl_offload'] = false
expect(chef_run).not_to render_file(file.name).with_content(/^#{secure_proxy_string}$/) expect(chef_run).not_to render_file(file.name).with_content(/^#{secure_proxy_string}$/)
end end
it 'configures ssl proxy when ssl_offload is set to true' do it 'configures ssl proxy when ssl_offload is set to true' do
node.set['openstack']['dashboard']['ssl_offload'] = true node.override['openstack']['dashboard']['ssl_offload'] = true
expect(chef_run).to render_file(file.name).with_content(/^#{secure_proxy_string}$/) expect(chef_run).to render_file(file.name).with_content(/^#{secure_proxy_string}$/)
end end
end end
@ -180,11 +180,11 @@ describe 'openstack-dashboard::horizon' do
context 'temp dir override' do context 'temp dir override' do
context 'temp dir is nil' do context 'temp dir is nil' do
it 'does not override temp dir when it is nil' do it 'does not override temp dir when it is nil' do
node.set['openstack']['dashboard']['file_upload_temp_dir'] = nil node.override['openstack']['dashboard']['file_upload_temp_dir'] = nil
expect(chef_run).not_to render_file(file.name).with_content(/^FILE_UPLOAD_TEMP_DIR =/) expect(chef_run).not_to render_file(file.name).with_content(/^FILE_UPLOAD_TEMP_DIR =/)
end end
it 'does override temp dir when it is not nil' do it 'does override temp dir when it is not nil' do
node.set['openstack']['dashboard']['file_upload_temp_dir'] = '/foobar' node.override['openstack']['dashboard']['file_upload_temp_dir'] = '/foobar'
expect(chef_run).to render_file(file.name).with_content(%r{^FILE_UPLOAD_TEMP_DIR = "/foobar"$}) expect(chef_run).to render_file(file.name).with_content(%r{^FILE_UPLOAD_TEMP_DIR = "/foobar"$})
end end
end end
@ -193,36 +193,36 @@ describe 'openstack-dashboard::horizon' do
context 'ssl settings' do context 'ssl settings' do
context 'use_ssl enabled' do context 'use_ssl enabled' do
before do before do
node.set['openstack']['dashboard']['use_ssl'] = true node.override['openstack']['dashboard']['use_ssl'] = true
end end
context 'csrf_cookie_secure setting' do context 'csrf_cookie_secure setting' do
it 'sets secure csrf cookie to true when the attribute is enabled' do it 'sets secure csrf cookie to true when the attribute is enabled' do
node.set['openstack']['dashboard']['csrf_cookie_secure'] = true node.override['openstack']['dashboard']['csrf_cookie_secure'] = true
expect(chef_run).to render_file(file.name).with_content(/^CSRF_COOKIE_SECURE = True$/) expect(chef_run).to render_file(file.name).with_content(/^CSRF_COOKIE_SECURE = True$/)
end end
it 'sets secure csrf cookie to false when the attribute is disabled' do it 'sets secure csrf cookie to false when the attribute is disabled' do
node.set['openstack']['dashboard']['csrf_cookie_secure'] = false node.override['openstack']['dashboard']['csrf_cookie_secure'] = false
expect(chef_run).to render_file(file.name).with_content(/^CSRF_COOKIE_SECURE = False$/) expect(chef_run).to render_file(file.name).with_content(/^CSRF_COOKIE_SECURE = False$/)
end end
end end
context 'session_cookie_secure setting' do context 'session_cookie_secure setting' do
it 'set secure csrf cookie to true when the sttribute is enabled' do it 'set secure csrf cookie to true when the sttribute is enabled' do
node.set['openstack']['dashboard']['session_cookie_secure'] = true node.override['openstack']['dashboard']['session_cookie_secure'] = true
expect(chef_run).to render_file(file.name).with_content(/^SESSION_COOKIE_SECURE = True$/) expect(chef_run).to render_file(file.name).with_content(/^SESSION_COOKIE_SECURE = True$/)
end end
it 'set secure csrf cookie to false when the sttribute is disabled' do it 'set secure csrf cookie to false when the sttribute is disabled' do
node.set['openstack']['dashboard']['session_cookie_secure'] = false node.override['openstack']['dashboard']['session_cookie_secure'] = false
expect(chef_run).to render_file(file.name).with_content(/^SESSION_COOKIE_SECURE = False$/) expect(chef_run).to render_file(file.name).with_content(/^SESSION_COOKIE_SECURE = False$/)
end end
end end
end end
it 'does not set secure csrf nor secure session cookie settings when use_ssl is disabled' do it 'does not set secure csrf nor secure session cookie settings when use_ssl is disabled' do
node.set['openstack']['dashboard']['use_ssl'] = false node.override['openstack']['dashboard']['use_ssl'] = false
[/^CSRF_COOKIE_SECURE$/, /^SESSION_COOKIE_SECURE$/].each do |setting| [/^CSRF_COOKIE_SECURE$/, /^SESSION_COOKIE_SECURE$/].each do |setting|
expect(chef_run).not_to render_file(file.name).with_content(setting) expect(chef_run).not_to render_file(file.name).with_content(setting)
end end
@ -250,8 +250,8 @@ describe 'openstack-dashboard::horizon' do
context 'identity and volume api version setting' do context 'identity and volume api version setting' do
it 'is configurable directly' do it 'is configurable directly' do
node.set['openstack']['dashboard']['identity_api_version'] = 'identity_api_version_value' node.override['openstack']['dashboard']['identity_api_version'] = 'identity_api_version_value'
node.set['openstack']['dashboard']['volume_api_version'] = 'volume_api_version_value' node.override['openstack']['dashboard']['volume_api_version'] = 'volume_api_version_value'
[ [
/^\s*"identity": identity_api_version_value,$/, /^\s*"identity": identity_api_version_value,$/,
/^\s*"volume": volume_api_version_value$/, /^\s*"volume": volume_api_version_value$/,
@ -261,7 +261,7 @@ describe 'openstack-dashboard::horizon' do
end end
it 'sets the proper value for identity v3.0 with volume default v2 from common attributes' do it 'sets the proper value for identity v3.0 with volume default v2 from common attributes' do
node.set['openstack']['api']['auth']['version'] = 'v3.0' node.override['openstack']['api']['auth']['version'] = 'v3.0'
[ [
/^\s*"identity": 3,$/, /^\s*"identity": 3,$/,
/^\s*"volume": 2$/, /^\s*"volume": 2$/,
@ -273,29 +273,29 @@ describe 'openstack-dashboard::horizon' do
context 'keystone multidomain support' do context 'keystone multidomain support' do
it 'sets to true when the attribute is enabled' do it 'sets to true when the attribute is enabled' do
node.set['openstack']['dashboard']['keystone_multidomain_support'] = true node.override['openstack']['dashboard']['keystone_multidomain_support'] = true
expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True$/) expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True$/)
end end
it 'sets to false when the attribute is disabled' do it 'sets to false when the attribute is disabled' do
node.set['openstack']['dashboard']['keystone_multidomain_support'] = false node.override['openstack']['dashboard']['keystone_multidomain_support'] = false
expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = False$/) expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = False$/)
end end
end end
it 'has a keystone default domain setting if identity api version is 3' do it 'has a keystone default domain setting if identity api version is 3' do
node.set['openstack']['dashboard']['identity_api_version'] = 3 node.override['openstack']['dashboard']['identity_api_version'] = 3
node.set['openstack']['dashboard']['keystone_default_domain'] = 'keystone_default_domain_value' node.override['openstack']['dashboard']['keystone_default_domain'] = 'keystone_default_domain_value'
expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "keystone_default_domain_value"$/) expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "keystone_default_domain_value"$/)
end end
it 'has a console_type setting' do it 'has a console_type setting' do
node.set['openstack']['dashboard']['console_type'] = 'console_type_value' node.override['openstack']['dashboard']['console_type'] = 'console_type_value'
expect(chef_run).to render_file(file.name).with_content(/^CONSOLE_TYPE = "console_type_value"$/) expect(chef_run).to render_file(file.name).with_content(/^CONSOLE_TYPE = "console_type_value"$/)
end end
it 'has a help_url setting' do it 'has a help_url setting' do
node.set['openstack']['dashboard']['help_url'] = 'help_url_value' node.override['openstack']['dashboard']['help_url'] = 'help_url_value'
expect(chef_run).to render_file(file.name).with_content(/\s*'help_url': "help_url_value",$/) expect(chef_run).to render_file(file.name).with_content(/\s*'help_url': "help_url_value",$/)
end end
@ -306,29 +306,29 @@ describe 'openstack-dashboard::horizon' do
context 'simple ip management' do context 'simple ip management' do
it 'enables the setting when the attribute is set' do it 'enables the setting when the attribute is set' do
node.set['openstack']['dashboard']['simple_ip_management'] = true node.override['openstack']['dashboard']['simple_ip_management'] = true
expect(chef_run).to render_file(file.name).with_content('HORIZON_CONFIG["simple_ip_management"] = True') expect(chef_run).to render_file(file.name).with_content('HORIZON_CONFIG["simple_ip_management"] = True')
end end
it 'disables the setting when the attribute is not set' do it 'disables the setting when the attribute is not set' do
node.set['openstack']['dashboard']['simple_ip_management'] = false node.override['openstack']['dashboard']['simple_ip_management'] = false
expect(chef_run).to render_file(file.name).with_content('HORIZON_CONFIG["simple_ip_management"] = False') expect(chef_run).to render_file(file.name).with_content('HORIZON_CONFIG["simple_ip_management"] = False')
end end
end end
it 'has default password_autocomplete setting' do it 'has default password_autocomplete setting' do
node.set['openstack']['dashboard']['password_autocomplete'] = 'password_autocomplete_value' node.override['openstack']['dashboard']['password_autocomplete'] = 'password_autocomplete_value'
expect(chef_run).to render_file(file.name).with_content(/^HORIZON_CONFIG\["password_autocomplete"\] = "password_autocomplete_value"$/) expect(chef_run).to render_file(file.name).with_content(/^HORIZON_CONFIG\["password_autocomplete"\] = "password_autocomplete_value"$/)
end end
it 'has configurable secret_key_path setting' do it 'has configurable secret_key_path setting' do
node.set['openstack']['dashboard']['secret_key_path'] = 'secret_key_path_value' node.override['openstack']['dashboard']['secret_key_path'] = 'secret_key_path_value'
expect(chef_run).to render_file(file.name).with_content(/^SECRET_KEY = secret_key.generate_or_read_from_file\(os.path.realpath\('secret_key_path_value'\)\)$/) expect(chef_run).to render_file(file.name).with_content(/^SECRET_KEY = secret_key.generate_or_read_from_file\(os.path.realpath\('secret_key_path_value'\)\)$/)
end end
context 'session backend' do context 'session backend' do
it 'sets the session engine to file when it is the session backend' do it 'sets the session engine to file when it is the session backend' do
node.set['openstack']['dashboard']['session_backend'] = 'file' node.override['openstack']['dashboard']['session_backend'] = 'file'
expect(chef_run).to render_file(file.name).with_content(/^SESSION_ENGINE = 'django.contrib.sessions.backends.file'$/) expect(chef_run).to render_file(file.name).with_content(/^SESSION_ENGINE = 'django.contrib.sessions.backends.file'$/)
end end
@ -358,7 +358,7 @@ describe 'openstack-dashboard::horizon' do
end end
it 'sets the session engine to db when sql is the session backend' do it 'sets the session engine to db when sql is the session backend' do
node.set['openstack']['dashboard']['session_backend'] = 'sql' node.override['openstack']['dashboard']['session_backend'] = 'sql'
expect(chef_run).to render_file(file.name).with_content(/^SESSION_ENGINE = 'django.contrib.sessions.backends.db'$/) expect(chef_run).to render_file(file.name).with_content(/^SESSION_ENGINE = 'django.contrib.sessions.backends.db'$/)
end end
end end
@ -368,26 +368,26 @@ describe 'openstack-dashboard::horizon' do
end end
it 'has a keystone default role' do it 'has a keystone default role' do
node.set['openstack']['dashboard']['keystone_default_role'] = 'keystone_default_role_value' node.override['openstack']['dashboard']['keystone_default_role'] = 'keystone_default_role_value'
expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_DEFAULT_ROLE = "keystone_default_role_value"$/) expect(chef_run).to render_file(file.name).with_content(/^OPENSTACK_KEYSTONE_DEFAULT_ROLE = "keystone_default_role_value"$/)
end end
context 'keystone_backend settings' do context 'keystone_backend settings' do
%w(native ldap).each do |keystone_backend_name| %w(native ldap).each do |keystone_backend_name|
it "sets the backend name to #{keystone_backend_name}" do it "sets the backend name to #{keystone_backend_name}" do
node.set['openstack']['dashboard']['keystone_backend']['name'] = keystone_backend_name node.override['openstack']['dashboard']['keystone_backend']['name'] = keystone_backend_name
expect(chef_run).to render_file(file.name).with_content(/^\s*'name': '#{keystone_backend_name}',$/) expect(chef_run).to render_file(file.name).with_content(/^\s*'name': '#{keystone_backend_name}',$/)
end end
end end
%w(can_edit_user can_edit_group can_edit_project can_edit_domain can_edit_role).each do |keystone_setting| %w(can_edit_user can_edit_group can_edit_project can_edit_domain can_edit_role).each do |keystone_setting|
it "enables the #{keystone_setting} keystone backend setting when the attribute is True" do it "enables the #{keystone_setting} keystone backend setting when the attribute is True" do
node.set['openstack']['dashboard']['keystone_backend'][keystone_setting] = true node.override['openstack']['dashboard']['keystone_backend'][keystone_setting] = true
expect(chef_run).to render_file(file.name).with_content(/^\s*\'#{keystone_setting}\': True,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*\'#{keystone_setting}\': True,$/)
end end
it "disables the #{keystone_setting} keystone backend setting when the attribute is False" do it "disables the #{keystone_setting} keystone backend setting when the attribute is False" do
node.set['openstack']['dashboard']['keystone_backend'][keystone_setting] = false node.override['openstack']['dashboard']['keystone_backend'][keystone_setting] = false
expect(chef_run).to render_file(file.name).with_content(/^\s*\'#{keystone_setting}\': False,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*\'#{keystone_setting}\': False,$/)
end end
end end
@ -395,21 +395,21 @@ describe 'openstack-dashboard::horizon' do
context 'neutron settings' do context 'neutron settings' do
it 'enables the enable_quotas setting when the attributes is True' do it 'enables the enable_quotas setting when the attributes is True' do
node.set['openstack']['dashboard']['neutron']['enable_quotas'] = true node.override['openstack']['dashboard']['neutron']['enable_quotas'] = true
expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_quotas': True,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_quotas': True,$/)
end end
it 'disables the enable_quotas setting when the attributes is False' do it 'disables the enable_quotas setting when the attributes is False' do
node.set['openstack']['dashboard']['neutron']['enable_quotas'] = false node.override['openstack']['dashboard']['neutron']['enable_quotas'] = false
expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_quotas': False,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_quotas': False,$/)
end end
context 'lbaas setting' do context 'lbaas setting' do
it 'enables the enable_lb setting when the attribute is true' do it 'enables the enable_lb setting when the attribute is true' do
node.set['openstack']['dashboard']['neutron']['enable_lb'] = true node.override['openstack']['dashboard']['neutron']['enable_lb'] = true
expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_lb': True,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_lb': True,$/)
end end
it 'disables the enable_lb setting when the attribute is falase' do it 'disables the enable_lb setting when the attribute is falase' do
node.set['openstack']['dashboard']['neutron']['enable_lb'] = false node.override['openstack']['dashboard']['neutron']['enable_lb'] = false
expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_lb': False,$/) expect(chef_run).to render_file(file.name).with_content(/^\s*'enable_lb': False,$/)
end end
end end
@ -419,7 +419,7 @@ describe 'openstack-dashboard::horizon' do
glanceclient neutronclient heatclient ceilometerclient troveclient glanceclient neutronclient heatclient ceilometerclient troveclient
swiftclient openstack_auth nose.plugins.manager django).each do |component| swiftclient openstack_auth nose.plugins.manager django).each do |component|
it "sets the logger level for #{component}" do it "sets the logger level for #{component}" do
node.set['openstack']['dashboard']['log_level'][component] = "#{component}_log_level_value" node.override['openstack']['dashboard']['log_level'][component] = "#{component}_log_level_value"
expect(chef_run).to render_file(file.name).with_content( expect(chef_run).to render_file(file.name).with_content(
/^\s*'#{component}': {\s*'handlers': \['console'\],\s*'level': '#{component}_log_level_value',$/ /^\s*'#{component}': {\s*'handlers': \['console'\],\s*'level': '#{component}_log_level_value',$/
) )
@ -436,8 +436,8 @@ describe 'openstack-dashboard::horizon' do
'db_name' => "#{service_type}_db", 'db_name' => "#{service_type}_db",
'host' => "#{service_type}_host", 'host' => "#{service_type}_host",
'port' => "#{service_type}_port") 'port' => "#{service_type}_port")
node.set['openstack']['db']['dashboard']['username'] = "#{service_type}_user" node.override['openstack']['db']['dashboard']['username'] = "#{service_type}_user"
node.set['openstack']['db']['python_packages'][service_type] = ['pkg1', 'pkg2'] node.override['openstack']['db']['python_packages'][service_type] = ['pkg1', 'pkg2']
end end
[/^\s*'ENGINE': '#{backend}',$/, [/^\s*'ENGINE': '#{backend}',$/,
@ -464,7 +464,7 @@ describe 'openstack-dashboard::horizon' do
context 'plugins enabled' do context 'plugins enabled' do
let(:plugins) { %w(testPlugin1 testPlugin2) } let(:plugins) { %w(testPlugin1 testPlugin2) }
before do before do
node.set['openstack']['dashboard']['plugins'] = plugins node.override['openstack']['dashboard']['plugins'] = plugins
end end
it 'shows the mod setting' do it 'shows the mod setting' do
@ -479,7 +479,7 @@ describe 'openstack-dashboard::horizon' do
end end
it 'does not show the mod setting if there are no plugins' do it 'does not show the mod setting if there are no plugins' do
node.set['openstack']['dashboard']['plugins'] = nil node.override['openstack']['dashboard']['plugins'] = nil
expect(chef_run).not_to render_file(file.name).with_content(mod_regex) expect(chef_run).not_to render_file(file.name).with_content(mod_regex)
end end
end end
@ -509,7 +509,7 @@ describe 'openstack-dashboard::horizon' do
end end
it 'does not execute when the migrate attribute is set to false' do it 'does not execute when the migrate attribute is set to false' do
node.set['openstack']['db']['dashboard']['migrate'] = false node.override['openstack']['db']['dashboard']['migrate'] = false
expect(chef_run_session_sql).not_to run_execute(sync_db_cmd).with( expect(chef_run_session_sql).not_to run_execute(sync_db_cmd).with(
cwd: node['openstack']['dashboard']['django_path'], cwd: node['openstack']['dashboard']['django_path'],
environment: sync_db_environment environment: sync_db_environment
@ -517,7 +517,7 @@ describe 'openstack-dashboard::horizon' do
end end
it 'executes when database backend is sqlite' do it 'executes when database backend is sqlite' do
node.set['openstack']['db']['dashboard']['service_type'] = 'sqlite' node.override['openstack']['db']['dashboard']['service_type'] = 'sqlite'
expect(chef_run_session_sql).to run_execute(sync_db_cmd).with( expect(chef_run_session_sql).to run_execute(sync_db_cmd).with(
cwd: node['openstack']['dashboard']['django_path'], cwd: node['openstack']['dashboard']['django_path'],
environment: sync_db_environment environment: sync_db_environment