Skip to content

Commit

Permalink
fix call to user-service (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-lor-cab authored Jan 10, 2024
1 parent e8efc4f commit b344e7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package gov.cabinetoffice.gap.adminbackend.controllers;

import gov.cabinetoffice.gap.adminbackend.constants.SpotlightExports;
import gov.cabinetoffice.gap.adminbackend.annotations.LambdasHeaderValidator;
import gov.cabinetoffice.gap.adminbackend.config.LambdaSecretConfigProperties;
import gov.cabinetoffice.gap.adminbackend.constants.SpotlightExports;
import gov.cabinetoffice.gap.adminbackend.dtos.S3ObjectKeyDTO;
import gov.cabinetoffice.gap.adminbackend.dtos.UrlDTO;
import gov.cabinetoffice.gap.adminbackend.dtos.submission.LambdaSubmissionDefinition;
Expand Down Expand Up @@ -31,7 +32,6 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -55,6 +55,8 @@ public class SubmissionsController {

private final FileService fileService;

private final LambdaSecretConfigProperties lambdaSecretConfigProperties;

@GetMapping(value = "/spotlight-export/{applicationId}", produces = EXPORT_CONTENT_TYPE)
public ResponseEntity<InputStreamResource> exportSpotlightChecks(@PathVariable Integer applicationId) {
log.info("Started submissions export for application " + applicationId);
Expand Down Expand Up @@ -108,12 +110,10 @@ public ResponseEntity getExportStatus(@PathVariable Integer applicationId) {
content = @Content(mediaType = "application/json")) })
@LambdasHeaderValidator
public ResponseEntity getSubmissionInfo(final @PathVariable @NotNull UUID submissionId,
final @PathVariable @NotNull UUID batchExportId,
@RequestHeader(HttpHeaders.AUTHORIZATION) String authHeader) {

final @PathVariable @NotNull UUID batchExportId) {
try {
final LambdaSubmissionDefinition submission = submissionsService.getSubmissionInfo(submissionId,
batchExportId, authHeader);
batchExportId, lambdaSecretConfigProperties.getSecret());
return ResponseEntity.ok(submission);
}
catch (NotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package gov.cabinetoffice.gap.adminbackend.controllers;

import gov.cabinetoffice.gap.adminbackend.constants.SpotlightExports;
import gov.cabinetoffice.gap.adminbackend.config.LambdaSecretConfigProperties;
import gov.cabinetoffice.gap.adminbackend.config.LambdasInterceptor;
import gov.cabinetoffice.gap.adminbackend.constants.SpotlightExports;
import gov.cabinetoffice.gap.adminbackend.dtos.S3ObjectKeyDTO;
import gov.cabinetoffice.gap.adminbackend.dtos.UrlDTO;
import gov.cabinetoffice.gap.adminbackend.dtos.submission.LambdaSubmissionDefinition;
Expand Down Expand Up @@ -71,6 +72,9 @@ class SubmissionsControllerTest {
@MockBean
private SubmissionsService submissionsService;

@MockBean
private LambdaSecretConfigProperties mockLambdaSecretConfigProperties;

@MockBean
private S3Service s3Service;

Expand Down Expand Up @@ -213,6 +217,7 @@ class getSubmissionInfo {
@Test
void happyPath() throws Exception {
final LambdaSubmissionDefinition lambdaSubmissionDefinition = LambdaSubmissionDefinition.builder().build();
when(mockLambdaSecretConfigProperties.getSecret()).thenReturn("secret");
when(submissionsService.getSubmissionInfo(any(UUID.class), any(UUID.class), anyString()))
.thenReturn(lambdaSubmissionDefinition);

Expand All @@ -225,6 +230,7 @@ void happyPath() throws Exception {

@Test
void unauthorisedPath() throws Exception {
when(mockLambdaSecretConfigProperties.getSecret()).thenReturn("secret");
when(submissionsService.getSubmissionInfo(any(UUID.class), any(UUID.class), anyString()))
.thenThrow(new UnauthorizedException());

Expand All @@ -236,6 +242,7 @@ void unauthorisedPath() throws Exception {

@Test
void resourceNotFoundPath() throws Exception {
when(mockLambdaSecretConfigProperties.getSecret()).thenReturn("secret");
when(submissionsService.getSubmissionInfo(any(UUID.class), any(UUID.class), anyString()))
.thenThrow(new NotFoundException());

Expand Down

0 comments on commit b344e7c

Please sign in to comment.