Skip to content

Commit 2c10d52

Browse files
committed
fix typo
1 parent 60aecb6 commit 2c10d52

File tree

13 files changed

+113
-45
lines changed

13 files changed

+113
-45
lines changed

src/AlibabaCloud.OSS.V2/Credentials/CredentialsProvideFunc.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11

2+
using System;
3+
24
namespace AlibabaCloud.OSS.V2.Credentials
35
{
46
/// <summary>
5-
/// CredentialsProviderFunc provides a helper wrapping a function value
7+
/// CredentialsProvideFunc provides a helper wrapping a function value
68
/// to satisfy the ICredentialsProvider interface.
79
/// </summary>
10+
[Obsolete("Please use CredentialsProviderFunc instead")]
811
public class CredentialsProvideFunc : ICredentialsProvider
912
{
1013
public delegate Credentials GetCredentialsFunc();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+

2+
namespace AlibabaCloud.OSS.V2.Credentials
3+
{
4+
/// <summary>
5+
/// CredentialsProviderFunc provides a helper wrapping a function value
6+
/// to satisfy the ICredentialsProvider interface.
7+
/// </summary>
8+
public class CredentialsProviderFunc : ICredentialsProvider
9+
{
10+
public delegate Credentials GetCredentialsFunc();
11+
12+
private readonly GetCredentialsFunc _func;
13+
/// <summary>
14+
/// Creates an instance of <see cref="CredentialsProviderFunc"/>
15+
/// </summary>
16+
/// <param name="func">a function that returns Credentials<see cref="Credentials"/></param>
17+
public CredentialsProviderFunc(GetCredentialsFunc func) => _func = func;
18+
19+
/// <inheritdoc/>
20+
public Credentials GetCredentials()
21+
{
22+
return _func();
23+
}
24+
}
25+
}

src/AlibabaCloud.OSS.V2/Credentials/StaticCredentialsProvide.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11

2+
using System;
3+
24
namespace AlibabaCloud.OSS.V2.Credentials
35
{
46
/// <summary>
57
/// Explicitly specify the AccessKey pair that you want to use to access OSS.
68
/// </summary>
9+
[Obsolete("Please use StaticCredentialsProvider instead")]
710
public class StaticCredentialsProvide : ICredentialsProvider
811
{
912
private readonly Credentials _credentials;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+

2+
namespace AlibabaCloud.OSS.V2.Credentials
3+
{
4+
/// <summary>
5+
/// Explicitly specify the AccessKey pair that you want to use to access OSS.
6+
/// </summary>
7+
public class StaticCredentialsProvider : ICredentialsProvider
8+
{
9+
private readonly Credentials _credentials;
10+
/// <summary>
11+
/// Creates an instance of <see cref="StaticCredentialsProvider"/>
12+
/// </summary>
13+
/// <param name="accessKeyId"></param>
14+
/// <param name="accessKeySecret"></param>
15+
public StaticCredentialsProvider(string accessKeyId, string accessKeySecret)
16+
{
17+
_credentials = new(accessKeyId, accessKeySecret);
18+
}
19+
20+
/// <summary>
21+
/// Creates an instance of <see cref="StaticCredentialsProvider"/>
22+
/// </summary>
23+
/// <param name="accessKeyId"></param>
24+
/// <param name="accessKeySecret"></param>
25+
/// <param name="securityToken"></param>
26+
public StaticCredentialsProvider(string accessKeyId, string accessKeySecret, string securityToken)
27+
{
28+
_credentials = new(accessKeyId, accessKeySecret, securityToken);
29+
}
30+
31+
/// <inheritdoc/>
32+
public Credentials GetCredentials()
33+
{
34+
return _credentials;
35+
}
36+
}
37+
}

test/AlibabaCloud.OSS.V2.IntegrationTests/ClientMiscTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text;
2-
using AlibabaCloud.OSS.V2.Models;
32
using AlibabaCloud.OSS.V2.IO;
3+
using AlibabaCloud.OSS.V2.Models;
44

55
namespace AlibabaCloud.OSS.V2.IntegrationTests;
66

@@ -517,7 +517,7 @@ public async Task TestPutGetObjectByFilePath()
517517
public async Task TestInsecureSkipVerifyTrue()
518518
{
519519
var cfg = Configuration.LoadDefault();
520-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
520+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
521521
cfg.Region = Utils.Region;
522522
cfg.InsecureSkipVerify = true;
523523

@@ -901,7 +901,7 @@ public async Task TestPutGetObjectByFilePathWithProgress()
901901

902902
// disable crc
903903
var cfg = Configuration.LoadDefault();
904-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
904+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
905905
cfg.Region = Utils.Region;
906906
cfg.Endpoint = Utils.Endpoint;
907907
cfg.DisableDownloadCrc64Check = true;

test/AlibabaCloud.OSS.V2.IntegrationTests/ClientObjectMultipartTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ await invClient.ListMultipartUploadsAsync(
781781
public async Task TestUploadPartWithCrcCheckDisable()
782782
{
783783
var cfg = Configuration.LoadDefault();
784-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
784+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
785785
cfg.Region = Utils.Region;
786786
cfg.Endpoint = Utils.Endpoint;
787787
cfg.DisableUploadCrc64Check = true;

test/AlibabaCloud.OSS.V2.IntegrationTests/ClientObjectTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ public async Task TestAppendObjectWithCrcCheckEnable()
15261526
public async Task TestAppendObjectWithCrcCheckDisable()
15271527
{
15281528
var cfg = Configuration.LoadDefault();
1529-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
1529+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
15301530
cfg.Region = Utils.Region;
15311531
cfg.Endpoint = Utils.Endpoint;
15321532
cfg.DisableUploadCrc64Check = true;
@@ -1572,7 +1572,7 @@ public async Task TestAppendObjectWithCrcCheckDisable()
15721572
public async Task TestPutObjectWithCrcCheckDisable()
15731573
{
15741574
var cfg = Configuration.LoadDefault();
1575-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
1575+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
15761576
cfg.Region = Utils.Region;
15771577
cfg.Endpoint = Utils.Endpoint;
15781578
cfg.DisableUploadCrc64Check = true;
@@ -1836,7 +1836,7 @@ public async Task TestGetObjectWithCrcCheckEnable()
18361836
public async Task TestGetObjectWithCrcCheckDisable()
18371837
{
18381838
var cfg = Configuration.LoadDefault();
1839-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
1839+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
18401840
cfg.Region = Utils.Region;
18411841
cfg.Endpoint = Utils.Endpoint;
18421842
cfg.DisableDownloadCrc64Check = true;

test/AlibabaCloud.OSS.V2.IntegrationTests/ClientPresignerTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ out var expires
196196
public async Task TestPresignGetAndPutObjectV1()
197197
{
198198
var cfg = Configuration.LoadDefault();
199-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(Utils.AccessKeyId, Utils.AccessKeySecret);
199+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(Utils.AccessKeyId, Utils.AccessKeySecret);
200200
cfg.Region = "cn-shenzhen";
201201
cfg.SignatureVersion = "v1";
202202

@@ -423,7 +423,7 @@ public async Task TestPresignAbortMultipartUpload()
423423
public void TestPresignFail()
424424
{
425425
var cfg = Configuration.LoadDefault();
426-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("", "");
426+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("", "");
427427
cfg.Region = Utils.Region;
428428
cfg.Endpoint = Utils.Endpoint;
429429

@@ -546,7 +546,7 @@ public void TestPresignFail()
546546
public void TestPresignWithExpirationTimeV4()
547547
{
548548
var cfg = Configuration.LoadDefault();
549-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("ak", "sk");
549+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("ak", "sk");
550550
cfg.Region = "cn-shenzhen";
551551

552552
using var client = new Client(cfg);
@@ -671,7 +671,7 @@ public void TestPresignWithExpirationTimeV4()
671671
public void TestPresignWithExpirationTimeV1()
672672
{
673673
var cfg = Configuration.LoadDefault();
674-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("ak", "sk");
674+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("ak", "sk");
675675
cfg.Region = "cn-shenzhen";
676676
cfg.SignatureVersion = "v1";
677677

@@ -800,7 +800,7 @@ public void TestPresignWithPresignExpirationException()
800800

801801
// v1 supports > 7 days Expiration
802802
var cfg = Configuration.LoadDefault();
803-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("ak", "sk");
803+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("ak", "sk");
804804
cfg.Region = "cn-shenzhen";
805805
cfg.SignatureVersion = "v1";
806806

@@ -831,7 +831,7 @@ public void TestPresignWithPresignExpirationException()
831831

832832
// v4 does not support > 7 days Expiration
833833
cfg = Configuration.LoadDefault();
834-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("ak", "sk");
834+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("ak", "sk");
835835
cfg.Region = "cn-shenzhen";
836836
cfg.SignatureVersion = "v4";
837837

test/AlibabaCloud.OSS.V2.IntegrationTests/Utils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static Client GetDefaultClient()
5454
if (_client != null) return _client;
5555

5656
var cfg = Configuration.LoadDefault();
57-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(AccessKeyId, AccessKeySecret);
57+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(AccessKeyId, AccessKeySecret);
5858
cfg.Region = Region;
5959
cfg.Endpoint = Endpoint;
6060

@@ -66,7 +66,7 @@ public static Client GetDefaultClient()
6666
public static Client GetClient(string region, string endpoint)
6767
{
6868
var cfg = Configuration.LoadDefault();
69-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide(AccessKeyId, AccessKeySecret);
69+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider(AccessKeyId, AccessKeySecret);
7070
cfg.Region = region;
7171
cfg.Endpoint = endpoint;
7272

@@ -78,7 +78,7 @@ public static Client GetInvalidAkClient()
7878
if (_invalidClient != null) return _invalidClient;
7979

8080
var cfg = Configuration.LoadDefault();
81-
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvide("invalid-ak", "invalid-sk");
81+
cfg.CredentialsProvider = new Credentials.StaticCredentialsProvider("invalid-ak", "invalid-sk");
8282
cfg.Region = Region;
8383
cfg.Endpoint = Endpoint;
8484

test/AlibabaCloud.OSS.V2.UnitTests/Credentials/CredentialsTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void TestCredentials()
5858
[Fact]
5959
public void TestStaticCredentialsProvide()
6060
{
61-
var provider = new V2.Credentials.StaticCredentialsProvide("ak", "sk");
61+
var provider = new V2.Credentials.StaticCredentialsProvider("ak", "sk");
6262
var cred = provider.GetCredentials();
6363
Assert.Equal("ak", cred.AccessKeyId);
6464
Assert.Equal("sk", cred.AccessKeySecret);
@@ -67,7 +67,7 @@ public void TestStaticCredentialsProvide()
6767
Assert.Null(cred.Expiration);
6868
Assert.False(cred.IsExpired);
6969

70-
provider = new V2.Credentials.StaticCredentialsProvide("ak", "sk", "token");
70+
provider = new V2.Credentials.StaticCredentialsProvider("ak", "sk", "token");
7171
cred = provider.GetCredentials();
7272
Assert.Equal("ak", cred.AccessKeyId);
7373
Assert.Equal("sk", cred.AccessKeySecret);
@@ -94,7 +94,7 @@ public void TestAnonymousCredentialsProvider()
9494
public void TestCredentialsProvideFunc()
9595
{
9696

97-
var provider = new V2.Credentials.CredentialsProvideFunc(() => new V2.Credentials.Credentials("ak", "sk"));
97+
var provider = new V2.Credentials.CredentialsProviderFunc(() => new V2.Credentials.Credentials("ak", "sk"));
9898
var cred = provider.GetCredentials();
9999
Assert.Equal("ak", cred.AccessKeyId);
100100
Assert.Equal("sk", cred.AccessKeySecret);
@@ -103,7 +103,7 @@ public void TestCredentialsProvideFunc()
103103
Assert.Null(cred.Expiration);
104104
Assert.False(cred.IsExpired);
105105

106-
provider = new V2.Credentials.CredentialsProvideFunc(() => new V2.Credentials.Credentials("ak", "sk", "token"));
106+
provider = new V2.Credentials.CredentialsProviderFunc(() => new V2.Credentials.Credentials("ak", "sk", "token"));
107107
cred = provider.GetCredentials();
108108
Assert.Equal("ak", cred.AccessKeyId);
109109
Assert.Equal("sk", cred.AccessKeySecret);

0 commit comments

Comments
 (0)