1818
1919import static org .apache .knox .gateway .services .security .impl .RemoteAliasService .REMOTE_ALIAS_SERVICE_TYPE ;
2020import static org .hamcrest .CoreMatchers .is ;
21+ import static org .hamcrest .CoreMatchers .not ;
2122import static org .hamcrest .CoreMatchers .notNullValue ;
2223import static org .hamcrest .MatcherAssert .assertThat ;
24+ import static org .hamcrest .Matchers .empty ;
2325import static org .hamcrest .Matchers .hasItems ;
2426import static org .hamcrest .Matchers .nullValue ;
2527import static org .junit .Assert .assertEquals ;
3638import java .util .HashSet ;
3739import java .util .List ;
3840import java .util .Map ;
41+ import java .util .Set ;
3942import java .util .concurrent .TimeUnit ;
4043
4144import org .apache .knox .gateway .config .GatewayConfig ;
@@ -143,6 +146,30 @@ public void testSSLCiphers() {
143146 config .set ( "ssl.include.ciphers" , " ONE , TWO , THREE " );
144147 assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
145148
149+ config .set ( "ssl.include.ciphers" , " ONE:TWO:THREE " );
150+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
151+
152+ config .set ( "ssl.include.ciphers" , " ONE:TWO,THREE " );
153+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
154+
155+ config .set ( "ssl.include.ciphers" , " ONE : TWO,THREE " );
156+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
157+
158+ config .set ( "ssl.include.ciphers" , " ONE : TWO\n THREE " );
159+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
160+
161+ config .set ( "ssl.include.ciphers" , " ONE,TWO \n THREE " );
162+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
163+
164+ config .set ( "ssl.include.ciphers" , " ONE,TWO \n THREE :FOUR" );
165+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" , "FOUR" )) );
166+
167+ config .set ( "ssl.include.ciphers" , " ONE,TWO,,THREE" );
168+ assertThat ( config .getIncludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
169+
170+ config .set ( "ssl.include.ciphers" , " ONE,TWO,,THREE" );
171+ assertThat ( config .getIncludedSSLCiphers (), not (hasItems ("" )) );
172+
146173 list = config .getExcludedSSLCiphers ();
147174 assertThat ( list , is (nullValue ()) );
148175
@@ -166,6 +193,130 @@ public void testSSLCiphers() {
166193
167194 config .set ( "ssl.exclude.ciphers" , " ONE , TWO , THREE " );
168195 assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
196+
197+ config .set ( "ssl.exclude.ciphers" , " ONE:TWO:THREE " );
198+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
199+
200+ config .set ( "ssl.exclude.ciphers" , " ONE:TWO,THREE " );
201+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
202+
203+ config .set ( "ssl.exclude.ciphers" , " ONE : TWO,THREE " );
204+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
205+
206+ config .set ( "ssl.exclude.ciphers" , " ONE : TWO\n THREE " );
207+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
208+
209+ config .set ( "ssl.exclude.ciphers" , " ONE,TWO \n THREE " );
210+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
211+
212+ config .set ( "ssl.exclude.ciphers" , " ONE,TWO \n THREE :FOUR" );
213+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" , "FOUR" )) );
214+
215+
216+ config .set ( "ssl.exclude.ciphers" , " ONE,TWO,,THREE" );
217+ assertThat ( config .getExcludedSSLCiphers (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
218+
219+ config .set ( "ssl.exclude.ciphers" , " ONE,TWO,,THREE" );
220+ assertThat ( config .getExcludedSSLCiphers (), not (hasItems ("" )) );
221+ }
222+
223+ @ Test
224+ public void testSSLProtocols () {
225+ GatewayConfigImpl config = new GatewayConfigImpl ();
226+ Set <String > list ;
227+
228+ list = config .getIncludedSSLProtocols ();
229+ assertThat ( list , is (empty ()) );
230+
231+ config .set ( "ssl.include.protocols" , "none" );
232+ assertThat ( config .getIncludedSSLProtocols (), is (empty ()) );
233+
234+ config .set ( "ssl.include.protocols" , "" );
235+ assertThat ( config .getIncludedSSLProtocols (), is (empty ()) );
236+
237+ config .set ( "ssl.include.protocols" , "ONE" );
238+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" )) );
239+
240+ config .set ( "ssl.include.protocols" , " ONE " );
241+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" )) );
242+
243+ config .set ( "ssl.include.protocols" , "ONE,TWO" );
244+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" )) );
245+
246+ config .set ( "ssl.include.protocols" , "ONE,TWO,THREE" );
247+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
248+
249+ config .set ( "ssl.include.protocols" , " ONE , TWO , THREE " );
250+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
251+
252+ config .set ( "ssl.include.protocols" , " ONE:TWO:THREE " );
253+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
254+
255+ config .set ( "ssl.include.protocols" , " ONE:TWO,THREE " );
256+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
257+
258+ config .set ( "ssl.include.protocols" , " ONE : TWO,THREE " );
259+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
260+
261+ config .set ( "ssl.include.protocols" , " ONE : TWO\n THREE " );
262+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
263+
264+ config .set ( "ssl.include.protocols" , " ONE,TWO \n THREE " );
265+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
266+
267+ config .set ( "ssl.include.protocols" , " ONE,TWO \n THREE :FOUR" );
268+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" , "FOUR" )) );
269+
270+ config .set ( "ssl.include.protocols" , " ONE,TWO,,THREE" );
271+ assertThat ( config .getIncludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
272+
273+ config .set ( "ssl.include.protocols" , " ONE,TWO,,THREE" );
274+ assertThat ( config .getIncludedSSLProtocols (), not (hasItems ("" )) );
275+
276+ config .set ( "ssl.exclude.protocols" , "none" );
277+ assertThat ( config .getExcludedSSLProtocols (), is (nullValue ()) );
278+
279+ config .set ( "ssl.exclude.protocols" , "" );
280+ assertThat ( config .getExcludedSSLProtocols (), is (nullValue ()) );
281+
282+ config .set ( "ssl.exclude.protocols" , "ONE" );
283+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" )) );
284+
285+ config .set ( "ssl.exclude.protocols" , " ONE " );
286+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" )) );
287+
288+ config .set ( "ssl.exclude.protocols" , "ONE,TWO" );
289+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" )) );
290+
291+ config .set ( "ssl.exclude.protocols" , "ONE,TWO,THREE" );
292+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
293+
294+ config .set ( "ssl.exclude.protocols" , " ONE , TWO , THREE " );
295+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
296+
297+ config .set ( "ssl.exclude.protocols" , " ONE:TWO:THREE " );
298+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
299+
300+ config .set ( "ssl.exclude.protocols" , " ONE:TWO,THREE " );
301+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
302+
303+ config .set ( "ssl.exclude.protocols" , " ONE : TWO,THREE " );
304+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
305+
306+ config .set ( "ssl.exclude.protocols" , " ONE : TWO\n THREE " );
307+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
308+
309+ config .set ( "ssl.exclude.protocols" , " ONE,TWO \n THREE " );
310+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
311+
312+ config .set ( "ssl.exclude.protocols" , " ONE,TWO \n THREE :FOUR" );
313+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" , "FOUR" )) );
314+
315+ config .set ( "ssl.exclude.protocols" , " ONE,TWO,,THREE" );
316+ assertThat ( config .getExcludedSSLProtocols (), is (hasItems ("ONE" ,"TWO" ,"THREE" )) );
317+
318+ config .set ( "ssl.exclude.protocols" , " ONE,TWO,,THREE" );
319+ assertThat ( config .getExcludedSSLProtocols (), not (hasItems ("" )) );
169320 }
170321
171322 // KNOX-2772
0 commit comments