77import com .fasterxml .jackson .core .JsonProcessingException ;
88import gov .cdc .usds .simplereport .config .authorization .UserPermission ;
99import gov .cdc .usds .simplereport .db .model .ConsoleApiAuditEvent ;
10+ import gov .cdc .usds .simplereport .db .model .Facility ;
11+ import gov .cdc .usds .simplereport .db .model .Organization ;
12+ import gov .cdc .usds .simplereport .db .model .Person ;
13+ import gov .cdc .usds .simplereport .db .model .TestEvent ;
14+ import gov .cdc .usds .simplereport .db .model .TestOrder ;
1015import gov .cdc .usds .simplereport .db .model .auxiliary .GraphQlInputs ;
1116import gov .cdc .usds .simplereport .db .model .auxiliary .HttpRequestDetails ;
1217import gov .cdc .usds .simplereport .logging .GraphqlQueryState ;
1318import gov .cdc .usds .simplereport .service .model .UserInfo ;
1419import gov .cdc .usds .simplereport .test_util .SliceTestConfiguration .WithSimpleReportEntryOnlyUser ;
20+ import gov .cdc .usds .simplereport .test_util .TestDataFactory ;
1521import java .util .LinkedHashMap ;
1622import java .util .List ;
1723import java .util .Map ;
2733class AuditServiceTest extends BaseServiceTest <AuditService > {
2834
2935 @ Autowired private ApiUserService _userService ;
36+ @ Autowired private TestDataFactory testDataFactory ;
3037 @ MockitoBean AuditLoggerService auditLoggerServiceSpy ;
3138 @ Captor private ArgumentCaptor <ConsoleApiAuditEvent > auditLogCaptor ;
3239
@@ -62,6 +69,14 @@ void smokeTestGraphqlAudit() throws JsonProcessingException {
6269 List <LinkedHashMap <String , String >> redactedMultiplexResults =
6370 List .of (covid19RedactedResult , fluARedactedResult , fluBRedactedResult );
6471
72+ int [] unredactablePrimitiveArray = new int [3 ];
73+ TestEvent [] redactableTestEventArray = new TestEvent [3 ];
74+ Organization org = testDataFactory .saveValidOrganization ();
75+ Facility facility = testDataFactory .createValidFacility (org );
76+ Person patient = testDataFactory .createFullPerson (org );
77+ TestOrder testOrder = testDataFactory .createTestOrder (patient , facility );
78+ redactableTestEventArray [0 ] = new TestEvent (testOrder );
79+
6580 state .setGraphqlDetails (
6681 new GraphQlInputs (
6782 "A" ,
@@ -72,7 +87,11 @@ void smokeTestGraphqlAudit() throws JsonProcessingException {
7287 "non-pii key" ,
7388 "non-pii value" ,
7489 "results" ,
75- multiplexResults )));
90+ multiplexResults ,
91+ "unredactablePrimitiveArray" ,
92+ unredactablePrimitiveArray ,
93+ "redactableTestEventArray" ,
94+ redactableTestEventArray )));
7695 state .setHttpDetails (
7796 new HttpRequestDetails (
7897 "foo.com" ,
@@ -91,6 +110,7 @@ void smokeTestGraphqlAudit() throws JsonProcessingException {
91110
92111 verify (auditLoggerServiceSpy , atLeastOnce ()).logEvent (auditLogCaptor .capture ());
93112 ConsoleApiAuditEvent saved = auditLogCaptor .getValue ();
113+ Map <String , Object > graphQlVariables = saved .getGraphqlQueryDetails ().getVariables ();
94114
95115 assertEquals (1L , auditLogCaptor .getAllValues ().size ());
96116 assertEquals ("ABCDE" , saved .getRequestId ());
@@ -102,9 +122,19 @@ void smokeTestGraphqlAudit() throws JsonProcessingException {
102122 "redacted" ,
103123 "results" ,
104124 redactedMultiplexResults ,
125+ "unredactablePrimitiveArray" ,
126+ unredactablePrimitiveArray ,
127+ "redactableTestEventArray" ,
128+ redactableTestEventArray ,
105129 "non-pii key" ,
106130 "non-pii value" ),
107- saved .getGraphqlQueryDetails ().getVariables ());
131+ graphQlVariables );
132+
133+ TestEvent [] redactableTestEventArrayResult =
134+ (TestEvent []) graphQlVariables .get ("redactableTestEventArray" );
135+ assertEquals ("redacted" , redactableTestEventArrayResult [0 ].getPatientData ().getCountry ());
136+ assertEquals ("redacted" , redactableTestEventArrayResult [0 ].getPatientData ().getRace ());
137+ assertEquals ("redacted" , redactableTestEventArrayResult [0 ].getPatientData ().getLookupId ());
108138 assertEquals (
109139 List .of (
110140 UserPermission .SEARCH_PATIENTS ,
0 commit comments