Skip to content

Commit

Permalink
RIPE NCC has merged c7221e69c
Browse files Browse the repository at this point in the history
* Fix typo [01a7e298b]
* Report lastUpdated in more cases [5ec659a0d]
* Update dependency io.freefair.lombok:io.freefair.lombok.gradle.plugin to v8.10.2 [6e6bd7f80]
  • Loading branch information
RPKI Team at RIPE NCC committed Oct 14, 2024
1 parent c24c9cf commit 9dfbaad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
}

dependencies {
implementation 'io.freefair.lombok:io.freefair.lombok.gradle.plugin:8.10'
implementation 'io.freefair.lombok:io.freefair.lombok.gradle.plugin:8.10.2'
implementation('com.gorylenko.gradle-git-properties:com.gorylenko.gradle-git-properties.gradle.plugin:2.4.2') {
exclude group: 'org.eclipse.jgit', module: 'org.eclipse.jgit'
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/net/ripe/rpki/rest/service/AnnouncementService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -114,13 +115,18 @@ private AnnouncementResponse getAnnouncements(CaName caName) {
).toList();

Instant risLastUpdated = bgpRisEntryViewService.getLastUpdated();
Function<String, AnnouncementResponse> reportProblem =
problem -> risLastUpdated == null ?
new AnnouncementResponse.Problem(problem) :
new AnnouncementResponse.ProblemWithTimestamp(problem, risLastUpdated);

if (certifiedResources.isEmpty())
return new AnnouncementResponse.Problem(NO_CA_RESOURCES);
return reportProblem.apply(NO_CA_RESOURCES);
else if (risLastUpdated == null)
return new AnnouncementResponse.Problem(NO_RIS_UPDATES);
return reportProblem.apply(NO_RIS_UPDATES);
else if (!announcements.isEmpty() &&
announcements.values().stream().allMatch(Collection::isEmpty))
return new AnnouncementResponse.Problem(NO_OVERLAP_WITH_RIS);
return reportProblem.apply(NO_OVERLAP_WITH_RIS);

var announcement = Stream.concat(announcedAnnouncements.stream(), notSeenAnnouncements.stream()).toList();
return new AnnouncementResponse.Announcements(announcement, risLastUpdated);
Expand Down Expand Up @@ -191,6 +197,7 @@ public ResponseEntity<List<BgpAnnouncement>> getAffectedAnnouncementsForCaAndRoa

public interface AnnouncementResponse {
record Problem(String emptyAnnouncementsReason) implements AnnouncementResponse {}
record ProblemWithTimestamp(String emptyAnnouncementsReason, Instant lastUpdated) implements AnnouncementResponse {}

record Announcements(List<BgpAnnouncement> announcements,
Instant lastUpdated) implements AnnouncementResponse { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ public void announcements_shouldGetAnnouncementNoOverlapsBetweenRisAndResources(
bgpRisEntries.put(true, Collections.emptyList());

when(bgpRisEntryViewService.findMostSpecificContainedAndNotContained(ipResourceSet)).thenReturn(bgpRisEntries);
when(bgpRisEntryViewService.getLastUpdated()).thenReturn(Instant.now());
Instant now = Instant.now();
when(bgpRisEntryViewService.getLastUpdated()).thenReturn(now);

when(roaService.getRoaConfiguration(CA_ID)).thenReturn(new RoaConfigurationData(new ArrayList<>()));

Expand All @@ -203,7 +204,8 @@ public void announcements_shouldGetAnnouncementNoOverlapsBetweenRisAndResources(
)
.andExpect(status().isOk())
.andExpect(content().contentType(APPLICATION_JSON))
.andExpect(jsonPath("$.emptyAnnouncementsReason").value(AnnouncementService.NO_OVERLAP_WITH_RIS));
.andExpect(jsonPath("$.emptyAnnouncementsReason").value(AnnouncementService.NO_OVERLAP_WITH_RIS))
.andExpect(jsonPath("$.lastUpdated").value(now.toString()));
}

@Test
Expand Down

0 comments on commit 9dfbaad

Please sign in to comment.