From b61efdcaf3ff6037f2fbac416635620193488cc8 Mon Sep 17 00:00:00 2001 From: shawnnqin Date: Wed, 29 Mar 2023 20:59:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=8D=95=E6=B5=8B=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QCloudCSharpSDK/COSXMLTests/ObjectTest.cs | 2 +- .../COSXMLTests/ServiceConfigTest.cs | 227 ++++++++++++++++++ 2 files changed, 228 insertions(+), 1 deletion(-) diff --git a/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs b/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs index 5e72798..837068b 100644 --- a/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs +++ b/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs @@ -1568,7 +1568,7 @@ public void TestUploadTaskCancelledAndRetry() var asyncTask = transferManager.UploadAsync(uploadTask); - Thread.Sleep(2000); + Thread.Sleep(500); uploadTask.Cancel(); Thread.Sleep(500); diff --git a/QCloudCSharpSDK/COSXMLTests/ServiceConfigTest.cs b/QCloudCSharpSDK/COSXMLTests/ServiceConfigTest.cs index 81386d0..fadaa69 100644 --- a/QCloudCSharpSDK/COSXMLTests/ServiceConfigTest.cs +++ b/QCloudCSharpSDK/COSXMLTests/ServiceConfigTest.cs @@ -1,4 +1,5 @@ using COSXML.Log; +using COSXML.Auth; using COSXML.Model.Service; using COSXML; using COSXML.Model.Object; @@ -107,5 +108,231 @@ public void TestCustomHost() Assert.AreEqual("service.cos.myqcloud.com", serviceRequest.GetHost()); } + + [Test()] + public void TestInvalidParams() + { + CosXmlServer cosXml; + try { + cosXml = new CosXmlServer(null, null); + Assert.Fail(); + } catch (Exception) + { + + } + + + } + + [Test()] + public void ServiceSchedueTest() + { + CosXmlConfig config = new CosXmlConfig.Builder() + .SetConnectionLimit(512) + .Build(); + + string secretId = Environment.GetEnvironmentVariable("SECRET_ID"); + string secretKey = Environment.GetEnvironmentVariable("SECRET_KEY"); + + QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId, secretKey, 600); + CosXmlServer cosXml = new CosXmlServer(config, qCloudCredentialProvider); + + GetServiceRequest serviceRequest = new GetServiceRequest(); + try { + cosXml.GetService(serviceRequest, null, null); + } catch (Exception) + { + + } + + PutBucketRequest putBucketRequest = new PutBucketRequest("dotnet-ut-obj-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.PutBucket(putBucketRequest, null, null); + } catch (Exception) + { + + } + + DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.DeleteBucket(deleteBucketRequest, null, null); + } catch (Exception) + { + + } + + HeadBucketRequest headBucketRequest = new HeadBucketRequest("dotnet-ut-obj-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.HeadBucket(headBucketRequest, null, null); + } catch (Exception) + { + + } + + PutBucketACLRequest pubBucketAclRequest = new PutBucketACLRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.PutBucketACL(pubBucketAclRequest, null, null); + } catch (Exception) + { + + } + + GetBucketACLRequest getBucketAclRequest = new GetBucketACLRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.GetBucketACL(getBucketAclRequest, null, null); + } catch (Exception) + { + + } + + PutBucketCORSRequest putBucketCORSRequest = new PutBucketCORSRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.PutBucketCORS(putBucketCORSRequest, null, null); + } catch (Exception) + { + + } + + GetBucketCORSRequest getBucketCORSRequest = new GetBucketCORSRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.GetBucketCORS(getBucketCORSRequest, null, null); + } catch (Exception) + { + + } + + DeleteBucketCORSRequest deleteBucketCORSRequest = new DeleteBucketCORSRequest("bucket"); + try { + cosXml.DeleteBucketCORS(deleteBucketCORSRequest, null, null); + } catch (Exception) + { + + } + + PutBucketLifecycleRequest putBucketLifecycleRequest = new PutBucketLifecycleRequest("bucket"); + try { + cosXml.PutBucketLifecycle(putBucketLifecycleRequest, null, null); + } catch (Exception) + { + + } + + GetBucketLifecycleRequest getBucketLifecycleRequest = new GetBucketLifecycleRequest("bucket"); + try { + cosXml.GetBucketLifecycle(getBucketLifecycleRequest, null, null); + } catch (Exception) + { + + } + + DeleteBucketLifecycleRequest deleteBucketLifecycleRequest = new DeleteBucketLifecycleRequest("bucket"); + try { + cosXml.DeleteBucketLifecycle(deleteBucketLifecycleRequest, null, null); + } catch (Exception) + { + + } + + PutBucketReplicationRequest putBucketReplicationRequest = new PutBucketReplicationRequest("bucket"); + try { + cosXml.PutBucketReplication(putBucketReplicationRequest, null, null); + } catch (Exception) + { + + } + + GetBucketReplicationRequest getBucketReplicationRequest = new GetBucketReplicationRequest("dotnet-ut-obj-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.GetBucketReplication(getBucketReplicationRequest, null, null); + } catch (Exception) + { + + } + try { + cosXml.GetBucketReplication(getBucketReplicationRequest); + } catch (Exception) + { + + } + + DeleteBucketReplicationRequest deleteBucketReplicationRequest = new DeleteBucketReplicationRequest("not-exist-bucket-" + Environment.GetEnvironmentVariable("APPID")); + try { + cosXml.DeleteBucketReplication(deleteBucketReplicationRequest); + } catch (Exception) + { + + } + try { + cosXml.DeleteBucketReplication(deleteBucketReplicationRequest, null, null); + } catch (Exception) + { + + } + + PutBucketVersioningRequest putBucketVersioningRequest = new PutBucketVersioningRequest("bucket"); + try { + cosXml.PutBucketVersioning(putBucketVersioningRequest, null, null); + } catch (Exception) + { + + } + + GetBucketVersioningRequest getBucketVersioningRequest = new GetBucketVersioningRequest("bucket"); + try { + cosXml.GetBucketVersioning(getBucketVersioningRequest, null, null); + } catch (Exception) + { + + } + + ListBucketVersionsRequest listBucketVersionsRequest = new ListBucketVersionsRequest("bucket"); + try { + cosXml.ListBucketVersions(listBucketVersionsRequest, null, null); + } catch (Exception) + { + + } + + PutBucketRefererRequest putBucketRefererRequest = new PutBucketRefererRequest("bucket"); + try { + cosXml.PutBucketReferer(putBucketRefererRequest, null, null); + } catch (Exception) + { + + } + + GetBucketRefererRequest getBucketRefererRequest = new GetBucketRefererRequest("bucket"); + try { + cosXml.GetBucketReferer(getBucketRefererRequest, null, null); + } catch (Exception) + { + + } + + DeleteBucketPolicyRequest deleteBucketPolicyRequest = new DeleteBucketPolicyRequest("bucket"); + try { + cosXml.DeleteBucketPolicy(deleteBucketPolicyRequest, null, null); + } catch (Exception) + { + + } + try { + cosXml.DeleteBucketPolicy(deleteBucketPolicyRequest); + } catch (Exception) + { + + } + + AppendObjectRequest appendObjectRequest = new AppendObjectRequest("bucket", "key"); + try { + cosXml.AppendObject(appendObjectRequest, null, null); + } catch (Exception) + { + + } + + Assert.Pass(); + + } } } \ No newline at end of file