public void SetBucketWebsiteTest() { try { const string indexPage = "index.html"; const string errorPage = "NotFound.html"; var sbwRequest = new SetBucketWebsiteRequest(_bucketName, indexPage, errorPage); _ossClient.SetBucketWebsite(sbwRequest); OssTestUtils.WaitForCacheExpire(); var swResult = _ossClient.GetBucketWebsite(_bucketName); Assert.AreEqual(swResult.IndexDocument, indexPage); Assert.AreEqual(swResult.ErrorDocument, errorPage); } finally { _ossClient.DeleteBucketWebsite(_bucketName); try { _ossClient.GetBucketWebsite(_bucketName); Assert.Fail("Get bucket website should not pass when it was not set or deleted"); } catch (OssException e) { Assert.AreEqual(OssErrorCode.NoSuchWebsiteConfiguration, e.ErrorCode); } } }
public void SetBucketWebsiteInvalidInputTest() { Parallel.ForEach(OssTestUtils.InvalidPageNamesList, invalidPageName => { try { var sbwRequest = new SetBucketWebsiteRequest(_bucketName, invalidPageName, invalidPageName); _ossClient.SetBucketWebsite(sbwRequest); Assert.Fail("Set Bucket website should fail with invalid page names"); } catch (ArgumentException) { Assert.IsTrue(true); } }); }
public static Task SetBucketWebsiteAsync(this IOss client, SetBucketWebsiteRequest setBucketWebSiteRequest) { return(Task.Factory.StartNew(() => client.SetBucketWebsite(setBucketWebSiteRequest))); }