4142 resource contents are written to logs on subscription failure (#4143)
* Add test reproducing the issue. * Adding solution and changelog. * Modification following code review. Co-authored-by: peartree <etienne.poirier@smilecdr.com>
This commit is contained in:
parent
26ef32c1dd
commit
a5fb87bb1d
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4142
|
||||
jira: SMILE-5312
|
||||
title: "Upon hitting a subscription delivery failure, we currently log the failing payload which could be considered PHI. Resource content is no longer written to logs on subscription failure."
|
|
@ -94,7 +94,7 @@ public abstract class BaseSubscriptionDeliverySubscriber implements MessageHandl
|
|||
return;
|
||||
}
|
||||
|
||||
throw new MessagingException(theMessage, Msg.code(2) + errorMsg, e);
|
||||
throw new MessagingException(Msg.code(2) + errorMsg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import javax.annotation.Nonnull;
|
|||
import java.net.URISyntaxException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -48,6 +49,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
|
|||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
@ -316,6 +318,32 @@ public class BaseSubscriptionDeliverySubscriberTest {
|
|||
assertEquals(jsonMessage.getPayload().getRequestPartitionId().toJson(), RequestPartitionId.defaultPartition().toJson());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestHookDeliveryFails_raisedExceptionShouldNotIncludeSubmittedResource() {
|
||||
when(myInterceptorBroadcaster.callHooks(any(), any())).thenReturn(true);
|
||||
|
||||
String familyName = "FAMILY";
|
||||
|
||||
Patient patient = generatePatient();
|
||||
patient.addName().setFamily(familyName);
|
||||
CanonicalSubscription subscription = generateSubscription();
|
||||
|
||||
ResourceDeliveryMessage payload = new ResourceDeliveryMessage();
|
||||
payload.setSubscription(subscription);
|
||||
payload.setPayload(myCtx, patient, EncodingEnum.JSON);
|
||||
payload.setOperationType(ResourceModifiedMessage.OperationTypeEnum.CREATE);
|
||||
|
||||
when(myGenericClient.update()).thenThrow(new InternalErrorException("FOO"));
|
||||
|
||||
try {
|
||||
mySubscriber.handleMessage(new ResourceDeliveryJsonMessage(payload));
|
||||
fail();
|
||||
} catch (MessagingException e) {
|
||||
String messageExceptionAsString = e.toString();
|
||||
assertFalse(messageExceptionAsString.contains(familyName));
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Patient generatePatient() {
|
||||
Patient patient = new Patient();
|
||||
|
|
Loading…
Reference in New Issue