public void GetPreSignedUriDefaultPositiveTest()
{
HttpWebRequest req = null;
HttpWebResponse res = null;
var now = DateTime.Now;
//set expiration time to 5 seconds later
var expireDate = now.AddSeconds(5);
var uri = _ossClient.GeneratePresignedUri(_bucketName, _objectKey, expireDate);
try
{
req = WebRequest.Create(uri) as HttpWebRequest;
req.Method = "GET";
res = req.GetResponse() as HttpWebResponse;
Assert.AreEqual(HttpStatusCode.OK, res.StatusCode, "response status code is not expected.");
using (var stream = res.GetResponseStream())
{
var actualETag = FileUtils.ComputeContentMd5(stream);
Assert.AreEqual(_objectETag.ToLowerInvariant(), actualETag.ToLowerInvariant());
}
}
catch (WebException)
{
//TODO:
}
finally
{
if(req != null) req.Abort();
if(res != null) res.Close();
}
}