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, new Progress()); 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); */ } } }