diff --git a/whois-api/src/main/java/net/ripe/db/whois/api/rdap/RdapService.java b/whois-api/src/main/java/net/ripe/db/whois/api/rdap/RdapService.java index 4ecef0d38a..b925610e44 100644 --- a/whois-api/src/main/java/net/ripe/db/whois/api/rdap/RdapService.java +++ b/whois-api/src/main/java/net/ripe/db/whois/api/rdap/RdapService.java @@ -171,7 +171,7 @@ public Response searchEntities( } if (name == null && handle != null) { - return handleSearch(new String[]{"organisation", "nic-hdl"}, handle, request); + return handleSearch(new String[]{"organisation", "nic-hdl", "mntner"}, handle, request); } throw new RdapException("400 Bad Request", "Either fn or handle is a required parameter, but never both", HttpStatus.BAD_REQUEST_400); diff --git a/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/RdapElasticServiceTestIntegration.java b/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/RdapElasticServiceTestIntegration.java index 074dbfcede..72bf7715ba 100644 --- a/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/RdapElasticServiceTestIntegration.java +++ b/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/RdapElasticServiceTestIntegration.java @@ -19,6 +19,7 @@ import net.ripe.db.whois.api.rdap.domain.Notice; import net.ripe.db.whois.api.rdap.domain.RdapObject; import net.ripe.db.whois.api.rdap.domain.Redaction; +import net.ripe.db.whois.api.rdap.domain.Role; import net.ripe.db.whois.api.rdap.domain.SearchResult; import net.ripe.db.whois.api.rest.client.RestClientUtils; import net.ripe.db.whois.common.rpsl.RpslObject; @@ -102,7 +103,6 @@ public void setup() throws IOException { "upd-to: noreply@ripe.net\n" + "auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + "mnt-by: OWNER-MNT\n" + - "referral-by: OWNER-MNT\n" + "created: 2022-08-14T11:48:28Z\n" + "last-modified: 2022-10-25T12:22:39Z\n" + "source: TEST"); @@ -653,6 +653,51 @@ public void search_entity_multiple_object_response() { assertThat(result.getNotices().get(0).getTitle(), is("Terms and Conditions")); } + @Test + public void search_entity_handle_mntner_then_response() { + + final SearchResult result = createResource("entities?handle=OWNER-MNT") + .request(MediaType.APPLICATION_JSON_TYPE) + .get(SearchResult.class); + + assertThat( + result.getEntitySearchResults() + .stream() + .map(Entity::getHandle) + .collect(Collectors.toList()), + containsInAnyOrder("OWNER-MNT")); + + assertThat(result.getNotices(), hasSize(1)); + assertThat(result.getNotices().getFirst().getTitle(), is("Terms and Conditions")); + + assertThat(result.getEntitySearchResults(), hasSize(1)); + + final Entity firstEntity = result.getEntitySearchResults().getFirst(); + assertThat(firstEntity.getHandle(), is("OWNER-MNT")); + assertThat(firstEntity.getVCardArray().toString(), is("[vcard, [" + + "[version, {}, text, 4.0], [fn, {}, text, OWNER-MNT], [kind, {}, text, individual]]]")); + + assertThat(result.getEntitySearchResults().getFirst().getEntitySearchResults(), hasSize(2)); + + //mnt-by OWNER-MNT + final Entity firstEntityMntBy = result.getEntitySearchResults().getFirst().getEntitySearchResults().getFirst(); + assertThat(firstEntityMntBy.getHandle(), is("OWNER-MNT")); + assertThat(firstEntityMntBy.getVCardArray().toString(), is("[vcard, [" + + "[version, {}, text, 4.0], [fn, {}, text, OWNER-MNT], [kind, {}, text, individual]]]")); + assertThat(firstEntityMntBy.getRoles(), hasSize(1)); + assertThat(firstEntityMntBy.getRoles().getFirst(), is(Role.REGISTRANT)); + + + //admin-c TP1-TEST + final Entity secondEntityAdminC = result.getEntitySearchResults().getFirst().getEntitySearchResults().get(1); + assertThat(secondEntityAdminC.getHandle(), is("TP1-TEST")); + assertThat(secondEntityAdminC.getVCardArray().toString(), is("[vcard, [" + + "[version, {}, text, 4.0], [fn, {}, text, Test Person], [kind, {}, text, individual], " + + "[adr, {label=Singel 258}, text, [, , , , , , ]], [tel, {type=voice}, text, +31 6 12345678]]]")); + assertThat(secondEntityAdminC.getRoles(), hasSize(1)); + assertThat(secondEntityAdminC.getRoles().getFirst(), is(Role.ADMINISTRATIVE)); + } + @Test public void lookup_person_entity_acl_denied() { try { diff --git a/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/WhoisRdapQueryLimitTestIntegration.java b/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/WhoisRdapQueryLimitTestIntegration.java index d81de57cc5..81b972de16 100644 --- a/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/WhoisRdapQueryLimitTestIntegration.java +++ b/whois-api/src/test/java/net/ripe/db/whois/api/elasticsearch/WhoisRdapQueryLimitTestIntegration.java @@ -59,7 +59,6 @@ public void setup() { "upd-to: noreply@ripe.net\n" + "auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ #test\n" + "mnt-by: OWNER-MNT\n" + - "referral-by: OWNER-MNT\n" + "created: 2022-08-14T11:48:28Z\n" + "last-modified: 2022-10-25T12:22:39Z\n" + "source: TEST");