diff options
author | crupest <crupest@outlook.com> | 2019-04-23 00:14:35 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-23 00:14:35 +0800 |
commit | 797b1da15c76f6598dcc48f675c1b82cb27a17ed (patch) | |
tree | 99754727d79f8ae27c96f35e2541d51be780deb4 /Timeline.Tests/QCloudCosServiceUnitTest.cs | |
parent | 752850049301290b991f748816c66352f578c057 (diff) | |
download | timeline-797b1da15c76f6598dcc48f675c1b82cb27a17ed.tar.gz timeline-797b1da15c76f6598dcc48f675c1b82cb27a17ed.tar.bz2 timeline-797b1da15c76f6598dcc48f675c1b82cb27a17ed.zip |
Remove qcloud cs sdk. I will write one by myself.
Develop signature algorithm.
Diffstat (limited to 'Timeline.Tests/QCloudCosServiceUnitTest.cs')
-rw-r--r-- | Timeline.Tests/QCloudCosServiceUnitTest.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Timeline.Tests/QCloudCosServiceUnitTest.cs b/Timeline.Tests/QCloudCosServiceUnitTest.cs new file mode 100644 index 00000000..c02f70be --- /dev/null +++ b/Timeline.Tests/QCloudCosServiceUnitTest.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Timeline.Services; +using Xunit; + +namespace Timeline.Tests +{ + public class QCloudCosServiceUnitTest + { + [Fact] + public void GenerateSignatureTest() + { + var credential = new QCloudCosService.QCloudCredentials + { + SecretId = "AKIDQjz3ltompVjBni5LitkWHFlFpwkn9U5q", + SecretKey = "BQYIM75p8x0iWVFSIgqEKwFprpRSVHlz" + }; + + var request = new QCloudCosService.RequestInfo + { + Method = "put", + Uri = "/exampleobject", + Parameters = new Dictionary<string, string>(), + Headers = new Dictionary<string, string> + { + ["Host"] = "examplebucket-1250000000.cos.ap-beijing.myqcloud.com", + ["x-cos-storage-class"] = "standard", + ["x-cos-content-sha1"] = "b502c3a1f48c8609ae212cdfb639dee39673f5e" + } + }; + + var signValidTime = new QCloudCosService.TimeDuration + { + Start = DateTimeOffset.FromUnixTimeSeconds(1417773892), + End = DateTimeOffset.FromUnixTimeSeconds(1417853898) + }; + + Assert.Equal("q-sign-algorithm=sha1&q-ak=AKIDQjz3ltompVjBni5LitkWHFlFpwkn9U5q&q-sign-time=1417773892;1417853898&q-key-time=1417773892;1417853898&q-header-list=host;x-cos-content-sha1;x-cos-storage-class&q-url-param-list=&q-signature=0ab12f43e74cbe148d705cd9fae8adc9a6d39cc1", QCloudCosService.GenerateSign(credential, request, signValidTime)); + } + } +} |