Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public void MetadataOverride()
[Fact]
public void CopyObjectWithObjectContexts()
{
string contextKey = "A\u00F1\u03A9\U0001F680";
string contextValue = "Ab\u00F1\u03A9\U0001F680";
string contextKey = "A\u00F1\u03A9\U0001F681";
string contextValue = "Ab\u00F1\u03A9\U0001F681";
Comment on lines +129 to +130

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While changing the Unicode character reduces the immediate collision risk between tests, hardcoding these values still leaves the tests vulnerable to collisions if multiple test runs occur simultaneously against the same bucket (e.g., in a CI environment). To ensure true isolation and prevent flakiness, consider appending a unique identifier to the keys and values.

            string contextKey = $"A\u00F1\u03A9\U0001F681-{IdGenerator.FromGuid()}";
            string contextValue = $"Ab\u00F1\u03A9\U0001F681-{IdGenerator.FromGuid()}";

var custom = new Dictionary<string, ObjectCustomContextPayload>
{
{ contextKey, new ObjectCustomContextPayload { Value = contextValue } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ public void PartialResponses()
[Fact]
public void ListObjectsMatchingContextKeyValuePair()
{
string contextKey = "A\u00F1\u03A9\U0001F680";
string contextValue = "Ab\u00F1\u03A9\U0001F680";
string contextKey = "A\u00F1\u03A9\U0001F683";
string contextValue = "Ab\u00F1\u03A9\U0001F683";
Comment on lines +131 to +132

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a dynamic suffix for the context key and value ensures that this test remains isolated even when multiple instances of the test suite run concurrently against the same shared bucket resources.

            string contextKey = $"A\u00F1\u03A9\U0001F683-{IdGenerator.FromGuid()}";
            string contextValue = $"Ab\u00F1\u03A9\U0001F683-{IdGenerator.FromGuid()}";

var custom = new Dictionary<string, ObjectCustomContextPayload>
{
{ contextKey, new ObjectCustomContextPayload { Value = contextValue } }

};
var destination = new Object
{
Bucket = _fixture.ReadBucket,
Bucket = _fixture.SingleVersionBucket,
Name = IdGenerator.FromGuid(),
Contexts = new Object.ContextsData { Custom = custom }
};
Expand All @@ -146,7 +146,7 @@ public void ListObjectsMatchingContextKeyValuePair()
_fixture.Client.UploadObject(destination, source);
string filter = $@"contexts.""{contextKey}""=""{contextValue}""";
var options = new ListObjectsOptions { Filter = filter };
var objects = _fixture.Client.ListObjects(_fixture.ReadBucket, options: options).ToList();
var objects = _fixture.Client.ListObjects(_fixture.SingleVersionBucket, options: options).ToList();
var obj = Assert.Single(objects);
var fetchedContext = Assert.Single(obj.Contexts.Custom);
Assert.Equal(contextKey, fetchedContext.Key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void ClearAllObjectContexts()
var client = _fixture.Client;
var custom = new Dictionary<string, ObjectCustomContextPayload>
{
{ "A\u00F1\u03A9\U0001F680", new ObjectCustomContextPayload { Value = "Ab\u00F1\u03A9\U0001F680" } }
{ "A\u00F1\u03A9\U0001F682", new ObjectCustomContextPayload { Value = "Ab\u00F1\u03A9\U0001F682" } }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding the context key and value here still poses a risk of collision during concurrent test execution. Using dynamic values with a unique identifier would provide better isolation and reliability.

                  { $"A\u00F1\u03A9\U0001F682-{IdGenerator.FromGuid()}", new ObjectCustomContextPayload { Value = $"Ab\u00F1\u03A9\U0001F682-{IdGenerator.FromGuid()}" } }

};

var destination = new Object
Expand Down
Loading