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:
Etienne Poirier 2022-10-17 11:09:17 -04:00 committed by GitHub
parent 26ef32c1dd
commit a5fb87bb1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -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."

View File

@ -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);
}
}

View File

@ -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();