Allow user without password in UriInfo.
This commit is contained in:
committed by
Scott Frederick
parent
9adc1f7287
commit
d510408e90
@@ -129,7 +129,9 @@ public class UriInfo {
|
||||
|
||||
if (userInfo != null) {
|
||||
String[] userPass = userInfo.split(":");
|
||||
if (userPass.length != 2) {
|
||||
if (userPass.length == 1) {
|
||||
return new String[]{userPass[0], null};
|
||||
} else if (userPass.length != 2) {
|
||||
throw new IllegalArgumentException("Bad userinfo in URI: " + uri);
|
||||
}
|
||||
return userPass;
|
||||
|
||||
@@ -40,10 +40,13 @@ public class StandardUriInfoFactoryTest {
|
||||
assertEquals(uri, result.getUriString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void createWithUsernameNoPassword() {
|
||||
String uri = "mysql://joe@localhost:1527/big_db";
|
||||
factory.createUri(uri);
|
||||
UriInfo result = factory.createUri(uri);
|
||||
|
||||
assertUriInfoEquals(result, "localhost", 1527, "joe", null, "big_db", null);
|
||||
assertEquals(uri, result.getUriString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -35,9 +35,11 @@ public class RelationalServiceInfoTest {
|
||||
assertEquals("jdbc:jdbcdbtype://hostname:1234/database", serviceInfo.getJdbcUrl());
|
||||
}
|
||||
|
||||
@Test(expected = java.lang.IllegalArgumentException.class)
|
||||
@Test
|
||||
public void jdbcUrlNoPassword() {
|
||||
createServiceInfo("dbtype://username@hostname/database");
|
||||
RelationalServiceInfo serviceInfo = createServiceInfo("dbtype://username@hostname/database");
|
||||
|
||||
assertEquals("jdbc:jdbcdbtype://hostname/database?user=username", serviceInfo.getJdbcUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,4 +66,4 @@ public class RelationalServiceInfoTest {
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user