Skip to content

Commit

Permalink
Merge bb1b495 into 9d7eedd
Browse files Browse the repository at this point in the history
  • Loading branch information
antaflos committed Jul 28, 2020
2 parents 9d7eedd + bb1b495 commit 4abb5b0
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 1 deletion.
2 changes: 2 additions & 0 deletions manifests/config.pp
Expand Up @@ -11,6 +11,8 @@
$manage_server_xml = $confluence::manage_server_xml,
$context_path = $confluence::context_path,
$ajp = $confluence::ajp,
# Additional connectors in server.xml
Confluence::Tomcat_connectors $tomcat_additional_connectors = $confluence::tomcat_additional_connectors,
) {

File {
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Expand Up @@ -44,6 +44,8 @@
$context_path = '',
# Options for the AJP connector
Hash $ajp = {},
# Additional connectors in server.xml
Confluence::Tomcat_connectors $tomcat_additional_connectors = {},
# Command to stop confluence in preparation to updgrade. This is configurable
# incase the confluence service is managed outside of puppet. eg: using the
# puppetlabs-corosync module: 'crm resource stop confluence && sleep 15'
Expand Down
48 changes: 48 additions & 0 deletions spec/classes/confluence_config_spec.rb
Expand Up @@ -127,6 +127,54 @@
end
end

context 'tomcat additional connectors' do
let(:params) do
{
version: '5.5.6',
javahome: '/opt/java',
manage_server_xml: 'template',
tomcat_additional_connectors: {
8081 => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '8123',
'secure' => true,
'scheme' => 'https'
},
8082 => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'bar.example.com',
'proxyPort' => '8124',
'scheme' => 'http'
}
}
}
end

it do
is_expected.to contain_file('/opt/confluence/atlassian-confluence-5.5.6/conf/server.xml').
with_content(%r{<Connector port="8081"}).
with_content(%r{connectionTimeout="20000"}).
with_content(%r{protocol="HTTP/1\.1"}).
with_content(%r{proxyName="foo\.example\.com"}).
with_content(%r{proxyPort="8123"}).
with_content(%r{scheme="https"}).
with_content(%r{secure="true"}).
with_content(%r{URIEncoding="UTF-8"}).
with_content(%r{<Connector port="8082"}).
with_content(%r{connectionTimeout="20000"}).
with_content(%r{protocol="HTTP/1\.1"}).
with_content(%r{proxyName="bar\.example\.com"}).
with_content(%r{proxyPort="8124"}).
with_content(%r{scheme="http"}).
with_content(%r{URIEncoding="UTF-8"})
end
end

context 'catalina_opts set to a string' do
let(:params) do
{
Expand Down
51 changes: 51 additions & 0 deletions spec/type_aliases/tomcat_attributes_spec.rb
@@ -0,0 +1,51 @@
require 'spec_helper'

describe 'Confluence::Tomcat_attributes' do
describe 'valid attributes' do
[
{ 'URIEncoding' => 'UTF-8' },
{ 'secure' => true },
{ 'proxyPort' => 8443 },
{
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '8123',
'secure' => true,
'scheme' => 'https'
},
{}
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end
end

describe 'invalid attributes' do
context 'with garbage inputs' do
[
{ %w[foo blah] => 'bar' },
{ true => 'false' },
{ 'proxyPort' => %w[8443 1234] },
{ 'schema' => { 'https' => 'false' } },
true,
false,
:keyword,
nil,
%w[yes no],
'',
'ネット',
'55555',
'0x123',
'yess',
'nooo'
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end
80 changes: 80 additions & 0 deletions spec/type_aliases/tomcat_connectors_spec.rb
@@ -0,0 +1,80 @@
require 'spec_helper'

describe 'Confluence::Tomcat_connectors' do
describe 'valid connector specifications' do
[
{
8081 => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '80',
'secure' => false,
'scheme' => 'http'
},
8443 => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '443',
'secure' => true,
'scheme' => 'https'
}
}
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end
end

describe 'invalid connector specifications' do
context 'with garbage inputs' do
[
{
'8081' => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '80',
'secure' => false,
'scheme' => 'http'
}
},
{
1023 => {
'URIEncoding' => 'UTF-8',
'connectionTimeout' => '20000',
'protocol' => 'HTTP/1.1',
'proxyName' => 'foo.example.com',
'proxyPort' => '80',
'secure' => false,
'scheme' => 'http'
}
},
{ %w[foo blah] => 'bar' },
{ true => 'false' },
{ 'proxyPort' => %w[8443 1234] },
{ 'schema' => { 'https' => 'false' } },
true,
false,
:keyword,
nil,
%w[yes no],
'',
'ネット',
'55555',
'0x123',
'yess',
'nooo'
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end
11 changes: 10 additions & 1 deletion templates/server.xml.erb
Expand Up @@ -16,7 +16,7 @@
<% @tomcat_proxy.sort.each do |key,value| -%>
<%= key %>=<%= "\"#{value}\"" %>
<% end -%>
<% end -%>
<% end -%>
/>

<% if @ajp and ! @ajp.empty? -%>
Expand All @@ -25,6 +25,15 @@
<%= key %> = <%= "\"#{value}\"" %>
<% end -%>
/>
<% end -%>
<% if @tomcat_additional_connectors and ! @tomcat_additional_connectors.empty? -%>
<% @tomcat_additional_connectors.sort.map do |port, attrs| -%>
<Connector port="<%= port -%>"
<% attrs.sort.map do |key, value| -%>
<%= key -%>="<%= value -%>"
<% end -%>
/>
<% end -%>
<% end -%>

<Engine name="Standalone" defaultHost="localhost" debug="0">
Expand Down
1 change: 1 addition & 0 deletions types/tomcat_attributes.pp
@@ -0,0 +1 @@
type Confluence::Tomcat_attributes = Hash[String[1], Scalar]
1 change: 1 addition & 0 deletions types/tomcat_connectors.pp
@@ -0,0 +1 @@
type Confluence::Tomcat_connectors = Hash[Stdlib::Port::Unprivileged, Confluence::Tomcat_attributes]

0 comments on commit 4abb5b0

Please sign in to comment.