X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/4b58c0049b8021ae3d281328c000309fb91314a3..d7288179638247cb10a9abec6f85503d1c72315f:/trunk/Pithos.Network.Test/CloudFilesClientTest.cs diff --git a/trunk/Pithos.Network.Test/CloudFilesClientTest.cs b/trunk/Pithos.Network.Test/CloudFilesClientTest.cs index aa402d0..e97b68c 100644 --- a/trunk/Pithos.Network.Test/CloudFilesClientTest.cs +++ b/trunk/Pithos.Network.Test/CloudFilesClientTest.cs @@ -1,108 +1,109 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace Pithos.Network.Test -{ - [TestFixture] - class CloudFilesClientTest - { - [Test] - public void TestPutHashMap() - { - var account = "890329@vho.grnet.gr"; - var apiKey = "24989dce4e0fcb072f8cb60c8922be19"; - var client = new CloudFilesClient(account, apiKey) - { - AuthenticationUrl = @"https://pithos.dev.grnet.gr", - UsePithos = true - }; - client.Authenticate(); - var fileName = @"vlc-1.1.11-win32.exe"; - var treeHash=Signature.CalculateTreeHashAsync(Path.Combine(@"e:\pithos\" ,fileName), 4*1024*1024 , "sha256", 2); - var result = client.PutHashMap(account, "pithos", fileName, treeHash).Result; - - Assert.AreEqual(0,result.Count); - } - - [Test] - public void TestAuthentication() - { - var account = "ikons@cslab.ece.ntua.gr"; - var apiKey = "fKzKaRd7Uhov+xca4B4rOQ=="; - var client = new CloudFilesClient(account, apiKey) - { - AuthenticationUrl = @"https://plus.pithos.grnet.gr", - UsePithos = true - }; - var accountInfo=client.Authenticate(); - var containers=client.ListContainers(accountInfo.UserName); - Assert.IsNotNull(containers); - var result=client.GetAccountPolicies(accountInfo); - - Assert.IsNotNull(accountInfo); - Assert.IsNotNull(result); - } - - - [Test] - public void TestFolders() - { - var account = "pkanavos@gmail.com"; - var apiKey = "kAhnqSZwzzCMMjtPHkuFhw=="; - - var client = new CloudFilesClient(account, apiKey) - { - AuthenticationUrl = @"https://pithos.dev.grnet.gr", - UsePithos = true - }; - var accountInfo = client.Authenticate(); - var containers = client.ListContainers(accountInfo.UserName); - Assert.IsNotNull(containers); - var result = client.GetAccountPolicies(accountInfo); - - Assert.IsNotNull(accountInfo); - Assert.IsNotNull(result); - - - var pithos=containers.First(c => c.Name == "pithos"); - var directories=client.ListObjects(account,"pithos","").Where(info=>info.IsDirectory); - Assert.That(directories,!Is.Empty); - Assert.IsTrue(directories.All(info=>info.IsDirectory)); - } - - - [Test] - public void TestBlockRange() - { - var account = "--"; - var apiKey = "--"; - - var client = new CloudFilesClient(account, apiKey) - { - AuthenticationUrl = @"https://pithos.dev.grnet.gr", - UsePithos = true - }; - - var blockSize = 4*1024*1024L; - - long endBlock = 512*blockSize; - //ulong endBlokcL = 512*blockSize; - - Assert.That(endBlock,Is.GreaterThan(0)); -/* - client.GetBlock(account,"Pithos",new Uri("somefile"),) - //var accountInfo = client.Authenticate(); - var containers = client.ListContainers(accountInfo.UserName); - */ - } - - - - } -} +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Pithos.Network.Test +{ + [TestFixture] + class CloudFilesClientTest + { + [Test] + public void TestPutHashMap() + { + var account = "890329@vho.grnet.gr"; + var apiKey = "24989dce4e0fcb072f8cb60c8922be19"; + var client = new CloudFilesClient(account, apiKey) + { + AuthenticationUrl = @"https://pithos.dev.grnet.gr", + UsePithos = true + }; + client.Authenticate(); + var fileName = @"vlc-1.1.11-win32.exe"; + var treeHash = Signature.CalculateTreeHashAsync(Path.Combine(@"e:\pithos\", fileName), 4 * 1024 * 1024, "sha256", 2,CancellationToken.None, new Progress()); + var result = client.PutHashMap(account, "pithos".ToEscapedUri(), fileName.ToEscapedUri(), treeHash).Result; + + Assert.AreEqual(0,result.Count); + } + + [Test] + public void TestAuthentication() + { + var account = "ikons@cslab.ece.ntua.gr"; + var apiKey = "fKzKaRd7Uhov+xca4B4rOQ=="; + var client = new CloudFilesClient(account, apiKey) + { + AuthenticationUrl = @"https://plus.pithos.grnet.gr", + UsePithos = true + }; + var accountInfo=client.Authenticate(); + var containers=client.ListContainers(accountInfo.UserName); + Assert.IsNotNull(containers); + var result=client.GetAccountPolicies(accountInfo); + + Assert.IsNotNull(accountInfo); + Assert.IsNotNull(result); + } + + + [Test] + public void TestFolders() + { + var account = "pkanavos@gmail.com"; + var apiKey = "kAhnqSZwzzCMMjtPHkuFhw=="; + + var client = new CloudFilesClient(account, apiKey) + { + AuthenticationUrl = @"https://pithos.dev.grnet.gr", + UsePithos = true + }; + var accountInfo = client.Authenticate(); + var containers = client.ListContainers(accountInfo.UserName); + Assert.IsNotNull(containers); + var result = client.GetAccountPolicies(accountInfo); + + Assert.IsNotNull(accountInfo); + Assert.IsNotNull(result); + + + var pithos = containers.First(c => c.Name == "pithos".ToEscapedUri()); + var directories = client.ListObjects(account, "pithos".ToEscapedUri(), "".ToEscapedUri()).Where(info => info.IsDirectory); + Assert.That(directories,!Is.Empty); + Assert.IsTrue(directories.All(info=>info.IsDirectory)); + } + + + [Test] + public void TestBlockRange() + { + var account = "--"; + var apiKey = "--"; + + var client = new CloudFilesClient(account, apiKey) + { + AuthenticationUrl = @"https://pithos.dev.grnet.gr", + UsePithos = true + }; + + var blockSize = 4*1024*1024L; + + long endBlock = 512*blockSize; + //ulong endBlokcL = 512*blockSize; + + Assert.That(endBlock,Is.GreaterThan(0)); +/* + client.GetBlock(account,"Pithos",new Uri("somefile"),) + //var accountInfo = client.Authenticate(); + var containers = client.ListContainers(accountInfo.UserName); + */ + } + + + + } +}