Add method to return both IP and port for SRV DNS lookup requests

Closes gh-9030
This commit is contained in:
Kathryn Newbould
2020-09-26 16:40:29 +02:00
committed by Eleftheria Stein
parent fa77f4c8ff
commit 2af322c06d
2 changed files with 48 additions and 4 deletions

View File

@@ -95,6 +95,16 @@ public class JndiDnsResolverTests {
assertThat(ipAddress).isEqualTo("63.246.7.80");
}
@Test
public void resolveServiceIpAddressWithPort() throws Exception {
BasicAttributes srvRecords = createSrvRecords();
BasicAttributes aRecords = new BasicAttributes("A", "63.246.7.80");
given(this.context.getAttributes("_ldap._tcp.springsource.com", new String[] { "SRV" })).willReturn(srvRecords);
given(this.context.getAttributes("kdc.springsource.com", new String[] { "A" })).willReturn(aRecords);
String ipAddress = this.dnsResolver.resolveServiceIpAddressAndPort("ldap", "springsource.com");
assertThat(ipAddress).isEqualTo("63.246.7.80:389");
}
@Test
public void testUnknowError() throws Exception {
given(this.context.getAttributes(any(String.class), any(String[].class)))