Skip to content

Commit fe2d0f1

Browse files
committed
check servicelink disabled
1 parent 0da078b commit fe2d0f1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/com/uid2/operator/service/SecureLinkValidatorService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ public boolean validateRequest(RoutingContext rc, JsonObject requestJsonObject,
4646
LOGGER.warn("Path: {} , ClientKey has ServiceId set, but LinkId in request was not authorized. ServiceId: {}, LinkId in request: {}", rc.normalizedPath(), clientKey.getServiceId(), linkId);
4747
return false;
4848
}
49+
if (serviceLink.isDisabled()) {
50+
LOGGER.warn("Path: {} , ServiceLink {} is disabled", rc.normalizedPath(), linkId);
51+
return false;
52+
}
4953
if (!serviceLink.getRoles().contains(role)) {
5054
LOGGER.warn("Path: {} , ServiceLink {} does not have role {}", rc.normalizedPath(), linkId, role);
51-
5255
return false;
5356
}
5457
Service service = rotatingServiceStore.getService(clientKey.getServiceId());

src/test/java/com/uid2/operator/service/SecureLinkValidatorServiceTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ void validateRequest_linkIdNotFound_returnsFalse() {
6767
assertFalse(service.validateRequest(this.routingContext, requestJsonObject, Role.MAPPER));
6868
}
6969

70+
@Test
71+
void validateRequest_linkIdFoundLinkDisabled_returnsFalse() {
72+
this.setClientKey(10);
73+
JsonObject requestJsonObject = new JsonObject();
74+
requestJsonObject.put(SecureLinkValidatorService.LINK_ID, "999");
75+
76+
when(this.rotatingServiceLinkStore.getServiceLink(10, "999")).thenReturn(new ServiceLink("999", 10, 100, "testServiceLink", Set.of(Role.MAPPER), true));
77+
78+
SecureLinkValidatorService service = new SecureLinkValidatorService(this.rotatingServiceLinkStore, this.rotatingServiceStore);
79+
assertFalse(service.validateRequest(this.routingContext, requestJsonObject, Role.MAPPER));
80+
}
81+
7082
@Test
7183
void validateRequest_roleNotInServiceLink_returnsFalse() {
7284
this.setClientKey(10);

0 commit comments

Comments
 (0)