Skip to content

Commit 44d4ead

Browse files
committed
Update UploadControllerTest.java
1 parent b6143ad commit 44d4ead

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Unrestriced File Upload/java/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cd 'Unrestriced File Upload/java'
2525

2626
**Windows:**
2727
```sh
28-
mvnw.cmd clean spring-boot:run
28+
./mvnw.cmd clean spring-boot:run
2929
```
3030
3. Open in Browser:
3131
```

Unrestriced File Upload/java/src/test/java/securecodingexamples/fileupload/pathmanipulation/UploadControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void testFileUploadSuccess() throws Exception {
5454
.file(file)
5555
.contentType(MediaType.MULTIPART_FORM_DATA))
5656
.andExpect(status().isOk())
57-
.andExpect(content().string("File Uploaded Successfully"));
57+
.andExpect(content().string("File Uploaded Successfully: sample.pdf"));
5858

5959
Assertions.assertTrue(new File(Paths.get(UPLOAD_DIRECTORY, "sample.pdf").toString()).exists());
6060
}
@@ -69,7 +69,7 @@ void testEmptyFileUpload() throws Exception {
6969
.file(emptyFile)
7070
.contentType(MediaType.MULTIPART_FORM_DATA))
7171
.andExpect(status().isBadRequest())
72-
.andExpect(content().string("No selected file"));
72+
.andExpect(content().string("File is Empty or No selected file"));
7373
}
7474

7575
// ✅ Test: Invalid File Extension
@@ -109,7 +109,7 @@ void testDuplicateFilename() throws Exception {
109109
MockMultipartFile file2 = new MockMultipartFile("file", "duplicate.pdf", "application/pdf", "%PDF-1.4 second content".getBytes());
110110
mockMvc.perform(multipart("/uploadFile").file(file2).contentType(MediaType.MULTIPART_FORM_DATA))
111111
.andExpect(status().isOk())
112-
.andExpect(content().string("File Uploaded Successfully"));
112+
.andExpect(content().string("File Uploaded Successfully: " + "duplicate_1.pdf"));
113113

114114
Assertions.assertTrue(new File(Paths.get(UPLOAD_DIRECTORY, "duplicate.pdf").toString()).exists());
115115
Assertions.assertTrue(new File(Paths.get(UPLOAD_DIRECTORY, "duplicate_1.pdf").toString()).exists());

0 commit comments

Comments
 (0)