@@ -82,6 +82,31 @@ public void testBridgeRegistration() throws Exception {
8282 assertEquals ("NC" , nc .getName ());
8383 }
8484
85+ @ Test
86+ public void testTransportSchemeBridgeAllowed () throws Exception {
87+ // Test composite network connector uri
88+ String name = proxy .addNetworkConnector ("static:(tcp://localhost,amqp://localhost)" );
89+ proxy .removeNetworkConnector (name );
90+
91+ // Test composite with missing parens
92+ name = proxy .addNetworkConnector ("static:amqp://localhost,tcp://127.0.0.1:0" );
93+ proxy .removeNetworkConnector (name );
94+
95+ // verify direct connector as well
96+ name = proxy .addNetworkConnector ("static:stomp://localhost" );
97+ proxy .removeNetworkConnector (name );
98+
99+ // verify nested composite URI
100+ name = proxy .addNetworkConnector (
101+ "static:(static:(static:(tcp+ssl://localhost:0,auto+nio+ssl://localhost)))" );
102+ proxy .removeNetworkConnector (name );
103+
104+ // verify nested composite URI is not blocked when not using parens
105+ name = proxy .addNetworkConnector (
106+ "static:static:static:123://localhost:0,auto+nio+ssl://localhost" );
107+ proxy .removeNetworkConnector (name );
108+ }
109+
85110 @ Test
86111 public void testTransportSchemeBridgeBlocked () throws Exception {
87112 for (String deniedScheme : DENIED_TRANSPORT_SCHEMES ) {
@@ -99,6 +124,14 @@ protected void testTransportSchemeBridgeBlocked(String scheme) throws Exception
99124 assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
100125 }
101126
127+ // Test composite with missing parens
128+ try {
129+ proxy .addNetworkConnector ("static:" + scheme + "://localhost,tcp://127.0.0.1:0" );
130+ fail ("Should have failed trying to add connector bridge with scheme: " + scheme );
131+ } catch (IllegalArgumentException e ) {
132+ assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
133+ }
134+
102135 // verify direct connector as well
103136 try {
104137 proxy .addNetworkConnector (scheme + "://localhost" );
@@ -114,6 +147,14 @@ protected void testTransportSchemeBridgeBlocked(String scheme) throws Exception
114147 } catch (IllegalArgumentException e ) {
115148 assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
116149 }
150+
151+ try {
152+ // verify nested composite URI is blocked when not using parens
153+ proxy .addNetworkConnector ("static:static:static:tcp://localhost:0," + scheme + "://localhost" );
154+ fail ("Should have failed trying to add connector bridge with scheme: " + scheme );
155+ } catch (IllegalArgumentException e ) {
156+ assertEquals ("Transport scheme '" + scheme + "' is not allowed" , e .getMessage ());
157+ }
117158 }
118159
119160 @ Test
@@ -124,12 +165,21 @@ public void testAddNetworkConnectorMaxComposite() throws Exception {
124165
125166 try {
126167 // verify nested composite URI with more than 5 levels is blocked. This has 6 nested
127- // (not including first wrapper url
168+ // (not including first wrapper url)
128169 proxy .addNetworkConnector (
129170 "static:(static:(static:(static:(static:(static:(tcp://localhost:0))))))" );
130171 fail ("Should have failed trying to add more than 5 connector bridges" );
131172 } catch (IllegalArgumentException e ) {
132173 assertEquals ("URI can't contain more than 5 nested composite URIs" , e .getMessage ());
133174 }
175+
176+ try {
177+ // verify nested composite URI with more than 5 levels is blocked without parens
178+ proxy .addNetworkConnector (
179+ "static:static:static:static:static:static:tcp://localhost:0" );
180+ fail ("Should have failed trying to add more than 5 connector bridges" );
181+ } catch (IllegalArgumentException e ) {
182+ assertEquals ("URI can't contain more than 5 nested composite URIs" , e .getMessage ());
183+ }
134184 }
135185}
0 commit comments