3434import static app .coronawarn .dcc .utils .TestValues .registrationTokenValue ;
3535import static app .coronawarn .dcc .utils .TestValues .testId ;
3636import static org .hamcrest .Matchers .equalTo ;
37+ import static org .mockito .ArgumentMatchers .anyString ;
3738import static org .mockito .ArgumentMatchers .eq ;
3839import static org .mockito .Mockito .doThrow ;
3940import static org .mockito .Mockito .never ;
5253import app .coronawarn .dcc .repository .DccRegistrationRepository ;
5354import app .coronawarn .dcc .repository .LabIdClaimRepository ;
5455import app .coronawarn .dcc .service .DccRegistrationService ;
56+ import app .coronawarn .dcc .service .HashingService ;
5557import app .coronawarn .dcc .service .LabIdClaimService ;
5658import app .coronawarn .dcc .utils .TestUtils ;
5759import com .fasterxml .jackson .databind .ObjectMapper ;
@@ -89,6 +91,9 @@ public class InternalDccControllerTest {
8991 @ Autowired
9092 DccRegistrationService dccRegistrationService ;
9193
94+ @ Autowired
95+ HashingService hashingService ;
96+
9297 @ MockBean
9398 VerificationServerClient verificationServerClientMock ;
9499
@@ -103,7 +108,7 @@ void setup() {
103108 when (verificationServerClientMock .result (eq (registrationToken )))
104109 .thenReturn (new InternalTestResult (6 , labId , testId , 0 ));
105110
106- when (signingApiClientMock .sign (eq (dccHashBase64 ), eq (labId )))
111+ when (signingApiClientMock .sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( )))
107112 .thenReturn (partialDcc );
108113 }
109114
@@ -123,7 +128,7 @@ void testUploadDcc() throws Exception {
123128 .andExpect (status ().isOk ())
124129 .andExpect (jsonPath ("$.partialDcc" ).value (equalTo (partialDccBase64 )));
125130
126- verify (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (labId ));
131+ verify (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
127132
128133 Optional <DccRegistration > dccRegistration = dccRegistrationRepository .findByRegistrationToken (registrationTokenValue );
129134
@@ -147,7 +152,7 @@ void testUploadDccFailedUnknownTestId() throws Exception {
147152 )
148153 .andExpect (status ().isNotFound ());
149154
150- verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (labId ));
155+ verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
151156 }
152157
153158 @ Test
@@ -166,7 +171,7 @@ void testUploadDccFailedLabIdNotAssignedToPartner() throws Exception {
166171 )
167172 .andExpect (status ().isForbidden ());
168173
169- verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (labId ));
174+ verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
170175 }
171176
172177 @ Test
@@ -186,7 +191,7 @@ void testUploadDccFailedAlreadyExists() throws Exception {
186191 )
187192 .andExpect (status ().isConflict ());
188193
189- verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (labId ));
194+ verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
190195 }
191196
192197 @ Test
@@ -202,7 +207,7 @@ void testUploadDccFailedInvalidDCC() throws Exception {
202207 )
203208 .andExpect (status ().isBadRequest ());
204209
205- verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (labId ));
210+ verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
206211 }
207212
208213 @ Test
@@ -218,7 +223,7 @@ void testUploadDccFailedInvalidDek() throws Exception {
218223 )
219224 .andExpect (status ().isBadRequest ());
220225
221- verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (labId ));
226+ verify (signingApiClientMock , never ()).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
222227 }
223228
224229 @ Test
@@ -228,7 +233,7 @@ void testUploadDccFailedBadResponseFromSignignAPI4xx() throws Exception {
228233 DccUploadRequest dccUploadRequest = new DccUploadRequest (dccHash , encryptedDccBase64 , encryptedDekBase64 );
229234
230235 doThrow (new FeignException .BadRequest ("" , dummyRequest , null ))
231- .when (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (labId ));
236+ .when (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
232237
233238 mockMvc .perform (post ("/version/v1/test/" + testId + "/dcc" )
234239 .contentType (MediaType .APPLICATION_JSON_VALUE )
@@ -254,7 +259,7 @@ void testUploadDccFailedBadResponseFromSignignAPI5xx() throws Exception {
254259 DccUploadRequest dccUploadRequest = new DccUploadRequest (dccHash , encryptedDccBase64 , encryptedDekBase64 );
255260
256261 doThrow (new FeignException .InternalServerError ("" , dummyRequest , null ))
257- .when (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (labId ));
262+ .when (signingApiClientMock ).sign (eq (dccHashBase64 ), eq (hashingService . hash ( labId )), anyString ( ));
258263
259264 mockMvc .perform (post ("/version/v1/test/" + testId + "/dcc" )
260265 .contentType (MediaType .APPLICATION_JSON_VALUE )
0 commit comments