root / trunk / Pithos.Network.Test / CloudFilesClientTest.cs @ c875d683
History | View | Annotate | Download (3.6 kB)
1 |
using System; |
---|---|
2 |
using System.Collections.Concurrent; |
3 |
using System.Collections.Generic; |
4 |
using System.IO; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Threading; |
8 |
using System.Threading.Tasks; |
9 |
using NUnit.Framework; |
10 |
|
11 |
namespace Pithos.Network.Test |
12 |
{ |
13 |
[TestFixture] |
14 |
class CloudFilesClientTest |
15 |
{ |
16 |
[Test] |
17 |
public void TestPutHashMap() |
18 |
{ |
19 |
var account = "890329@vho.grnet.gr"; |
20 |
var apiKey = "24989dce4e0fcb072f8cb60c8922be19"; |
21 |
var client = new CloudFilesClient(account, apiKey) |
22 |
{ |
23 |
AuthenticationUrl = @"https://pithos.dev.grnet.gr", |
24 |
UsePithos = true |
25 |
}; |
26 |
client.Authenticate(); |
27 |
var fileName = @"vlc-1.1.11-win32.exe"; |
28 |
var treeHash = Signature.CalculateTreeHashAsync(Path.Combine(@"e:\pithos\", fileName), 4 * 1024 * 1024, "sha256", 2,CancellationToken.None, new Progress<double>()); |
29 |
var result = client.PutHashMap(account, "pithos", fileName, treeHash).Result; |
30 |
|
31 |
Assert.AreEqual(0,result.Count); |
32 |
} |
33 |
|
34 |
[Test] |
35 |
public void TestAuthentication() |
36 |
{ |
37 |
var account = "ikons@cslab.ece.ntua.gr"; |
38 |
var apiKey = "fKzKaRd7Uhov+xca4B4rOQ=="; |
39 |
var client = new CloudFilesClient(account, apiKey) |
40 |
{ |
41 |
AuthenticationUrl = @"https://plus.pithos.grnet.gr", |
42 |
UsePithos = true |
43 |
}; |
44 |
var accountInfo=client.Authenticate(); |
45 |
var containers=client.ListContainers(accountInfo.UserName); |
46 |
Assert.IsNotNull(containers); |
47 |
var result=client.GetAccountPolicies(accountInfo); |
48 |
|
49 |
Assert.IsNotNull(accountInfo); |
50 |
Assert.IsNotNull(result); |
51 |
} |
52 |
|
53 |
|
54 |
[Test] |
55 |
public void TestFolders() |
56 |
{ |
57 |
var account = "pkanavos@gmail.com"; |
58 |
var apiKey = "kAhnqSZwzzCMMjtPHkuFhw=="; |
59 |
|
60 |
var client = new CloudFilesClient(account, apiKey) |
61 |
{ |
62 |
AuthenticationUrl = @"https://pithos.dev.grnet.gr", |
63 |
UsePithos = true |
64 |
}; |
65 |
var accountInfo = client.Authenticate(); |
66 |
var containers = client.ListContainers(accountInfo.UserName); |
67 |
Assert.IsNotNull(containers); |
68 |
var result = client.GetAccountPolicies(accountInfo); |
69 |
|
70 |
Assert.IsNotNull(accountInfo); |
71 |
Assert.IsNotNull(result); |
72 |
|
73 |
|
74 |
var pithos=containers.First(c => c.Name == "pithos"); |
75 |
var directories=client.ListObjects(account,"pithos","").Where(info=>info.IsDirectory); |
76 |
Assert.That(directories,!Is.Empty); |
77 |
Assert.IsTrue(directories.All(info=>info.IsDirectory)); |
78 |
} |
79 |
|
80 |
|
81 |
[Test] |
82 |
public void TestBlockRange() |
83 |
{ |
84 |
var account = "--"; |
85 |
var apiKey = "--"; |
86 |
|
87 |
var client = new CloudFilesClient(account, apiKey) |
88 |
{ |
89 |
AuthenticationUrl = @"https://pithos.dev.grnet.gr", |
90 |
UsePithos = true |
91 |
}; |
92 |
|
93 |
var blockSize = 4*1024*1024L; |
94 |
|
95 |
long endBlock = 512*blockSize; |
96 |
//ulong endBlokcL = 512*blockSize; |
97 |
|
98 |
Assert.That(endBlock,Is.GreaterThan(0)); |
99 |
/* |
100 |
client.GetBlock(account,"Pithos",new Uri("somefile"),) |
101 |
//var accountInfo = client.Authenticate(); |
102 |
var containers = client.ListContainers(accountInfo.UserName); |
103 |
*/ |
104 |
} |
105 |
|
106 |
|
107 |
|
108 |
} |
109 |
} |