Skip to content

Commit

Permalink
feat: fix mntner when querying by handle in RDAP entities
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelAHM committed Dec 23, 2024
1 parent 93f7301 commit 18895e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,13 @@ private static Event createEvent(final LocalDateTime lastChanged, final Action a

private void mapContactEntities(final RdapObject rdapObject, final RpslObject rpslObject, final String requestUrl) {
final Map<CIString, Entity> contactsEntities = Maps.newTreeMap();
final List<RpslAttribute> filteredAttributes = rpslObject.getAttributes().stream().filter( rpslAttribute -> CONTACT_ATTRIBUTE_TO_ROLE_NAME.containsKey(rpslAttribute.getType())).collect(Collectors.toList());
final List<RpslAttribute> filteredAttributes = rpslObject.getAttributes().stream().filter( rpslAttribute -> {
final AttributeType attributeType = rpslAttribute.getType();
if (attributeType == null){
return false;
}
return CONTACT_ATTRIBUTE_TO_ROLE_NAME.containsKey(rpslAttribute.getType());
}).toList();

filteredAttributes.forEach( rpslAttribute -> {
for (final CIString value : rpslAttribute.getCleanValues()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,23 @@ 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"));
}

@Test
public void lookup_person_entity_acl_denied() {
try {
Expand Down

0 comments on commit 18895e3

Please sign in to comment.