johannesboyne / gofakes3

A simple fake AWS S3 object storage (used for local test-runs against AWS S3 APIs)
MIT License
361 stars 84 forks source link

:bug: Add test for changed body when putting tag #71

Closed elgohr closed 1 year ago

elgohr commented 1 year ago

At the moment the body is changed when putting a tag. I just created the test . Could you please have a look at the implementation?

johannesboyne commented 1 year ago

Thanks a lot for the test-case! As it currently fails (obviously), it would be best to also include the implementation! I have not looked at the implementation details behind the tagging, but it looks straight forward here https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html

PUT /{Key+}?tagging&versionId=VersionId HTTP/1.1 
Host: Bucket.s3.amazonaws.com 
Content-MD5: ContentMD5 
x-amz-sdk-checksum-algorithm: ChecksumAlgorithm 
x-amz-expected-bucket-owner: ExpectedBucketOwner 
x-amz-request-payer: RequestPayer 
<?xml version="1.0" encoding="UTF-8"?>
  <Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <TagSet>
    <Tag>
      <Key>string</Key>
      <Value>string</Value>
    </Tag>
  </TagSet>
</Tagging>

The implementation would be probably as follows:

  1. Adding a route https://github.com/johannesboyne/gofakes3/blob/master/routing.go#L21
  2. Followed by a new function within gofakes3.go that implements the tagging correctly

Are you open to that?

Just adding the failing test-case could cause other implementations to fail if they check libs for test-cases.

elgohr commented 1 year ago

So how would you put that into https://github.com/johannesboyne/gofakes3/blob/master/backend.go#L133 ? There're a few concepts, like the homebrewn router, that take me time to understand. I guess it would be faster when you would give it a try.

johannesboyne commented 1 year ago

Worked on in PR #75

elgohr commented 1 year ago

Would have been great if you cherry-picked my commit - but I'm happy anyway for the topic to move on