commit
46f09be1c0
|
@ -1127,18 +1127,21 @@ public class RabbitProperties {
|
|||
}
|
||||
|
||||
private String parseUsernameAndPassword(String input) {
|
||||
if (input.contains("@")) {
|
||||
String[] split = StringUtils.split(input, "@");
|
||||
String creds = split[0];
|
||||
input = split[1];
|
||||
split = StringUtils.split(creds, ":");
|
||||
this.username = split[0];
|
||||
if (split.length > 0) {
|
||||
this.password = split[1];
|
||||
}
|
||||
}
|
||||
String[] splitInput = StringUtils.split(input, "@");
|
||||
if (splitInput == null) {
|
||||
return input;
|
||||
}
|
||||
String credentials = splitInput[0];
|
||||
String[] splitCredentials = StringUtils.split(credentials, ":");
|
||||
if (splitCredentials == null) {
|
||||
this.username = credentials;
|
||||
}
|
||||
else {
|
||||
this.username = splitCredentials[0];
|
||||
this.password = splitCredentials[1];
|
||||
}
|
||||
return splitInput[1];
|
||||
}
|
||||
|
||||
private String parseVirtualHost(String input) {
|
||||
int hostIndex = input.indexOf('/');
|
||||
|
|
|
@ -331,4 +331,11 @@ class RabbitPropertiesTests {
|
|||
assertThat(container).hasFieldOrPropertyWithValue("deBatchingEnabled", direct.isDeBatchingEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
void determineUsernameWithoutPassword() {
|
||||
this.properties.setAddresses("user@rabbit1.example.com:1234/alpha");
|
||||
assertThat(this.properties.determineUsername()).isEqualTo("user");
|
||||
assertThat(this.properties.determinePassword()).isEqualTo("guest");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue