diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsController.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsController.java index 5f4bf69f..d7006006 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsController.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsController.java @@ -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; @@ -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; @@ -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 exportSpotlightChecks(@PathVariable Integer applicationId) { log.info("Started submissions export for application " + applicationId); @@ -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) { diff --git a/src/test/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsControllerTest.java b/src/test/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsControllerTest.java index cb12b56c..7110ab1c 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsControllerTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/controllers/SubmissionsControllerTest.java @@ -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; @@ -71,6 +72,9 @@ class SubmissionsControllerTest { @MockBean private SubmissionsService submissionsService; + @MockBean + private LambdaSecretConfigProperties mockLambdaSecretConfigProperties; + @MockBean private S3Service s3Service; @@ -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); @@ -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()); @@ -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());