Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RDAP Relation extension #1608

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0116abd
feat: create controller
MiguelAHM Nov 28, 2024
cf6bcc6
feat: rdap Relation endpoint and ITs
MiguelAHM Dec 2, 2024
387c40b
feat: fix bottom to match the RFC
MiguelAHM Dec 3, 2024
4cbd0be
feat: remove unecessary changes and fix typo
MiguelAHM Dec 3, 2024
32ca759
feat: add more ITs
MiguelAHM Dec 4, 2024
243efbb
feat: remove unecessary changes
MiguelAHM Dec 4, 2024
dabd4d5
Merge branch 'master' into DB-5889-relation-searches-endpoints
MiguelAHM Dec 10, 2024
68a345a
feat: enable status query parameter
MiguelAHM Dec 11, 2024
8073771
feat: add Integration tests for status query parameter
MiguelAHM Dec 11, 2024
4b687b7
feat: add test for status active
MiguelAHM Dec 11, 2024
9ae6dd2
feat: add redirect, and TODOS
MiguelAHM Dec 11, 2024
ed3514d
feat: remove import
MiguelAHM Dec 13, 2024
152d79d
feat: add relation conformances
MiguelAHM Dec 13, 2024
081c654
feat: add its for relations
MiguelAHM Dec 13, 2024
c1dc87f
feat: add an IT for export database tests and include dummy object in…
MiguelAHM Dec 13, 2024
a8f140a
feat: nrtmv4 snapshot should create dummy object
MiguelAHM Dec 16, 2024
ea996d3
Revert "feat: add an IT for export database tests and include dummy o…
MiguelAHM Dec 16, 2024
62355f2
Revert "feat: nrtmv4 snapshot should create dummy object"
MiguelAHM Dec 16, 2024
0b4f644
feat: remove non related changes
MiguelAHM Dec 16, 2024
01ba51d
Merge branch 'master' into DB-5911-add-RDAP-relation-extension
MiguelAHM Dec 16, 2024
6edef97
Merge branch 'master' into DB-5911-add-RDAP-relation-extension
MiguelAHM Dec 24, 2024
3986cd8
feat: renaming methods
MiguelAHM Dec 24, 2024
a51ec19
Merge branch 'master' into DB-5911-add-RDAP-relation-extension
eshryane Jan 9, 2025
3ac8ed2
feat: fix conflicts
MiguelAHM Jan 17, 2025
147334a
feat: unecessary changes
MiguelAHM Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ public enum RdapConformance {
NRO_PROFILE_0("nro_rdap_profile_0"),
FLAT_MODEL("nro_rdap_profile_asn_flat_0"),
REDACTED("redacted"),
GEO_FEED_1("geofeed1");
GEO_FEED_1("geofeed1"),
RIR_SEARCH_1("rirSearch1"),
IPS("ips"),
IP_SEARCH_RESULTS("ipSearchResults"),
AUTNUMS("autnums"),
AUTNUM_SEARCH_RESULTS("autnumSearchResults");


private final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class RdapObjectMapper {
ZONE_C, Role.ZONE,
ORG, Role.REGISTRANT,// TODO: [MA] both mnt_by and org have same role
MNT_IRT, Role.ABUSE);
private final RdapRelationService rdapRelationService;

@Autowired
public RdapObjectMapper(
Expand All @@ -133,13 +134,14 @@ public RdapObjectMapper(
final ReservedResources reservedResources,
final Ipv4Tree ipv4Tree,
final Ipv6Tree ipv6Tree,
@Value("${rdap.port43:}") final String port43) {
@Value("${rdap.port43:}") final String port43, RdapRelationService rdapRelationService) {
this.noticeFactory = noticeFactory;
this.rpslObjectDao = rpslObjectDao;
this.ipv4Tree = ipv4Tree;
this.ipv6Tree = ipv6Tree;
this.port43 = port43;
this.reservedResources = reservedResources;
this.rdapRelationService = rdapRelationService;
}

public Object map(final String requestUrl,
Expand Down Expand Up @@ -183,6 +185,7 @@ public Object mapSearch(final String requestUrl, final List<RpslObject> objects,

final RdapObject rdapObject = mapCommonNoticesAndPort(searchResult, requestUrl);
mapCommonLinks(rdapObject, requestUrl);
includeRirSearchConformance(rdapObject, requestUrl);
return mapCommonConformances(rdapObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conformance should be included if it is a RIR search ?

Copy link
Contributor Author

@MiguelAHM MiguelAHM Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Jira says
"Always return the "rirSearch1" extension on all responses."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case we should add all conformance to every rdap response but we do not. For ex: we add geofeed Conformance only if it is Ip request . I think we need to be consistent about it. Let's discuss it with Ed

}

Expand All @@ -198,6 +201,7 @@ public Object mapDomainEntity(
rdapObject.getLinks().add(COPYRIGHT_LINK);

mapRedactions(rdapObject);
includeRirSearchConformance(rdapObject, requestUrl);
return mapCommonConformances(rdapObject);
}

Expand Down Expand Up @@ -323,6 +327,7 @@ private RdapObject mapCommons(final RdapObject rdapResponse, final String reques
final RdapObject rdapObject = mapCommonNoticesAndPort(rdapResponse, requestUrl);
mapCommonLinks(rdapObject, requestUrl);
mapRedactions(rdapResponse);
includeRirSearchConformance(rdapObject, requestUrl);
return mapCommonConformances(rdapObject);
}

Expand Down Expand Up @@ -362,6 +367,10 @@ private RdapObject mapCommonConformances(final RdapObject rdapResponse) {
return rdapResponse;
}

private void includeRirSearchConformance(final RdapObject rdapResponse, final String requestUrl) {
rdapRelationService.includeRirSearchConformance(rdapResponse, requestUrl);
}

private Ip createIp(final RpslObject rpslObject, final String requestUrl) {
final Ip ip = new Ip();
final IpInterval ipInterval = IpInterval.parse(rpslObject.getKey());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.ripe.db.whois.api.rdap;

import com.google.common.collect.Sets;
import net.ripe.db.whois.api.rdap.domain.RdapObject;
import net.ripe.db.whois.api.rdap.domain.RdapRequestType;
import net.ripe.db.whois.api.rdap.domain.RelationType;
import net.ripe.db.whois.common.dao.RpslObjectDao;
import net.ripe.db.whois.common.domain.CIString;
Expand Down Expand Up @@ -66,6 +68,21 @@ public List<String> getDomainsByRelationType(final String pkey, final RelationTy
.toList();
}


public void includeRirSearchConformance(final RdapObject rdapObject, final String requestUrl){
rdapObject.getRdapConformance().add(RdapConformance.RIR_SEARCH_1.getValue());
if (requestUrl == null) {
return;
}
if (requestUrl.contains(RdapRequestType.IPS.name().toLowerCase())){
rdapObject.getRdapConformance().addAll(List.of(RdapConformance.IPS.getValue(), RdapConformance.IP_SEARCH_RESULTS.getValue()));
return;
}
if (requestUrl.contains(RdapRequestType.AUTNUMS.name().toLowerCase())){
rdapObject.getRdapConformance().addAll(List.of(RdapConformance.AUTNUMS.getValue(), RdapConformance.AUTNUM_SEARCH_RESULTS.getValue()));
}
}

public List<String> getInetnumRelationPkeys(final String pkey, final RelationType relationType){
final IpInterval ip = IpInterval.parse(pkey);
final List<IpEntry> ipEntries = getEntries(getIpTree(ip), relationType, ip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ public void search_redactions() {
.map(Redaction::getPrePath)
.collect(Collectors.toList()), containsInAnyOrder("$.entities[?(@.handle=='PP1-TEST')].vcardArray[1][?(@[0]=='e-mail')]"));

assertThat(result.getRdapConformance(), containsInAnyOrder("cidr0", "rdap_level_0", "nro_rdap_profile_0", "redacted"));
assertThat(result.getRdapConformance(), containsInAnyOrder("cidr0", "rdap_level_0", "nro_rdap_profile_0",
"redacted", "rirSearch1"));
}

// helper methods
Expand Down Expand Up @@ -1043,9 +1044,9 @@ protected void assertErrorDescriptionContains(final WebApplicationException exce

private void assertCommon(RdapObject object) {
assertThat(object.getPort43(), is("whois.ripe.net"));
assertThat(object.getRdapConformance(), hasSize(4));
assertThat(object.getRdapConformance(), hasSize(5));
assertThat(object.getRdapConformance(), containsInAnyOrder("rdap_level_0", "cidr0", "nro_rdap_profile_0",
"redacted"));
"redacted", "rirSearch1"));
}

private void assertTnCNotice(final Notice notice, final String value) {
Expand Down
Loading
Loading