Skip to content

Commit 9cc0fcc

Browse files
committed
DMP-5271 [API Validation] GET/transcriptions/{transcription_id}/documen — apply input validation (High)
Added input validation to get transcription document as well as ensuring response codes are single quoted
1 parent 4bd4122 commit 9cc0fcc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/integrationTest/java/uk/gov/hmcts/darts/transcriptions/controller/TranscriptionControllerDownloadTranscriptIntTest.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void downloadTranscript_shouldReturn401Error_whenUserNotFound() throws Exception
163163
}
164164

165165
@Test
166-
void downloadTranscriptShouldReturnNotFoundError() throws Exception {
166+
void downloadTranscript_ShouldReturnNotFoundError() throws Exception {
167167
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(URL_TEMPLATE, transcriptionId)
168168
.header(
169169
"accept",
@@ -185,7 +185,7 @@ void downloadTranscriptShouldReturnNotFoundError() throws Exception {
185185
}
186186

187187
@Test
188-
void downloadTranscriptShouldReturnOkWithMicrosoftWordNew() throws Exception {
188+
void downloadTranscript_ShouldReturnOk_WithMicrosoftWordNew() throws Exception {
189189
final String fileName = "Test Document.docx";
190190
final String fileType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
191191
final int fileSize = 11_937;
@@ -257,7 +257,7 @@ void downloadTranscriptShouldReturnOkWithMicrosoftWordNew() throws Exception {
257257

258258
@Test
259259
@SuppressWarnings("PMD.CloseResource")
260-
void downloadTranscriptShouldReturnOkWithMicrosoftWordOld() throws Exception {
260+
void downloadTranscript_ShouldReturnOk_WithMicrosoftWordOld() throws Exception {
261261
final String fileName = "Test Document.doc";
262262
final String fileType = "application/msword";
263263
final int fileSize = 22_528;
@@ -319,4 +319,25 @@ void downloadTranscriptShouldReturnOkWithMicrosoftWordOld() throws Exception {
319319
verifyNoMoreInteractions(mockAuditApi, mockDataManagementFacade, mockFileBasedDownloadResponseMetaData);
320320
}
321321

322+
@Test
323+
void downloadTranscript_ShouldReturnError_WhenNegativeTranscriptionIdUsed() throws Exception {
324+
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/transcriptions/-123/document")
325+
.header(
326+
"accept",
327+
"application/msword",
328+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
329+
);
330+
MvcResult mvcResult = mockMvc.perform(requestBuilder)
331+
.andExpect(status().isNotFound())
332+
.andReturn();
333+
334+
String actualResponse = mvcResult.getResponse().getContentAsString();
335+
336+
String expectedResponse = """
337+
{"type":"TRANSCRIPTION_101","title":"The requested transcription cannot be found","status":404}
338+
""";
339+
JSONAssert.assertEquals(expectedResponse, actualResponse, JSONCompareMode.NON_EXTENSIBLE);
340+
341+
verifyNoInteractions(mockAuditApi);
342+
}
322343
}

0 commit comments

Comments
 (0)