@@ -68,6 +68,214 @@ def self.clear_cache
6868
6969 it { is_expected . not_to contain_file ( FILENAME_CLUSTER_PROPS ) }
7070 it { is_expected . not_to contain_file ( FILENAME_CHECK_JAVA_SH ) }
71+
72+ # Test web.xml management with default values
73+ it do
74+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
75+ with_changes ( [ 'set session-config/session-timeout/#text 300' ] )
76+ end
77+
78+ it 'removes HTTPS redirect when disabled' do
79+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
80+ with_changes ( [ 'rm security-constraint[user-data-constraint/transport-guarantee/#text="CONFIDENTIAL"]' ] ) .
81+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size > 0' )
82+ end
83+ end
84+
85+ context 'with enable_https_redirect' do
86+ let ( :params ) do
87+ {
88+ javahome : '/opt/java' ,
89+ version : DEFAULT_VERSION ,
90+ enable_https_redirect : true ,
91+ }
92+ end
93+
94+ it { is_expected . to compile . with_all_deps }
95+
96+ it 'configures HTTPS redirect in web.xml' do
97+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
98+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size == 0' ) .
99+ with_changes ( [
100+ 'set security-constraint[last()+1]/web-resource-collection/web-resource-name/#text "all-except-attachments"' ,
101+ 'set security-constraint[last()]/web-resource-collection/url-pattern[1]/#text "*.jsp"' ,
102+ 'set security-constraint[last()]/web-resource-collection/url-pattern[2]/#text "*.jspa"' ,
103+ 'set security-constraint[last()]/web-resource-collection/url-pattern[3]/#text "/browse/*"' ,
104+ 'set security-constraint[last()]/web-resource-collection/url-pattern[4]/#text "/issues/*"' ,
105+ 'set security-constraint[last()]/user-data-constraint/transport-guarantee/#text "CONFIDENTIAL"' ,
106+ ] )
107+ end
108+
109+ it 'does not remove HTTPS redirect' do
110+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
111+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size == 0' )
112+ end
113+ end
114+
115+ context 'with custom session_timeout' do
116+ let ( :params ) do
117+ {
118+ javahome : '/opt/java' ,
119+ version : DEFAULT_VERSION ,
120+ session_timeout : 480 ,
121+ }
122+ end
123+
124+ it { is_expected . to compile . with_all_deps }
125+
126+ it 'sets custom session timeout' do
127+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
128+ with_changes ( [ 'set session-config/session-timeout/#text 480' ] )
129+ end
130+
131+ it 'removes HTTPS redirect when disabled' do
132+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
133+ with_changes ( [ 'rm security-constraint[user-data-constraint/transport-guarantee/#text="CONFIDENTIAL"]' ] ) .
134+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size > 0' )
135+ end
136+ end
137+
138+ context 'with both enable_https_redirect and custom session_timeout' do
139+ let ( :params ) do
140+ {
141+ javahome : '/opt/java' ,
142+ version : DEFAULT_VERSION ,
143+ enable_https_redirect : true ,
144+ session_timeout : 600 ,
145+ }
146+ end
147+
148+ it { is_expected . to compile . with_all_deps }
149+
150+ it 'sets custom session timeout' do
151+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
152+ with_changes ( [ 'set session-config/session-timeout/#text 600' ] )
153+ end
154+
155+ it 'configures HTTPS redirect' do
156+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' )
157+ end
158+ end
159+
160+ context 'web.xml augeas resources' do
161+ let ( :params ) do
162+ {
163+ javahome : '/opt/java' ,
164+ version : DEFAULT_VERSION ,
165+ }
166+ end
167+
168+ it 'manages session timeout with augeas' do
169+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
170+ with_incl ( "#{ PATH_INSTALLATION_BASE } /atlassian-jira/WEB-INF/web.xml" ) .
171+ with_lens ( 'Xml.lns' ) .
172+ with_context ( "/files#{ PATH_INSTALLATION_BASE } /atlassian-jira/WEB-INF/web.xml/web-app" )
173+ end
174+
175+ it 'manages https redirect with augeas' do
176+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
177+ with_incl ( "#{ PATH_INSTALLATION_BASE } /atlassian-jira/WEB-INF/web.xml" ) .
178+ with_lens ( 'Xml.lns' ) .
179+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size > 0' )
180+ end
181+ end
182+
183+ context 'with web.xml and different JIRA versions' do
184+ let ( :params ) do
185+ {
186+ javahome : '/opt/java' ,
187+ version : '9.4.0' ,
188+ enable_https_redirect : true ,
189+ session_timeout : 360 ,
190+ }
191+ end
192+
193+ it { is_expected . to compile . with_all_deps }
194+
195+ it 'manages custom session timeout' do
196+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
197+ with_changes ( [ 'set session-config/session-timeout/#text 360' ] )
198+ end
199+
200+ it 'enables https redirect' do
201+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
202+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size == 0' ) .
203+ with_changes ( [
204+ 'set security-constraint[last()+1]/web-resource-collection/web-resource-name/#text "all-except-attachments"' ,
205+ 'set security-constraint[last()]/web-resource-collection/url-pattern[1]/#text "*.jsp"' ,
206+ 'set security-constraint[last()]/web-resource-collection/url-pattern[2]/#text "*.jspa"' ,
207+ 'set security-constraint[last()]/web-resource-collection/url-pattern[3]/#text "/browse/*"' ,
208+ 'set security-constraint[last()]/web-resource-collection/url-pattern[4]/#text "/issues/*"' ,
209+ 'set security-constraint[last()]/user-data-constraint/transport-guarantee/#text "CONFIDENTIAL"' ,
210+ ] )
211+ end
212+ end
213+
214+ context 'with web.xml and OpenJDK 11' do
215+ let ( :params ) do
216+ {
217+ javahome : '/usr/lib/jvm/jre-11-openjdk' ,
218+ java_package : 'java-11-openjdk-headless' ,
219+ jvm_type : 'openjdk-11' ,
220+ enable_https_redirect : true ,
221+ session_timeout : 420 ,
222+ }
223+ end
224+
225+ it { is_expected . to compile . with_all_deps }
226+ it { is_expected . to contain_package ( 'java-11-openjdk-headless' ) }
227+
228+ it 'manages custom session timeout' do
229+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
230+ with_changes ( [ 'set session-config/session-timeout/#text 420' ] )
231+ end
232+
233+ it 'enables https redirect' do
234+ is_expected . to contain_augeas ( 'jira-web.xml-https-redirect' ) .
235+ with_onlyif ( 'match security-constraint/user-data-constraint/transport-guarantee[#text="CONFIDENTIAL"] size == 0' ) .
236+ with_changes ( [
237+ 'set security-constraint[last()+1]/web-resource-collection/web-resource-name/#text "all-except-attachments"' ,
238+ 'set security-constraint[last()]/web-resource-collection/url-pattern[1]/#text "*.jsp"' ,
239+ 'set security-constraint[last()]/web-resource-collection/url-pattern[2]/#text "*.jspa"' ,
240+ 'set security-constraint[last()]/web-resource-collection/url-pattern[3]/#text "/browse/*"' ,
241+ 'set security-constraint[last()]/web-resource-collection/url-pattern[4]/#text "/issues/*"' ,
242+ 'set security-constraint[last()]/user-data-constraint/transport-guarantee/#text "CONFIDENTIAL"' ,
243+ ] )
244+ end
245+ end
246+
247+ context 'with minimum session timeout' do
248+ let ( :params ) do
249+ {
250+ javahome : '/opt/java' ,
251+ version : DEFAULT_VERSION ,
252+ session_timeout : 1 ,
253+ }
254+ end
255+
256+ it { is_expected . to compile . with_all_deps }
257+
258+ it 'allows minimum valid session timeout' do
259+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
260+ with_changes ( [ 'set session-config/session-timeout/#text 1' ] )
261+ end
262+ end
263+
264+ context 'with large session timeout' do
265+ let ( :params ) do
266+ {
267+ javahome : '/opt/java' ,
268+ version : DEFAULT_VERSION ,
269+ session_timeout : 1440 ,
270+ }
271+ end
272+
273+ it { is_expected . to compile . with_all_deps }
274+
275+ it 'allows large session timeout (24 hours)' do
276+ is_expected . to contain_augeas ( 'jira-web.xml-session-timeout' ) .
277+ with_changes ( [ 'set session-config/session-timeout/#text 1440' ] )
278+ end
71279 end
72280
73281 context 'with java install' do
0 commit comments