Skip to content

Commit c3e5f9c

Browse files
committed
Providers have changed their way of handling owner information
1 parent 53a718d commit c3e5f9c

File tree

6 files changed

+47
-51
lines changed

6 files changed

+47
-51
lines changed

Src/ProviderTests/Code/TestConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ internal static class TestConstants
44
{
55
public const string TestUsername = "qvistian";
66
public const string TestEmail = "[email protected]";
7-
public const string TestUserId = "c5c6efaa2ab5d42d85f044a90bfb0bfcfc1daa322d725a2aeff1915fb31717ce";
87
}

Src/ProviderTests/Multipart/ListPartsTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Net;
1+
using System.Net;
22
using Genbox.ProviderTests.Code;
33
using Genbox.ProviderTests.Misc;
44
using Genbox.SimpleS3.Core.Abstracts;
@@ -34,8 +34,11 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
3434
Assert.Equal(1000, listResp1.MaxParts);
3535
Assert.False(listResp1.IsTruncated);
3636

37-
if (provider == S3Provider.AmazonS3)
38-
Assert.Equal(TestConstants.TestUsername, listResp1.Owner.Name);
37+
// Wasabi still returns display names, others don't.
38+
if (provider == S3Provider.Wasabi)
39+
Assert.Equal(TestConstants.TestUsername, listResp1.Owner?.Name);
40+
else
41+
Assert.Null(listResp1.Owner?.Name);
3942

4043
Assert.Empty(listResp1.Parts);
4144

@@ -67,8 +70,10 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
6770
Assert.Equal(1000, listResp2.MaxParts);
6871
Assert.False(listResp2.IsTruncated);
6972

70-
if (provider == S3Provider.AmazonS3)
71-
Assert.Equal(TestConstants.TestUsername, listResp2.Owner.Name);
73+
if (provider == S3Provider.Wasabi)
74+
Assert.Equal(TestConstants.TestUsername, listResp2.Owner?.Name);
75+
else
76+
Assert.Null(listResp2.Owner?.Name);
7277

7378
S3Part part = Assert.Single(listResp2.Parts);
7479

Src/ProviderTests/Objects/ListObjectVersionsTests.cs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Security.Cryptography;
33
using Genbox.ProviderTests.Code;
44
using Genbox.ProviderTests.Misc;
@@ -59,11 +59,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
5959
if (provider != S3Provider.GoogleCloudStorage)
6060
Assert.Equal(StorageClass.Standard, version1.StorageClass);
6161

62-
if (provider == S3Provider.AmazonS3)
63-
{
64-
Assert.Equal(TestConstants.TestUserId, version1.Owner?.Id);
65-
Assert.Equal(TestConstants.TestUsername, version1.Owner?.Name);
66-
}
62+
Assert.NotNull(version1.Owner?.Id);
63+
Assert.Null(version1.Owner?.Name);
6764

6865
S3Version version2 = listResp.Versions[1];
6966
Assert.Equal("2", version2.ObjectKey);
@@ -76,11 +73,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
7673
if (provider != S3Provider.GoogleCloudStorage)
7774
Assert.Equal(StorageClass.Standard, version2.StorageClass);
7875

79-
if (provider == S3Provider.AmazonS3)
80-
{
81-
Assert.Equal(TestConstants.TestUserId, version2.Owner?.Id);
82-
Assert.Equal(TestConstants.TestUsername, version2.Owner?.Name);
83-
}
76+
Assert.NotNull(version2.Owner?.Id);
77+
Assert.Null(version2.Owner?.Name);
8478

8579
//This is the latest version of object 3 and should be 4 in size
8680
S3Version version3 = listResp.Versions[2];
@@ -94,11 +88,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
9488
if (provider != S3Provider.GoogleCloudStorage)
9589
Assert.Equal(StorageClass.Standard, version3.StorageClass);
9690

97-
if (provider == S3Provider.AmazonS3)
98-
{
99-
Assert.Equal(TestConstants.TestUserId, version3.Owner?.Id);
100-
Assert.Equal(TestConstants.TestUsername, version3.Owner?.Name);
101-
}
91+
Assert.NotNull(version3.Owner?.Id);
92+
Assert.Null(version3.Owner?.Name);
10293

10394
//This was the previous version of object 3, so it should not be the latest and have 3 in size
10495
S3Version version3A = listResp.Versions[3];
@@ -112,11 +103,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
112103
if (provider != S3Provider.GoogleCloudStorage)
113104
Assert.Equal(StorageClass.Standard, version3A.StorageClass);
114105

115-
if (provider == S3Provider.AmazonS3)
116-
{
117-
Assert.Equal(TestConstants.TestUserId, version3A.Owner?.Id);
118-
Assert.Equal(TestConstants.TestUsername, version3A.Owner?.Name);
119-
}
106+
Assert.NotNull(version3A.Owner?.Id);
107+
Assert.Null(version3A.Owner?.Name);
120108

121109
//This is the latest version of object 2, since it was deleted
122110
S3DeleteMarker delMarker = listResp.DeleteMarkers[0];
@@ -125,11 +113,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
125113
Assert.Equal(putResp4.VersionId, delMarker.VersionId);
126114
Assert.Equal(DateTimeOffset.UtcNow.DateTime, delMarker.LastModified.DateTime, TimeSpan.FromMinutes(1));
127115

128-
if (provider == S3Provider.AmazonS3)
129-
{
130-
Assert.Equal(TestConstants.TestUserId, delMarker.Owner.Id);
131-
Assert.Equal(TestConstants.TestUsername, delMarker.Owner.Name);
132-
}
116+
Assert.NotNull(delMarker.Owner.Id);
117+
Assert.Null(delMarker.Owner.Name);
133118
});
134119
}
135120

Src/ProviderTests/Objects/ListObjectsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Security.Cryptography;
33
using System.Text;
44
using Genbox.ProviderTests.Code;
@@ -131,7 +131,7 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
131131
}
132132

133133
[Theory]
134-
[MultipleProviders(S3Provider.AmazonS3 | S3Provider.GoogleCloudStorage)]
134+
[MultipleProviders(S3Provider.GoogleCloudStorage)]
135135
public async Task ListObjectsWithOwner(S3Provider provider, string _, ISimpleClient client)
136136
{
137137
await CreateTempBucketAsync(provider, client, async tempBucket =>
@@ -147,8 +147,8 @@ await CreateTempBucketAsync(provider, client, async tempBucket =>
147147

148148
if (provider == S3Provider.AmazonS3)
149149
{
150-
Assert.Equal(TestConstants.TestUsername, obj.Owner!.Name);
151-
Assert.Equal(TestConstants.TestUserId, obj.Owner.Id);
150+
Assert.NotNull(obj.Owner?.Id);
151+
Assert.Equal(TestConstants.TestUsername, obj.Owner?.Name);
152152
}
153153
else
154154
Assert.NotNull(obj.Owner);

Src/ProviderTests/Objects/ObjectAclTests.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Genbox.ProviderTests.Code;
1+
using Genbox.ProviderTests.Code;
22
using Genbox.ProviderTests.Misc;
33
using Genbox.SimpleS3.Core.Abstracts;
44
using Genbox.SimpleS3.Core.Enums;
@@ -29,34 +29,45 @@ public async Task PutGetObjectAcl(S3Provider provider, string bucket, ISimpleCli
2929

3030
if (provider == S3Provider.AmazonS3)
3131
{
32+
Assert.NotNull(grant.Grantee.Id);
3233
Assert.Equal(GrantType.CanonicalUser, grant.Grantee.Type);
33-
Assert.Equal(TestConstants.TestUserId, grant.Grantee.Id);
34-
Assert.Equal(TestConstants.TestUsername, grant.Grantee.DisplayName);
34+
}
35+
else
36+
{
37+
Assert.Equal(GrantType.AmazonCustomerByEmail, grant.Grantee.Type);
3538
}
3639

40+
Assert.Null(grant.Grantee.DisplayName);
41+
3742
//Update the object to have another ACL using Canned ACLs
3843
PutObjectAclResponse putResp2 = await client.PutObjectAclAsync(bucket, objectKey, r => r.Acl = ObjectCannedAcl.PublicRead);
3944
Assert.Equal(200, putResp2.StatusCode);
4045

4146
GetObjectAclResponse getResp2 = await client.GetObjectAclAsync(bucket, objectKey);
4247
Assert.Equal(200, getResp2.StatusCode);
4348
Assert.Equal(2, getResp2.Grants.Count);
49+
Assert.NotNull(getResp2.Owner.Id);
4450

4551
if (provider == S3Provider.AmazonS3)
46-
{
47-
Assert.Equal(TestConstants.TestUserId, getResp2.Owner.Id);
48-
Assert.Equal(TestConstants.TestUsername, getResp2.Owner.Name);
49-
}
52+
Assert.Null(getResp2.Owner.Name);
53+
else if (provider == S3Provider.GoogleCloudStorage)
54+
Assert.Equal(TestConstants.TestEmail, getResp2.Owner.Name, StringComparer.OrdinalIgnoreCase);
5055

5156
//This is the default owner ACL
5257
S3Grant first = getResp2.Grants[0];
5358

5459
if (provider == S3Provider.AmazonS3)
5560
{
56-
Assert.Equal(TestConstants.TestUserId, first.Grantee.Id);
57-
Assert.Equal(TestConstants.TestUsername, first.Grantee.DisplayName);
61+
Assert.NotNull(first.Grantee.Id);
5862
Assert.Equal(GrantType.CanonicalUser, first.Grantee.Type);
5963
}
64+
else if (provider == S3Provider.GoogleCloudStorage)
65+
{
66+
Assert.Null(first.Grantee.Id);
67+
Assert.Equal(GrantType.AmazonCustomerByEmail, first.Grantee.Type);
68+
}
69+
70+
Assert.Null(first.Grantee.DisplayName);
6071

6172
Assert.Equal(S3Permission.FullControl, first.Permission);
6273

Src/ProviderTests/Objects/PutObjectTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Security.Cryptography;
33
using Genbox.HttpBuilders.Enums;
44
using Genbox.ProviderTests.Code;
@@ -100,19 +100,15 @@ public async Task PutObjectStorageClass(S3Provider _, string bucket, ISimpleClie
100100
}
101101

102102
[Theory]
103-
[MultipleProviders(S3Provider.AmazonS3 | S3Provider.GoogleCloudStorage)]
103+
[MultipleProviders(S3Provider.GoogleCloudStorage)]
104104
public async Task MultiplePermissions(S3Provider _, string bucket, ISimpleClient client)
105105
{
106106
PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(MultiplePermissions), null, r =>
107107
{
108108
r.AclGrantRead.AddEmail(TestConstants.TestEmail);
109-
r.AclGrantRead.AddUserId(TestConstants.TestUserId);
110109
r.AclGrantReadAcp.AddEmail(TestConstants.TestEmail);
111-
r.AclGrantReadAcp.AddUserId(TestConstants.TestUserId);
112110
r.AclGrantWriteAcp.AddEmail(TestConstants.TestEmail);
113-
r.AclGrantWriteAcp.AddUserId(TestConstants.TestUserId);
114111
r.AclGrantFullControl.AddEmail(TestConstants.TestEmail);
115-
r.AclGrantFullControl.AddUserId(TestConstants.TestUserId);
116112
});
117113

118114
Assert.Equal(200, putResp.StatusCode);

0 commit comments

Comments
 (0)