From 4229c704df95a171c9d53bd2f4ce5b82789c6c4f Mon Sep 17 00:00:00 2001 From: TomJKing Date: Fri, 30 Aug 2024 12:28:23 +0100 Subject: [PATCH] User id required in key for cloudfront proxy permissions --- .../service/services/dataload/DataLoadInitiation.scala | 6 +++--- .../transfer/service/api/TransferServiceServerSpec.scala | 6 +++--- .../service/services/dataload/DataLoadInitiationSpec.scala | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiation.scala b/src/main/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiation.scala index 446add2..9d54241 100644 --- a/src/main/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiation.scala +++ b/src/main/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiation.scala @@ -16,12 +16,12 @@ class DataLoadInitiation(graphQlApiService: GraphQlApiService) { addConsignmentResult <- graphQlApiService.addConsignment(token) consignmentId = addConsignmentResult.consignmentid.get _ <- graphQlApiService.startUpload(token, consignmentId) - result <- loadDetails(consignmentId, sourceSystem) + result <- loadDetails(consignmentId, token.userId, sourceSystem) } yield result } - private def loadDetails(transferId: UUID, sourceSystem: SourceSystem): IO[LoadDetails] = { - val s3KeyPrefix = s"$sourceSystem/$transferId" + private def loadDetails(transferId: UUID, userId: UUID, sourceSystem: SourceSystem): IO[LoadDetails] = { + val s3KeyPrefix = s"$userId/$sourceSystem/$transferId" val maxNumberRecords = transferConfigurationConfig.maxNumberRecords val recordsS3Bucket = AWSS3LoadDestination(s"${s3Config.recordsUploadBucket}", s"$s3KeyPrefix/records") val metadataS3Bucket = AWSS3LoadDestination(s"${s3Config.metadataUploadBucket}", s"$s3KeyPrefix/metadata") diff --git a/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/api/TransferServiceServerSpec.scala b/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/api/TransferServiceServerSpec.scala index 1cdfdfe..03d3799 100644 --- a/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/api/TransferServiceServerSpec.scala +++ b/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/api/TransferServiceServerSpec.scala @@ -10,7 +10,7 @@ import org.http4s.implicits.http4sLiteralsSyntax import org.http4s.{Header, Headers, Method, Request, Status} import org.scalatest.matchers.should.Matchers import org.typelevel.ci.CIString -import uk.gov.nationalarchives.tdr.transfer.service.TestUtils.{invalidToken, validUserToken} +import uk.gov.nationalarchives.tdr.transfer.service.TestUtils.{invalidToken, userId, validUserToken} import uk.gov.nationalarchives.tdr.transfer.service.api.controllers.LoadController import uk.gov.nationalarchives.tdr.transfer.service.api.model.LoadModel.{AWSS3LoadDestination, LoadDetails} import uk.gov.nationalarchives.tdr.transfer.service.services.ExternalServicesSpec @@ -45,8 +45,8 @@ class TransferServiceServerSpec extends ExternalServicesSpec with Matchers { ) .unsafeRunSync() - val expectedRecordsDestination = AWSS3LoadDestination("s3BucketNameRecords", s"sharepoint/$transferId/records") - val expectedMetadataLoadDestination = AWSS3LoadDestination("s3BucketNameMetadata", s"sharepoint/$transferId/metadata") + val expectedRecordsDestination = AWSS3LoadDestination("s3BucketNameRecords", s"$userId/sharepoint/$transferId/records") + val expectedMetadataLoadDestination = AWSS3LoadDestination("s3BucketNameMetadata", s"$userId/sharepoint/$transferId/metadata") response.status shouldBe Status.Ok val body = response.as[Json].unsafeRunSync() diff --git a/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiationSpec.scala b/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiationSpec.scala index f3bfe71..e67c4a2 100644 --- a/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiationSpec.scala +++ b/src/test/scala/uk/gov/nationalarchives/tdr/transfer/service/services/dataload/DataLoadInitiationSpec.scala @@ -31,8 +31,8 @@ class DataLoadInitiationSpec extends BaseSpec { val expectedResult = LoadDetails( consignmentId, - AWSS3LoadDestination("s3BucketNameRecords", s"$sourceSystem/$consignmentId/records"), - AWSS3LoadDestination("s3BucketNameMetadata", s"$sourceSystem/$consignmentId/metadata"), + AWSS3LoadDestination("s3BucketNameRecords", s"$userId/$sourceSystem/$consignmentId/records"), + AWSS3LoadDestination("s3BucketNameMetadata", s"$userId/$sourceSystem/$consignmentId/metadata"), expectedTransferConfiguration )