Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,20 @@ void addBaseResume_shouldPersistResumeAndReturn201() throws Exception {
}

@Test
void addBaseResume_shouldRejectNonGoogleDocsFile() throws Exception {
void addBaseResume_shouldRejectUnsupportedFileType() throws Exception {
googleDriveConnectionRepository.save(buildConnection());
googleDriveApiClient.fileMetadataById.put("pdf-file",
googleDriveApiClient.fileMetadataById.put("docx-file",
new GoogleDriveApiClient.DriveFileMetadata(
"pdf-file",
"Resume.pdf",
"application/pdf",
"docx-file",
"Resume.docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
null
));

mockMvc.perform(post("/api/v1/google-drive/base-resumes")
.header("Authorization", "Bearer " + betaAccessToken)
.contentType(MediaType.APPLICATION_JSON)
.content("{\"documentIdOrUrl\":\"pdf-file\"}"))
.content("{\"documentIdOrUrl\":\"docx-file\"}"))
.andExpect(status().isBadRequest());
}

Expand Down Expand Up @@ -671,5 +671,10 @@ public void replaceGoogleDocPlaceholders(String accessToken, String documentId,
public DriveFileMetadata exportGoogleDocAsPdf(String accessToken, String documentId, String targetFolderId, String pdfName) {
return new DriveFileMetadata("pdf-file", pdfName, "application/pdf", null);
}

@Override
public byte[] downloadFileBytes(String accessToken, String fileId) {
return new byte[0];
}
}
}
3 changes: 3 additions & 0 deletions src/test/java/com/jobtracker/integration/mcp/McpAuthIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jobtracker.dto.auth.AuthResponse;
import com.jobtracker.dto.auth.RegisterRequest;
import com.jobtracker.integration.AbstractIntegrationTest;
import com.jobtracker.repository.GoogleDriveConnectionRepository;
import com.jobtracker.repository.RefreshTokenRepository;
import com.jobtracker.repository.UserRepository;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -48,11 +49,13 @@ class McpAuthIT extends AbstractIntegrationTest {
@Autowired private ObjectMapper objectMapper;
@Autowired private UserRepository userRepository;
@Autowired private RefreshTokenRepository refreshTokenRepository;
@Autowired private GoogleDriveConnectionRepository googleDriveConnectionRepository;

private String accessToken;

@BeforeEach
void setUp() throws Exception {
googleDriveConnectionRepository.deleteAll();
refreshTokenRepository.deleteAll();
userRepository.deleteAll();

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/jobtracker/unit/GoogleDriveServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,20 @@ void updateRootFolder_shouldPersistFolderMetadata() {
}

@Test
void addBaseResume_shouldRejectNonGoogleDocsFiles() {
void addBaseResume_shouldRejectUnsupportedFileTypes() {
when(securityUtils.getCurrentUserId()).thenReturn(USER_ID);
when(connectionRepository.findByUserId(USER_ID)).thenReturn(Optional.of(connection));
when(googleDriveApiClient.getFileMetadata("access-token", "not-a-doc"))
.thenReturn(new GoogleDriveApiClient.DriveFileMetadata(
"not-a-doc",
"Resume.pdf",
"application/pdf",
"Resume.docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
null
));

assertThatThrownBy(() -> googleDriveService.addBaseResume(new GoogleDriveBaseResumeRequest("not-a-doc", null, false)))
.isInstanceOf(BadRequestException.class)
.hasMessageContaining("Only Google Docs base resumes are supported");
.hasMessageContaining("Only Google Docs documents and PDF files are supported");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class McpResumeContentResourcesTest {
@Test
void baseResumeContent_readsRequestedResourceAndReturnsText() {
UUID resumeId = UUID.randomUUID();
BaseResumeContentResponse response = new BaseResumeContentResponse(resumeId, "Base CV", "EN", true, "base-text");
BaseResumeContentResponse response = new BaseResumeContentResponse(resumeId, "Base CV", "EN", true, false, "base-text");
when(resumeGenerationService.getBaseResumeContent(resumeId)).thenReturn(response);

String result = baseResumeContentResource.baseResumeContent(resumeId.toString());
Expand Down
Loading