Skip to content

Commit

Permalink
B-22056 - additional test and .envrc cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-mchugh committed Jan 9, 2025
1 parent 1729cbd commit 75deebb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export TZ="UTC"

# AWS development access
#
# To use S3/SES for local builds, you'll need to uncomment the following.
# To use S3/SES or SNS&SQS for local builds, you'll need to uncomment the following.
# Do not commit the change:
#
# export STORAGE_BACKEND=s3
Expand All @@ -238,7 +238,7 @@ export TZ="UTC"
#
# Instructions for using S3 storage backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1470955567/How+to+test+storing+data+in+S3+locally
# Instructions for using SES email backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1467973894/How+to+test+sending+email+locally
# Instructions for using SNS&SQS backend here: ...
# Instructions for using SNS&SQS backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/2793242625/How+to+test+notifications+receiver+locally
#
# The default and equivalent to not being set is:
#
Expand Down
47 changes: 46 additions & 1 deletion pkg/handlers/internalapi/uploads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,52 @@ func (suite *HandlerSuite) TestGetUploadStatusHandlerFailure() {
suite.Error(err)
})

// TODO: ADD A FORBIDDEN TEST
suite.Run("Error when attempting access to another service member's upload", func() {
fakeS3 := storageTest.NewFakeS3Storage(true)
localReceiver := notifications.StubNotificationReceiver{}

otherServiceMember := factory.BuildServiceMember(suite.DB(), nil, nil)

orders := factory.BuildOrder(suite.DB(), nil, nil)
uploadUser1 := factory.BuildUserUpload(suite.DB(), []factory.Customization{
{
Model: orders.UploadedOrders,
LinkOnly: true,
},
{
Model: models.Upload{
Filename: "FileName",
Bytes: int64(15),
ContentType: uploader.FileTypePDF,
},
},
}, nil)

file := suite.Fixture(FixturePDF)
_, err := fakeS3.Store(uploadUser1.Upload.StorageKey, file.Data, "somehash", nil)
suite.NoError(err)

params := uploadop.NewGetUploadStatusParams()
params.UploadID = strfmt.UUID(uploadUser1.Upload.ID.String())

req := &http.Request{}
req = suite.AuthenticateRequest(req, otherServiceMember)
params.HTTPRequest = req

handlerConfig := suite.HandlerConfig()
handlerConfig.SetFileStorer(fakeS3)
handlerConfig.SetNotificationReceiver(localReceiver)
uploadInformationFetcher := upload.NewUploadInformationFetcher()
handler := GetUploadStatusHandler{handlerConfig, uploadInformationFetcher}

response := handler.Handle(params)
_, ok := response.(*uploadop.GetUploadStatusForbidden)
suite.True(ok)

queriedUpload := models.Upload{}
err = suite.DB().Find(&queriedUpload, uploadUser1.Upload.ID)
suite.NoError(err)
})
}

func (suite *HandlerSuite) TestCreatePPMUploadsHandlerSuccess() {
Expand Down

0 comments on commit 75deebb

Please sign in to comment.