Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow defining additional Tomcat connectors #205

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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) }
igalic marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
end
end
80 changes: 80 additions & 0 deletions spec/type_aliases/tomcat_connectors_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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| -%>
igalic marked this conversation as resolved.
Show resolved Hide resolved
<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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Confluence::Tomcat_attributes = Hash[String[1], Scalar]
1 change: 1 addition & 0 deletions types/tomcat_connectors.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Confluence::Tomcat_connectors = Hash[Stdlib::Port::Unprivileged, Confluence::Tomcat_attributes]