Skip to content

Commit

Permalink
Merge branch 'master' into remove_referral_by_from_nrtm_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eshryane authored Jan 8, 2025
2 parents a940bf3 + 5eae2e2 commit 9d4cc13
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
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 @@ -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;
Expand Down Expand Up @@ -102,7 +103,6 @@ public void setup() throws IOException {
"upd-to: [email protected]\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");
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void setup() {
"upd-to: [email protected]\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");
Expand Down

0 comments on commit 9d4cc13

Please sign in to comment.