Skip to content

Commit

Permalink
User id required in key for cloudfront proxy permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJKing committed Aug 30, 2024
1 parent 0044abd commit 4229c70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 4229c70

Please sign in to comment.